From 6132623dbf3076da11cdb85c494fadd7ee0f0a93 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 2 Dec 2024 21:02:35 +0100 Subject: Share the same stack everywhere MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As documented in the code, we are not implementing any kind of memory protection, so in theory any process (regardless if running in user or kernel space) would be able to tamper with other processes' stack. Hence, don't even pretend that we are separating stacks and share the same global stack everywhere. This simplifies things a bit. Signed-off-by: Miquel Sabaté Solà --- kernel/head.S | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'kernel/head.S') diff --git a/kernel/head.S b/kernel/head.S index 9a12833..4390cc9 100644 --- a/kernel/head.S +++ b/kernel/head.S @@ -94,11 +94,13 @@ _start_kernel: li t6, 0 csrw sscratch, 0 - // Point tp and sp to the init task. The 'tp' register will always point to - // the current process being executed, and it will be shown on debug when + // Point 'tp' to the init task. The 'tp' register will always point to the + // current process being executed, and it will be shown on debug when // printing out messages. la tp, tasks - la sp, tasks + THREAD_SIZE + + // Point 'sp' the our general stack. + la sp, stack + THREAD_SIZE // The `start_kernel` function requires an argument to be passed, which is // the pointer to the `fdt` blob. The bootloader puts this on the `a1` -- cgit v1.2.3