From de4847156b6eb9c27b436bbc00cbd5fcfbe217af Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 6 Oct 2018 22:01:49 +0100 Subject: [PATCH] kernel: allow for cases with only a small window in the base page If you have a 4x16K or similar mapping model and most of the upper page is taken up by discard and common then there may not be 4K to randomly play with. In that case firstly we overflow and miscalculate the pages, secondly we then scribble on stuff we shouldn't. Instead tighten it up so there needs to be only 512 bytes (plus vectors etc - 256 bytes on Z80) of space. --- Kernel/start.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Kernel/start.c b/Kernel/start.c index f54ee750..0f0d23f4 100644 --- a/Kernel/start.c +++ b/Kernel/start.c @@ -83,7 +83,7 @@ void create_init(void) { uint8_t *j; - udata.u_top = PROGLOAD + 4096; /* Plenty for the boot */ + udata.u_top = PROGLOAD + 512; /* Plenty for the boot */ init_process = ptab_alloc(); udata.u_ptab = init_process; init_process->p_top = udata.u_top; @@ -99,8 +99,10 @@ void create_init(void) *j = NO_FILE; } /* Poke the execve arguments into user data space so _execve() can read them back */ + /* Some systems only have a tiny window we can use at boot as most of + this space is loaded with common memory */ argptr = PROGLOAD; - progptr = PROGLOAD + 2048; + progptr = PROGLOAD + 256; uzero((void *)progptr, 32); add_argument("/init"); @@ -112,7 +114,7 @@ void complete_init(void) uputp(0, (void *)argptr); /* Set up things to look like the process is calling _execve() */ udata.u_argn2 = (arg_t)argptr; /* Environment (none) */ - udata.u_argn = (arg_t)PROGLOAD + 2048; /* "/init" */ + udata.u_argn = (arg_t)PROGLOAD + 256; /* "/init" */ udata.u_argn1 = (arg_t)PROGLOAD; /* Arguments */ #ifdef CONFIG_LEVEL_2 -- 2.34.1