Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port-mm-code #47

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e929a63
Push my initial work for uploading memory manager
Jun 1, 2015
c50cd20
add slib_env to use page_alloc.c
Jun 1, 2015
f0f45ab
Add headers from arm/include/asm and try to initilize buddy system fr…
Jun 2, 2015
ed2c3fe
recover init/main.c
Jun 2, 2015
dfe766d
add WANT_PAGE_VIRTUAL to use page->virtual
Jun 2, 2015
63b48b1
a working version done
Jun 3, 2015
13c94a1
delete prink debug message
Jun 3, 2015
abebc87
add a tiny change
Jun 18, 2015
05cd7d3
try to make no impact on upstream kernel
Jun 18, 2015
fbe7dd3
solve OPT=no compiler crash
Jun 18, 2015
883afb4
solve undefined symbol for init_mm
Jun 18, 2015
4cbbff4
Merge pull request #1 from libos-nuse/nuse
jyizheng Jun 27, 2015
07bc3b6
Merge pull request #2 from libos-nuse/master
jyizheng Jun 27, 2015
6064bf2
test
jyizheng Sep 1, 2015
305f67b
add build.sh
jyizheng Sep 1, 2015
7a2bd8d
remove test
jyizheng Sep 1, 2015
56bc555
delete build.sh
jyizheng Sep 1, 2015
770464d
merge arch/lib/glue.c
jyizheng Sep 1, 2015
8f1788e
add #endif
jyizheng Sep 1, 2015
f583c91
solve some unreferced symbol problem
jyizheng Sep 2, 2015
ebcdbff
change barrier.h
jyizheng Sep 2, 2015
16399d4
Merge upstream which solved unresovle symbol "rumpns_end"
jyizheng Sep 2, 2015
93273fd
disable some compile time check for atomic variables
jyizheng Sep 2, 2015
71adfe1
Do cleanup according to Hajime's suggestions.
jyizheng Sep 3, 2015
ff865bc
git rid of #if 0 useless code
jyizheng Sep 3, 2015
58602f8
Resolve Hajime'c commemts. Check here:
jyizheng Sep 3, 2015
53d0f17
add cache_is_vivt back to highmem.c again to resolve some warnings
jyizheng Sep 3, 2015
099e19c
resolve merge conflit
jyizheng Sep 4, 2015
396eca8
resolve pull request comments
jyizheng Sep 7, 2015
3573715
1)Change __MR_MAX_ZONES in arch/lib/Makefile
jyizheng Sep 7, 2015
34af0b6
Lib:
jyizheng Sep 7, 2015
7b04e14
disable compile time check
jyizheng Sep 7, 2015
a7c9ded
resolve pull request comments
jyizheng Sep 8, 2015
a68bf58
add something missing in the last commit
jyizheng Sep 8, 2015
fe485cf
Merge remote-tracking branch 'upstream/master'
jyizheng Oct 10, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 3 additions & 2 deletions arch/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ kernel/time/_to_keep=time.o timekeeping.o jiffies.o clocksource.o ntp.o
kernel/rcu_to_keep=rcu/srcu.o rcu/pdate.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 @@ -127,7 +128,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;
}
45 changes: 42 additions & 3 deletions arch/lib/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
#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;
/* used by sysinfo in kernel/timer.c */
Expand All @@ -59,6 +59,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 +306,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to remind private message to @jyizheng )

  1. I would like to see whether those include/asm code taken from arch/arm can replace with asm-generic headers or not.
  2. if there is a certain reason to use another arch code (e.g., arm), then symbolic link or copying automatically during make would be nicer than stored in arch/lib/include.

#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
1 change: 1 addition & 0 deletions arch/lib/include/asm/pgtable-hwdef.h
Loading