diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-14 21:30:11 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-14 21:30:11 +0300 |
| commit | cabbf335824db0df835e4c541c19d3803ce38454 (patch) | |
| tree | e7397d2b6637545b8e18f26135e3ad2a0a2fbe1e /common/tcb.c | |
| parent | 025778e89e7d0fe3cd1ad53537c9cc6f3cd819cc (diff) | |
| download | kmi-cabbf335824db0df835e4c541c19d3803ce38454.tar.gz kmi-cabbf335824db0df835e4c541c19d3803ce38454.zip | |
add canary to kernel stack
Diffstat (limited to 'common/tcb.c')
| -rw-r--r-- | common/tcb.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/tcb.c b/common/tcb.c index 1e25f47..9768eb0 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -7,7 +7,6 @@ */ #include <apos/tcb.h> -#include <arch/cpu.h> #include <apos/mem.h> #include <apos/conf.h> #include <apos/pmem.h> @@ -16,6 +15,9 @@ #include <apos/types.h> #include <apos/assert.h> #include <apos/string.h> +#include <apos/canary.h> + +#include <arch/cpu.h> #include <arch/vmem.h> /* arguably exessively many globals... */ @@ -137,7 +139,7 @@ struct tcb *create_thread(struct tcb *p) { hard_assert(tcbs, 0); - vm_t bottom = alloc_page(MM_O0, 0); + vm_t bottom = alloc_page(KERNEL_STACK_PAGE_ORDER, 0); /* move tcb to top of kernel stack, keeping alignment in check * (hopefully) */ /** \todo check alignment */ @@ -163,6 +165,7 @@ struct tcb *create_thread(struct tcb *p) t->rid = p->rid; t->rpc.vmem = create_vmem(); + set_canary(t); return t; } @@ -303,8 +306,9 @@ struct tcb *cur_proc() void use_tcb(struct tcb *t) { - t->cpu_id = cpu_id(); - cpu_tcb[cpu_id()] = t; + id_t cpu = cpu_id(); + t->cpu_id = cpu; + cpu_tcb[cpu] = t; } struct tcb *get_tcb(id_t tid) |
