From: Jeff Dike This patch calculates section boundaries differently so as to not get tripped up by holes in the binary such as are introduced by exec-shield. Signed-off-by: Andrew Morton --- 25-akpm/arch/um/kernel/tt/process_kern.c | 2 +- 25-akpm/arch/um/kernel/um_arch.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff -puN arch/um/kernel/tt/process_kern.c~uml-fix-binary-layout-assumption arch/um/kernel/tt/process_kern.c --- 25/arch/um/kernel/tt/process_kern.c~uml-fix-binary-layout-assumption 2004-09-11 16:40:03.797641144 -0700 +++ 25-akpm/arch/um/kernel/tt/process_kern.c 2004-09-11 16:40:03.802640384 -0700 @@ -423,7 +423,7 @@ static void mprotect_kernel_mem(int w) protect_memory(start, end - start, 1, w, 1, 1); start = (unsigned long) UML_ROUND_DOWN(&__bss_start); - end = (unsigned long) UML_ROUND_UP(&_end); + end = (unsigned long) UML_ROUND_UP(brk_start); protect_memory(start, end - start, 1, w, 1, 1); mprotect_kernel_vm(w); diff -puN arch/um/kernel/um_arch.c~uml-fix-binary-layout-assumption arch/um/kernel/um_arch.c --- 25/arch/um/kernel/um_arch.c~uml-fix-binary-layout-assumption 2004-09-11 16:40:03.799640840 -0700 +++ 25-akpm/arch/um/kernel/um_arch.c 2004-09-11 16:40:03.803640232 -0700 @@ -306,7 +306,7 @@ unsigned long end_iomem; int linux_main(int argc, char **argv) { - unsigned long avail; + unsigned long avail, diff; unsigned long virtmem_size, max_physmem; unsigned int i, add; @@ -324,6 +324,16 @@ int linux_main(int argc, char **argv) brk_start = (unsigned long) sbrk(0); CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); + /* Increase physical memory size for exec-shield users + so they actually get what they asked for. This should + add zero for non-exec shield users */ + + diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end); + if(diff > 1024 * 1024){ + printf("Adding %ld bytes to physical memory to account for " + "exec-shield gap\n", diff); + physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end); + } uml_physmem = uml_start; _