diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/aarch64/conf/GENERIC | 7 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 16 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/mp.c | 17 | ||||
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 8 |
4 files changed, 23 insertions, 25 deletions
diff --git a/sys/arch/aarch64/conf/GENERIC b/sys/arch/aarch64/conf/GENERIC index eeb9d9d..702a248 100644 --- a/sys/arch/aarch64/conf/GENERIC +++ b/sys/arch/aarch64/conf/GENERIC @@ -1,10 +1,3 @@ // Kernel options option SERIAL_DEBUG yes // Enable kmsg serial logging option USER_KMSG yes // Show kmsg in user consoles - -// Kernel constants -setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ) - -// Console attributes -setval CONSOLE_BG 0x000000 -setval CONSOLE_FG 0xB57614 diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 40950f9..efd1af8 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -111,8 +111,16 @@ tlb_shootdown_isr(void *p) } static void -setup_vectors(void) +setup_vectors(struct cpu_info *ci) { + union tss_stack scstack; + + /* Try to allocate a syscall stack */ + if (tss_alloc_stack(&scstack, DEFAULT_PAGESIZE) != 0) { + panic("failed to allocate syscall stack\n"); + } + + tss_update_ist(ci, scstack, IST_SYSCALL); idt_set_desc(0x0, IDT_TRAP_GATE, ISR(arith_err), 0); idt_set_desc(0x2, IDT_TRAP_GATE, ISR(nmi), 0); idt_set_desc(0x3, IDT_TRAP_GATE, ISR(breakpoint_handler), 0); @@ -125,7 +133,7 @@ setup_vectors(void) idt_set_desc(0xC, IDT_TRAP_GATE, ISR(ss_fault), 0); idt_set_desc(0xD, IDT_TRAP_GATE, ISR(general_prot), 0); idt_set_desc(0xE, IDT_TRAP_GATE, ISR(page_fault), 0); - idt_set_desc(0x80, IDT_USER_INT_GATE, ISR(syscall_isr), 0); + idt_set_desc(0x80, IDT_USER_INT_GATE, ISR(syscall_isr), IST_SYSCALL); idt_set_desc(HALT_VECTOR, IDT_INT_GATE, ISR(cpu_halt_isr), 0); idt_set_desc(TLB_VECTOR, IDT_INT_GATE, ISR(tlb_shootdown_isr), 0); pin_isr_load(); @@ -405,10 +413,10 @@ cpu_startup(struct cpu_info *ci) gdt_load(); idt_load(); - setup_vectors(); wrmsr(IA32_GS_BASE, (uintptr_t)ci); - init_tss(ci); + setup_vectors(ci); + try_mitigate_spectre(); cpu_get_info(ci); diff --git a/sys/arch/amd64/amd64/mp.c b/sys/arch/amd64/amd64/mp.c index 21881b2..20f550f 100644 --- a/sys/arch/amd64/amd64/mp.c +++ b/sys/arch/amd64/amd64/mp.c @@ -56,6 +56,7 @@ static void ap_trampoline(struct limine_smp_info *si) { struct cpu_info *ci; + struct proc *idle; ci = dynalloc(sizeof(*ci)); __assert(ci != NULL); @@ -64,6 +65,11 @@ ap_trampoline(struct limine_smp_info *si) cpu_startup(ci); spinlock_acquire(&ci_list_lock); ci_list[ncpu_up] = ci; + + ci->id = ncpu_up; + spawn(&g_proc0, sched_enter, NULL, 0, &idle); + proc_pin(idle, ci->id); + spinlock_release(&ci_list_lock); atomic_inc_int(&ncpu_up); @@ -110,6 +116,7 @@ mp_bootstrap_aps(struct cpu_info *ci) { struct limine_smp_response *resp = g_smp_req.response; struct limine_smp_info **cpus; + struct proc *idle; size_t cpu_init_counter; uint32_t ncpu; @@ -121,6 +128,10 @@ mp_bootstrap_aps(struct cpu_info *ci) cpu_init_counter = ncpu - 1; ci_list[0] = ci; + /* Pin an idle thread to the BSP */ + spawn(&g_proc0, sched_enter, NULL, 0, &idle); + proc_pin(idle, 0); + if (resp->cpu_count == 1) { pr_trace("CPU has 1 core, no APs to bootstrap...\n"); return; @@ -136,12 +147,6 @@ mp_bootstrap_aps(struct cpu_info *ci) cpus[i]->goto_address = ap_trampoline; } - /* Start up idle threads */ - pr_trace("kicking %d idle threads...\n", ncpu); - for (uint32_t i = 0; i < ncpu; ++i) { - spawn(&g_proc0, sched_enter, NULL, 0, NULL); - } - /* Wait for all cores to be ready */ while ((ncpu_up - 1) < cpu_init_counter); } diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index e407fa9..6f573f3 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -9,12 +9,4 @@ option SPECTRE_IBRS no // Enable the IBRS CPU feature option SERIAL_DEBUG yes // Enable kmsg serial logging option USER_KMSG no // Show kmsg in user consoles option CPU_SMEP yes // Supervisor Memory Exec Protection -option PANIC_SCR no // Clear screen on panic option I8042_POLL yes // Use polling for the i8042 - -// Kernel constants -setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ) - -// Console attributes -setval CONSOLE_BG 0x000000 -setval CONSOLE_FG 0xB57614 |