diff --git a/headers/private/kernel/arch/x86/64/cpu.h b/headers/private/kernel/arch/x86/64/cpu.h index 02860371b8..e6c15951c6 100644 --- a/headers/private/kernel/arch/x86/64/cpu.h +++ b/headers/private/kernel/arch/x86/64/cpu.h @@ -48,6 +48,8 @@ x86_context_switch(arch_thread* oldState, arch_thread* newState) "r14", "r15", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15", "memory"); + // so that x87 FPU floating-point instructions can be executed + asm volatile("emms"); asm volatile("ldmxcsr %0" : : "m" (sseControl)); asm volatile("fldcw %0" : : "m" (fpuControl)); } diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index 9281a5e71a..05eff26306 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -161,6 +161,9 @@ x86_unexpected_exception(iframe* frame) // TODO: Determine the correct cause via the FPU status // register! signalAddress = frame->ip; + // clear any pending exceptions, otherwise loading a new control word + // could raise exceptions. + asm volatile("fnclex"); break; case 17: // Alignment Check Exception (#AC)