Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
	 Mathias Krause <minipli@grsecurity.net>,
	Andrew Jones <andrew.jones@linux.dev>
Subject: [kvm-unit-tests PATCH v3 02/20] x86/vmx: Drop unused guest_regs "support" in nested VMX infrastructure
Date: Thu, 14 May 2026 14:04:42 -0700	[thread overview]
Message-ID: <20260514210500.1626871-3-seanjc@google.com> (raw)
In-Reply-To: <20260514210500.1626871-1-seanjc@google.com>

Drop vmx_tests.guest_regs as no tests use the functionality, the field is
very misleading (it's only used to set the initial regs, i.e. it's not an
up-to-date snapshot), and per-test register state doesn't play nice with
tests that create and run multiple vCPUs.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx.c       |  3 +--
 x86/vmx.h       |  1 -
 x86/vmx_tests.c | 44 +++++++++++++++++++++-----------------------
 3 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index 2b85ef0b..44ee3697 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1834,6 +1834,7 @@ static int test_run(struct vmx_test *test)
 		return 1;
 	}
 
+	memset(&regs, 0, sizeof(regs));
 	init_vmcs(&(test->vmcs));
 	/* Directly call test->init is ok here, init_vmcs has done
 	   vmcs init, vmclear and vmptrld*/
@@ -1843,8 +1844,6 @@ static int test_run(struct vmx_test *test)
 	v2_guest_main = NULL;
 	test->exits = 0;
 	current = test;
-	regs = test->guest_regs;
-	vmcs_write(GUEST_RFLAGS, regs.rflags | X86_EFLAGS_FIXED);
 	launched = 0;
 	guest_finished = 0;
 	printf("\nTest suite: %s\n", test->name);
diff --git a/x86/vmx.h b/x86/vmx.h
index f4ed5339..425b1c43 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -121,7 +121,6 @@ struct vmx_test {
 	int (*init)(struct vmcs *vmcs);
 	void (*guest_main)(void);
 	int (*exit_handler)(union exit_reason exit_reason);
-	struct regs guest_regs;
 	int (*entry_failure_handler)(struct vmentry_result *result);
 	struct vmcs *vmcs;
 	int exits;
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 83d88480..e0d5e390 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -11757,37 +11757,35 @@ static void vmx_cet_test(void)
 
 #define TEST(name) { #name, .v2 = name }
 
-/* name/init/guest_main/exit_handler/guest_regs */
+/* name/init/guest_main/exit_handler/vmfail_handler */
 struct vmx_test vmx_tests[] = {
-	{ "null", NULL, basic_guest_main, basic_exit_handler, {0} },
-	{ "vmenter", NULL, vmenter_main, vmenter_exit_handler, {0} },
+	{ "null", NULL, basic_guest_main, basic_exit_handler, },
+	{ "vmenter", NULL, vmenter_main, vmenter_exit_handler, },
 	{ "preemption timer", preemption_timer_init, preemption_timer_main,
-		preemption_timer_exit_handler, {0} },
+		preemption_timer_exit_handler },
 	{ "control field PAT", test_ctrl_pat_init, test_ctrl_pat_main,
-		test_ctrl_pat_exit_handler, {0} },
+		test_ctrl_pat_exit_handler },
 	{ "control field EFER", test_ctrl_efer_init, test_ctrl_efer_main,
-		test_ctrl_efer_exit_handler, {0} },
-	{ "CR shadowing", NULL, cr_shadowing_main,
-		cr_shadowing_exit_handler, {0} },
-	{ "I/O bitmap", iobmp_init, iobmp_main, iobmp_exit_handler,
-		{0} },
+		test_ctrl_efer_exit_handler },
+	{ "CR shadowing", NULL, cr_shadowing_main, cr_shadowing_exit_handler },
+	{ "I/O bitmap", iobmp_init, iobmp_main, iobmp_exit_handler },
 	{ "instruction intercept", insn_intercept_init, insn_intercept_main,
-		insn_intercept_exit_handler, {0} },
-	{ "EPT A/D disabled", ept_init, ept_main, ept_exit_handler, {0} },
-	{ "EPT A/D enabled", eptad_init, eptad_main, eptad_exit_handler, {0} },
-	{ "PML", pml_init, pml_main, pml_exit_handler, {0} },
-	{ "interrupt", interrupt_init, interrupt_main, interrupt_exit_handler, {0} },
-	{ "nmi_hlt", nmi_hlt_init, nmi_hlt_main, nmi_hlt_exit_handler, {0} },
-	{ "debug controls", dbgctls_init, dbgctls_main, dbgctls_exit_handler, {0} },
+		insn_intercept_exit_handler },
+	{ "EPT A/D disabled", ept_init, ept_main, ept_exit_handler },
+	{ "EPT A/D enabled", eptad_init, eptad_main, eptad_exit_handler },
+	{ "PML", pml_init, pml_main, pml_exit_handler },
+	{ "interrupt", interrupt_init, interrupt_main, interrupt_exit_handler },
+	{ "nmi_hlt", nmi_hlt_init, nmi_hlt_main, nmi_hlt_exit_handler },
+	{ "debug controls", dbgctls_init, dbgctls_main, dbgctls_exit_handler },
 	{ "MSR switch", msr_switch_init, msr_switch_main,
-		msr_switch_exit_handler, {0}, msr_switch_entry_failure },
-	{ "vmmcall", vmmcall_init, vmmcall_main, vmmcall_exit_handler, {0} },
+		msr_switch_exit_handler, msr_switch_entry_failure },
+	{ "vmmcall", vmmcall_init, vmmcall_main, vmmcall_exit_handler },
 	{ "disable RDTSCP", disable_rdtscp_init, disable_rdtscp_main,
-		disable_rdtscp_exit_handler, {0} },
+		disable_rdtscp_exit_handler },
 	{ "exit_monitor_from_l2_test", NULL, exit_monitor_from_l2_main,
-		exit_monitor_from_l2_handler, {0} },
+		exit_monitor_from_l2_handler },
 	{ "invalid_msr", invalid_msr_init, invalid_msr_main,
-		invalid_msr_exit_handler, {0}, invalid_msr_entry_failure},
+		invalid_msr_exit_handler, invalid_msr_entry_failure},
 	/* Basic V2 tests. */
 	TEST(v2_null_test),
 	TEST(v2_multiple_entries_test),
@@ -11873,5 +11871,5 @@ struct vmx_test vmx_tests[] = {
 	TEST(vmx_canonical_test),
 	/* "Load CET" VM-entry/exit controls tests. */
 	TEST(vmx_cet_test),
-	{ NULL, NULL, NULL, NULL, {0} },
+	{ NULL, NULL, NULL, NULL },
 };
-- 
2.54.0.563.g4f69b47b94-goog


  parent reply	other threads:[~2026-05-14 21:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 21:04 [kvm-unit-tests PATCH v3 00/20] x86: Better backtraces for leaf functions Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 01/20] x86/vmx: Drop unused SYSENTER "support" in nested VMX infrastructure Sean Christopherson
2026-05-14 21:04 ` Sean Christopherson [this message]
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 03/20] x86/svm: Sort (and swap) GPRs by their index, not alphabetically Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 04/20] x86: Dedup guest/host context switch of registers across SVM and VMX Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 05/20] x86/virt: Use macro shenanigans to get reg offsets when swapping guest/host regs Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 06/20] x86/virt: Track "guest regs" using per-CPU variable Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 07/20] x86/svm: Don't VMLOAD/VMSAVE "guest" state around VMRUN Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 08/20] x86/vmx: Use separate VMCSes for BSP vs. AP in INIT test Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 09/20] x86/vmx: Swap GPRs after checking "launched" status Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 10/20] x86/vmx: Track VMCS "launched" state per-CPU Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 11/20] x86/vmx: Track "is this CPU in guest mode" per-CPU Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 12/20] x86/vmx: Communicate hypercalls via RAX, not a global field Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 13/20] x86/vmx: Initialize test stage in SIPI test *before* launching AP thread Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 14/20] x86/kvmclock: Replace spaces with tabs Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 15/20] x86/kvmclock: Skip kvmclock test when not running on KVM with CLOCKSOURCE2 Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 16/20] x86/vmx: Tag "struct vmx_msr_entry" as needing to be 16-byte aligned Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 17/20] x86/smp: Align the stack to a 16-byte boundary when invoking SMP function calls Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 18/20] x86/vmx: Write to KVM's WALL_CLOCK MSR via VM-Entry load list sync in SIPI test Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 19/20] x86: Better backtraces for leaf functions Sean Christopherson
2026-05-14 21:05 ` [kvm-unit-tests PATCH v3 20/20] x86: Prevent realmode test code instrumentation with nop-mcount Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260514210500.1626871-3-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=minipli@grsecurity.net \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox