From 29fe6716800e14c9a48951e6cec1b92896604192 Mon Sep 17 00:00:00 2001 From: Jan Kobler Date: Tue, 3 Jun 2014 15:51:55 +0200 Subject: [PATCH] arm: clear highly mapped kernel bss . added bss range values for the high (paged) kernel and clear it in pre_init . this changes the meaning of the current _edata end _end in the pre_init phase to mean: highly mapped bss; and the new symbols _kern_unpaged_edata ... _kern_unpaged_edata to mean directly mapped (pre_init) bss. This was previously _edata and _end. . added a sanity check in kmain (ben@) The values can be verified by: ${CROSS_TOOLS}/arm-elf32-minix-objdump -xD ${OBJ}/kernel/kernel Signed-off-by: Jan Kobler --- kernel/arch/earm/kernel.lds | 8 +++++--- kernel/arch/earm/pre_init.c | 6 ++++++ kernel/main.c | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kernel/arch/earm/kernel.lds b/kernel/arch/earm/kernel.lds index c448dc140..9070b38bb 100644 --- a/kernel/arch/earm/kernel.lds +++ b/kernel/arch/earm/kernel.lds @@ -16,11 +16,10 @@ SECTIONS .unpaged_text ALIGN(4096) : { unpaged_*.o(.text) } .unpaged_data ALIGN(4096) : { unpaged_*.o(.data .rodata*) } - __k_unpaged__kern_unpaged__edata = .; - __k_unpaged__edata = .; + __k_unpaged__kern_unpaged_edata = .; + .unpaged_bss ALIGN(4096) : { unpaged_*.o(.bss COMMON) } __k_unpaged__kern_unpaged_end = .; - __k_unpaged__end = .; . += _kern_offset; @@ -34,12 +33,15 @@ SECTIONS .data ALIGN(4096) : AT(ADDR(.data) - _kern_offset) { *(.data .rodata* ) } . = ALIGN(4096); _edata = .; + __k_unpaged__edata = . - _kern_offset; .bss ALIGN(4096) : AT(ADDR(.bss) - _kern_offset) { *(.bss* COMMON) __k_unpaged__kern_size = . - _kern_vir_base; _kern_size = __k_unpaged__kern_size; + . += 4096; } _end = .; + __k_unpaged__end = . - _kern_offset; /DISCARD/ : { diff --git a/kernel/arch/earm/pre_init.c b/kernel/arch/earm/pre_init.c index 86b4e52aa..a7c757b8f 100644 --- a/kernel/arch/earm/pre_init.c +++ b/kernel/arch/earm/pre_init.c @@ -37,9 +37,14 @@ static void setup_mbi(multiboot_info_t *mbi, char *bootargs); /* Kernel may use memory */ int kernel_may_alloc = 1; +/* kernel bss */ extern u32_t _edata; extern u32_t _end; +/* kernel unpaged bss */ +extern char _kern_unpaged_edata; +extern char _kern_unpaged_end; + /** * * The following function combines a few things together @@ -374,6 +379,7 @@ kinfo_t *pre_init(int argc, char **argv) /* Clear BSS */ memset(&_edata, 0, (u32_t)&_end - (u32_t)&_edata); + memset(&_kern_unpaged_edata, 0, (u32_t)&_kern_unpaged_end - (u32_t)&_kern_unpaged_edata); /* we get called in a c like fashion where the first arg * is the program name (load address) and the rest are diff --git a/kernel/main.c b/kernel/main.c index 8670ba530..cf59c09b0 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -123,6 +123,11 @@ void kmain(kinfo_t *local_cbi) struct boot_image *ip; /* boot image pointer */ register struct proc *rp; /* process pointer */ register int i, j; + static int bss_test; + + /* bss sanity check */ + assert(bss_test == 0); + bss_test = 1; /* save a global copy of the boot parameters */ memcpy(&kinfo, local_cbi, sizeof(kinfo));