diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-02 21:02:35 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-02 21:02:35 +0100 |
| commit | 6132623dbf3076da11cdb85c494fadd7ee0f0a93 (patch) | |
| tree | bcfeaade99c13b9a02fff282e8ef3998e405f14a /kernel/main.c | |
| parent | d4e2441ad7063ce7ca29981ca527b1aa643b0b0c (diff) | |
| download | fbos-6132623dbf3076da11cdb85c494fadd7ee0f0a93.tar.gz fbos-6132623dbf3076da11cdb85c494fadd7ee0f0a93.zip | |
Share the same stack everywhere
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à <mikisabate@gmail.com>
Diffstat (limited to 'kernel/main.c')
| -rw-r--r-- | kernel/main.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/kernel/main.c b/kernel/main.c index 9c524c4..19220f6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -4,16 +4,22 @@ #include <fbos/sched.h> #include <fbos/dt.h> -// Stacks to be used by our processes. -unsigned long stack[4][THREAD_SIZE / sizeof(unsigned long)]; +// Stack to be used by our processes. "Blasphemy!" I hear you say. "How dare you +// use the same stack for kernel and user space?" It's not like this is some +// sort of utopian system in which everyone shares everything, but since this +// stupidly simple kernel does not even bother to implement paging nor any other +// memory protection of any kind, it's not like separating stacks for each +// process and kernel space would make much of a difference. Hence, let's keep +// it simple and have the same stack everwhere. +uint64_t stack[THREAD_SIZE / sizeof(uint64_t)]; // Initialize the list of structs by providing a fixed stack address and empty // values everywhere else. struct task_struct tasks[4] = { - [TASK_INIT] = { .stack = stack[0], .name = "init", .entry_addr = nullptr, }, - [TASK_FIZZ] = { .stack = stack[1], .name = "fizz", .entry_addr = nullptr, }, - [TASK_BUZZ] = { .stack = stack[2], .name = "buzz", .entry_addr = nullptr, }, - [TASK_FIZZBUZZ] = { .stack = stack[3], .name = "fizzbuzz", .entry_addr = nullptr, }, + [TASK_INIT] = { .stack = stack, .name = "init", .entry_addr = nullptr, }, + [TASK_FIZZ] = { .stack = stack, .name = "fizz", .entry_addr = nullptr, }, + [TASK_BUZZ] = { .stack = stack, .name = "buzz", .entry_addr = nullptr, }, + [TASK_FIZZBUZZ] = { .stack = stack, .name = "fizzbuzz", .entry_addr = nullptr, }, }; // Defined in fbos/init.h. |
