diff options
author | Ian Moffett <ian@osmora.org> | 2025-04-18 21:57:44 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-04-18 21:57:44 -0400 |
commit | 9906547712a88cf4dc012a6f6bd6e2ad04c5e3f3 (patch) | |
tree | 41b40ec97f5082793b08a495f6a935bc3c1ed25f /sys/arch/amd64/amd64 | |
parent | 0b5adaff02190dad76d845381a41b998696d9e97 (diff) | |
parent | 92d4f9dae64ab5325feca1f39e5955415e8275b9 (diff) |
Merge branch 'expt' into aarch64
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/lapic_intr.S | 5 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 14 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 20 |
3 files changed, 36 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/lapic_intr.S b/sys/arch/amd64/amd64/lapic_intr.S index ab6f5ab..e22cbca 100644 --- a/sys/arch/amd64/amd64/lapic_intr.S +++ b/sys/arch/amd64/amd64/lapic_intr.S @@ -33,6 +33,7 @@ .globl lapic_tmr_isr INTRENTRY(lapic_tmr_isr, handle_lapic_tmr) handle_lapic_tmr: - call sched_switch - call lapic_eoi + call sched_switch // Context switch per every timer IRQ + call i8042_sync // Sometimes needed depending on i8042 quirks + call lapic_eoi // Done! Signal that we finished to the Local APIC retq diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index a5fb4bf..07d6cdd 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -40,7 +40,9 @@ #include <machine/cpuid.h> #include <machine/lapic.h> #include <machine/uart.h> +#include <machine/sync.h> #include <machine/intr.h> +#include <machine/isa/i8042var.h> #if defined(__SPECTRE_IBRS) #define SPECTRE_IBRS __SPECTRE_IBRS @@ -207,6 +209,17 @@ this_cpu(void) return ci; } +/* + * Sync all system operation + */ +int +md_sync_all(void) +{ + lapic_eoi(); + i8042_sync(); + return 0; +} + void cpu_startup(struct cpu_info *ci) { @@ -220,6 +233,5 @@ cpu_startup(struct cpu_info *ci) init_tss(ci); try_mitigate_spectre(); - __ASMV("sti"); /* Unmask interrupts */ lapic_init(); } diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 29056b0..9a3a7ba 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -35,6 +35,8 @@ #include <sys/syscall.h> #include <sys/sched.h> #include <sys/proc.h> +#include <machine/cpu.h> +#include <machine/isa/i8042var.h> #include <machine/trap.h> #include <machine/frame.h> #include <machine/intr.h> @@ -118,6 +120,20 @@ trap_user(struct trapframe *tf) dispatch_signals(td); } +static void +trap_quirks(struct cpu_info *ci) +{ + static uint8_t count; + + if (ISSET(ci->irq_mask, CPU_IRQ(1)) && count < 1) { + ++count; + pr_error("detected buggy i8042\n"); + pr_error("applying I8042_HOSTILE quirk\n"); + i8042_quirk(I8042_HOSTILE); + return; + } +} + void trap_syscall(struct trapframe *tf) { @@ -139,6 +155,8 @@ trap_syscall(struct trapframe *tf) void trap_handler(struct trapframe *tf) { + struct cpu_info *ci; + splraise(IPL_HIGH); if (tf->trapno >= NELEM(trap_type)) { @@ -146,6 +164,8 @@ trap_handler(struct trapframe *tf) } pr_error("got %s\n", trap_type[tf->trapno]); + ci = this_cpu(); + trap_quirks(ci); /* Handle traps from userland */ if (ISSET(tf->cs, 3)) { |