| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/26 23:55 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"KVM",
"KVM_INTEL",
"KVM_HYPERV"
],
"FocusSymbols": [
"handle_vmptrld",
"handle_vmptrst"
],
"KMSANReasoning": "The patch modifies `handle_vmptrld` and `handle_vmptrst` in KVM's VMX nested virtualization code. In `handle_vmptrst`, it changes the behavior when eVMCS is used: instead of returning 1 (doing nothing), it now sets the local variable `current_vmptr` to `hv_evmcs_vmptr` and writes it to guest memory. `current_vmptr` is a `gpa_t` (a 64-bit integer), which is fully initialized before being written to the guest via `kvm_write_guest_virt_system`. There are no structs with padding or uninitialized fields involved. The rest of the changes are in KVM selftests. There is no risk of uninitialized memory reads or info-leaks introduced by this patch. Standard KASAN and other bug detectors are sufficient to catch any potential memory corruption or logic bugs.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies the behavior of VMPTRLD and VMPTRST instructions in nested VMX when Enlightened VMCS (eVMCS) is used. It changes VMPTRLD to queue a #UD exception and VMPTRST to return the eVMCS GPA instead of just returning 1. This is a functional change in KVM's nested virtualization logic that is reachable from guest execution and should be fuzzed.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/26 23:55 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 399c2ebb041d26980183aae134635686bb04cb04\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Aug 26 23:55:25 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c\nindex 151873407abd3..3058efa65c82c 100644\n--- a/arch/x86/kvm/vmx/nested.c\n+++ b/arch/x86/kvm/vmx/nested.c\n@@ -5897,6 +5897,12 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)\n \tif (!nested_vmx_check_permission(vcpu))\n \t\treturn 1;\n \n+\t/* Forbid normal VMPTRLD if Enlightened version was used */\n+\tif (nested_vmx_is_evmptr12_valid(vmx)) {\n+\t\tkvm_queue_exception(vcpu, UD_VECTOR);\n+\t\treturn 1;\n+\t}\n+\n \tif (nested_vmx_get_vmptr(vcpu, \u0026vmptr, \u0026r))\n \t\treturn r;\n \n@@ -5906,10 +5912,6 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)\n \tif (vmptr == vmx-\u003enested.vmxon_ptr)\n \t\treturn nested_vmx_fail(vcpu, VMXERR_VMPTRLD_VMXON_POINTER);\n \n-\t/* Forbid normal VMPTRLD if Enlightened version was used */\n-\tif (nested_vmx_is_evmptr12_valid(vmx))\n-\t\treturn 1;\n-\n \tif (vmx-\u003enested.current_vmptr != vmptr) {\n \t\tstruct gfn_to_hva_cache *ghc = \u0026vmx-\u003enested.vmcs12_cache;\n \t\tstruct vmcs_hdr hdr;\n@@ -5962,7 +5964,7 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)\n {\n \tunsigned long exit_qual = vmx_get_exit_qual(vcpu);\n \tu32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);\n-\tgpa_t current_vmptr = to_vmx(vcpu)-\u003enested.current_vmptr;\n+\tgpa_t current_vmptr;\n \tstruct x86_exception e;\n \tgva_t gva;\n \tint r;\n@@ -5970,8 +5972,16 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)\n \tif (!nested_vmx_check_permission(vcpu))\n \t\treturn 1;\n \n-\tif (unlikely(nested_vmx_is_evmptr12_valid(to_vmx(vcpu))))\n-\t\treturn 1;\n+\t/*\n+\t * Hyper-V TLFS does not specify the behavior of VMPTRST when eVMCS is used\n+\t * but genuine Hyper-V seems to be returning eVMCS GPA.\n+\t */\n+#ifdef CONFIG_KVM_HYPERV\n+\tif (nested_vmx_is_evmptr12_valid(to_vmx(vcpu)))\n+\t\tcurrent_vmptr = to_vmx(vcpu)-\u003enested.hv_evmcs_vmptr;\n+\telse\n+#endif\n+\t\tcurrent_vmptr = to_vmx(vcpu)-\u003enested.current_vmptr;\n \n \tif (get_vmx_mem_address(vcpu, exit_qual, instr_info,\n \t\t\t\ttrue, sizeof(gpa_t), \u0026gva))\ndiff --git a/tools/testing/selftests/kvm/include/x86/evmcs.h b/tools/testing/selftests/kvm/include/x86/evmcs.h\nindex 82a8ea6b661f0..c5b9d26f6cdbe 100644\n--- a/tools/testing/selftests/kvm/include/x86/evmcs.h\n+++ b/tools/testing/selftests/kvm/include/x86/evmcs.h\n@@ -265,14 +265,6 @@ static inline bool load_evmcs(struct hyperv_test_pages *hv)\n \treturn true;\n }\n \n-static inline int evmcs_vmptrst(u64 *value)\n-{\n-\t*value = current_vp_assist-\u003ecurrent_nested_vmcs \u0026\n-\t\t~HV_X64_MSR_VP_ASSIST_PAGE_ENABLE;\n-\n-\treturn 0;\n-}\n-\n static inline int evmcs_vmread(u64 encoding, u64 *value)\n {\n \tswitch (encoding) {\ndiff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h\nindex 6e6f70035508a..282b8aaff7995 100644\n--- a/tools/testing/selftests/kvm/include/x86/processor.h\n+++ b/tools/testing/selftests/kvm/include/x86/processor.h\n@@ -1318,7 +1318,7 @@ gva_t vm_alloc_stack(struct kvm_vm *vm, int nr_pages);\n \t\"lea 1f(%%rip), %%r10\\n\\t\"\t\t\t\t\\\n \t\"lea 2f(%%rip), %%r11\\n\\t\"\t\t\t\t\\\n \tfep \"1: \" insn \"\\n\\t\"\t\t\t\t\t\\\n-\t\"xor %%r9, %%r9\\n\\t\"\t\t\t\t\t\\\n+\t\"mov $0, %%r9d\\n\\t\"\t\t\t\t\t\\\n \t\"2:\\n\\t\"\t\t\t\t\t\t\\\n \t\"mov %%r9b, %[vector]\\n\\t\"\t\t\t\t\\\n \t\"mov %%r10, %[error_code]\\n\\t\"\ndiff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h\nindex 04f5e34dea3ae..cd82a6be6963c 100644\n--- a/tools/testing/selftests/kvm/include/x86/vmx.h\n+++ b/tools/testing/selftests/kvm/include/x86/vmx.h\n@@ -309,126 +309,91 @@ struct vmx_msr_entry {\n \n #include \"evmcs.h\"\n \n-static inline int vmxon(u64 phys)\n-{\n-\tu8 ret;\n-\n-\t__asm__ __volatile__ (\"vmxon %[pa]; setna %[ret]\"\n-\t\t: [ret]\"=rm\"(ret)\n-\t\t: [pa]\"m\"(phys)\n-\t\t: \"cc\", \"memory\");\n-\n-\treturn ret;\n+#define GUEST_ASSERT_VMX_INSN_SUCCEEDED(insn, __r, __pa)\t\t\\\n+\t__GUEST_ASSERT(!__r, __stringify(insn) \"[0x%lx] hit %s\",\t\\\n+\t\t __pa, __r \u003c 0 ? \"VM-Fail\" : ex_str(__r))\n+\n+#define BUILD_VMCS_ASM_HELPERS(insn)\t\t\t\t\t\\\n+static inline int __##insn(u64 vmcs_pa)\t\t\t\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\tu64 error_code;\t\t\t\t\t\t\t\\\n+\tu8 vector;\t\t\t\t\t\t\t\\\n+\tu8 failed;\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\tasm volatile(KVM_ASM_SAFE(__stringify(insn) \" %[pa]\")\t\t\\\n+\t\t \"\\n\\tsetna %[failed]\"\t\t\t\t\\\n+\t\t : KVM_ASM_SAFE_OUTPUTS(vector, error_code),\t\\\n+\t\t [failed]\"=qm\"(failed)\t\t\t\t\\\n+\t\t : [pa]\"m\"(vmcs_pa)\t\t\t\t\t\\\n+\t\t : \"cc\", \"memory\", KVM_ASM_SAFE_CLOBBERS);\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\treturn vector ? vector : failed ? -EINVAL : 0;\t\t\t\\\n+}\t\t\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+static inline void insn(u64 vmcs_pa)\t\t\t\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\tint ret = __##insn(vmcs_pa);\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\tGUEST_ASSERT_VMX_INSN_SUCCEEDED(insn, ret, vmcs_pa);\t\t\\\n }\n \n+BUILD_VMCS_ASM_HELPERS(vmxon)\n+BUILD_VMCS_ASM_HELPERS(vmptrld)\n+BUILD_VMCS_ASM_HELPERS(vmclear)\n+\n static inline void vmxoff(void)\n {\n \t__asm__ __volatile__(\"vmxoff\");\n }\n \n-static inline int vmclear(u64 vmcs_pa)\n-{\n-\tu8 ret;\n-\n-\t__asm__ __volatile__ (\"vmclear %[pa]; setna %[ret]\"\n-\t\t: [ret]\"=rm\"(ret)\n-\t\t: [pa]\"m\"(vmcs_pa)\n-\t\t: \"cc\", \"memory\");\n-\n-\treturn ret;\n-}\n-\n-static inline int vmptrld(u64 vmcs_pa)\n-{\n-\tu8 ret;\n-\n-\tif (enable_evmcs)\n-\t\treturn -1;\n-\n-\t__asm__ __volatile__ (\"vmptrld %[pa]; setna %[ret]\"\n-\t\t: [ret]\"=rm\"(ret)\n-\t\t: [pa]\"m\"(vmcs_pa)\n-\t\t: \"cc\", \"memory\");\n-\n-\treturn ret;\n-}\n-\n-static inline int vmptrst(u64 *value)\n+static inline u64 vmptrst(void)\n {\n-\tu64 tmp;\n+\tu64 value = 0;\n \tu8 ret;\n \n-\tif (enable_evmcs)\n-\t\treturn evmcs_vmptrst(value);\n-\n \t__asm__ __volatile__(\"vmptrst %[value]; setna %[ret]\"\n-\t\t: [value]\"=m\"(tmp), [ret]\"=rm\"(ret)\n+\t\t: [value]\"=m\"(value), [ret]\"=rm\"(ret)\n \t\t: : \"cc\", \"memory\");\n \n-\t*value = tmp;\n-\treturn ret;\n-}\n-\n-/*\n- * A wrapper around vmptrst that ignores errors and returns zero if the\n- * vmptrst instruction fails.\n- */\n-static inline u64 vmptrstz(void)\n-{\n-\tu64 value = 0;\n-\tvmptrst(\u0026value);\n+\t__GUEST_ASSERT(!ret, \"vmptrst failed\");\n \treturn value;\n }\n \n-static inline int vmlaunch(void)\n-{\n-\tint ret;\n-\n-\tif (enable_evmcs)\n-\t\treturn evmcs_vmlaunch();\n-\n-\t__asm__ __volatile__(\"push $0;\"\n-\t\t\t \"vmwrite %%rsp, %[host_rsp];\"\n-\t\t\t \"lea 1f(%%rip), %%rax;\"\n-\t\t\t \"vmwrite %%rax, %[host_rip];\"\n-\t\t\t VMX_SWITCH_GPRS_ASM\n-\t\t\t \"vmlaunch;\"\n-\t\t\t \"incq (%%rsp);\"\n-\t\t\t \"1: ;\"\n-\t\t\t VMX_SWITCH_GPRS_ASM\n-\t\t\t \"pop %%rax;\"\n-\t\t\t : [ret]\"=\u0026a\"(ret)\n-\t\t\t : [host_rsp]\"r\"((u64)HOST_RSP),\n-\t\t\t [host_rip]\"r\"((u64)HOST_RIP),\n-\t\t\t GUEST_REGS_OFFSETS\n-\t\t\t : \"memory\", \"cc\");\n-\treturn ret;\n-}\n-\n-static inline int vmresume(void)\n-{\n-\tint ret;\n-\n-\tif (enable_evmcs)\n-\t\treturn evmcs_vmresume();\n-\n-\t__asm__ __volatile__(\"push $0;\"\n-\t\t\t \"vmwrite %%rsp, %[host_rsp];\"\n-\t\t\t \"lea 1f(%%rip), %%rax;\"\n-\t\t\t \"vmwrite %%rax, %[host_rip];\"\n-\t\t\t VMX_SWITCH_GPRS_ASM\n-\t\t\t \"vmresume;\"\n-\t\t\t \"incq (%%rsp);\"\n-\t\t\t \"1: ;\"\n-\t\t\t VMX_SWITCH_GPRS_ASM\n-\t\t\t \"pop %%rax;\"\n-\t\t\t : [ret]\"=\u0026a\"(ret)\n-\t\t\t : [host_rsp]\"r\"((u64)HOST_RSP),\n-\t\t\t [host_rip]\"r\"((u64)HOST_RIP),\n-\t\t\t GUEST_REGS_OFFSETS\n-\t\t\t : \"memory\", \"cc\");\n-\treturn ret;\n+#define BUILD_VMX_VM_ENTRY_HELPERS(insn)\t\t\t\t\\\n+static inline int __##insn(void)\t\t\t\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\tint ret;\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\tif (enable_evmcs)\t\t\t\t\t\t\\\n+\t\treturn evmcs_##insn();\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\t__asm__ __volatile__(\"push $0;\"\t\t\t\t\t\\\n+\t\t\t \"vmwrite %%rsp, %[host_rsp];\"\t\t\\\n+\t\t\t \"lea 1f(%%rip), %%rax;\"\t\t\t\\\n+\t\t\t \"vmwrite %%rax, %[host_rip];\"\t\t\\\n+\t\t\t VMX_SWITCH_GPRS_ASM\t\t\t\\\n+\t\t\t __stringify(insn)\";\"\t\t\t\\\n+\t\t\t \"incq (%%rsp);\"\t\t\t\t\\\n+\t\t\t \"1: ;\"\t\t\t\t\t\\\n+\t\t\t VMX_SWITCH_GPRS_ASM\t\t\t\\\n+\t\t\t \"pop %%rax;\"\t\t\t\t\\\n+\t\t\t : [ret]\"=\u0026a\"(ret)\t\t\t\t\\\n+\t\t\t : [host_rsp]\"r\"((u64)HOST_RSP),\t\t\\\n+\t\t\t [host_rip]\"r\"((u64)HOST_RIP),\t\t\\\n+\t\t\t GUEST_REGS_OFFSETS\t\t\t\\\n+\t\t\t : \"memory\", \"cc\");\t\t\t\t\\\n+\treturn ret;\t\t\t\t\t\t\t\\\n+}\t\t\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+static inline void insn(void)\t\t\t\t\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\tint ret;\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\\\n+\tret = __##insn();\t\t\t\t\t\t\\\n+\t__GUEST_ASSERT(!ret, __stringify(insn) \" hit VM-Fail\");\t\t\\\n }\n+BUILD_VMX_VM_ENTRY_HELPERS(vmlaunch)\n+BUILD_VMX_VM_ENTRY_HELPERS(vmresume)\n \n static inline void vmcall(void)\n {\n@@ -550,9 +515,9 @@ union vmx_ctrl_msr {\n };\n \n struct vmx_pages *vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva);\n-bool prepare_for_vmx_operation(struct vmx_pages *vmx);\n+void prepare_for_vmx_operation(struct vmx_pages *vmx);\n void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip);\n-bool load_vmcs(struct vmx_pages *vmx);\n+void load_vmcs(struct vmx_pages *vmx);\n \n bool ept_1g_pages_supported(void);\n \ndiff --git a/tools/testing/selftests/kvm/lib/x86/memstress.c b/tools/testing/selftests/kvm/lib/x86/memstress.c\nindex e19e8b5a09c5a..6a1815fb97e95 100644\n--- a/tools/testing/selftests/kvm/lib/x86/memstress.c\n+++ b/tools/testing/selftests/kvm/lib/x86/memstress.c\n@@ -33,14 +33,14 @@ __asm__(\n static void l1_vmx_code(struct vmx_pages *vmx, u64 vcpu_id)\n {\n \tGUEST_ASSERT(vmx-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx));\n-\tGUEST_ASSERT(load_vmcs(vmx));\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \tGUEST_ASSERT(ept_1g_pages_supported());\n \n \t*(u64 *)vmx-\u003estack = vcpu_id;\n \tprepare_vmcs(vmx, memstress_l2_guest_entry);\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);\n \tGUEST_DONE();\n }\ndiff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/selftests/kvm/lib/x86/vmx.c\nindex 089e1a8af53fc..5c6cadc08405a 100644\n--- a/tools/testing/selftests/kvm/lib/x86/vmx.c\n+++ b/tools/testing/selftests/kvm/lib/x86/vmx.c\n@@ -125,7 +125,7 @@ vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva)\n \treturn vmx;\n }\n \n-bool prepare_for_vmx_operation(struct vmx_pages *vmx)\n+void prepare_for_vmx_operation(struct vmx_pages *vmx)\n {\n \tu64 feature_control;\n \tu64 required;\n@@ -163,28 +163,20 @@ bool prepare_for_vmx_operation(struct vmx_pages *vmx)\n \n \t/* Enter VMX root operation. */\n \t*(u32 *)(vmx-\u003evmxon) = vmcs_revision();\n-\tif (vmxon(vmx-\u003evmxon_gpa))\n-\t\treturn false;\n-\n-\treturn true;\n+\tvmxon(vmx-\u003evmxon_gpa);\n }\n \n-bool load_vmcs(struct vmx_pages *vmx)\n+void load_vmcs(struct vmx_pages *vmx)\n {\n \t/* Load a VMCS. */\n \t*(u32 *)(vmx-\u003evmcs) = vmcs_revision();\n-\tif (vmclear(vmx-\u003evmcs_gpa))\n-\t\treturn false;\n+\tvmclear(vmx-\u003evmcs_gpa);\n \n-\tif (vmptrld(vmx-\u003evmcs_gpa))\n-\t\treturn false;\n+\tvmptrld(vmx-\u003evmcs_gpa);\n \n \t/* Setup shadow VMCS, do not load it yet. */\n \t*(u32 *)(vmx-\u003eshadow_vmcs) = vmcs_revision() | 0x80000000ul;\n-\tif (vmclear(vmx-\u003eshadow_vmcs_gpa))\n-\t\treturn false;\n-\n-\treturn true;\n+\tvmclear(vmx-\u003eshadow_vmcs_gpa);\n }\n \n static bool ept_vpid_cap_supported(u64 mask)\ndiff --git a/tools/testing/selftests/kvm/x86/aperfmperf_test.c b/tools/testing/selftests/kvm/x86/aperfmperf_test.c\nindex 845cb685f1743..a082658c1e484 100644\n--- a/tools/testing/selftests/kvm/x86/aperfmperf_test.c\n+++ b/tools/testing/selftests/kvm/x86/aperfmperf_test.c\n@@ -70,8 +70,8 @@ static void l1_svm_code(struct svm_test_data *svm)\n \n static void l1_vmx_code(struct vmx_pages *vmx)\n {\n-\tGUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);\n-\tGUEST_ASSERT_EQ(load_vmcs(vmx), true);\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \n \tprepare_vmcs(vmx, NULL);\n \n@@ -83,7 +83,7 @@ static void l1_vmx_code(struct vmx_pages *vmx)\n \t\tvmreadz(CPU_BASED_VM_EXEC_CONTROL) | CPU_BASED_USE_MSR_BITMAPS);\n \n \tGUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n }\n \n static void guest_code(void *nested_test_data)\ndiff --git a/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c b/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c\nindex aa7f3b405fd32..a06f37e0bd068 100644\n--- a/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c\n+++ b/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c\n@@ -55,11 +55,11 @@ static void guest_code(struct vmx_pages *vmx_pages,\n \tenable_vp_assist(hv_pages-\u003evp_assist_gpa, hv_pages-\u003evp_assist);\n \tevmcs_enable();\n \n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n \tGUEST_ASSERT(load_evmcs(hv_pages));\n \tprepare_vmcs(vmx_pages, l2_guest_code);\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \n \t/* L2 exits via vmcall if test fails */\n \tsync_with_host(2);\ndiff --git a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c\nindex 63ea1533e4ead..b7c2a254291e5 100644\n--- a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c\n+++ b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c\n@@ -23,7 +23,11 @@ static int ud_count;\n static void guest_ud_handler(struct ex_regs *regs)\n {\n \tud_count++;\n-\tregs-\u003erip += 3; /* VMLAUNCH */\n+\t/*\n+\t * VMLAUNCH insn can't be easily covered by KVM_ASM_SAFE framework but\n+\t * luckily the instruction is always three bytes.\n+\t */\n+\tregs-\u003erip += 3;\n }\n \n static void guest_nmi_handler(struct ex_regs *regs)\n@@ -89,20 +93,19 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,\n \tenable_vp_assist(hv_pages-\u003evp_assist_gpa, hv_pages-\u003evp_assist);\n \tevmcs_enable();\n \n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n \tGUEST_SYNC(3);\n \tGUEST_ASSERT(load_evmcs(hv_pages));\n-\tGUEST_ASSERT(vmptrstz() == hv_pages-\u003eenlightened_vmcs_gpa);\n+\t/* VMPTRST returns -1 until VMLAUNCH with eVMCS ptr set */\n+\tGUEST_ASSERT(vmptrst() == -1);\n \n \tGUEST_SYNC(4);\n-\tGUEST_ASSERT(vmptrstz() == hv_pages-\u003eenlightened_vmcs_gpa);\n \n \tprepare_vmcs(vmx_pages, l2_guest_code);\n \n \tGUEST_SYNC(5);\n-\tGUEST_ASSERT(vmptrstz() == hv_pages-\u003eenlightened_vmcs_gpa);\n \tcurrent_evmcs-\u003erevision_id = -1u;\n-\tGUEST_ASSERT(vmlaunch());\n+\tGUEST_ASSERT(__vmlaunch());\n \tcurrent_evmcs-\u003erevision_id = EVMCS_VERSION;\n \tGUEST_SYNC(6);\n \n@@ -117,17 +120,17 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,\n \tcurrent_vp_assist-\u003enested_control.features.directhypercall = 1;\n \t*(u32 *)(hv_pages-\u003epartition_assist) = 0;\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_EXCEPTION_NMI);\n \tGUEST_ASSERT_EQ((vmreadz(VM_EXIT_INTR_INFO) \u0026 0xff), NMI_VECTOR);\n-\tGUEST_ASSERT(vmptrstz() == hv_pages-\u003eenlightened_vmcs_gpa);\n+\tGUEST_ASSERT(vmptrst() == hv_pages-\u003eenlightened_vmcs_gpa);\n \n \t/*\n \t * NMI forces L2-\u003eL1 exit, resuming L2 and hope that EVMCS is\n \t * up-to-date (RIP points where it should and not at the beginning\n \t * of l2_guest_code(). GUEST_SYNC(9) checks that.\n \t */\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \n \tGUEST_SYNC(10);\n \n@@ -138,13 +141,13 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,\n \tvmwrite(CPU_BASED_VM_EXEC_CONTROL, vmreadz(CPU_BASED_VM_EXEC_CONTROL) |\n \t\tCPU_BASED_USE_MSR_BITMAPS);\n \t__set_bit(MSR_FS_BASE \u0026 0x1fff, vmx_pages-\u003emsr + 0x400);\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);\n \tcurrent_evmcs-\u003eguest_rip += 2; /* rdmsr */\n \n \t/* Enable enlightened MSR bitmap */\n \tcurrent_evmcs-\u003ehv_enlightenments_control.msr_bitmap = 1;\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);\n \tcurrent_evmcs-\u003eguest_rip += 2; /* rdmsr */\n \n@@ -152,14 +155,14 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,\n \t__set_bit(MSR_GS_BASE \u0026 0x1fff, vmx_pages-\u003emsr + 0x400);\n \t/* Make sure HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP is set */\n \tcurrent_evmcs-\u003ehv_clean_fields |= HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \t/* Make sure we don't see EXIT_REASON_MSR_READ here so eMSR bitmap works */\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \tcurrent_evmcs-\u003eguest_rip += 3; /* vmcall */\n \n \t/* Now tell KVM we've changed MSR-Bitmap */\n \tcurrent_evmcs-\u003ehv_clean_fields \u0026= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);\n \tcurrent_evmcs-\u003eguest_rip += 2; /* rdmsr */\n \n@@ -167,21 +170,29 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,\n \t * L2 TLB flush test. First VMCALL should be handled directly by L0,\n \t * no VMCALL exit expected.\n \t */\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);\n \tcurrent_evmcs-\u003eguest_rip += 2; /* rdmsr */\n \t/* Enable synthetic vmexit */\n \t*(u32 *)(hv_pages-\u003epartition_assist) = 1;\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == HV_VMX_SYNTHETIC_EXIT_REASON_TRAP_AFTER_FLUSH);\n \n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \tGUEST_SYNC(11);\n \n-\t/* Try enlightened vmptrld with an incorrect GPA */\n+\t/* VMPTRLD instruction causes #UD after enlightened VMLAUNCH */\n+\tGUEST_ASSERT(__vmptrld(hv_pages-\u003eenlightened_vmcs_gpa) == UD_VECTOR);\n+\n+\t/*\n+\t * Try enlightened vmptrld with an incorrect GPA. GUEST_SYNC(12) signals\n+\t * the host to enable guest_ud_handler() which cannot be enabled beforehand\n+\t * to not override the default fixup handler from KVM_ASM_SAFE().\n+\t */\n+\tGUEST_SYNC(12);\n \tevmcs_vmptrld(0xdeadbeef, hv_pages-\u003eenlightened_vmcs);\n-\tGUEST_ASSERT(vmlaunch());\n+\tGUEST_ASSERT(__vmlaunch());\n \tGUEST_ASSERT(ud_count == 1);\n \tGUEST_DONE();\n }\n@@ -253,7 +264,6 @@ int main(int argc, char *argv[])\n \tvcpu_args_set(vcpu, 3, vmx_pages_gva, hv_pages_gva, addr_gva2gpa(vm, hcall_page));\n \tvcpu_set_msr(vcpu, HV_X64_MSR_VP_INDEX, vcpu-\u003eid);\n \n-\tvm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);\n \tvm_install_exception_handler(vm, NMI_VECTOR, guest_nmi_handler);\n \n \tpr_info(\"Running L1 which uses EVMCS to run L2\\n\");\n@@ -283,7 +293,7 @@ int main(int argc, char *argv[])\n \n \t\t/* Force immediate L2-\u003eL1 exit before resuming */\n \t\tif (stage == 8) {\n-\t\t\tpr_info(\"Injecting NMI into L1 before L2 had a chance to run after restore\\n\");\n+\t\t\tpr_debug(\"Injecting NMI into L1 before L2 had a chance to run after restore\\n\");\n \t\t\tinject_nmi(vcpu);\n \t\t}\n \n@@ -293,9 +303,14 @@ int main(int argc, char *argv[])\n \t\t * KVM_STATE_NESTED_EVMCS is not lost.\n \t\t */\n \t\tif (stage == 9) {\n-\t\t\tpr_info(\"Trying extra KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle\\n\");\n+\t\t\tpr_debug(\"Trying extra KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle\\n\");\n \t\t\tvcpu = save_restore_vm(vm, vcpu);\n \t\t}\n+\n+\t\tif (stage == 12) {\n+\t\t\tpr_debug(\"Trying enlightened VMLAUNCH with an invalid PTR\\n\");\n+\t\t\tvm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);\n+\t\t}\n \t}\n \n done:\ndiff --git a/tools/testing/selftests/kvm/x86/kvm_buslock_test.c b/tools/testing/selftests/kvm/x86/kvm_buslock_test.c\nindex 25a182be00a97..337d3c28bc6df 100644\n--- a/tools/testing/selftests/kvm/x86/kvm_buslock_test.c\n+++ b/tools/testing/selftests/kvm/x86/kvm_buslock_test.c\n@@ -42,13 +42,13 @@ static void l1_svm_code(struct svm_test_data *svm)\n \n static void l1_vmx_code(struct vmx_pages *vmx)\n {\n-\tGUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);\n-\tGUEST_ASSERT_EQ(load_vmcs(vmx), true);\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \n \tprepare_vmcs(vmx, NULL);\n \n \tGUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n }\n \n static void guest_code(void *test_data)\ndiff --git a/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c b/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c\nindex b974cfb347d6e..1f4a5e44a6ef0 100644\n--- a/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c\n@@ -30,13 +30,13 @@ static void l2_guest_code(void)\n \n static void l1_vmx_code(struct vmx_pages *vmx_pages)\n {\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \t/* Prepare the VMCS for L2 execution. */\n \tprepare_vmcs(vmx_pages, l2_guest_code);\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(0);\n }\n \ndiff --git a/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c b/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c\nindex 26b474bf13535..7987ce50c3829 100644\n--- a/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c\n@@ -93,8 +93,8 @@ void l1_vmx_code(struct vmx_pages *vmx)\n \tvoid *l2_rip;\n \n \tGUEST_ASSERT(vmx-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx));\n-\tGUEST_ASSERT(load_vmcs(vmx));\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \n \tif (vmx-\u003eeptp_gpa)\n \t\tl2_rip = l2_guest_code_tdp_enabled;\n@@ -104,7 +104,7 @@ void l1_vmx_code(struct vmx_pages *vmx)\n \tprepare_vmcs(vmx, l2_rip);\n \n \tGUEST_SYNC(TEST_SYNC_NO_FAULT);\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_SYNC(TEST_SYNC_NO_FAULT);\n \tGUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);\n \tGUEST_DONE();\ndiff --git a/tools/testing/selftests/kvm/x86/nested_emulation_test.c b/tools/testing/selftests/kvm/x86/nested_emulation_test.c\nindex e08c6b0697e50..11fe4a31eda0b 100644\n--- a/tools/testing/selftests/kvm/x86/nested_emulation_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_emulation_test.c\n@@ -66,8 +66,8 @@ static void guest_code(void *test_data)\n \t\t\t\t\t BIT_ULL(INTERCEPT_HLT);\n \t\tvmcb-\u003econtrol.intercept_exceptions = 0;\n \t} else {\n-\t\tGUEST_ASSERT(prepare_for_vmx_operation(test_data));\n-\t\tGUEST_ASSERT(load_vmcs(test_data));\n+\t\tprepare_for_vmx_operation(test_data);\n+\t\tload_vmcs(test_data);\n \n \t\tprepare_vmcs(test_data, NULL);\n \t\tGUEST_ASSERT(!vmwrite(GUEST_IDTR_LIMIT, 0));\n@@ -102,7 +102,7 @@ static void guest_code(void *test_data)\n \t\t\texit_insn_len = vmcb-\u003econtrol.next_rip - vmcb-\u003esave.rip;\n \t\t\tGUEST_ASSERT_EQ(vmcb-\u003esave.rip, (u64)l2_instruction);\n \t\t} else {\n-\t\t\tGUEST_ASSERT_EQ(i ? vmresume() : vmlaunch(), 0);\n+\t\t\ti ? vmresume() : vmlaunch();\n \t\t\texit_reason = vmreadz(VM_EXIT_REASON);\n \t\t\texit_insn_len = vmreadz(VM_EXIT_INSTRUCTION_LEN);\n \t\t\tGUEST_ASSERT_EQ(vmreadz(GUEST_RIP), (u64)l2_instruction);\ndiff --git a/tools/testing/selftests/kvm/x86/nested_exceptions_test.c b/tools/testing/selftests/kvm/x86/nested_exceptions_test.c\nindex aeec3121c8e83..c36c11b5f518b 100644\n--- a/tools/testing/selftests/kvm/x86/nested_exceptions_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_exceptions_test.c\n@@ -112,7 +112,7 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)\n {\n \tGUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_code));\n \n-\tGUEST_ASSERT_EQ(vector == SS_VECTOR ? vmlaunch() : vmresume(), 0);\n+\tvector == SS_VECTOR ? vmlaunch() : vmresume();\n \n \tif (vector == FAKE_TRIPLE_FAULT_VECTOR)\n \t\treturn;\n@@ -125,9 +125,9 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)\n \n static void l1_vmx_code(struct vmx_pages *vmx)\n {\n-\tGUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);\n+\tprepare_for_vmx_operation(vmx);\n \n-\tGUEST_ASSERT_EQ(load_vmcs(vmx), true);\n+\tload_vmcs(vmx);\n \n \tprepare_vmcs(vmx, NULL);\n \tGUEST_ASSERT_EQ(vmwrite(GUEST_IDTR_LIMIT, 0), 0);\ndiff --git a/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c b/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c\nindex 8c2ba9674558e..101c1fe79eeb4 100644\n--- a/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c\n@@ -40,21 +40,21 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)\n {\n \tuintptr_t save_cr3;\n \n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \tprepare_vmcs(vmx_pages, l2_guest_code);\n \n \t/* Try to run L2 with invalid CR3 and make sure it fails */\n \tsave_cr3 = vmreadz(GUEST_CR3);\n \tvmwrite(GUEST_CR3, -1ull);\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) ==\n \t\t (EXIT_REASON_FAILED_VMENTRY | EXIT_REASON_INVALID_STATE));\n \n \t/* Now restore CR3 and make sure L2 runs successfully */\n \tvmwrite(GUEST_CR3, save_cr3);\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \tGUEST_DONE();\ndiff --git a/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c b/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c\nindex 2e04563790ff2..d6c443e3d147c 100644\n--- a/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c\n@@ -55,12 +55,12 @@ static void l1_vmx_code(struct vmx_pages *vmx, u64 expected_fault_gpa,\n \tu64 exit_qual;\n \n \tGUEST_ASSERT(vmx-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx));\n-\tGUEST_ASSERT(load_vmcs(vmx));\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \n \tprepare_vmcs(vmx, l2_entry);\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \n \t/* Verify we got an EPT violation exit */\n \t__GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_EPT_VIOLATION,\ndiff --git a/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c\nindex cb79d7b9619c2..c60dea899624b 100644\n--- a/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c\n@@ -86,8 +86,8 @@ static void l1_guest_code(void *data)\n \t\tstruct vmx_pages *vmx_pages = data;\n \t\tu32 control;\n \n-\t\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\t\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\t\tprepare_for_vmx_operation(vmx_pages);\n+\t\tload_vmcs(vmx_pages);\n \n \t\tprepare_vmcs(vmx_pages, l2_guest_code);\n \t\tcontrol = vmreadz(CPU_BASED_VM_EXEC_CONTROL);\n@@ -95,7 +95,7 @@ static void l1_guest_code(void *data)\n \t\tvmwrite(CPU_BASED_VM_EXEC_CONTROL, control);\n \t\tvmwrite(TSC_OFFSET, TSC_OFFSET_VALUE);\n \n-\t\tGUEST_ASSERT(!vmlaunch());\n+\t\tvmlaunch();\n \t\tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \t} else {\n \t\tstruct svm_test_data *svm = data;\ndiff --git a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c\nindex 18f765835bf4c..b2fc7f0b5b3c8 100644\n--- a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c\n+++ b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c\n@@ -105,8 +105,8 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)\n \t/* check that L1's frequency looks alright before launching L2 */\n \tcheck_tsc_freq(UCHECK_L1);\n \n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \t/* prepare the VMCS for L2 execution */\n \tprepare_vmcs(vmx_pages, l2_guest_code);\n@@ -125,7 +125,7 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)\n \tvmwrite(TSC_MULTIPLIER_HIGH, TSC_MULTIPLIER_L2 \u003e\u003e 32);\n \n \t/* launch L2 */\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \t/* check that L1's frequency still looks good */\ndiff --git a/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c b/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c\nindex 507391ab2c930..f88427e925fcc 100644\n--- a/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c\n+++ b/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c\n@@ -98,17 +98,17 @@ static void l1_svm_code(struct svm_test_data *svm)\n \n static void l1_vmx_code(struct vmx_pages *vmx)\n {\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx));\n-\tGUEST_ASSERT(load_vmcs(vmx));\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \tprepare_vmcs(vmx, guest_access_memory);\n \n \tGUEST_ASSERT(!vmwrite(EXCEPTION_BITMAP, BIT(UD_VECTOR)));\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \twhile (1) {\n \t\tGUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_EXCEPTION_NMI);\n \t\tGUEST_ASSERT_EQ(vmreadz(VM_EXIT_INTR_INFO) \u0026 0xff, UD_VECTOR);\n-\t\tGUEST_ASSERT(!vmresume());\n+\t\tvmresume();\n \t}\n }\n \ndiff --git a/tools/testing/selftests/kvm/x86/smm_test.c b/tools/testing/selftests/kvm/x86/smm_test.c\nindex d1edafd5af755..377df09e582ad 100644\n--- a/tools/testing/selftests/kvm/x86/smm_test.c\n+++ b/tools/testing/selftests/kvm/x86/smm_test.c\n@@ -78,8 +78,8 @@ static void guest_code(void *arg)\n \t\tif (this_cpu_has(X86_FEATURE_SVM)) {\n \t\t\tgeneric_svm_setup(svm, l2_guest_code);\n \t\t} else {\n-\t\t\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\t\t\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\t\t\tprepare_for_vmx_operation(vmx_pages);\n+\t\t\tload_vmcs(vmx_pages);\n \t\t\tprepare_vmcs(vmx_pages, l2_guest_code);\n \t\t}\n \ndiff --git a/tools/testing/selftests/kvm/x86/state_test.c b/tools/testing/selftests/kvm/x86/state_test.c\nindex 4a1056a6cb8dc..38c9689ac6014 100644\n--- a/tools/testing/selftests/kvm/x86/state_test.c\n+++ b/tools/testing/selftests/kvm/x86/state_test.c\n@@ -75,32 +75,32 @@ void vmx_l2_guest_code(void)\n static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)\n {\n \tGUEST_ASSERT(vmx_pages-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n \tGUEST_SYNC(3);\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n-\tGUEST_ASSERT(vmptrstz() == vmx_pages-\u003evmcs_gpa);\n+\tload_vmcs(vmx_pages);\n+\tGUEST_ASSERT(vmptrst() == vmx_pages-\u003evmcs_gpa);\n \n \tGUEST_SYNC(4);\n-\tGUEST_ASSERT(vmptrstz() == vmx_pages-\u003evmcs_gpa);\n+\tGUEST_ASSERT(vmptrst() == vmx_pages-\u003evmcs_gpa);\n \n \tprepare_vmcs(vmx_pages, vmx_l2_guest_code);\n \n \tGUEST_SYNC(5);\n-\tGUEST_ASSERT(vmptrstz() == vmx_pages-\u003evmcs_gpa);\n-\tGUEST_ASSERT(!vmlaunch());\n-\tGUEST_ASSERT(vmptrstz() == vmx_pages-\u003evmcs_gpa);\n+\tGUEST_ASSERT(vmptrst() == vmx_pages-\u003evmcs_gpa);\n+\tvmlaunch();\n+\tGUEST_ASSERT(vmptrst() == vmx_pages-\u003evmcs_gpa);\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \t/* Check that the launched state is preserved. */\n-\tGUEST_ASSERT(vmlaunch());\n+\tGUEST_ASSERT(__vmlaunch());\n \n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \tGUEST_SYNC(7);\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \tvmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + 3);\n@@ -108,28 +108,28 @@ static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)\n \tvmwrite(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_SHADOW_VMCS);\n \tvmwrite(VMCS_LINK_POINTER, vmx_pages-\u003eshadow_vmcs_gpa);\n \n-\tGUEST_ASSERT(!vmptrld(vmx_pages-\u003eshadow_vmcs_gpa));\n-\tGUEST_ASSERT(vmlaunch());\n+\tvmptrld(vmx_pages-\u003eshadow_vmcs_gpa);\n+\tGUEST_ASSERT(__vmlaunch());\n \tGUEST_SYNC(8);\n-\tGUEST_ASSERT(vmlaunch());\n-\tGUEST_ASSERT(vmresume());\n+\tGUEST_ASSERT(__vmlaunch());\n+\tGUEST_ASSERT(__vmresume());\n \n \tvmwrite(GUEST_RIP, 0xc0ffee);\n \tGUEST_SYNC(9);\n \tGUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffee);\n \n-\tGUEST_ASSERT(!vmptrld(vmx_pages-\u003evmcs_gpa));\n-\tGUEST_ASSERT(!vmresume());\n+\tvmptrld(vmx_pages-\u003evmcs_gpa);\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n-\tGUEST_ASSERT(!vmptrld(vmx_pages-\u003eshadow_vmcs_gpa));\n+\tvmptrld(vmx_pages-\u003eshadow_vmcs_gpa);\n \tGUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffffee);\n-\tGUEST_ASSERT(vmlaunch());\n-\tGUEST_ASSERT(vmresume());\n+\tGUEST_ASSERT(__vmlaunch());\n+\tGUEST_ASSERT(__vmresume());\n \tGUEST_SYNC(13);\n \tGUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffffee);\n-\tGUEST_ASSERT(vmlaunch());\n-\tGUEST_ASSERT(vmresume());\n+\tGUEST_ASSERT(__vmlaunch());\n+\tGUEST_ASSERT(__vmresume());\n }\n \n static void __attribute__((__flatten__)) guest_code(void *arg)\ndiff --git a/tools/testing/selftests/kvm/x86/triple_fault_event_test.c b/tools/testing/selftests/kvm/x86/triple_fault_event_test.c\nindex 0d83516f4bd08..bb31a1ba8932e 100644\n--- a/tools/testing/selftests/kvm/x86/triple_fault_event_test.c\n+++ b/tools/testing/selftests/kvm/x86/triple_fault_event_test.c\n@@ -25,12 +25,12 @@ void l1_guest_code_vmx(struct vmx_pages *vmx)\n {\n \n \tGUEST_ASSERT(vmx-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx));\n-\tGUEST_ASSERT(load_vmcs(vmx));\n+\tprepare_for_vmx_operation(vmx);\n+\tload_vmcs(vmx);\n \n \tprepare_vmcs(vmx, l2_guest_code);\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \t/* L2 should triple fault after a triple fault event injected. */\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_TRIPLE_FAULT);\n \tGUEST_DONE();\ndiff --git a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c\nindex 463f73aa9159a..fe29c869a2356 100644\n--- a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c\n+++ b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c\n@@ -38,8 +38,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)\n {\n \tu32 control;\n \n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \t/* Prepare the VMCS for L2 execution. */\n \tprepare_vmcs(vmx_pages, l2_guest_code);\n@@ -53,14 +53,14 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)\n \n \t/* Try to launch L2 with the memory-backed APIC-access address. */\n \tGUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \tvmwrite(APIC_ACCESS_ADDR, high_gpa);\n \n \t/* Try to resume L2 with the unbacked APIC-access address. */\n \tGUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \n \tGUEST_DONE();\ndiff --git a/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c b/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c\nindex f9b88a6f6113d..e578221da247c 100644\n--- a/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c\n+++ b/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c\n@@ -33,8 +33,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)\n {\n \tu32 control;\n \n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \t/* Prepare the VMCS for L2 execution. */\n \tprepare_vmcs(vmx_pages, l2_guest_code);\n@@ -62,7 +62,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)\n \t * Run L2 to switch to x2APIC mode, which in turn will uninhibit APICv,\n \t * as KVM should force the APIC ID back to its default.\n \t */\n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \tvmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN));\n \tGUEST_ASSERT(rdmsr(MSR_IA32_APICBASE) \u0026 MSR_IA32_APICBASE_EXTD);\n@@ -90,7 +90,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)\n \t * handles the x2APIC =\u003e xAPIC transition and inhibits APICv while L2\n \t * is active.\n \t */\n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \tGUEST_ASSERT(!(rdmsr(MSR_IA32_APICBASE) \u0026 MSR_IA32_APICBASE_EXTD));\n \ndiff --git a/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c b/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c\nindex c8379124b3172..3017938fa9937 100644\n--- a/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c\n+++ b/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c\n@@ -41,8 +41,8 @@ static void l2_guest_code(void)\n \n static void l1_guest_code(struct vmx_pages *vmx_pages)\n {\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \t/* Prepare the VMCS for L2 execution. */\n \tprepare_vmcs(vmx_pages, l2_guest_code);\n@@ -55,7 +55,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)\n \tGUEST_ASSERT(!(vmreadz(CPU_BASED_VM_EXEC_CONTROL) \u0026 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) ||\n \t\t !(vmreadz(SECONDARY_VM_EXEC_CONTROL) \u0026 SECONDARY_EXEC_UNRESTRICTED_GUEST));\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \n \t/* L2 should triple fault after main() stuffs invalid guest state. */\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_TRIPLE_FAULT);\ndiff --git a/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c b/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c\nindex 75073efa926da..b3651c5ab1384 100644\n--- a/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c\n+++ b/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c\n@@ -37,8 +37,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)\n \tGUEST_ASSERT(rdmsr(MSR_GS_BASE) == LA57_GS_BASE);\n \n \tGUEST_ASSERT(vmx_pages-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n \n \tprepare_vmcs(vmx_pages, l2_guest_code);\n \n@@ -56,7 +56,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)\n \tguest_cr4 \u0026= ~X86_CR4_LA57;\n \tvmwrite(GUEST_CR4, guest_cr4);\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \n \texit_reason = vmreadz(VM_EXIT_REASON);\n \tGUEST_ASSERT(exit_reason == EXIT_REASON_VMCALL);\ndiff --git a/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c b/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c\nindex eb8021c33cd43..cda53df33888e 100644\n--- a/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c\n+++ b/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c\n@@ -71,9 +71,9 @@ void l1_guest_code(struct vmx_pages *vmx_pages)\n \tu64 l1_tsc_deadline, l2_tsc_deadline;\n \n \tGUEST_ASSERT(vmx_pages-\u003evmcs_gpa);\n-\tGUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));\n-\tGUEST_ASSERT(load_vmcs(vmx_pages));\n-\tGUEST_ASSERT(vmptrstz() == vmx_pages-\u003evmcs_gpa);\n+\tprepare_for_vmx_operation(vmx_pages);\n+\tload_vmcs(vmx_pages);\n+\tGUEST_ASSERT(vmptrst() == vmx_pages-\u003evmcs_gpa);\n \n \tprepare_vmcs(vmx_pages, l2_guest_code);\n \n@@ -90,7 +90,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)\n \t !(ctrl_exit_rev.clr \u0026 VM_EXIT_SAVE_VMX_PREEMPTION_TIMER))\n \t\treturn;\n \n-\tGUEST_ASSERT(!vmlaunch());\n+\tvmlaunch();\n \tGUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);\n \tvmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN));\n \n@@ -110,7 +110,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)\n \n \tl1_vmx_pt_start = (rdtsc() \u003e\u003e vmx_pt_rate) \u003c\u003c vmx_pt_rate;\n \n-\tGUEST_ASSERT(!vmresume());\n+\tvmresume();\n \n \tl1_vmx_pt_finish = rdtsc();\n \n"
} |
| 2/1 | 2026/08/26 23:55 | agent | patch-evaluator |
1mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"KVM",
"KVM_INTEL",
"KVM_HYPERV"
],
"FocusSymbols": [
"handle_vmptrld",
"handle_vmptrst"
],
"Reasoning": "The patch modifies the behavior of VMPTRLD and VMPTRST instructions in nested VMX when Enlightened VMCS (eVMCS) is used. It changes VMPTRLD to queue a #UD exception and VMPTRST to return the eVMCS GPA instead of just returning 1. This is a functional change in KVM's nested virtualization logic that is reachable from guest execution and should be fuzzed.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 399c2ebb041d26980183aae134635686bb04cb04
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Aug 26 23:55:25 2026 +0000
syz-cluster: applied patch under review
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 151873407abd3..3058efa65c82c 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5897,6 +5897,12 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
if (!nested_vmx_check_permission(vcpu))
return 1;
+ /* Forbid normal VMPTRLD if Enlightened version was used */
+ if (nested_vmx_is_evmptr12_valid(vmx)) {
+ kvm_queue_exception(vcpu, UD_VECTOR);
+ return 1;
+ }
+
if (nested_vmx_get_vmptr(vcpu, &vmptr, &r))
return r;
@@ -5906,10 +5912,6 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
if (vmptr == vmx->nested.vmxon_ptr)
return nested_vmx_fail(vcpu, VMXERR_VMPTRLD_VMXON_POINTER);
- /* Forbid normal VMPTRLD if Enlightened version was used */
- if (nested_vmx_is_evmptr12_valid(vmx))
- return 1;
-
if (vmx->nested.current_vmptr != vmptr) {
struct gfn_to_hva_cache *ghc = &vmx->nested.vmcs12_cache;
struct vmcs_hdr hdr;
@@ -5962,7 +5964,7 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
{
unsigned long exit_qual = vmx_get_exit_qual(vcpu);
u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);
- gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
+ gpa_t current_vmptr;
struct x86_exception e;
gva_t gva;
int r;
@@ -5970,8 +5972,16 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
if (!nested_vmx_check_permission(vcpu))
return 1;
- if (unlikely(nested_vmx_is_evmptr12_valid(to_vmx(vcpu))))
- return 1;
+ /*
+ * Hyper-V TLFS does not specify the behavior of VMPTRST when eVMCS is used
+ * but genuine Hyper-V seems to be returning eVMCS GPA.
+ */
+#ifdef CONFIG_KVM_HYPERV
+ if (nested_vmx_is_evmptr12_valid(to_vmx(vcpu)))
+ current_vmptr = to_vmx(vcpu)->nested.hv_evmcs_vmptr;
+ else
+#endif
+ current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
if (get_vmx_mem_address(vcpu, exit_qual, instr_info,
true, sizeof(gpa_t), &gva))
diff --git a/tools/testing/selftests/kvm/include/x86/evmcs.h b/tools/testing/selftests/kvm/include/x86/evmcs.h
index 82a8ea6b661f0..c5b9d26f6cdbe 100644
--- a/tools/testing/selftests/kvm/include/x86/evmcs.h
+++ b/tools/testing/selftests/kvm/include/x86/evmcs.h
@@ -265,14 +265,6 @@ static inline bool load_evmcs(struct hyperv_test_pages *hv)
return true;
}
-static inline int evmcs_vmptrst(u64 *value)
-{
- *value = current_vp_assist->current_nested_vmcs &
- ~HV_X64_MSR_VP_ASSIST_PAGE_ENABLE;
-
- return 0;
-}
-
static inline int evmcs_vmread(u64 encoding, u64 *value)
{
switch (encoding) {
diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h
index 6e6f70035508a..282b8aaff7995 100644
--- a/tools/testing/selftests/kvm/include/x86/processor.h
+++ b/tools/testing/selftests/kvm/include/x86/processor.h
@@ -1318,7 +1318,7 @@ gva_t vm_alloc_stack(struct kvm_vm *vm, int nr_pages);
"lea 1f(%%rip), %%r10\n\t" \
"lea 2f(%%rip), %%r11\n\t" \
fep "1: " insn "\n\t" \
- "xor %%r9, %%r9\n\t" \
+ "mov $0, %%r9d\n\t" \
"2:\n\t" \
"mov %%r9b, %[vector]\n\t" \
"mov %%r10, %[error_code]\n\t"
diff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h
index 04f5e34dea3ae..cd82a6be6963c 100644
--- a/tools/testing/selftests/kvm/include/x86/vmx.h
+++ b/tools/testing/selftests/kvm/include/x86/vmx.h
@@ -309,126 +309,91 @@ struct vmx_msr_entry {
#include "evmcs.h"
-static inline int vmxon(u64 phys)
-{
- u8 ret;
-
- __asm__ __volatile__ ("vmxon %[pa]; setna %[ret]"
- : [ret]"=rm"(ret)
- : [pa]"m"(phys)
- : "cc", "memory");
-
- return ret;
+#define GUEST_ASSERT_VMX_INSN_SUCCEEDED(insn, __r, __pa) \
+ __GUEST_ASSERT(!__r, __stringify(insn) "[0x%lx] hit %s", \
+ __pa, __r < 0 ? "VM-Fail" : ex_str(__r))
+
+#define BUILD_VMCS_ASM_HELPERS(insn) \
+static inline int __##insn(u64 vmcs_pa) \
+{ \
+ u64 error_code; \
+ u8 vector; \
+ u8 failed; \
+ \
+ asm volatile(KVM_ASM_SAFE(__stringify(insn) " %[pa]") \
+ "\n\tsetna %[failed]" \
+ : KVM_ASM_SAFE_OUTPUTS(vector, error_code), \
+ [failed]"=qm"(failed) \
+ : [pa]"m"(vmcs_pa) \
+ : "cc", "memory", KVM_ASM_SAFE_CLOBBERS); \
+ \
+ return vector ? vector : failed ? -EINVAL : 0; \
+} \
+ \
+static inline void insn(u64 vmcs_pa) \
+{ \
+ int ret = __##insn(vmcs_pa); \
+ \
+ GUEST_ASSERT_VMX_INSN_SUCCEEDED(insn, ret, vmcs_pa); \
}
+BUILD_VMCS_ASM_HELPERS(vmxon)
+BUILD_VMCS_ASM_HELPERS(vmptrld)
+BUILD_VMCS_ASM_HELPERS(vmclear)
+
static inline void vmxoff(void)
{
__asm__ __volatile__("vmxoff");
}
-static inline int vmclear(u64 vmcs_pa)
-{
- u8 ret;
-
- __asm__ __volatile__ ("vmclear %[pa]; setna %[ret]"
- : [ret]"=rm"(ret)
- : [pa]"m"(vmcs_pa)
- : "cc", "memory");
-
- return ret;
-}
-
-static inline int vmptrld(u64 vmcs_pa)
-{
- u8 ret;
-
- if (enable_evmcs)
- return -1;
-
- __asm__ __volatile__ ("vmptrld %[pa]; setna %[ret]"
- : [ret]"=rm"(ret)
- : [pa]"m"(vmcs_pa)
- : "cc", "memory");
-
- return ret;
-}
-
-static inline int vmptrst(u64 *value)
+static inline u64 vmptrst(void)
{
- u64 tmp;
+ u64 value = 0;
u8 ret;
- if (enable_evmcs)
- return evmcs_vmptrst(value);
-
__asm__ __volatile__("vmptrst %[value]; setna %[ret]"
- : [value]"=m"(tmp), [ret]"=rm"(ret)
+ : [value]"=m"(value), [ret]"=rm"(ret)
: : "cc", "memory");
- *value = tmp;
- return ret;
-}
-
-/*
- * A wrapper around vmptrst that ignores errors and returns zero if the
- * vmptrst instruction fails.
- */
-static inline u64 vmptrstz(void)
-{
- u64 value = 0;
- vmptrst(&value);
+ __GUEST_ASSERT(!ret, "vmptrst failed");
return value;
}
-static inline int vmlaunch(void)
-{
- int ret;
-
- if (enable_evmcs)
- return evmcs_vmlaunch();
-
- __asm__ __volatile__("push $0;"
- "vmwrite %%rsp, %[host_rsp];"
- "lea 1f(%%rip), %%rax;"
- "vmwrite %%rax, %[host_rip];"
- VMX_SWITCH_GPRS_ASM
- "vmlaunch;"
- "incq (%%rsp);"
- "1: ;"
- VMX_SWITCH_GPRS_ASM
- "pop %%rax;"
- : [ret]"=&a"(ret)
- : [host_rsp]"r"((u64)HOST_RSP),
- [host_rip]"r"((u64)HOST_RIP),
- GUEST_REGS_OFFSETS
- : "memory", "cc");
- return ret;
-}
-
-static inline int vmresume(void)
-{
- int ret;
-
- if (enable_evmcs)
- return evmcs_vmresume();
-
- __asm__ __volatile__("push $0;"
- "vmwrite %%rsp, %[host_rsp];"
- "lea 1f(%%rip), %%rax;"
- "vmwrite %%rax, %[host_rip];"
- VMX_SWITCH_GPRS_ASM
- "vmresume;"
- "incq (%%rsp);"
- "1: ;"
- VMX_SWITCH_GPRS_ASM
- "pop %%rax;"
- : [ret]"=&a"(ret)
- : [host_rsp]"r"((u64)HOST_RSP),
- [host_rip]"r"((u64)HOST_RIP),
- GUEST_REGS_OFFSETS
- : "memory", "cc");
- return ret;
+#define BUILD_VMX_VM_ENTRY_HELPERS(insn) \
+static inline int __##insn(void) \
+{ \
+ int ret; \
+ \
+ if (enable_evmcs) \
+ return evmcs_##insn(); \
+ \
+ __asm__ __volatile__("push $0;" \
+ "vmwrite %%rsp, %[host_rsp];" \
+ "lea 1f(%%rip), %%rax;" \
+ "vmwrite %%rax, %[host_rip];" \
+ VMX_SWITCH_GPRS_ASM \
+ __stringify(insn)";" \
+ "incq (%%rsp);" \
+ "1: ;" \
+ VMX_SWITCH_GPRS_ASM \
+ "pop %%rax;" \
+ : [ret]"=&a"(ret) \
+ : [host_rsp]"r"((u64)HOST_RSP), \
+ [host_rip]"r"((u64)HOST_RIP), \
+ GUEST_REGS_OFFSETS \
+ : "memory", "cc"); \
+ return ret; \
+} \
+ \
+static inline void insn(void) \
+{ \
+ int ret; \
+ \
+ ret = __##insn(); \
+ __GUEST_ASSERT(!ret, __stringify(insn) " hit VM-Fail"); \
}
+BUILD_VMX_VM_ENTRY_HELPERS(vmlaunch)
+BUILD_VMX_VM_ENTRY_HELPERS(vmresume)
static inline void vmcall(void)
{
@@ -550,9 +515,9 @@ union vmx_ctrl_msr {
};
struct vmx_pages *vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva);
-bool prepare_for_vmx_operation(struct vmx_pages *vmx);
+void prepare_for_vmx_operation(struct vmx_pages *vmx);
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip);
-bool load_vmcs(struct vmx_pages *vmx);
+void load_vmcs(struct vmx_pages *vmx);
bool ept_1g_pages_supported(void);
diff --git a/tools/testing/selftests/kvm/lib/x86/memstress.c b/tools/testing/selftests/kvm/lib/x86/memstress.c
index e19e8b5a09c5a..6a1815fb97e95 100644
--- a/tools/testing/selftests/kvm/lib/x86/memstress.c
+++ b/tools/testing/selftests/kvm/lib/x86/memstress.c
@@ -33,14 +33,14 @@ __asm__(
static void l1_vmx_code(struct vmx_pages *vmx, u64 vcpu_id)
{
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
GUEST_ASSERT(ept_1g_pages_supported());
*(u64 *)vmx->stack = vcpu_id;
prepare_vmcs(vmx, memstress_l2_guest_entry);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);
GUEST_DONE();
}
diff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/selftests/kvm/lib/x86/vmx.c
index 089e1a8af53fc..5c6cadc08405a 100644
--- a/tools/testing/selftests/kvm/lib/x86/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86/vmx.c
@@ -125,7 +125,7 @@ vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva)
return vmx;
}
-bool prepare_for_vmx_operation(struct vmx_pages *vmx)
+void prepare_for_vmx_operation(struct vmx_pages *vmx)
{
u64 feature_control;
u64 required;
@@ -163,28 +163,20 @@ bool prepare_for_vmx_operation(struct vmx_pages *vmx)
/* Enter VMX root operation. */
*(u32 *)(vmx->vmxon) = vmcs_revision();
- if (vmxon(vmx->vmxon_gpa))
- return false;
-
- return true;
+ vmxon(vmx->vmxon_gpa);
}
-bool load_vmcs(struct vmx_pages *vmx)
+void load_vmcs(struct vmx_pages *vmx)
{
/* Load a VMCS. */
*(u32 *)(vmx->vmcs) = vmcs_revision();
- if (vmclear(vmx->vmcs_gpa))
- return false;
+ vmclear(vmx->vmcs_gpa);
- if (vmptrld(vmx->vmcs_gpa))
- return false;
+ vmptrld(vmx->vmcs_gpa);
/* Setup shadow VMCS, do not load it yet. */
*(u32 *)(vmx->shadow_vmcs) = vmcs_revision() | 0x80000000ul;
- if (vmclear(vmx->shadow_vmcs_gpa))
- return false;
-
- return true;
+ vmclear(vmx->shadow_vmcs_gpa);
}
static bool ept_vpid_cap_supported(u64 mask)
diff --git a/tools/testing/selftests/kvm/x86/aperfmperf_test.c b/tools/testing/selftests/kvm/x86/aperfmperf_test.c
index 845cb685f1743..a082658c1e484 100644
--- a/tools/testing/selftests/kvm/x86/aperfmperf_test.c
+++ b/tools/testing/selftests/kvm/x86/aperfmperf_test.c
@@ -70,8 +70,8 @@ static void l1_svm_code(struct svm_test_data *svm)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
- GUEST_ASSERT_EQ(load_vmcs(vmx), true);
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, NULL);
@@ -83,7 +83,7 @@ static void l1_vmx_code(struct vmx_pages *vmx)
vmreadz(CPU_BASED_VM_EXEC_CONTROL) | CPU_BASED_USE_MSR_BITMAPS);
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
}
static void guest_code(void *nested_test_data)
diff --git a/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c b/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c
index aa7f3b405fd32..a06f37e0bd068 100644
--- a/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c
+++ b/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c
@@ -55,11 +55,11 @@ static void guest_code(struct vmx_pages *vmx_pages,
enable_vp_assist(hv_pages->vp_assist_gpa, hv_pages->vp_assist);
evmcs_enable();
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
GUEST_ASSERT(load_evmcs(hv_pages));
prepare_vmcs(vmx_pages, l2_guest_code);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* L2 exits via vmcall if test fails */
sync_with_host(2);
diff --git a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c
index 63ea1533e4ead..b7c2a254291e5 100644
--- a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c
+++ b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c
@@ -23,7 +23,11 @@ static int ud_count;
static void guest_ud_handler(struct ex_regs *regs)
{
ud_count++;
- regs->rip += 3; /* VMLAUNCH */
+ /*
+ * VMLAUNCH insn can't be easily covered by KVM_ASM_SAFE framework but
+ * luckily the instruction is always three bytes.
+ */
+ regs->rip += 3;
}
static void guest_nmi_handler(struct ex_regs *regs)
@@ -89,20 +93,19 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
enable_vp_assist(hv_pages->vp_assist_gpa, hv_pages->vp_assist);
evmcs_enable();
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
GUEST_SYNC(3);
GUEST_ASSERT(load_evmcs(hv_pages));
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
+ /* VMPTRST returns -1 until VMLAUNCH with eVMCS ptr set */
+ GUEST_ASSERT(vmptrst() == -1);
GUEST_SYNC(4);
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
prepare_vmcs(vmx_pages, l2_guest_code);
GUEST_SYNC(5);
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
current_evmcs->revision_id = -1u;
- GUEST_ASSERT(vmlaunch());
+ GUEST_ASSERT(__vmlaunch());
current_evmcs->revision_id = EVMCS_VERSION;
GUEST_SYNC(6);
@@ -117,17 +120,17 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
current_vp_assist->nested_control.features.directhypercall = 1;
*(u32 *)(hv_pages->partition_assist) = 0;
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_EXCEPTION_NMI);
GUEST_ASSERT_EQ((vmreadz(VM_EXIT_INTR_INFO) & 0xff), NMI_VECTOR);
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
+ GUEST_ASSERT(vmptrst() == hv_pages->enlightened_vmcs_gpa);
/*
* NMI forces L2->L1 exit, resuming L2 and hope that EVMCS is
* up-to-date (RIP points where it should and not at the beginning
* of l2_guest_code(). GUEST_SYNC(9) checks that.
*/
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_SYNC(10);
@@ -138,13 +141,13 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
vmwrite(CPU_BASED_VM_EXEC_CONTROL, vmreadz(CPU_BASED_VM_EXEC_CONTROL) |
CPU_BASED_USE_MSR_BITMAPS);
__set_bit(MSR_FS_BASE & 0x1fff, vmx_pages->msr + 0x400);
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
/* Enable enlightened MSR bitmap */
current_evmcs->hv_enlightenments_control.msr_bitmap = 1;
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
@@ -152,14 +155,14 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
__set_bit(MSR_GS_BASE & 0x1fff, vmx_pages->msr + 0x400);
/* Make sure HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP is set */
current_evmcs->hv_clean_fields |= HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;
- GUEST_ASSERT(!vmresume());
+ vmresume();
/* Make sure we don't see EXIT_REASON_MSR_READ here so eMSR bitmap works */
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
current_evmcs->guest_rip += 3; /* vmcall */
/* Now tell KVM we've changed MSR-Bitmap */
current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
@@ -167,21 +170,29 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
* L2 TLB flush test. First VMCALL should be handled directly by L0,
* no VMCALL exit expected.
*/
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
/* Enable synthetic vmexit */
*(u32 *)(hv_pages->partition_assist) = 1;
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == HV_VMX_SYNTHETIC_EXIT_REASON_TRAP_AFTER_FLUSH);
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_SYNC(11);
- /* Try enlightened vmptrld with an incorrect GPA */
+ /* VMPTRLD instruction causes #UD after enlightened VMLAUNCH */
+ GUEST_ASSERT(__vmptrld(hv_pages->enlightened_vmcs_gpa) == UD_VECTOR);
+
+ /*
+ * Try enlightened vmptrld with an incorrect GPA. GUEST_SYNC(12) signals
+ * the host to enable guest_ud_handler() which cannot be enabled beforehand
+ * to not override the default fixup handler from KVM_ASM_SAFE().
+ */
+ GUEST_SYNC(12);
evmcs_vmptrld(0xdeadbeef, hv_pages->enlightened_vmcs);
- GUEST_ASSERT(vmlaunch());
+ GUEST_ASSERT(__vmlaunch());
GUEST_ASSERT(ud_count == 1);
GUEST_DONE();
}
@@ -253,7 +264,6 @@ int main(int argc, char *argv[])
vcpu_args_set(vcpu, 3, vmx_pages_gva, hv_pages_gva, addr_gva2gpa(vm, hcall_page));
vcpu_set_msr(vcpu, HV_X64_MSR_VP_INDEX, vcpu->id);
- vm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);
vm_install_exception_handler(vm, NMI_VECTOR, guest_nmi_handler);
pr_info("Running L1 which uses EVMCS to run L2\n");
@@ -283,7 +293,7 @@ int main(int argc, char *argv[])
/* Force immediate L2->L1 exit before resuming */
if (stage == 8) {
- pr_info("Injecting NMI into L1 before L2 had a chance to run after restore\n");
+ pr_debug("Injecting NMI into L1 before L2 had a chance to run after restore\n");
inject_nmi(vcpu);
}
@@ -293,9 +303,14 @@ int main(int argc, char *argv[])
* KVM_STATE_NESTED_EVMCS is not lost.
*/
if (stage == 9) {
- pr_info("Trying extra KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle\n");
+ pr_debug("Trying extra KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle\n");
vcpu = save_restore_vm(vm, vcpu);
}
+
+ if (stage == 12) {
+ pr_debug("Trying enlightened VMLAUNCH with an invalid PTR\n");
+ vm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);
+ }
}
done:
diff --git a/tools/testing/selftests/kvm/x86/kvm_buslock_test.c b/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
index 25a182be00a97..337d3c28bc6df 100644
--- a/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
+++ b/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
@@ -42,13 +42,13 @@ static void l1_svm_code(struct svm_test_data *svm)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
- GUEST_ASSERT_EQ(load_vmcs(vmx), true);
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, NULL);
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
}
static void guest_code(void *test_data)
diff --git a/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c b/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c
index b974cfb347d6e..1f4a5e44a6ef0 100644
--- a/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c
@@ -30,13 +30,13 @@ static void l2_guest_code(void)
static void l1_vmx_code(struct vmx_pages *vmx_pages)
{
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(0);
}
diff --git a/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c b/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c
index 26b474bf13535..7987ce50c3829 100644
--- a/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c
@@ -93,8 +93,8 @@ void l1_vmx_code(struct vmx_pages *vmx)
void *l2_rip;
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
if (vmx->eptp_gpa)
l2_rip = l2_guest_code_tdp_enabled;
@@ -104,7 +104,7 @@ void l1_vmx_code(struct vmx_pages *vmx)
prepare_vmcs(vmx, l2_rip);
GUEST_SYNC(TEST_SYNC_NO_FAULT);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_SYNC(TEST_SYNC_NO_FAULT);
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/nested_emulation_test.c b/tools/testing/selftests/kvm/x86/nested_emulation_test.c
index e08c6b0697e50..11fe4a31eda0b 100644
--- a/tools/testing/selftests/kvm/x86/nested_emulation_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_emulation_test.c
@@ -66,8 +66,8 @@ static void guest_code(void *test_data)
BIT_ULL(INTERCEPT_HLT);
vmcb->control.intercept_exceptions = 0;
} else {
- GUEST_ASSERT(prepare_for_vmx_operation(test_data));
- GUEST_ASSERT(load_vmcs(test_data));
+ prepare_for_vmx_operation(test_data);
+ load_vmcs(test_data);
prepare_vmcs(test_data, NULL);
GUEST_ASSERT(!vmwrite(GUEST_IDTR_LIMIT, 0));
@@ -102,7 +102,7 @@ static void guest_code(void *test_data)
exit_insn_len = vmcb->control.next_rip - vmcb->save.rip;
GUEST_ASSERT_EQ(vmcb->save.rip, (u64)l2_instruction);
} else {
- GUEST_ASSERT_EQ(i ? vmresume() : vmlaunch(), 0);
+ i ? vmresume() : vmlaunch();
exit_reason = vmreadz(VM_EXIT_REASON);
exit_insn_len = vmreadz(VM_EXIT_INSTRUCTION_LEN);
GUEST_ASSERT_EQ(vmreadz(GUEST_RIP), (u64)l2_instruction);
diff --git a/tools/testing/selftests/kvm/x86/nested_exceptions_test.c b/tools/testing/selftests/kvm/x86/nested_exceptions_test.c
index aeec3121c8e83..c36c11b5f518b 100644
--- a/tools/testing/selftests/kvm/x86/nested_exceptions_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_exceptions_test.c
@@ -112,7 +112,7 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)
{
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_code));
- GUEST_ASSERT_EQ(vector == SS_VECTOR ? vmlaunch() : vmresume(), 0);
+ vector == SS_VECTOR ? vmlaunch() : vmresume();
if (vector == FAKE_TRIPLE_FAULT_VECTOR)
return;
@@ -125,9 +125,9 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
+ prepare_for_vmx_operation(vmx);
- GUEST_ASSERT_EQ(load_vmcs(vmx), true);
+ load_vmcs(vmx);
prepare_vmcs(vmx, NULL);
GUEST_ASSERT_EQ(vmwrite(GUEST_IDTR_LIMIT, 0), 0);
diff --git a/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c b/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c
index 8c2ba9674558e..101c1fe79eeb4 100644
--- a/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c
@@ -40,21 +40,21 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
{
uintptr_t save_cr3;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
/* Try to run L2 with invalid CR3 and make sure it fails */
save_cr3 = vmreadz(GUEST_CR3);
vmwrite(GUEST_CR3, -1ull);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) ==
(EXIT_REASON_FAILED_VMENTRY | EXIT_REASON_INVALID_STATE));
/* Now restore CR3 and make sure L2 runs successfully */
vmwrite(GUEST_CR3, save_cr3);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c b/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
index 2e04563790ff2..d6c443e3d147c 100644
--- a/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
@@ -55,12 +55,12 @@ static void l1_vmx_code(struct vmx_pages *vmx, u64 expected_fault_gpa,
u64 exit_qual;
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, l2_entry);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* Verify we got an EPT violation exit */
__GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_EPT_VIOLATION,
diff --git a/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c
index cb79d7b9619c2..c60dea899624b 100644
--- a/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c
@@ -86,8 +86,8 @@ static void l1_guest_code(void *data)
struct vmx_pages *vmx_pages = data;
u32 control;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
@@ -95,7 +95,7 @@ static void l1_guest_code(void *data)
vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
vmwrite(TSC_OFFSET, TSC_OFFSET_VALUE);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
} else {
struct svm_test_data *svm = data;
diff --git a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
index 18f765835bf4c..b2fc7f0b5b3c8 100644
--- a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
@@ -105,8 +105,8 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
/* check that L1's frequency looks alright before launching L2 */
check_tsc_freq(UCHECK_L1);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* prepare the VMCS for L2 execution */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -125,7 +125,7 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
vmwrite(TSC_MULTIPLIER_HIGH, TSC_MULTIPLIER_L2 >> 32);
/* launch L2 */
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
/* check that L1's frequency still looks good */
diff --git a/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c b/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c
index 507391ab2c930..f88427e925fcc 100644
--- a/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c
+++ b/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c
@@ -98,17 +98,17 @@ static void l1_svm_code(struct svm_test_data *svm)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, guest_access_memory);
GUEST_ASSERT(!vmwrite(EXCEPTION_BITMAP, BIT(UD_VECTOR)));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
while (1) {
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_EXCEPTION_NMI);
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_INTR_INFO) & 0xff, UD_VECTOR);
- GUEST_ASSERT(!vmresume());
+ vmresume();
}
}
diff --git a/tools/testing/selftests/kvm/x86/smm_test.c b/tools/testing/selftests/kvm/x86/smm_test.c
index d1edafd5af755..377df09e582ad 100644
--- a/tools/testing/selftests/kvm/x86/smm_test.c
+++ b/tools/testing/selftests/kvm/x86/smm_test.c
@@ -78,8 +78,8 @@ static void guest_code(void *arg)
if (this_cpu_has(X86_FEATURE_SVM)) {
generic_svm_setup(svm, l2_guest_code);
} else {
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
}
diff --git a/tools/testing/selftests/kvm/x86/state_test.c b/tools/testing/selftests/kvm/x86/state_test.c
index 4a1056a6cb8dc..38c9689ac6014 100644
--- a/tools/testing/selftests/kvm/x86/state_test.c
+++ b/tools/testing/selftests/kvm/x86/state_test.c
@@ -75,32 +75,32 @@ void vmx_l2_guest_code(void)
static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)
{
GUEST_ASSERT(vmx_pages->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
GUEST_SYNC(3);
- GUEST_ASSERT(load_vmcs(vmx_pages));
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ load_vmcs(vmx_pages);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
GUEST_SYNC(4);
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
prepare_vmcs(vmx_pages, vmx_l2_guest_code);
GUEST_SYNC(5);
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
- GUEST_ASSERT(!vmlaunch());
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
+ vmlaunch();
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
/* Check that the launched state is preserved. */
- GUEST_ASSERT(vmlaunch());
+ GUEST_ASSERT(__vmlaunch());
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_SYNC(7);
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + 3);
@@ -108,28 +108,28 @@ static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)
vmwrite(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_SHADOW_VMCS);
vmwrite(VMCS_LINK_POINTER, vmx_pages->shadow_vmcs_gpa);
- GUEST_ASSERT(!vmptrld(vmx_pages->shadow_vmcs_gpa));
- GUEST_ASSERT(vmlaunch());
+ vmptrld(vmx_pages->shadow_vmcs_gpa);
+ GUEST_ASSERT(__vmlaunch());
GUEST_SYNC(8);
- GUEST_ASSERT(vmlaunch());
- GUEST_ASSERT(vmresume());
+ GUEST_ASSERT(__vmlaunch());
+ GUEST_ASSERT(__vmresume());
vmwrite(GUEST_RIP, 0xc0ffee);
GUEST_SYNC(9);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffee);
- GUEST_ASSERT(!vmptrld(vmx_pages->vmcs_gpa));
- GUEST_ASSERT(!vmresume());
+ vmptrld(vmx_pages->vmcs_gpa);
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
- GUEST_ASSERT(!vmptrld(vmx_pages->shadow_vmcs_gpa));
+ vmptrld(vmx_pages->shadow_vmcs_gpa);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffffee);
- GUEST_ASSERT(vmlaunch());
- GUEST_ASSERT(vmresume());
+ GUEST_ASSERT(__vmlaunch());
+ GUEST_ASSERT(__vmresume());
GUEST_SYNC(13);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffffee);
- GUEST_ASSERT(vmlaunch());
- GUEST_ASSERT(vmresume());
+ GUEST_ASSERT(__vmlaunch());
+ GUEST_ASSERT(__vmresume());
}
static void __attribute__((__flatten__)) guest_code(void *arg)
diff --git a/tools/testing/selftests/kvm/x86/triple_fault_event_test.c b/tools/testing/selftests/kvm/x86/triple_fault_event_test.c
index 0d83516f4bd08..bb31a1ba8932e 100644
--- a/tools/testing/selftests/kvm/x86/triple_fault_event_test.c
+++ b/tools/testing/selftests/kvm/x86/triple_fault_event_test.c
@@ -25,12 +25,12 @@ void l1_guest_code_vmx(struct vmx_pages *vmx)
{
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, l2_guest_code);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* L2 should triple fault after a triple fault event injected. */
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_TRIPLE_FAULT);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
index 463f73aa9159a..fe29c869a2356 100644
--- a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
@@ -38,8 +38,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
{
u32 control;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -53,14 +53,14 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
/* Try to launch L2 with the memory-backed APIC-access address. */
GUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(APIC_ACCESS_ADDR, high_gpa);
/* Try to resume L2 with the unbacked APIC-access address. */
GUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c b/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c
index f9b88a6f6113d..e578221da247c 100644
--- a/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c
@@ -33,8 +33,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
{
u32 control;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -62,7 +62,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
* Run L2 to switch to x2APIC mode, which in turn will uninhibit APICv,
* as KVM should force the APIC ID back to its default.
*/
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN));
GUEST_ASSERT(rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD);
@@ -90,7 +90,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
* handles the x2APIC => xAPIC transition and inhibits APICv while L2
* is active.
*/
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_ASSERT(!(rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD));
diff --git a/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c b/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c
index c8379124b3172..3017938fa9937 100644
--- a/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c
+++ b/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c
@@ -41,8 +41,8 @@ static void l2_guest_code(void)
static void l1_guest_code(struct vmx_pages *vmx_pages)
{
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -55,7 +55,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
GUEST_ASSERT(!(vmreadz(CPU_BASED_VM_EXEC_CONTROL) & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) ||
!(vmreadz(SECONDARY_VM_EXEC_CONTROL) & SECONDARY_EXEC_UNRESTRICTED_GUEST));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* L2 should triple fault after main() stuffs invalid guest state. */
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_TRIPLE_FAULT);
diff --git a/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c b/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c
index 75073efa926da..b3651c5ab1384 100644
--- a/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c
@@ -37,8 +37,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
GUEST_ASSERT(rdmsr(MSR_GS_BASE) == LA57_GS_BASE);
GUEST_ASSERT(vmx_pages->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -56,7 +56,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
guest_cr4 &= ~X86_CR4_LA57;
vmwrite(GUEST_CR4, guest_cr4);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
exit_reason = vmreadz(VM_EXIT_REASON);
GUEST_ASSERT(exit_reason == EXIT_REASON_VMCALL);
diff --git a/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c b/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
index eb8021c33cd43..cda53df33888e 100644
--- a/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
@@ -71,9 +71,9 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
u64 l1_tsc_deadline, l2_tsc_deadline;
GUEST_ASSERT(vmx_pages->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -90,7 +90,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
!(ctrl_exit_rev.clr & VM_EXIT_SAVE_VMX_PREEMPTION_TIMER))
return;
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN));
@@ -110,7 +110,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
l1_vmx_pt_start = (rdtsc() >> vmx_pt_rate) << vmx_pt_rate;
- GUEST_ASSERT(!vmresume());
+ vmresume();
l1_vmx_pt_finish = rdtsc();
|
| 3/2 | 2026/08/26 23:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19239 output: 21 thoughts: 1206 Thoughts: **Analyzing the Impact of the VMPTRLD/VMPTRST Patch in KVM Nested VMX** Alright, let's break this down. We've got a patch that's altering the behavior of `VMPTRLD` and `VMPTRST` instructions within KVM's nested VMX environment, specifically when eVMCS is in play. The core of this seems to be in `arch/x86/kvm/vmx/nested.c`, so that's where I'm focusing. Looking at `handle_vmptrld`, the patch's main change is replacing a simple return with `kvm_queue_exception(vcpu, UD_VECTOR)` when eVMCS is active. Previously, just returning 1 might have been a subtle bug or a misinterpretation of the intended behavior. Returning 1 in a KVM exit handler often signals to resume the guest, but without advancing the instruction pointer (RIP), this would lead to either an infinite loop or, more likely, an unexpected failure. It looks like it was intended to fail/skip the instruction, but wasn't doing that, but there was an expectation that something *should* fail. Now, the patch correctly queues a #UD exception, which is the proper way to handle an undefined instruction. Now, for `handle_vmptrst`. Here, the change involves returning `hv_evmcs_vmptr` instead of just 1. It seems like the previous behavior, returning 1, might have also been a bug. In this case, there's a conditional compilation based on `CONFIG_KVM_HYPERV`, and the patch now conditionally assigns `current_vmptr` with `hv_evmcs_vmptr` when `nested_vmx_is_evmptr12_valid` is true. It appears Hyper-V TLFS does not define the behavior when eVMCS is used, but genuine Hyper-V returns eVMCS GPA. So, functionally, this is a change in how KVM handles nested VMX in certain scenarios. It looks like we're fixing a subtle bug and improving the accuracy of how KVM interacts with nested VMX in this context. The Hyper-V specific conditional is worth considering. This definitely warrants further scrutiny and testing, especially because these types of changes can expose new attack surfaces or reveal previously hidden bugs. Let's see: `KVM`, `KVM_INTEL`, and `KVM_HYPERV` are the key config options to keep in mind, and that code is in `arch/x86/kvm/vmx/nested.c`. Now, I should make sure I understand how to exercise this code and create a focused fuzzing setup. |
| 4/2 | 2026/08/26 23:55 | tool | grepper |
0mArgs:{
"Expression": "config KVM_HYPERV"
}Results: {
"Output": "arch/x86/kvm/Kconfig=183=config KVM_SMM\n--\narch/x86/kvm/Kconfig-193-\narch/x86/kvm/Kconfig:194:config KVM_HYPERV\narch/x86/kvm/Kconfig-195-\tbool \"Support for Microsoft Hyper-V emulation\"\n"
} |
| 5/2 | 2026/08/26 23:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21154 output: 20 thoughts: 29 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, and delivered as a first-person summary: **Digging into KVM Configuration** Alright, so `KVM_HYPERV` is definitely a recognized configuration option – good. Now, before I proceed with any changes related to that, I need to understand its dependencies thoroughly. My primary concern, as always, is Intel-specific virtualization. The performance implications of any changes, especially with Hyper-V in the mix, could be significant on an Intel-based system, so a deep dive into `KVM_INTEL`'s relationship with `KVM_HYPERV` is essential. I need to know precisely how they interact, if there are any potential conflicts, and, critically, if enabling `KVM_HYPERV` has any cascading effect on `KVM_INTEL` features or performance. Understanding that relationship is the foundation for any decisions I'll make going forward. I'll need to review the kernel documentation and relevant source code to get a clear picture. |
| 6/2 | 2026/08/26 23:55 | tool | grepper |
0mArgs:{
"Expression": "config KVM_INTEL"
}Results: {
"Output": "arch/x86/kvm/Kconfig=83=config KVM_SW_PROTECTED_VM\n--\narch/x86/kvm/Kconfig-95-\narch/x86/kvm/Kconfig:96:config KVM_INTEL\narch/x86/kvm/Kconfig-97-\ttristate \"KVM for Intel (and compatible) processors support\"\n--\narch/x86/kvm/Kconfig-106-\narch/x86/kvm/Kconfig:107:config KVM_INTEL_PROVE_VE\narch/x86/kvm/Kconfig-108- bool \"Check that guests do not receive #VE exceptions\"\n--\narch/x86/kvm/Kconfig=122=config X86_SGX_KVM\n--\narch/x86/kvm/Kconfig-133-\narch/x86/kvm/Kconfig:134:config KVM_INTEL_TDX\narch/x86/kvm/Kconfig-135-\tbool \"Intel Trust Domain Extensions (TDX) support\"\n"
} |
| 7/2 | 2026/08/26 23:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21718 output: 38 thoughts: 27 Thoughts: Here's my summary, as though I were thinking through the process: **KVM_INTEL Dependency Deep Dive** Okay, so I need to understand the dependencies related to `KVM_INTEL`. Time to dive into the Kconfig file for the x86 architecture, specifically `arch/x86/kvm/Kconfig`. I'm expecting this file to define the build-time configuration options for KVM on Intel processors and, crucially, to specify any other kernel features or hardware support that *must* be enabled or satisfied for `KVM_INTEL` to be viable. I want to see which features this is dependent on. |
| 8/2 | 2026/08/26 23:55 | tool | read-file |
0mArgs:{
"File": "arch/x86/kvm/Kconfig",
"FirstLine": 90,
"LineCount": 20
}Results: {
"Contents": " 90:\t\t protected VMs are purely a development and testing vehicle for\n 91:\t\t KVM_CREATE_GUEST_MEMFD. Attempting to run a \"real\" VM workload as a\n 92:\t\t software-protected VM will fail miserably.\n 93:\t\n 94:\t\t If unsure, say \"N\".\n 95:\t\n 96:\tconfig KVM_INTEL\n 97:\t\ttristate \"KVM for Intel (and compatible) processors support\"\n 98:\t\tdepends on KVM \u0026\u0026 IA32_FEAT_CTL\n 99:\t\tselect X86_FRED if X86_64\n 100:\t\thelp\n 101:\t\t Provides support for KVM on processors equipped with Intel's VT\n 102:\t\t extensions, a.k.a. Virtual Machine Extensions (VMX).\n 103:\t\n 104:\t\t To compile this as a module, choose M here: the module\n 105:\t\t will be called kvm-intel.\n 106:\t\n 107:\tconfig KVM_INTEL_PROVE_VE\n 108:\t bool \"Check that guests do not receive #VE exceptions\"\n 109:\t depends on KVM_INTEL \u0026\u0026 EXPERT\n"
} |
| 9/2 | 2026/08/26 23:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22254 output: 39 thoughts: 43 Thoughts: **My KVM Setup Considerations** Okay, so I'm looking at getting this KVM environment set up properly. It's clear that I'm going to need both `KVM` and `KVM_INTEL` enabled – that's a given for any modern Intel-based virtualization. And the situation is more complex than it once was, as now it also looks like I need `KVM_HYPERV` too. Alright, I should take a look at the `KVM_HYPERV` dependencies now, to ensure I've covered everything to give myself the best chance of compatibility. That should be my next step. |
| 10/2 | 2026/08/26 23:55 | tool | read-file |
0mArgs:{
"File": "arch/x86/kvm/Kconfig",
"FirstLine": 190,
"LineCount": 20
}Results: {
"Contents": " 190:\t\t firmware to implement UEFI secure boot.\n 191:\t\n 192:\t\t If unsure, say Y.\n 193:\t\n 194:\tconfig KVM_HYPERV\n 195:\t\tbool \"Support for Microsoft Hyper-V emulation\"\n 196:\t\tdepends on KVM_X86\n 197:\t\tdefault y\n 198:\t\thelp\n 199:\t\t Provides KVM support for emulating Microsoft Hyper-V. This allows KVM\n 200:\t\t to expose a subset of the paravirtualized interfaces defined in the\n 201:\t\t Hyper-V Hypervisor Top-Level Functional Specification (TLFS):\n 202:\t\t https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs\n 203:\t\t These interfaces are required for the correct and performant functioning\n 204:\t\t of Windows and Hyper-V guests on KVM.\n 205:\t\n 206:\t\t If unsure, say \"Y\".\n 207:\t\n 208:\tconfig KVM_XEN\n 209:\t\tbool \"Support for Xen hypercall interface\"\n"
} |
| 11/2 | 2026/08/26 23:55 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22794 output: 19 thoughts: 115 Thoughts: **Analyzing KVM Configuration and Patch Impact** Okay, so I'm looking at these KVM configurations: `KVM`, `KVM_INTEL`, and `KVM_HYPERV`. The core of my interest lies in how this patch affects the system, specifically around the functions `handle_vmptrld` and `handle_vmptrst`. My initial thought is to quickly verify if these functions are inlined or something obvious. It's crucial to understand their scope before diving deeper. Ah, they're defined as static functions in `arch/x86/kvm/vmx/nested.c`. Alright, so, not inlined. Now I need to confirm that they are not exported or somehow referenced through an array. This will inform how the patch will be applied and I need to determine the scope of these changes. |
| 12/2 | 2026/08/26 23:56 | tool | grepper |
0mArgs:{
"Expression": "handle_vmptrld"
}Results: {
"Output": "arch/x86/kvm/vmx/nested.c=5877=static void set_current_vmptr(struct vcpu_vmx *vmx, gpa_t vmptr)\n--\narch/x86/kvm/vmx/nested.c-5890-/* Emulate the VMPTRLD instruction */\narch/x86/kvm/vmx/nested.c:5891:static int handle_vmptrld(struct kvm_vcpu *vcpu)\narch/x86/kvm/vmx/nested.c-5892-{\n--\narch/x86/kvm/vmx/nested.c=7435=__init int nested_vmx_hardware_setup(int (*exit_handlers[])(struct kvm_vcpu *))\n--\narch/x86/kvm/vmx/nested.c-7467-\texit_handlers[EXIT_REASON_VMLAUNCH]\t= handle_vmlaunch;\narch/x86/kvm/vmx/nested.c:7468:\texit_handlers[EXIT_REASON_VMPTRLD]\t= handle_vmptrld;\narch/x86/kvm/vmx/nested.c-7469-\texit_handlers[EXIT_REASON_VMPTRST]\t= handle_vmptrst;\n--\narch/x86/kvm/vmx/vmx.c=4761=static u32 vmx_secondary_exec_control(struct vcpu_vmx *vmx)\n--\narch/x86/kvm/vmx/vmx.c-4800-\t/* SECONDARY_EXEC_SHADOW_VMCS is enabled when L1 executes VMPTRLD\narch/x86/kvm/vmx/vmx.c:4801:\t (handle_vmptrld).\narch/x86/kvm/vmx/vmx.c-4802-\t We can NOT enable shadow_vmcs here because we don't have yet\n"
} |
| 13/2 | 2026/08/26 23:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 23617 output: 20 thoughts: 157 Thoughts: **My Analysis of VM Exit Handling** Okay, so I'm looking at how VM exits are managed, and it seems like the system uses an `exit_handlers` array. Right, that makes sense. But the instructions are very specific: I'm supposed to favor non-static, non-inlined API entrypoint functions over those internal, static helper functions. The reason is they want distinct symbol addresses. Now, I'm noting that `handle_vmptrld` and `handle_vmptrst` are declared as `static`, which at first would suggest they'd be inlined by the compiler and not have distinct symbols. But wait, I remember how these are used. They are function pointers *within* the `exit_handlers` array. Since they are function pointers, I don't think they're inlined. Though, I am a bit concerned because `nested_vmx_hardware_setup` seems to be responsible for setting them up. It's a key function I'll need to keep in mind. So, I think I'm on the right track here, and the real entry point for VM exits is `vmx_handle_exit` in `arch/x86/kvm/vmx/vmx.c`. That's where I need to focus my attention. Let's dig into that function and see what's happening. |
| 14/2 | 2026/08/26 23:56 | tool | grepper |
0mArgs:{
"Expression": "vmx_handle_exit"
}Results: {
"Output": "arch/x86/kvm/vmx/main.c=157=static int vt_handle_exit(struct kvm_vcpu *vcpu,\n--\narch/x86/kvm/vmx/main.c-162-\narch/x86/kvm/vmx/main.c:163:\treturn vmx_handle_exit(vcpu, fastpath);\narch/x86/kvm/vmx/main.c-164-}\n--\narch/x86/kvm/vmx/main.c=888=struct kvm_x86_ops vt_x86_ops __initdata = {\n--\narch/x86/kvm/vmx/main.c-1002-\t.check_intercept = vmx_check_intercept,\narch/x86/kvm/vmx/main.c:1003:\t.handle_exit_irqoff = vmx_handle_exit_irqoff,\narch/x86/kvm/vmx/main.c-1004-\n--\narch/x86/kvm/vmx/vmx.c=5429=static int handle_exception_nmi(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/vmx.c-5494-\t * MMIO, it is better to report an internal error.\narch/x86/kvm/vmx/vmx.c:5495:\t * See the comments in vmx_handle_exit.\narch/x86/kvm/vmx/vmx.c-5496-\t */\n--\narch/x86/kvm/vmx/vmx.c=6268=static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/vmx.c-6272-\t * VM-Exits. Unconditionally set the flag here and leave the handling to\narch/x86/kvm/vmx/vmx.c:6273:\t * vmx_handle_exit().\narch/x86/kvm/vmx/vmx.c-6274-\t */\n--\narch/x86/kvm/vmx/vmx.c=6501=void dump_vmcs(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/vmx.c-6705- */\narch/x86/kvm/vmx/vmx.c:6706:static int __vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)\narch/x86/kvm/vmx/vmx.c-6707-{\n--\narch/x86/kvm/vmx/vmx.c-6864-\narch/x86/kvm/vmx/vmx.c:6865:int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)\narch/x86/kvm/vmx/vmx.c-6866-{\narch/x86/kvm/vmx/vmx.c:6867:\tint ret = __vmx_handle_exit(vcpu, exit_fastpath);\narch/x86/kvm/vmx/vmx.c-6868-\n--\narch/x86/kvm/vmx/vmx.c=7178=static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu,\n--\narch/x86/kvm/vmx/vmx.c-7193-\narch/x86/kvm/vmx/vmx.c:7194:void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)\narch/x86/kvm/vmx/vmx.c-7195-{\n--\narch/x86/kvm/vmx/x86_ops.h=28=void vmx_vcpu_put(struct kvm_vcpu *vcpu);\narch/x86/kvm/vmx/x86_ops.h:29:int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath);\narch/x86/kvm/vmx/x86_ops.h:30:void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu);\narch/x86/kvm/vmx/x86_ops.h-31-int vmx_skip_emulated_instruction(struct kvm_vcpu *vcpu);\n--\ntools/perf/Documentation/perf-intel-pt.txt=1592=Notes:\n--\ntools/perf/Documentation/perf-intel-pt.txt-1612- CPU 3/KVM 13376/13384 [002] 7919.408803862: branches: ffffffffc0f662e9 vmx_vcpu_run+0x3b9 ([kernel.kallsyms]) =\u003e ffffffffc0f619a0 __vmx_co...\ntools/perf/Documentation/perf-intel-pt.txt:1613: CPU 3/KVM 13376/13384 [002] 7919.408803872: branches: ffffffffc109cfb2 vcpu_enter_guest+0x752 ([kernel.kallsyms]) =\u003e ffffffffc0f5f570 vmx_...\ntools/perf/Documentation/perf-intel-pt.txt-1614- CPU 3/KVM 13376/13384 [002] 7919.408803881: branches: ffffffffc109d028 vcpu_enter_guest+0x7c8 ([kernel.kallsyms]) =\u003e ffffffffb234f900 __sr...\ntools/perf/Documentation/perf-intel-pt.txt:1615: CPU 3/KVM 13376/13384 [002] 7919.408803897: branches: ffffffffc109d06f vcpu_enter_guest+0x80f ([kernel.kallsyms]) =\u003e ffffffffc0f72e30 vmx_...\ntools/perf/Documentation/perf-intel-pt.txt:1616: CPU 3/KVM 13376/13384 [002] 7919.408803897: branches: ffffffffc0f72e3d vmx_handle_exit+0xd ([kernel.kallsyms]) =\u003e ffffffffc0f727c0 __vmx_h...\ntools/perf/Documentation/perf-intel-pt.txt:1617: CPU 3/KVM 13376/13384 [002] 7919.408803897: branches: ffffffffc0f72b15 __vmx_handle_exit+0x355 ([kernel.kallsyms]) =\u003e ffffffffc0f60ae0 vmx...\ntools/perf/Documentation/perf-intel-pt.txt:1618: CPU 3/KVM 13376/13384 [002] 7919.408803903: branches: ffffffffc0f72994 __vmx_handle_exit+0x1d4 ([kernel.kallsyms]) =\u003e ffffffffc10b7090 kvm...\ntools/perf/Documentation/perf-intel-pt.txt-1619- CPU 3/KVM 13376/13384 [002] 7919.408803903: branches: ffffffffc10b70f1 kvm_emulate_cpuid+0x61 ([kernel.kallsyms]) =\u003e ffffffffc10b6e10 kvm_...\n"
} |
| 15/2 | 2026/08/26 23:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 26189 output: 19 thoughts: 282 Thoughts: **My Analysis of VM Exit Handling** Okay, so I'm diving into this VMX code, and my initial thought was that `vmx_handle_exit` looked like the primary entry point, a good starting point. But then, I remembered that `nested_vmx_hardware_setup` actually populates this `exit_handlers` array – that's crucial. I need to keep that in mind. Now, let's see, what other functions are important? Ah, right, `nested_vmx_get_vmptr` is called from `handle_vmptrld`. Interesting. And, critically, those `handle_vmptrld` and `handle_vmptrst` functions are declared as `static`. I also glanced at `nested_vmx_is_evmptr12_valid` which is inline. `nested_vmx_check_permission` is also `static`. I'm starting to zero in now. I should circle back to `nested_vmx_hardware_setup` and trace its usage. Wait a minute... while `vmx_handle_exit` *is* the main VM exit handler, my attention is being drawn to `handle_vmptrld` and `handle_vmptrst`. They're the ones that appear to have been modified. The fact that they are `static` is significant. That likely means they *won't* be inlined, because their addresses are probably being taken and put into that `exit_handlers` array. So, the compiler can't optimize them away. I need to confirm that. If they're in an array of function pointers, inlining is impossible, because you need the actual address of the function. So, if that's the case, then `handle_vmptrld` and `handle_vmptrst` really *are* the significant functions to focus on. That would be a major clue. Okay, let's verify that assumption. |
| 16/2 | 2026/08/26 23:56 | tool | grepper |
0mArgs:{
"Expression": "handle_vmptrld"
}Results: {
"Output": "arch/x86/kvm/vmx/nested.c=5877=static void set_current_vmptr(struct vcpu_vmx *vmx, gpa_t vmptr)\n--\narch/x86/kvm/vmx/nested.c-5890-/* Emulate the VMPTRLD instruction */\narch/x86/kvm/vmx/nested.c:5891:static int handle_vmptrld(struct kvm_vcpu *vcpu)\narch/x86/kvm/vmx/nested.c-5892-{\n--\narch/x86/kvm/vmx/nested.c=7435=__init int nested_vmx_hardware_setup(int (*exit_handlers[])(struct kvm_vcpu *))\n--\narch/x86/kvm/vmx/nested.c-7467-\texit_handlers[EXIT_REASON_VMLAUNCH]\t= handle_vmlaunch;\narch/x86/kvm/vmx/nested.c:7468:\texit_handlers[EXIT_REASON_VMPTRLD]\t= handle_vmptrld;\narch/x86/kvm/vmx/nested.c-7469-\texit_handlers[EXIT_REASON_VMPTRST]\t= handle_vmptrst;\n--\narch/x86/kvm/vmx/vmx.c=4761=static u32 vmx_secondary_exec_control(struct vcpu_vmx *vmx)\n--\narch/x86/kvm/vmx/vmx.c-4800-\t/* SECONDARY_EXEC_SHADOW_VMCS is enabled when L1 executes VMPTRLD\narch/x86/kvm/vmx/vmx.c:4801:\t (handle_vmptrld).\narch/x86/kvm/vmx/vmx.c-4802-\t We can NOT enable shadow_vmcs here because we don't have yet\n"
} |
| 17/2 | 2026/08/26 23:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 27421 output: 28 thoughts: 286 Thoughts: **My Reasoning on Symbol Selection** Okay, so I'm looking for the best symbols to focus our fuzzing efforts. I see the target functions are definitely *not* inlined, because their addresses are taken, making them part of the `exit_handlers` array. That means they have distinct symbol addresses. Good, so `handle_vmptrld` and `handle_vmptrst` look like strong candidates to start with. Wait, let me just double-check the guidance… the instructions do say to prefer non-static, non-inlined entrypoint functions. These *are* static, but they are *not* inlined, since we can point to their addresses. They do have distinct symbol addresses, even though static, due to their not being inlined. However, I'll hedge my bets and add `vmx_handle_exit` or `__vmx_handle_exit` to the list, just to be safe. Hold on… `vmx_handle_exit` is described as a generic hot-path function. The instructions specifically say to avoid those to prevent skewed test distributions. That makes sense; a generic function would likely cover a lot of unrelated code, and we're looking to specifically target VMPTRLD and VMPTRST exits. So, I should avoid `vmx_handle_exit`. That leaves me back at `handle_vmptrld` and `handle_vmptrst`. They are specific to the VMPTRLD and VMPTRST exits, which is *exactly* what we need to fuzz. Perfect. Now, a quick confirmation: can syzkaller even *reach* these VM exits? Yes, we can trigger VM exits using VMPTRLD and VMPTRST instructions within the guest, so those symbols should be accessible. Alright, before I lock in the final selection, let's verify if `nested_vmx_is_evmptr12_valid` has relevance here. |
| 18/2 | 2026/08/26 23:56 | tool | grepper |
0mArgs:{
"Expression": "nested_vmx_is_evmptr12_valid"
}Results: {
"Output": "arch/x86/kvm/vmx/hyperv.h=20=static inline bool evmptr_is_valid(u64 evmptr)\n--\narch/x86/kvm/vmx/hyperv.h-24-\narch/x86/kvm/vmx/hyperv.h:25:static inline bool nested_vmx_is_evmptr12_valid(struct vcpu_vmx *vmx)\narch/x86/kvm/vmx/hyperv.h-26-{\n--\narch/x86/kvm/vmx/hyperv.h=64=static inline bool evmptr_is_valid(u64 evmptr)\n--\narch/x86/kvm/vmx/hyperv.h-68-\narch/x86/kvm/vmx/hyperv.h:69:static inline bool nested_vmx_is_evmptr12_valid(struct vcpu_vmx *vmx)\narch/x86/kvm/vmx/hyperv.h-70-{\n--\narch/x86/kvm/vmx/nested.c=195=static int nested_vmx_fail(struct kvm_vcpu *vcpu, u32 vm_instruction_error)\n--\narch/x86/kvm/vmx/nested.c-203-\tif (vmx-\u003enested.current_vmptr == INVALID_GPA \u0026\u0026\narch/x86/kvm/vmx/nested.c:204:\t !nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-205-\t\treturn nested_vmx_failInvalid(vcpu);\n--\narch/x86/kvm/vmx/nested.c=2274=void nested_sync_vmcs12_to_shadow(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/nested.c-2277-\narch/x86/kvm/vmx/nested.c:2278:\tif (nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-2279-\t\tcopy_vmcs12_to_enlightened(vmx);\n--\narch/x86/kvm/vmx/nested.c=2431=static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct loaded_vmcs *vmcs01,\n--\narch/x86/kvm/vmx/nested.c-2436-\narch/x86/kvm/vmx/nested.c:2437:\tif (vmx-\u003enested.dirty_vmcs12 || nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-2438-\t\tprepare_vmcs02_early_rare(vmx, vmcs12);\n--\narch/x86/kvm/vmx/nested.c=2760=static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,\n--\narch/x86/kvm/vmx/nested.c-2767-\narch/x86/kvm/vmx/nested.c:2768:\tif (vmx-\u003enested.dirty_vmcs12 || nested_vmx_is_evmptr12_valid(vmx)) {\narch/x86/kvm/vmx/nested.c-2769-\t\tprepare_vmcs02_rare(vmx, vmcs12);\n--\narch/x86/kvm/vmx/nested.c-2771-\narch/x86/kvm/vmx/nested.c:2772:\t\tload_guest_pdptrs_vmcs12 = !nested_vmx_is_evmptr12_valid(vmx) ||\narch/x86/kvm/vmx/nested.c-2773-\t\t\t!(evmcs-\u003ehv_clean_fields \u0026 HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1);\n--\narch/x86/kvm/vmx/nested.c-2901-\t */\narch/x86/kvm/vmx/nested.c:2902:\tif (nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-2903-\t\tevmcs-\u003ehv_clean_fields |= HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL;\n--\narch/x86/kvm/vmx/nested.c=3629=enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,\n--\narch/x86/kvm/vmx/nested.c-3782-\tvmcs12-\u003evm_exit_reason = exit_reason.full;\narch/x86/kvm/vmx/nested.c:3783:\tif (enable_shadow_vmcs || nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-3784-\t\tvmx-\u003enested.need_vmcs12_to_shadow_sync = true;\n--\narch/x86/kvm/vmx/nested.c=3792=static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)\n--\narch/x86/kvm/vmx/nested.c-3813-\narch/x86/kvm/vmx/nested.c:3814:\tif (CC(!nested_vmx_is_evmptr12_valid(vmx) \u0026\u0026\narch/x86/kvm/vmx/nested.c-3815-\t vmx-\u003enested.current_vmptr == INVALID_GPA))\n--\narch/x86/kvm/vmx/nested.c-3828-\narch/x86/kvm/vmx/nested.c:3829:\tif (nested_vmx_is_evmptr12_valid(vmx)) {\narch/x86/kvm/vmx/nested.c-3830-\t\tstruct hv_enlightened_vmcs *evmcs = nested_vmx_evmcs(vmx);\n--\narch/x86/kvm/vmx/nested.c=4653=static void sync_vmcs02_to_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)\n--\narch/x86/kvm/vmx/nested.c-4656-\narch/x86/kvm/vmx/nested.c:4657:\tif (nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-4658-\t\tsync_vmcs02_to_vmcs12_rare(vcpu, vmcs12);\n--\narch/x86/kvm/vmx/nested.c-4660-\tvmx-\u003enested.need_sync_vmcs02_to_vmcs12_rare =\narch/x86/kvm/vmx/nested.c:4661:\t\t!nested_vmx_is_evmptr12_valid(vmx);\narch/x86/kvm/vmx/nested.c-4662-\n--\narch/x86/kvm/vmx/nested.c=5073=void __nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,\n--\narch/x86/kvm/vmx/nested.c-5180-\tif ((vm_exit_reason != -1) \u0026\u0026\narch/x86/kvm/vmx/nested.c:5181:\t (enable_shadow_vmcs || nested_vmx_is_evmptr12_valid(vmx)))\narch/x86/kvm/vmx/nested.c-5182-\t\tvmx-\u003enested.need_vmcs12_to_shadow_sync = true;\n--\narch/x86/kvm/vmx/nested.c=5664=static int handle_vmread(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/nested.c-5683-\narch/x86/kvm/vmx/nested.c:5684:\tif (!nested_vmx_is_evmptr12_valid(vmx)) {\narch/x86/kvm/vmx/nested.c-5685-\t\t/*\n--\narch/x86/kvm/vmx/nested.c=5891=static int handle_vmptrld(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/nested.c-5900-\t/* Forbid normal VMPTRLD if Enlightened version was used */\narch/x86/kvm/vmx/nested.c:5901:\tif (nested_vmx_is_evmptr12_valid(vmx)) {\narch/x86/kvm/vmx/nested.c-5902-\t\tkvm_queue_exception(vcpu, UD_VECTOR);\n--\narch/x86/kvm/vmx/nested.c=5963=static int handle_vmptrst(struct kvm_vcpu *vcpu)\n--\narch/x86/kvm/vmx/nested.c-5979-#ifdef CONFIG_KVM_HYPERV\narch/x86/kvm/vmx/nested.c:5980:\tif (nested_vmx_is_evmptr12_valid(to_vmx(vcpu)))\narch/x86/kvm/vmx/nested.c-5981-\t\tcurrent_vmptr = to_vmx(vcpu)-\u003enested.hv_evmcs_vmptr;\n--\narch/x86/kvm/vmx/nested.c=6764=static int vmx_get_nested_state(struct kvm_vcpu *vcpu,\n--\narch/x86/kvm/vmx/nested.c-6852-\t\tif (!vmx-\u003enested.need_vmcs12_to_shadow_sync) {\narch/x86/kvm/vmx/nested.c:6853:\t\t\tif (nested_vmx_is_evmptr12_valid(vmx))\narch/x86/kvm/vmx/nested.c-6854-\t\t\t\t/*\n"
} |
| 19/2 | 2026/08/26 23:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 30909 output: 157 thoughts: 788 Thoughts: **My Assessment of the KVM Patch for Nested VMX and eVMCS** Okay, so I've been digging into this patch. It's focused on how KVM handles VMPTRLD and VMPTRST within nested VMX when the Enlightened VMCS (eVMCS) feature is in play. The key symbols here are definitely `handle_vmptrld` and `handle_vmptrst`. Those are the entry points for the relevant VM exits, and they're exactly where the patch makes the critical changes. I considered including `nested_vmx_run` initially because it's the main function for VMLAUNCH/VMRESUME, and therefore interacts with the eVMCS, but the changes center on the `handle_*` functions. I confirmed that the patch also touches `tools/testing/selftests/kvm/x86/hyperv_evmcs.c` and other tests, which is a good sign. It shows this is a functional change, it's testable, and, crucially, it's reachable. This all points to this patch being worth fuzzing, as it's changing core behaviour. My reasoning is straightforward: the patch fundamentally alters the behavior of the VMPTRLD and VMPTRST instructions within nested VMX when eVMCS is active. It's replacing the standard instruction handling with either a #UD exception (for VMPTRLD) or returning the eVMCS GPA (for VMPTRST). This is a functional change in KVM's nested virtualization logic, and it can be triggered during guest execution. I've got the `FocusSymbols` as `["handle_vmptrld", "handle_vmptrst"]`. The `EnableConfigs` are `["KVM", "KVM_INTEL", "KVM_HYPERV"]` which is all I need since `KVM_X86` is selected by `KVM` and `KVM_HYPERV` depends on `KVM_X86`. Just to be sure, I double-checked the functions and the patch code again. Those `handle_*` functions are static, but their addresses are used in the `exit_handlers` array, so they definitely aren't inlined and have distinct symbols. They are the API entrypoints for handling those specific VM exit reasons. Looking at the code, it confirms what I thought. With eVMCS valid, the patch queues a #UD exception for `handle_vmptrld`. For `handle_vmptrst`, it returns the eVMCS GPA when `KVM_HYPERV` is enabled, instead of skipping the instruction (or looping), as the Hyper-V TLFS does not specify what to do. The rest of the patch then focuses on selftests to cover this new behaviour. Yep, looks good. Everything checks out. |
| 20/2 | 2026/08/26 23:56 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"KVM",
"KVM_INTEL",
"KVM_HYPERV"
],
"FocusSymbols": [
"handle_vmptrld",
"handle_vmptrst"
],
"Reasoning": "The patch modifies the behavior of VMPTRLD and VMPTRST instructions in nested VMX when Enlightened VMCS (eVMCS) is used. It changes VMPTRLD to queue a #UD exception and VMPTRST to return the eVMCS GPA instead of just returning 1. This is a functional change in KVM's nested virtualization logic that is reachable from guest execution and should be fuzzed.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"KVM",
"KVM_INTEL",
"KVM_HYPERV"
],
"FocusSymbols": [
"handle_vmptrld",
"handle_vmptrst"
],
"Reasoning": "The patch modifies the behavior of VMPTRLD and VMPTRST instructions in nested VMX when Enlightened VMCS (eVMCS) is used. It changes VMPTRLD to queue a #UD exception and VMPTRST to return the eVMCS GPA instead of just returning 1. This is a functional change in KVM's nested virtualization logic that is reachable from guest execution and should be fuzzed.",
"WorthFuzzing": true
} |
| 21/1 | 2026/08/26 23:56 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 22/2 | 2026/08/26 23:56 | agent | kmsan-evaluator |
0mModel:best-expensive Args: null Results: {
"KMSANReasoning": "The patch modifies `handle_vmptrld` and `handle_vmptrst` in KVM's VMX nested virtualization code. In `handle_vmptrst`, it changes the behavior when eVMCS is used: instead of returning 1 (doing nothing), it now sets the local variable `current_vmptr` to `hv_evmcs_vmptr` and writes it to guest memory. `current_vmptr` is a `gpa_t` (a 64-bit integer), which is fully initialized before being written to the guest via `kvm_write_guest_virt_system`. There are no structs with padding or uninitialized fields involved. The rest of the changes are in KVM selftests. There is no risk of uninitialized memory reads or info-leaks introduced by this patch. Standard KASAN and other bug detectors are sufficient to catch any potential memory corruption or logic bugs.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: For your convenience, here is the diff of the changes:
commit 399c2ebb041d26980183aae134635686bb04cb04
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Aug 26 23:55:25 2026 +0000
syz-cluster: applied patch under review
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 151873407abd3..3058efa65c82c 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5897,6 +5897,12 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
if (!nested_vmx_check_permission(vcpu))
return 1;
+ /* Forbid normal VMPTRLD if Enlightened version was used */
+ if (nested_vmx_is_evmptr12_valid(vmx)) {
+ kvm_queue_exception(vcpu, UD_VECTOR);
+ return 1;
+ }
+
if (nested_vmx_get_vmptr(vcpu, &vmptr, &r))
return r;
@@ -5906,10 +5912,6 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
if (vmptr == vmx->nested.vmxon_ptr)
return nested_vmx_fail(vcpu, VMXERR_VMPTRLD_VMXON_POINTER);
- /* Forbid normal VMPTRLD if Enlightened version was used */
- if (nested_vmx_is_evmptr12_valid(vmx))
- return 1;
-
if (vmx->nested.current_vmptr != vmptr) {
struct gfn_to_hva_cache *ghc = &vmx->nested.vmcs12_cache;
struct vmcs_hdr hdr;
@@ -5962,7 +5964,7 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
{
unsigned long exit_qual = vmx_get_exit_qual(vcpu);
u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);
- gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
+ gpa_t current_vmptr;
struct x86_exception e;
gva_t gva;
int r;
@@ -5970,8 +5972,16 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
if (!nested_vmx_check_permission(vcpu))
return 1;
- if (unlikely(nested_vmx_is_evmptr12_valid(to_vmx(vcpu))))
- return 1;
+ /*
+ * Hyper-V TLFS does not specify the behavior of VMPTRST when eVMCS is used
+ * but genuine Hyper-V seems to be returning eVMCS GPA.
+ */
+#ifdef CONFIG_KVM_HYPERV
+ if (nested_vmx_is_evmptr12_valid(to_vmx(vcpu)))
+ current_vmptr = to_vmx(vcpu)->nested.hv_evmcs_vmptr;
+ else
+#endif
+ current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
if (get_vmx_mem_address(vcpu, exit_qual, instr_info,
true, sizeof(gpa_t), &gva))
diff --git a/tools/testing/selftests/kvm/include/x86/evmcs.h b/tools/testing/selftests/kvm/include/x86/evmcs.h
index 82a8ea6b661f0..c5b9d26f6cdbe 100644
--- a/tools/testing/selftests/kvm/include/x86/evmcs.h
+++ b/tools/testing/selftests/kvm/include/x86/evmcs.h
@@ -265,14 +265,6 @@ static inline bool load_evmcs(struct hyperv_test_pages *hv)
return true;
}
-static inline int evmcs_vmptrst(u64 *value)
-{
- *value = current_vp_assist->current_nested_vmcs &
- ~HV_X64_MSR_VP_ASSIST_PAGE_ENABLE;
-
- return 0;
-}
-
static inline int evmcs_vmread(u64 encoding, u64 *value)
{
switch (encoding) {
diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h
index 6e6f70035508a..282b8aaff7995 100644
--- a/tools/testing/selftests/kvm/include/x86/processor.h
+++ b/tools/testing/selftests/kvm/include/x86/processor.h
@@ -1318,7 +1318,7 @@ gva_t vm_alloc_stack(struct kvm_vm *vm, int nr_pages);
"lea 1f(%%rip), %%r10\n\t" \
"lea 2f(%%rip), %%r11\n\t" \
fep "1: " insn "\n\t" \
- "xor %%r9, %%r9\n\t" \
+ "mov $0, %%r9d\n\t" \
"2:\n\t" \
"mov %%r9b, %[vector]\n\t" \
"mov %%r10, %[error_code]\n\t"
diff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h
index 04f5e34dea3ae..cd82a6be6963c 100644
--- a/tools/testing/selftests/kvm/include/x86/vmx.h
+++ b/tools/testing/selftests/kvm/include/x86/vmx.h
@@ -309,126 +309,91 @@ struct vmx_msr_entry {
#include "evmcs.h"
-static inline int vmxon(u64 phys)
-{
- u8 ret;
-
- __asm__ __volatile__ ("vmxon %[pa]; setna %[ret]"
- : [ret]"=rm"(ret)
- : [pa]"m"(phys)
- : "cc", "memory");
-
- return ret;
+#define GUEST_ASSERT_VMX_INSN_SUCCEEDED(insn, __r, __pa) \
+ __GUEST_ASSERT(!__r, __stringify(insn) "[0x%lx] hit %s", \
+ __pa, __r < 0 ? "VM-Fail" : ex_str(__r))
+
+#define BUILD_VMCS_ASM_HELPERS(insn) \
+static inline int __##insn(u64 vmcs_pa) \
+{ \
+ u64 error_code; \
+ u8 vector; \
+ u8 failed; \
+ \
+ asm volatile(KVM_ASM_SAFE(__stringify(insn) " %[pa]") \
+ "\n\tsetna %[failed]" \
+ : KVM_ASM_SAFE_OUTPUTS(vector, error_code), \
+ [failed]"=qm"(failed) \
+ : [pa]"m"(vmcs_pa) \
+ : "cc", "memory", KVM_ASM_SAFE_CLOBBERS); \
+ \
+ return vector ? vector : failed ? -EINVAL : 0; \
+} \
+ \
+static inline void insn(u64 vmcs_pa) \
+{ \
+ int ret = __##insn(vmcs_pa); \
+ \
+ GUEST_ASSERT_VMX_INSN_SUCCEEDED(insn, ret, vmcs_pa); \
}
+BUILD_VMCS_ASM_HELPERS(vmxon)
+BUILD_VMCS_ASM_HELPERS(vmptrld)
+BUILD_VMCS_ASM_HELPERS(vmclear)
+
static inline void vmxoff(void)
{
__asm__ __volatile__("vmxoff");
}
-static inline int vmclear(u64 vmcs_pa)
-{
- u8 ret;
-
- __asm__ __volatile__ ("vmclear %[pa]; setna %[ret]"
- : [ret]"=rm"(ret)
- : [pa]"m"(vmcs_pa)
- : "cc", "memory");
-
- return ret;
-}
-
-static inline int vmptrld(u64 vmcs_pa)
-{
- u8 ret;
-
- if (enable_evmcs)
- return -1;
-
- __asm__ __volatile__ ("vmptrld %[pa]; setna %[ret]"
- : [ret]"=rm"(ret)
- : [pa]"m"(vmcs_pa)
- : "cc", "memory");
-
- return ret;
-}
-
-static inline int vmptrst(u64 *value)
+static inline u64 vmptrst(void)
{
- u64 tmp;
+ u64 value = 0;
u8 ret;
- if (enable_evmcs)
- return evmcs_vmptrst(value);
-
__asm__ __volatile__("vmptrst %[value]; setna %[ret]"
- : [value]"=m"(tmp), [ret]"=rm"(ret)
+ : [value]"=m"(value), [ret]"=rm"(ret)
: : "cc", "memory");
- *value = tmp;
- return ret;
-}
-
-/*
- * A wrapper around vmptrst that ignores errors and returns zero if the
- * vmptrst instruction fails.
- */
-static inline u64 vmptrstz(void)
-{
- u64 value = 0;
- vmptrst(&value);
+ __GUEST_ASSERT(!ret, "vmptrst failed");
return value;
}
-static inline int vmlaunch(void)
-{
- int ret;
-
- if (enable_evmcs)
- return evmcs_vmlaunch();
-
- __asm__ __volatile__("push $0;"
- "vmwrite %%rsp, %[host_rsp];"
- "lea 1f(%%rip), %%rax;"
- "vmwrite %%rax, %[host_rip];"
- VMX_SWITCH_GPRS_ASM
- "vmlaunch;"
- "incq (%%rsp);"
- "1: ;"
- VMX_SWITCH_GPRS_ASM
- "pop %%rax;"
- : [ret]"=&a"(ret)
- : [host_rsp]"r"((u64)HOST_RSP),
- [host_rip]"r"((u64)HOST_RIP),
- GUEST_REGS_OFFSETS
- : "memory", "cc");
- return ret;
-}
-
-static inline int vmresume(void)
-{
- int ret;
-
- if (enable_evmcs)
- return evmcs_vmresume();
-
- __asm__ __volatile__("push $0;"
- "vmwrite %%rsp, %[host_rsp];"
- "lea 1f(%%rip), %%rax;"
- "vmwrite %%rax, %[host_rip];"
- VMX_SWITCH_GPRS_ASM
- "vmresume;"
- "incq (%%rsp);"
- "1: ;"
- VMX_SWITCH_GPRS_ASM
- "pop %%rax;"
- : [ret]"=&a"(ret)
- : [host_rsp]"r"((u64)HOST_RSP),
- [host_rip]"r"((u64)HOST_RIP),
- GUEST_REGS_OFFSETS
- : "memory", "cc");
- return ret;
+#define BUILD_VMX_VM_ENTRY_HELPERS(insn) \
+static inline int __##insn(void) \
+{ \
+ int ret; \
+ \
+ if (enable_evmcs) \
+ return evmcs_##insn(); \
+ \
+ __asm__ __volatile__("push $0;" \
+ "vmwrite %%rsp, %[host_rsp];" \
+ "lea 1f(%%rip), %%rax;" \
+ "vmwrite %%rax, %[host_rip];" \
+ VMX_SWITCH_GPRS_ASM \
+ __stringify(insn)";" \
+ "incq (%%rsp);" \
+ "1: ;" \
+ VMX_SWITCH_GPRS_ASM \
+ "pop %%rax;" \
+ : [ret]"=&a"(ret) \
+ : [host_rsp]"r"((u64)HOST_RSP), \
+ [host_rip]"r"((u64)HOST_RIP), \
+ GUEST_REGS_OFFSETS \
+ : "memory", "cc"); \
+ return ret; \
+} \
+ \
+static inline void insn(void) \
+{ \
+ int ret; \
+ \
+ ret = __##insn(); \
+ __GUEST_ASSERT(!ret, __stringify(insn) " hit VM-Fail"); \
}
+BUILD_VMX_VM_ENTRY_HELPERS(vmlaunch)
+BUILD_VMX_VM_ENTRY_HELPERS(vmresume)
static inline void vmcall(void)
{
@@ -550,9 +515,9 @@ union vmx_ctrl_msr {
};
struct vmx_pages *vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva);
-bool prepare_for_vmx_operation(struct vmx_pages *vmx);
+void prepare_for_vmx_operation(struct vmx_pages *vmx);
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip);
-bool load_vmcs(struct vmx_pages *vmx);
+void load_vmcs(struct vmx_pages *vmx);
bool ept_1g_pages_supported(void);
diff --git a/tools/testing/selftests/kvm/lib/x86/memstress.c b/tools/testing/selftests/kvm/lib/x86/memstress.c
index e19e8b5a09c5a..6a1815fb97e95 100644
--- a/tools/testing/selftests/kvm/lib/x86/memstress.c
+++ b/tools/testing/selftests/kvm/lib/x86/memstress.c
@@ -33,14 +33,14 @@ __asm__(
static void l1_vmx_code(struct vmx_pages *vmx, u64 vcpu_id)
{
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
GUEST_ASSERT(ept_1g_pages_supported());
*(u64 *)vmx->stack = vcpu_id;
prepare_vmcs(vmx, memstress_l2_guest_entry);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);
GUEST_DONE();
}
diff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/selftests/kvm/lib/x86/vmx.c
index 089e1a8af53fc..5c6cadc08405a 100644
--- a/tools/testing/selftests/kvm/lib/x86/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86/vmx.c
@@ -125,7 +125,7 @@ vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva)
return vmx;
}
-bool prepare_for_vmx_operation(struct vmx_pages *vmx)
+void prepare_for_vmx_operation(struct vmx_pages *vmx)
{
u64 feature_control;
u64 required;
@@ -163,28 +163,20 @@ bool prepare_for_vmx_operation(struct vmx_pages *vmx)
/* Enter VMX root operation. */
*(u32 *)(vmx->vmxon) = vmcs_revision();
- if (vmxon(vmx->vmxon_gpa))
- return false;
-
- return true;
+ vmxon(vmx->vmxon_gpa);
}
-bool load_vmcs(struct vmx_pages *vmx)
+void load_vmcs(struct vmx_pages *vmx)
{
/* Load a VMCS. */
*(u32 *)(vmx->vmcs) = vmcs_revision();
- if (vmclear(vmx->vmcs_gpa))
- return false;
+ vmclear(vmx->vmcs_gpa);
- if (vmptrld(vmx->vmcs_gpa))
- return false;
+ vmptrld(vmx->vmcs_gpa);
/* Setup shadow VMCS, do not load it yet. */
*(u32 *)(vmx->shadow_vmcs) = vmcs_revision() | 0x80000000ul;
- if (vmclear(vmx->shadow_vmcs_gpa))
- return false;
-
- return true;
+ vmclear(vmx->shadow_vmcs_gpa);
}
static bool ept_vpid_cap_supported(u64 mask)
diff --git a/tools/testing/selftests/kvm/x86/aperfmperf_test.c b/tools/testing/selftests/kvm/x86/aperfmperf_test.c
index 845cb685f1743..a082658c1e484 100644
--- a/tools/testing/selftests/kvm/x86/aperfmperf_test.c
+++ b/tools/testing/selftests/kvm/x86/aperfmperf_test.c
@@ -70,8 +70,8 @@ static void l1_svm_code(struct svm_test_data *svm)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
- GUEST_ASSERT_EQ(load_vmcs(vmx), true);
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, NULL);
@@ -83,7 +83,7 @@ static void l1_vmx_code(struct vmx_pages *vmx)
vmreadz(CPU_BASED_VM_EXEC_CONTROL) | CPU_BASED_USE_MSR_BITMAPS);
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
}
static void guest_code(void *nested_test_data)
diff --git a/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c b/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c
index aa7f3b405fd32..a06f37e0bd068 100644
--- a/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c
+++ b/tools/testing/selftests/kvm/x86/evmcs_smm_controls_test.c
@@ -55,11 +55,11 @@ static void guest_code(struct vmx_pages *vmx_pages,
enable_vp_assist(hv_pages->vp_assist_gpa, hv_pages->vp_assist);
evmcs_enable();
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
GUEST_ASSERT(load_evmcs(hv_pages));
prepare_vmcs(vmx_pages, l2_guest_code);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* L2 exits via vmcall if test fails */
sync_with_host(2);
diff --git a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c
index 63ea1533e4ead..b7c2a254291e5 100644
--- a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c
+++ b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c
@@ -23,7 +23,11 @@ static int ud_count;
static void guest_ud_handler(struct ex_regs *regs)
{
ud_count++;
- regs->rip += 3; /* VMLAUNCH */
+ /*
+ * VMLAUNCH insn can't be easily covered by KVM_ASM_SAFE framework but
+ * luckily the instruction is always three bytes.
+ */
+ regs->rip += 3;
}
static void guest_nmi_handler(struct ex_regs *regs)
@@ -89,20 +93,19 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
enable_vp_assist(hv_pages->vp_assist_gpa, hv_pages->vp_assist);
evmcs_enable();
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
GUEST_SYNC(3);
GUEST_ASSERT(load_evmcs(hv_pages));
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
+ /* VMPTRST returns -1 until VMLAUNCH with eVMCS ptr set */
+ GUEST_ASSERT(vmptrst() == -1);
GUEST_SYNC(4);
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
prepare_vmcs(vmx_pages, l2_guest_code);
GUEST_SYNC(5);
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
current_evmcs->revision_id = -1u;
- GUEST_ASSERT(vmlaunch());
+ GUEST_ASSERT(__vmlaunch());
current_evmcs->revision_id = EVMCS_VERSION;
GUEST_SYNC(6);
@@ -117,17 +120,17 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
current_vp_assist->nested_control.features.directhypercall = 1;
*(u32 *)(hv_pages->partition_assist) = 0;
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_EXCEPTION_NMI);
GUEST_ASSERT_EQ((vmreadz(VM_EXIT_INTR_INFO) & 0xff), NMI_VECTOR);
- GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
+ GUEST_ASSERT(vmptrst() == hv_pages->enlightened_vmcs_gpa);
/*
* NMI forces L2->L1 exit, resuming L2 and hope that EVMCS is
* up-to-date (RIP points where it should and not at the beginning
* of l2_guest_code(). GUEST_SYNC(9) checks that.
*/
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_SYNC(10);
@@ -138,13 +141,13 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
vmwrite(CPU_BASED_VM_EXEC_CONTROL, vmreadz(CPU_BASED_VM_EXEC_CONTROL) |
CPU_BASED_USE_MSR_BITMAPS);
__set_bit(MSR_FS_BASE & 0x1fff, vmx_pages->msr + 0x400);
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
/* Enable enlightened MSR bitmap */
current_evmcs->hv_enlightenments_control.msr_bitmap = 1;
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
@@ -152,14 +155,14 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
__set_bit(MSR_GS_BASE & 0x1fff, vmx_pages->msr + 0x400);
/* Make sure HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP is set */
current_evmcs->hv_clean_fields |= HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;
- GUEST_ASSERT(!vmresume());
+ vmresume();
/* Make sure we don't see EXIT_REASON_MSR_READ here so eMSR bitmap works */
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
current_evmcs->guest_rip += 3; /* vmcall */
/* Now tell KVM we've changed MSR-Bitmap */
current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
@@ -167,21 +170,29 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
* L2 TLB flush test. First VMCALL should be handled directly by L0,
* no VMCALL exit expected.
*/
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_MSR_READ);
current_evmcs->guest_rip += 2; /* rdmsr */
/* Enable synthetic vmexit */
*(u32 *)(hv_pages->partition_assist) = 1;
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == HV_VMX_SYNTHETIC_EXIT_REASON_TRAP_AFTER_FLUSH);
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_SYNC(11);
- /* Try enlightened vmptrld with an incorrect GPA */
+ /* VMPTRLD instruction causes #UD after enlightened VMLAUNCH */
+ GUEST_ASSERT(__vmptrld(hv_pages->enlightened_vmcs_gpa) == UD_VECTOR);
+
+ /*
+ * Try enlightened vmptrld with an incorrect GPA. GUEST_SYNC(12) signals
+ * the host to enable guest_ud_handler() which cannot be enabled beforehand
+ * to not override the default fixup handler from KVM_ASM_SAFE().
+ */
+ GUEST_SYNC(12);
evmcs_vmptrld(0xdeadbeef, hv_pages->enlightened_vmcs);
- GUEST_ASSERT(vmlaunch());
+ GUEST_ASSERT(__vmlaunch());
GUEST_ASSERT(ud_count == 1);
GUEST_DONE();
}
@@ -253,7 +264,6 @@ int main(int argc, char *argv[])
vcpu_args_set(vcpu, 3, vmx_pages_gva, hv_pages_gva, addr_gva2gpa(vm, hcall_page));
vcpu_set_msr(vcpu, HV_X64_MSR_VP_INDEX, vcpu->id);
- vm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);
vm_install_exception_handler(vm, NMI_VECTOR, guest_nmi_handler);
pr_info("Running L1 which uses EVMCS to run L2\n");
@@ -283,7 +293,7 @@ int main(int argc, char *argv[])
/* Force immediate L2->L1 exit before resuming */
if (stage == 8) {
- pr_info("Injecting NMI into L1 before L2 had a chance to run after restore\n");
+ pr_debug("Injecting NMI into L1 before L2 had a chance to run after restore\n");
inject_nmi(vcpu);
}
@@ -293,9 +303,14 @@ int main(int argc, char *argv[])
* KVM_STATE_NESTED_EVMCS is not lost.
*/
if (stage == 9) {
- pr_info("Trying extra KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle\n");
+ pr_debug("Trying extra KVM_GET_NESTED_STATE/KVM_SET_NESTED_STATE cycle\n");
vcpu = save_restore_vm(vm, vcpu);
}
+
+ if (stage == 12) {
+ pr_debug("Trying enlightened VMLAUNCH with an invalid PTR\n");
+ vm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);
+ }
}
done:
diff --git a/tools/testing/selftests/kvm/x86/kvm_buslock_test.c b/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
index 25a182be00a97..337d3c28bc6df 100644
--- a/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
+++ b/tools/testing/selftests/kvm/x86/kvm_buslock_test.c
@@ -42,13 +42,13 @@ static void l1_svm_code(struct svm_test_data *svm)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
- GUEST_ASSERT_EQ(load_vmcs(vmx), true);
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, NULL);
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
}
static void guest_code(void *test_data)
diff --git a/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c b/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c
index b974cfb347d6e..1f4a5e44a6ef0 100644
--- a/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_close_kvm_test.c
@@ -30,13 +30,13 @@ static void l2_guest_code(void)
static void l1_vmx_code(struct vmx_pages *vmx_pages)
{
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(0);
}
diff --git a/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c b/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c
index 26b474bf13535..7987ce50c3829 100644
--- a/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_dirty_log_test.c
@@ -93,8 +93,8 @@ void l1_vmx_code(struct vmx_pages *vmx)
void *l2_rip;
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
if (vmx->eptp_gpa)
l2_rip = l2_guest_code_tdp_enabled;
@@ -104,7 +104,7 @@ void l1_vmx_code(struct vmx_pages *vmx)
prepare_vmcs(vmx, l2_rip);
GUEST_SYNC(TEST_SYNC_NO_FAULT);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_SYNC(TEST_SYNC_NO_FAULT);
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/nested_emulation_test.c b/tools/testing/selftests/kvm/x86/nested_emulation_test.c
index e08c6b0697e50..11fe4a31eda0b 100644
--- a/tools/testing/selftests/kvm/x86/nested_emulation_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_emulation_test.c
@@ -66,8 +66,8 @@ static void guest_code(void *test_data)
BIT_ULL(INTERCEPT_HLT);
vmcb->control.intercept_exceptions = 0;
} else {
- GUEST_ASSERT(prepare_for_vmx_operation(test_data));
- GUEST_ASSERT(load_vmcs(test_data));
+ prepare_for_vmx_operation(test_data);
+ load_vmcs(test_data);
prepare_vmcs(test_data, NULL);
GUEST_ASSERT(!vmwrite(GUEST_IDTR_LIMIT, 0));
@@ -102,7 +102,7 @@ static void guest_code(void *test_data)
exit_insn_len = vmcb->control.next_rip - vmcb->save.rip;
GUEST_ASSERT_EQ(vmcb->save.rip, (u64)l2_instruction);
} else {
- GUEST_ASSERT_EQ(i ? vmresume() : vmlaunch(), 0);
+ i ? vmresume() : vmlaunch();
exit_reason = vmreadz(VM_EXIT_REASON);
exit_insn_len = vmreadz(VM_EXIT_INSTRUCTION_LEN);
GUEST_ASSERT_EQ(vmreadz(GUEST_RIP), (u64)l2_instruction);
diff --git a/tools/testing/selftests/kvm/x86/nested_exceptions_test.c b/tools/testing/selftests/kvm/x86/nested_exceptions_test.c
index aeec3121c8e83..c36c11b5f518b 100644
--- a/tools/testing/selftests/kvm/x86/nested_exceptions_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_exceptions_test.c
@@ -112,7 +112,7 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)
{
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_code));
- GUEST_ASSERT_EQ(vector == SS_VECTOR ? vmlaunch() : vmresume(), 0);
+ vector == SS_VECTOR ? vmlaunch() : vmresume();
if (vector == FAKE_TRIPLE_FAULT_VECTOR)
return;
@@ -125,9 +125,9 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
+ prepare_for_vmx_operation(vmx);
- GUEST_ASSERT_EQ(load_vmcs(vmx), true);
+ load_vmcs(vmx);
prepare_vmcs(vmx, NULL);
GUEST_ASSERT_EQ(vmwrite(GUEST_IDTR_LIMIT, 0), 0);
diff --git a/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c b/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c
index 8c2ba9674558e..101c1fe79eeb4 100644
--- a/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_invalid_cr3_test.c
@@ -40,21 +40,21 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
{
uintptr_t save_cr3;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
/* Try to run L2 with invalid CR3 and make sure it fails */
save_cr3 = vmreadz(GUEST_CR3);
vmwrite(GUEST_CR3, -1ull);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) ==
(EXIT_REASON_FAILED_VMENTRY | EXIT_REASON_INVALID_STATE));
/* Now restore CR3 and make sure L2 runs successfully */
vmwrite(GUEST_CR3, save_cr3);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c b/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
index 2e04563790ff2..d6c443e3d147c 100644
--- a/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
@@ -55,12 +55,12 @@ static void l1_vmx_code(struct vmx_pages *vmx, u64 expected_fault_gpa,
u64 exit_qual;
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, l2_entry);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* Verify we got an EPT violation exit */
__GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_EPT_VIOLATION,
diff --git a/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c
index cb79d7b9619c2..c60dea899624b 100644
--- a/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tsc_adjust_test.c
@@ -86,8 +86,8 @@ static void l1_guest_code(void *data)
struct vmx_pages *vmx_pages = data;
u32 control;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
@@ -95,7 +95,7 @@ static void l1_guest_code(void *data)
vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
vmwrite(TSC_OFFSET, TSC_OFFSET_VALUE);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
} else {
struct svm_test_data *svm = data;
diff --git a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
index 18f765835bf4c..b2fc7f0b5b3c8 100644
--- a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
+++ b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c
@@ -105,8 +105,8 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
/* check that L1's frequency looks alright before launching L2 */
check_tsc_freq(UCHECK_L1);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* prepare the VMCS for L2 execution */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -125,7 +125,7 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
vmwrite(TSC_MULTIPLIER_HIGH, TSC_MULTIPLIER_L2 >> 32);
/* launch L2 */
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
/* check that L1's frequency still looks good */
diff --git a/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c b/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c
index 507391ab2c930..f88427e925fcc 100644
--- a/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c
+++ b/tools/testing/selftests/kvm/x86/save_restore_pf_stress_test.c
@@ -98,17 +98,17 @@ static void l1_svm_code(struct svm_test_data *svm)
static void l1_vmx_code(struct vmx_pages *vmx)
{
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, guest_access_memory);
GUEST_ASSERT(!vmwrite(EXCEPTION_BITMAP, BIT(UD_VECTOR)));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
while (1) {
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_EXCEPTION_NMI);
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_INTR_INFO) & 0xff, UD_VECTOR);
- GUEST_ASSERT(!vmresume());
+ vmresume();
}
}
diff --git a/tools/testing/selftests/kvm/x86/smm_test.c b/tools/testing/selftests/kvm/x86/smm_test.c
index d1edafd5af755..377df09e582ad 100644
--- a/tools/testing/selftests/kvm/x86/smm_test.c
+++ b/tools/testing/selftests/kvm/x86/smm_test.c
@@ -78,8 +78,8 @@ static void guest_code(void *arg)
if (this_cpu_has(X86_FEATURE_SVM)) {
generic_svm_setup(svm, l2_guest_code);
} else {
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
}
diff --git a/tools/testing/selftests/kvm/x86/state_test.c b/tools/testing/selftests/kvm/x86/state_test.c
index 4a1056a6cb8dc..38c9689ac6014 100644
--- a/tools/testing/selftests/kvm/x86/state_test.c
+++ b/tools/testing/selftests/kvm/x86/state_test.c
@@ -75,32 +75,32 @@ void vmx_l2_guest_code(void)
static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)
{
GUEST_ASSERT(vmx_pages->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
GUEST_SYNC(3);
- GUEST_ASSERT(load_vmcs(vmx_pages));
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ load_vmcs(vmx_pages);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
GUEST_SYNC(4);
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
prepare_vmcs(vmx_pages, vmx_l2_guest_code);
GUEST_SYNC(5);
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
- GUEST_ASSERT(!vmlaunch());
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
+ vmlaunch();
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
/* Check that the launched state is preserved. */
- GUEST_ASSERT(vmlaunch());
+ GUEST_ASSERT(__vmlaunch());
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_SYNC(7);
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + 3);
@@ -108,28 +108,28 @@ static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)
vmwrite(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_SHADOW_VMCS);
vmwrite(VMCS_LINK_POINTER, vmx_pages->shadow_vmcs_gpa);
- GUEST_ASSERT(!vmptrld(vmx_pages->shadow_vmcs_gpa));
- GUEST_ASSERT(vmlaunch());
+ vmptrld(vmx_pages->shadow_vmcs_gpa);
+ GUEST_ASSERT(__vmlaunch());
GUEST_SYNC(8);
- GUEST_ASSERT(vmlaunch());
- GUEST_ASSERT(vmresume());
+ GUEST_ASSERT(__vmlaunch());
+ GUEST_ASSERT(__vmresume());
vmwrite(GUEST_RIP, 0xc0ffee);
GUEST_SYNC(9);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffee);
- GUEST_ASSERT(!vmptrld(vmx_pages->vmcs_gpa));
- GUEST_ASSERT(!vmresume());
+ vmptrld(vmx_pages->vmcs_gpa);
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
- GUEST_ASSERT(!vmptrld(vmx_pages->shadow_vmcs_gpa));
+ vmptrld(vmx_pages->shadow_vmcs_gpa);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffffee);
- GUEST_ASSERT(vmlaunch());
- GUEST_ASSERT(vmresume());
+ GUEST_ASSERT(__vmlaunch());
+ GUEST_ASSERT(__vmresume());
GUEST_SYNC(13);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffffee);
- GUEST_ASSERT(vmlaunch());
- GUEST_ASSERT(vmresume());
+ GUEST_ASSERT(__vmlaunch());
+ GUEST_ASSERT(__vmresume());
}
static void __attribute__((__flatten__)) guest_code(void *arg)
diff --git a/tools/testing/selftests/kvm/x86/triple_fault_event_test.c b/tools/testing/selftests/kvm/x86/triple_fault_event_test.c
index 0d83516f4bd08..bb31a1ba8932e 100644
--- a/tools/testing/selftests/kvm/x86/triple_fault_event_test.c
+++ b/tools/testing/selftests/kvm/x86/triple_fault_event_test.c
@@ -25,12 +25,12 @@ void l1_guest_code_vmx(struct vmx_pages *vmx)
{
GUEST_ASSERT(vmx->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx));
- GUEST_ASSERT(load_vmcs(vmx));
+ prepare_for_vmx_operation(vmx);
+ load_vmcs(vmx);
prepare_vmcs(vmx, l2_guest_code);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* L2 should triple fault after a triple fault event injected. */
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_TRIPLE_FAULT);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
index 463f73aa9159a..fe29c869a2356 100644
--- a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
@@ -38,8 +38,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
{
u32 control;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -53,14 +53,14 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
/* Try to launch L2 with the memory-backed APIC-access address. */
GUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(APIC_ACCESS_ADDR, high_gpa);
/* Try to resume L2 with the unbacked APIC-access address. */
GUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_DONE();
diff --git a/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c b/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c
index f9b88a6f6113d..e578221da247c 100644
--- a/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_apicv_updates_test.c
@@ -33,8 +33,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
{
u32 control;
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -62,7 +62,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
* Run L2 to switch to x2APIC mode, which in turn will uninhibit APICv,
* as KVM should force the APIC ID back to its default.
*/
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN));
GUEST_ASSERT(rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD);
@@ -90,7 +90,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
* handles the x2APIC => xAPIC transition and inhibits APICv while L2
* is active.
*/
- GUEST_ASSERT(!vmresume());
+ vmresume();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
GUEST_ASSERT(!(rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD));
diff --git a/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c b/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c
index c8379124b3172..3017938fa9937 100644
--- a/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c
+++ b/tools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c
@@ -41,8 +41,8 @@ static void l2_guest_code(void)
static void l1_guest_code(struct vmx_pages *vmx_pages)
{
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
/* Prepare the VMCS for L2 execution. */
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -55,7 +55,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
GUEST_ASSERT(!(vmreadz(CPU_BASED_VM_EXEC_CONTROL) & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) ||
!(vmreadz(SECONDARY_VM_EXEC_CONTROL) & SECONDARY_EXEC_UNRESTRICTED_GUEST));
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
/* L2 should triple fault after main() stuffs invalid guest state. */
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_TRIPLE_FAULT);
diff --git a/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c b/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c
index 75073efa926da..b3651c5ab1384 100644
--- a/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_nested_la57_state_test.c
@@ -37,8 +37,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
GUEST_ASSERT(rdmsr(MSR_GS_BASE) == LA57_GS_BASE);
GUEST_ASSERT(vmx_pages->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -56,7 +56,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
guest_cr4 &= ~X86_CR4_LA57;
vmwrite(GUEST_CR4, guest_cr4);
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
exit_reason = vmreadz(VM_EXIT_REASON);
GUEST_ASSERT(exit_reason == EXIT_REASON_VMCALL);
diff --git a/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c b/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
index eb8021c33cd43..cda53df33888e 100644
--- a/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_preemption_timer_test.c
@@ -71,9 +71,9 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
u64 l1_tsc_deadline, l2_tsc_deadline;
GUEST_ASSERT(vmx_pages->vmcs_gpa);
- GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
- GUEST_ASSERT(load_vmcs(vmx_pages));
- GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
+ prepare_for_vmx_operation(vmx_pages);
+ load_vmcs(vmx_pages);
+ GUEST_ASSERT(vmptrst() == vmx_pages->vmcs_gpa);
prepare_vmcs(vmx_pages, l2_guest_code);
@@ -90,7 +90,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
!(ctrl_exit_rev.clr & VM_EXIT_SAVE_VMX_PREEMPTION_TIMER))
return;
- GUEST_ASSERT(!vmlaunch());
+ vmlaunch();
GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
vmwrite(GUEST_RIP, vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN));
@@ -110,7 +110,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
l1_vmx_pt_start = (rdtsc() >> vmx_pt_rate) << vmx_pt_rate;
- GUEST_ASSERT(!vmresume());
+ vmresume();
l1_vmx_pt_finish = rdtsc();
|
| 23/3 | 2026/08/26 23:56 | llm | kmsan-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19236 output: 222 thoughts: 1666 Thoughts: **Analysis of KVM VMX Nested Virtualization Patch** Okay, here's my take on this patch. It looks like we're tweaking the handling of `VMPTRLD` and `VMPTRST` within KVM's VMX nested virtualization code, specifically in `arch/x86/kvm/vmx/nested.c`. I see changes to `handle_vmptrld` and `handle_vmptrst`, along with some modifications in the selftests under `tools/testing/selftests/kvm/include/x86/vmx.h` and elsewhere. Focusing on `handle_vmptrld`, it seems we're now explicitly preventing a "normal" `VMPTRLD` if the "Enlightened" version has been used. The code now triggers a UD exception (`UD_VECTOR`) in this case. That's straightforward enough – essentially, enforcing the expected behavior and potentially erroring out if things are not as anticipated. The more interesting part is `handle_vmptrst`. Previously, if `nested_vmx_is_evmptr12_valid()` was true, the function would return 1, meaning it would effectively do nothing. Now, though, it's changed. With the addition of `#ifdef CONFIG_KVM_HYPERV`, the code now sets `current_vmptr` to `to_vmx(vcpu)->nested.hv_evmcs_vmptr` when it sees an eVMCS. Then it goes on to write *that* value to guest memory. This behavior makes sense if you're working with Hyper-V TLFS. My initial thought was, "Hold on, is this going to expose uninitialized memory?" We're dealing with `current_vmptr`, a `gpa_t` (so, a `u64`). It's assigned either `to_vmx(vcpu)->nested.hv_evmcs_vmptr` or `to_vmx(vcpu)->nested.current_vmptr`. Both of these are within the `nested_vmx` struct. But after a second look, I can see that `hv_evmcs_vmptr` is initialized when eVMCS is loaded and `current_vmptr` is initialized when `VMPTRLD` executes. We're not reading from an uninitialized field. The patch is simply ensuring that it writes a known GPA for eVMCS usage. Let's double-check the write to the guest memory via `kvm_write_guest_virt_system` within `handle_vmptrst`. The code grabs the guest virtual address (`gva`) and writes the fully initialized `current_vmptr` to it. I'm satisfied that `current_vmptr` is an 8-byte value and is fully initialized before being written, so no padding or uninitialized memory concerns here. So, after this deeper dive, I'm confident that this patch *doesn't* introduce any uninitialized memory issues or risks. It's simply changing the *value* written in a specific eVMCS scenario. KMSAN is overkill here. Standard KASAN and other bug detectors should be sufficient. |
| 24/3 | 2026/08/26 23:57 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch modifies `handle_vmptrld` and `handle_vmptrst` in KVM's VMX nested virtualization code. In `handle_vmptrst`, it changes the behavior when eVMCS is used: instead of returning 1 (doing nothing), it now sets the local variable `current_vmptr` to `hv_evmcs_vmptr` and writes it to guest memory. `current_vmptr` is a `gpa_t` (a 64-bit integer), which is fully initialized before being written to the guest via `kvm_write_guest_virt_system`. There are no structs with padding or uninitialized fields involved. The rest of the changes are in KVM selftests. There is no risk of uninitialized memory reads or info-leaks introduced by this patch. Standard KASAN and other bug detectors are sufficient to catch any potential memory corruption or logic bugs.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch modifies `handle_vmptrld` and `handle_vmptrst` in KVM's VMX nested virtualization code. In `handle_vmptrst`, it changes the behavior when eVMCS is used: instead of returning 1 (doing nothing), it now sets the local variable `current_vmptr` to `hv_evmcs_vmptr` and writes it to guest memory. `current_vmptr` is a `gpa_t` (a 64-bit integer), which is fully initialized before being written to the guest via `kvm_write_guest_virt_system`. There are no structs with padding or uninitialized fields involved. The rest of the changes are in KVM selftests. There is no risk of uninitialized memory reads or info-leaks introduced by this patch. Standard KASAN and other bug detectors are sufficient to catch any potential memory corruption or logic bugs.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|