x86_64: implement proper user/kernel %gs base switching

the %gs base address is now always set to the current cpu block while
in kernel-mode, and is switched back to the userspace %gs base
when returning to user-mode.
This commit is contained in:
2026-02-23 18:26:21 +00:00
parent 273557fa9f
commit dbe117135b
4 changed files with 47 additions and 15 deletions

View File

@@ -1,5 +1,3 @@
#include "arch/msr.h"
#include <arch/gdt.h>
#include <arch/tss.h>
#include <kernel/libc/string.h>
@@ -22,9 +20,6 @@ void tss_init(struct tss *tss, struct tss_ptr *ptr)
void tss_load(struct tss *tss)
{
tss_flush(TSS_GDT_INDEX);
uintptr_t kernel_gs_base_reg = 0xC0000102;
wrmsr(kernel_gs_base_reg, (uintptr_t)tss);
}
virt_addr_t tss_get_kstack(struct tss *tss)