From: Jan Kiszka <[email protected]> Modern Intel CPUs provide a set of new instruction (tpause, umonitor, umwait) which need to be permitted by the hypervisor. Otherwise, they cause #UD. The Linux kernel uses tpause for implementing udelay since kernel 5.8. So we will see crashes when denying this under Jailhouse.
The pattern to enable it is analogous to rdtscp, xsaves & Co. Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/x86/include/asm/processor.h | 3 +++ hypervisor/arch/x86/include/asm/vmx.h | 1 + hypervisor/arch/x86/vmx.c | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hypervisor/arch/x86/include/asm/processor.h b/hypervisor/arch/x86/include/asm/processor.h index 3a7d9f93..faba3ecc 100644 --- a/hypervisor/arch/x86/include/asm/processor.h +++ b/hypervisor/arch/x86/include/asm/processor.h @@ -32,6 +32,9 @@ #define X86_FEATURE_INVPCID (1 << 10) #define X86_FEATURE_CAT (1 << 15) +/* leaf 0x07, subleaf 0, ECX */ +#define X86_FEATURE_WAITPKG (1 << 5) + /* leaf 0x0d, subleaf 1, EAX */ #define X86_FEATURE_XSAVES (1 << 3) diff --git a/hypervisor/arch/x86/include/asm/vmx.h b/hypervisor/arch/x86/include/asm/vmx.h index c03ffc55..5b0c0653 100644 --- a/hypervisor/arch/x86/include/asm/vmx.h +++ b/hypervisor/arch/x86/include/asm/vmx.h @@ -228,6 +228,7 @@ enum vmx_state { VMXOFF = 0, VMXON, VMCS_READY }; #define SECONDARY_EXEC_UNRESTRICTED_GUEST (1UL << 7) #define SECONDARY_EXEC_INVPCID (1UL << 12) #define SECONDARY_EXEC_XSAVES (1UL << 20) +#define SECONDARY_EXEC_USR_WAIT_PAUSE (1UL << 26) #define VM_EXIT_HOST_ADDR_SPACE_SIZE (1UL << 9) #define VM_EXIT_SAVE_IA32_PAT (1UL << 18) diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c index bf25d00d..5a69710d 100644 --- a/hypervisor/arch/x86/vmx.c +++ b/hypervisor/arch/x86/vmx.c @@ -237,13 +237,16 @@ static int vmx_check_features(void) !(vmx_proc_ctrl2 & SECONDARY_EXEC_UNRESTRICTED_GUEST)) return trace_error(-EIO); - /* require RDTSCP, INVPCID, XSAVES if present in CPUID */ + /* require RDTSCP, INVPCID, XSAVES, TPAUSE/UMONITOR/UMWAIT if present + * in CPUID */ if (cpuid_edx(0x80000001, 0) & X86_FEATURE_RDTSCP) secondary_exec_addon |= SECONDARY_EXEC_RDTSCP; if (cpuid_ebx(0x07, 0) & X86_FEATURE_INVPCID) secondary_exec_addon |= SECONDARY_EXEC_INVPCID; if (cpuid_eax(0x0d, 1) & X86_FEATURE_XSAVES) secondary_exec_addon |= SECONDARY_EXEC_XSAVES; + if (cpuid_ecx(0x07, 0) & X86_FEATURE_WAITPKG) + secondary_exec_addon |= SECONDARY_EXEC_USR_WAIT_PAUSE; if ((vmx_proc_ctrl2 & secondary_exec_addon) != secondary_exec_addon) return trace_error(-EIO); -- 2.34.1 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/5e6cbd45-054b-6ddd-f104-a567cfcfb433%40siemens.com.
