aboutsummaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-02-29 11:15:35 -0500
committerIan Moffett <ian@osmora.org>2024-02-29 11:15:35 -0500
commit6d5dbb5ff23bf64ac4ea99e11adbde5583be522c (patch)
tree7d7f8605cfa268ceaa4b0eb9bf0a8892f680a330 /sys/arch/amd64
parent04c1af796571245635e5b6627b29840a7420b60c (diff)
kernel/amd64: tss: Allocate stack for RSP0
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/tss.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/tss.c b/sys/arch/amd64/amd64/tss.c
index 8bd7deb..aefc1f2 100644
--- a/sys/arch/amd64/amd64/tss.c
+++ b/sys/arch/amd64/amd64/tss.c
@@ -43,6 +43,9 @@ static void
alloc_resources(struct cpu_info *cpu)
{
struct tss_entry *tss;
+ const size_t STACK_SIZE = 0x1000;
+ static uintptr_t rsp0_base = 0, rsp0 = 0;
+
/*
* Allocate TSS entries for this CPU
@@ -50,9 +53,19 @@ alloc_resources(struct cpu_info *cpu)
if (cpu->tss == NULL) {
/* Allocate a TSS for this CPU */
tss = dynalloc(sizeof(*tss));
+
if (tss == NULL)
panic("Failed to alloc %d bytes for TSS\n", sizeof(*tss));
+
memset(tss, 0, sizeof(*tss));
+ rsp0_base = (uintptr_t)dynalloc(STACK_SIZE);
+
+ if (rsp0_base == 0)
+ panic("Could not allocate rsp0 base\n");
+
+ rsp0 = rsp0_base + STACK_SIZE;
+ tss->rsp0_lo = __SHIFTOUT(rsp0, __MASK(32));
+ tss->rsp0_hi = __SHIFTOUT(rsp0, __MASK(32) << 32);
cpu->tss = tss;
}
}