diff options
| author | Ian Moffett <ian@osmora.org> | 2025-11-19 19:00:55 -0500 |
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2025-11-19 19:00:55 -0500 |
| commit | d6d40e9ecf2aff5b1e265d26f7651e8633eddabd (patch) | |
| tree | a90fea7b0553ce08a20078ab11049bf789c53c49 /sys/arch | |
| parent | fd43b12a711856e23e010b4b561ecc6aa6940074 (diff) | |
kern/amd64: mp: Load per-core GDT/IDT
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch')
| -rw-r--r-- | sys/arch/amd64/cpu/mp.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/arch/amd64/cpu/mp.c b/sys/arch/amd64/cpu/mp.c index 1fdc9f7..6911a49 100644 --- a/sys/arch/amd64/cpu/mp.c +++ b/sys/arch/amd64/cpu/mp.c @@ -105,6 +105,9 @@ struct mtrr_save { uintptr_t physmask[256]; } mtrr_save; +extern struct gdtr GDTR; +extern void idt_load(void); + static struct cpu_info *cpu_list[MAX_CPUS]; static struct ap_bootspace bs; static volatile size_t ap_sync = 0; @@ -293,6 +296,18 @@ cpu_lm_entry(void) atomic_inc_int(&aps_up); cpu_list[aps_up] = ci; + /* Initialize the GDT */ + memcpy(ci->ap_gdt, (void *)GDTR.offset, GDTR.limit); + ci->ap_gdtr.offset = (uintptr_t)&ci->ap_gdt[0]; + ci->ap_gdtr.limit = GDTR.limit; + __asmv( + "lgdt %0" + : + : "m" (ci->ap_gdtr) + : "memory" + ); + + idt_load(); cpu_idle(); __builtin_unreachable(); } |
