[kernel] Set mxcsr and xcr0 in cpu_early_init

There are some SSE instructions (moveaps, moveups) in userland code that
QEMU software emulation seems to be fine with but generate `#UD` on KVM.
So let's finally get floating-point support working. This is the first
step, just setting the control regs to try to fix that error.
This commit is contained in:
Justin C. Miller
2023-02-23 18:22:22 -08:00
parent 841ac41e36
commit 95627ba43c
5 changed files with 87 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
CPU_FEATURE_OPT(pcid, 0x00000001, 0, ecx, 17)
CPU_FEATURE_OPT(x2apic, 0x00000001, 0, ecx, 21)
CPU_FEATURE_REQ(xsave, 0x00000001, 0, ecx, 26)
CPU_FEATURE_OPT(in_hv, 0x00000001, 0, ecx, 31)
CPU_FEATURE_REQ(fpu, 0x00000001, 0, edx, 0)
@@ -19,6 +21,11 @@ CPU_FEATURE_OPT(invpcid, 0x00000007, 0, ebx, 10)
CPU_FEATURE_OPT(pku, 0x00000007, 0, ecx, 3)
CPU_FEATURE_OPT(rdpid, 0x00000007, 0, ecx, 22)
CPU_FEATURE_OPT(xsaveopt, 0x0000000d, 1, eax, 0)
CPU_FEATURE_OPT(xsavec, 0x0000000d, 1, eax, 1)
CPU_FEATURE_OPT(xinuse, 0x0000000d, 1, eax, 2)
CPU_FEATURE_OPT(xsaves, 0x0000000d, 1, eax, 3)
CPU_FEATURE_OPT(extapic, 0x80000001, 0, ecx, 3)
CPU_FEATURE_OPT(rdtscp, 0x80000001, 0, edx, 27)