Skip to content

Commit

Permalink
Temporarl rebase to yizheng's mm branch
Browse files Browse the repository at this point in the history
Push my initial work for uploading memory manager

add slib_env to use page_alloc.c

Add headers from arm/include/asm and try to initilize buddy system freelists

recover init/main.c

add WANT_PAGE_VIRTUAL to use page->virtual

a working version done

delete prink debug message

add a tiny change

try to make no impact on upstream kernel

solve OPT=no compiler crash

solve undefined symbol for init_mm

test

add build.sh

remove test

delete build.sh

add #endif

solve some unreferced symbol problem

change barrier.h

disable some compile time check for atomic variables

Do cleanup according to Hajime's suggestions.
Check here for details:
#44 (comment)

git rid of #if 0 useless code

Resolve Hajime'c commemts. Check here:
https://github.com/libos-nuse/net-next-nuse/pull/47/files#r38614406

add cache_is_vivt back to highmem.c again to resolve some warnings

resolve pull request comments

1)Change __MR_MAX_ZONES in arch/lib/Makefile
2)Use symbolic link in arch/lib/include
3)Resolve ERRORs reported by checkpatch.pl

Lib:
   1) resovle undefined symbol rumpns_irq_stat

disable compile time check

resolve pull request comments

add something missing in the last commit
  • Loading branch information
yjiao authored and thehajime committed Oct 9, 2015
1 parent 988f567 commit 82c0c7a
Show file tree
Hide file tree
Showing 45 changed files with 898 additions and 150 deletions.
47 changes: 42 additions & 5 deletions arch/lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ config MODULES
option modules

config MMU
def_bool n
def_bool y

config FPU
def_bool n
Expand Down Expand Up @@ -61,9 +61,6 @@ config BASE_FULL
config SELECT_MEMORY_MODEL
def_bool n

config FLAT_NODE_MEM_MAP
def_bool n

config PAGEFLAGS_EXTENDED
def_bool n

Expand Down Expand Up @@ -121,4 +118,44 @@ source "crypto/Kconfig"
source "lib/Kconfig"

config SLIB
def_bool y
def_bool y

config HAVE_MEMBLOCK
def_bool y

config DEBUG_INFO
def_bool y

config FLAT_NODE_MEM_MAP
def_bool y

config NO_BOOTMEM
def_bool y

config HIGHMEM
def_bool y

config CPU_COPY_V6
def_bool y

config CPU_TLB_V7
def_bool y

config PAGE_OFFSET
hex
default 0xC0000000

config PHYS_OFFSET
hex
default 0x00000000

config ARM_L1_CACHE_SHIFT
int
default 6

config PGTABLE_LEVELS
int
default 2

config HAVE_ARCH_PFN_VALID
def_bool y
7 changes: 4 additions & 3 deletions arch/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ rwsem.o semaphore.o kfifo.o cred.o user.o groups.o ksysfs.o
kernel/time/_to_keep=time.o timekeeping.o jiffies.o clocksource.o ntp.o timer.o \
hrtimer.o
kernel/sched/_to_keep=wait.o completion.o
kernel/rcu_to_keep=rcu/srcu.o rcu/pdate.o rcu/tiny.o
kernel/rcu_to_keep=rcu/srcu.o rcu/update.o rcu/tiny.o
kernel/locking_to_keep=locking/mutex.o
kernel/bpf_to_keep=bpf/core.o
mm/_to_keep=util.o list_lru.o slib.o
mm/_to_keep=util.o list_lru.o slib.o page_alloc.o memblock.o mmzone.o slib_env.o \
nobootmem.o highmem.o oom_kill.o
crypto/_to_keep=aead.o ahash.o shash.o api.o algapi.o cipher.o compress.o proc.o \
crc32c_generic.o rng.o
drivers/base/_to_keep=class.o core.o bus.o dd.o driver.o devres.o module.o map.o syscore.o
Expand Down Expand Up @@ -129,7 +130,7 @@ quiet_cmd_objsmk = OBJS-MK $@
done > $@

$(ARCH_DIR)/objs.mk: $(ARCH_DIR)/Makefile.print $(srctree)/.config $(ARCH_DIR)/Makefile
+$(call if_changed,objsmk)
+$(call if_changed,objsmk);

quiet_cmd_linker = GEN $@
cmd_linker = ld -shared --verbose | ./$^ > $@
Expand Down
5 changes: 0 additions & 5 deletions arch/lib/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,3 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,
{
return -ENOSYS;
}

unsigned int nr_free_buffer_pages(void)
{
return 65535;
}
53 changes: 50 additions & 3 deletions arch/lib/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,33 @@
#include <linux/init_task.h>
#include <linux/sched/rt.h>
#include <linux/backing-dev.h>
#include <linux/file.h>
#include <stdarg.h>
#include "sim-assert.h"
#include "sim.h"
#include "lib.h"


struct pipe_buffer;
struct file;
struct pipe_inode_info;
struct wait_queue_t;
struct kernel_param;
struct super_block;

struct mm_struct init_mm;

/* defined in sched.c, used in net/sched/em_meta.c */
unsigned long avenrun[3];
/* defined in mm/page_alloc.c */
struct pglist_data __refdata contig_page_data;
/* defined in linux/mmzone.h mm/memory.c */
struct page *mem_map = 0;
unsigned long max_mapnr;
unsigned long highest_memmap_pfn __read_mostly;

/* vmscan */
unsigned long vm_total_pages;

/* used during boot. */
//struct tvec_base boot_tvec_bases;
/* used by sysinfo in kernel/timer.c */
int nr_threads = 0;
/* not very useful in mm/vmstat.c */
Expand All @@ -59,6 +67,30 @@ DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly;
const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits);

/* memory.c */
unsigned long highest_memmap_pfn __read_mostly;
unsigned long max_mapnr;

/*
* Randomize the address space (stacks, mmaps, brk, etc.).
*
* ( When CONFIG_COMPAT_BRK=y we exclude brk from randomization,
* as ancient (libc5 based) binaries can segfault. )
*/
int randomize_va_space __read_mostly =
#ifdef CONFIG_COMPAT_BRK
1;
#else
2;
#endif

/* vmscan.c */
unsigned long vm_total_pages;

/* arm/mmu.c */
pgprot_t pgprot_kernel;


struct backing_dev_info noop_backing_dev_info = {
.name = "noop",
.capabilities = 0,
Expand Down Expand Up @@ -282,3 +314,18 @@ void on_each_cpu_mask(const struct cpumask *mask,
smp_call_func_t func, void *info, bool wait)
{
}

unsigned long
arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
lib_assert(false);
return 0;
}

#ifdef CONFIG_HAVE_ARCH_PFN_VALID
int pfn_valid(unsigned long pfn)
{
return memblock_is_memory(__pfn_to_phys(pfn));
}
#endif
92 changes: 86 additions & 6 deletions arch/lib/include/asm/barrier.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,88 @@
#include <asm-generic/barrier.h>
#ifndef __ASM_BARRIER_H
#define __ASM_BARRIER_H

#ifndef __ASSEMBLY__
#include <asm/outercache.h>

#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");

#if __LINUX_ARM_ARCH__ >= 7 || \
(__LINUX_ARM_ARCH__ == 6 && defined(CONFIG_CPU_32v6K))
#define sev() __asm__ __volatile__ ("sev" : : : "memory")
#define wfe() __asm__ __volatile__ ("wfe" : : : "memory")
#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
#endif

#if __LINUX_ARM_ARCH__ >= 7
#define isb(option) __asm__ __volatile__ ("isb " #option : : : "memory")
#define dsb(option) __asm__ __volatile__ ("dsb " #option : : : "memory")
#define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
#define isb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
: : "r" (0) : "memory")
#define dsb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
: : "r" (0) : "memory")
#define dmb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \
: : "r" (0) : "memory")
#elif defined(CONFIG_CPU_FA526)
#define isb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
: : "r" (0) : "memory")
#define dsb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
: : "r" (0) : "memory")
#define dmb(x) __asm__ __volatile__ ("" : : : "memory")
#else
#define isb(x) __asm__ __volatile__ ("" : : : "memory")
#define dsb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
: : "r" (0) : "memory")
#define dmb(x) __asm__ __volatile__ ("" : : : "memory")
#endif

#ifdef CONFIG_ARCH_HAS_BARRIERS
#include <mach/barriers.h>
#elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP)
#define mb() do { dsb(); outer_sync(); } while (0)
#define rmb() dsb()
#define wmb() do { dsb(st); outer_sync(); } while (0)
#define dma_rmb() dmb(osh)
#define dma_wmb() dmb(oshst)
#else
#define mb() barrier()
#define rmb() barrier()
#define wmb() barrier()
#define dma_rmb() barrier()
#define dma_wmb() barrier()
#endif

#ifndef CONFIG_SMP
#define smp_mb() barrier()
#define smp_rmb() barrier()
#define smp_wmb() barrier()
#else
#define smp_mb() dmb(ish)
#define smp_rmb() smp_mb()
#define smp_wmb() dmb(ishst)
#endif

#undef smp_store_release
#define smp_store_release(p, v) \
do { \
smp_mb(); \
ACCESS_ONCE(*p) = (v); \
} while (0)
do { \
smp_mb(); \
ACCESS_ONCE(*p) = (v); \
} while (0)

#define smp_load_acquire(p) \
({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
smp_mb(); \
___p1; \
})

#define read_barrier_depends() do { } while(0)
#define smp_read_barrier_depends() do { } while(0)

#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)

#define smp_mb__before_atomic() smp_mb()
#define smp_mb__after_atomic() smp_mb()

#endif /* !__ASSEMBLY__ */
#endif /* __ASM_BARRIER_H */
1 change: 1 addition & 0 deletions arch/lib/include/asm/cache.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/cachetype.h
10 changes: 0 additions & 10 deletions arch/lib/include/asm/elf.h

This file was deleted.

1 change: 1 addition & 0 deletions arch/lib/include/asm/elf.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/glue-proc.h
25 changes: 25 additions & 0 deletions arch/lib/include/asm/glue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* arch/arm/include/asm/glue.h
*
* Copyright (C) 1997-1999 Russell King
* Copyright (C) 2000-2002 Deep Blue Solutions Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This file provides the glue to stick the processor-specific bits
* into the kernel in an efficient manner. The idea is to use branches
* when we're only targeting one class of TLB, or indirect calls
* when we're targeting multiple classes of TLBs.
*/
#ifdef __KERNEL__

#ifdef __STDC__
#define ____glue(name,fn) name##fn
#else
#define ____glue(name,fn) name/**/fn
#endif
#define __glue(name,fn) ____glue(name,fn)

#endif
8 changes: 0 additions & 8 deletions arch/lib/include/asm/hardirq.h

This file was deleted.

1 change: 1 addition & 0 deletions arch/lib/include/asm/hardirq.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/highmem.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/hwcap.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/kmap_types.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/memory.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/mmu.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/outercache.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/page-arm.h
24 changes: 13 additions & 11 deletions arch/lib/include/asm/page.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifndef _ASM_SIM_PAGE_H
#define _ASM_SIM_PAGE_H

typedef struct {} pud_t;

#define THREAD_ORDER 1
#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
/*
* arch/arm/include/asm/page.h
*
* Copyright (C) 1995-2003 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _ASM_LIB_PAGE_H
#define _ASM_LIB_PAGE_H

#define WANT_PAGE_VIRTUAL 1
#include <asm/page-arm.h>

#include <asm-generic/page.h>
#include <asm-generic/getorder.h>

#endif /* _ASM_SIM_PAGE_H */
#endif
1 change: 1 addition & 0 deletions arch/lib/include/asm/pgtable-2level-hwdef.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/pgtable-2level-types.h
1 change: 1 addition & 0 deletions arch/lib/include/asm/pgtable-2level.h
Loading

0 comments on commit 82c0c7a

Please sign in to comment.