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 01/20] x86/vmx: Drop unused SYSENTER "support" in nested VMX infrastructure
Date: Thu, 14 May 2026 14:04:41 -0700 [thread overview]
Message-ID: <20260514210500.1626871-2-seanjc@google.com> (raw)
In-Reply-To: <20260514210500.1626871-1-seanjc@google.com>
Drop the unused SYSTENTER "support" from the nested VMX infrastructure, in
quotes because the code is half-baked (and that's being generous) and
likely has never been used.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
x86/vmx.c | 32 +++++---------------------------
x86/vmx.h | 20 --------------------
x86/vmx_tests.c | 45 +++++++++++++++++++++------------------------
3 files changed, 26 insertions(+), 71 deletions(-)
diff --git a/x86/vmx.c b/x86/vmx.c
index eb2965d8..2b85ef0b 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -42,7 +42,7 @@
u64 *bsp_vmxon_region;
struct vmcs *vmcs_root;
u32 vpid_cnt;
-u64 guest_stack_top, guest_syscall_stack_top;
+u64 guest_stack_top;
u32 ctrl_pin, ctrl_enter, ctrl_exit, ctrl_cpu[2];
struct regs regs;
@@ -76,7 +76,6 @@ union vmx_ept_vpid ept_vpid;
extern struct descriptor_table_ptr gdt_descr;
extern struct descriptor_table_ptr idt_descr;
extern void *vmx_return;
-extern void *entry_sysenter;
extern void *guest_entry;
static volatile u32 stage;
@@ -561,25 +560,6 @@ void vmx_inc_test_stage(void)
barrier();
}
-/* entry_sysenter */
-asm(
- ".align 4, 0x90\n\t"
- ".globl entry_sysenter\n\t"
- "entry_sysenter:\n\t"
- SAVE_GPR
- " and $0xf, %rax\n\t"
- " mov %rax, %rdi\n\t"
- " call syscall_handler\n\t"
- LOAD_GPR
- " vmresume\n\t"
-);
-
-static void __attribute__((__used__)) syscall_handler(u64 syscall_no)
-{
- if (current->syscall_handler)
- current->syscall_handler(syscall_no);
-}
-
static const char * const exit_reason_descriptions[] = {
[VMX_EXC_NMI] = "VMX_EXC_NMI",
[VMX_EXTINT] = "VMX_EXTINT",
@@ -1123,7 +1103,7 @@ static void init_vmcs_host(void)
vmcs_write(HOST_CR0, read_cr0());
vmcs_write(HOST_CR3, read_cr3());
vmcs_write(HOST_CR4, read_cr4());
- vmcs_write(HOST_SYSENTER_EIP, (u64)(&entry_sysenter));
+ vmcs_write(HOST_SYSENTER_EIP, rdmsr(MSR_IA32_SYSENTER_EIP));
vmcs_write(HOST_SYSENTER_CS, KERNEL_CS);
if (ctrl_exit_rev.clr & EXI_LOAD_PAT)
vmcs_write(HOST_PAT, rdmsr(MSR_IA32_CR_PAT));
@@ -1172,8 +1152,8 @@ static void init_vmcs_guest(void)
vmcs_write(GUEST_CR3, guest_cr3);
vmcs_write(GUEST_CR4, guest_cr4);
vmcs_write(GUEST_SYSENTER_CS, KERNEL_CS);
- vmcs_write(GUEST_SYSENTER_ESP, guest_syscall_stack_top);
- vmcs_write(GUEST_SYSENTER_EIP, (u64)(&entry_sysenter));
+ vmcs_write(GUEST_SYSENTER_ESP, rdmsr(MSR_IA32_SYSENTER_ESP));
+ vmcs_write(GUEST_SYSENTER_EIP, rdmsr(MSR_IA32_SYSENTER_EIP));
vmcs_write(GUEST_DR7, 0);
vmcs_write(GUEST_EFER, rdmsr(MSR_EFER));
@@ -1319,7 +1299,6 @@ static void alloc_bsp_vmx_pages(void)
{
bsp_vmxon_region = alloc_page();
guest_stack_top = (uintptr_t)alloc_page() + PAGE_SIZE;
- guest_syscall_stack_top = (uintptr_t)alloc_page() + PAGE_SIZE;
vmcs_root = alloc_page();
}
@@ -1840,8 +1819,7 @@ static int test_run(struct vmx_test *test)
/* Validate V2 interface. */
if (test->v2) {
int ret = 0;
- if (test->init || test->guest_main || test->exit_handler ||
- test->syscall_handler) {
+ if (test->init || test->guest_main || test->exit_handler) {
report_fail("V2 test cannot specify V1 callbacks.");
ret = 1;
}
diff --git a/x86/vmx.h b/x86/vmx.h
index 7ad7672a..f4ed5339 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);
- void (*syscall_handler)(u64 syscall_no);
struct regs guest_regs;
int (*entry_failure_handler)(struct vmentry_result *result);
struct vmcs *vmcs;
@@ -589,25 +588,6 @@ enum vm_entry_failure_code {
ENTRY_FAIL_VMCS_LINK_PTR = 4,
};
-#define SAVE_GPR \
- "xchg %rax, regs\n\t" \
- "xchg %rcx, regs+0x8\n\t" \
- "xchg %rdx, regs+0x10\n\t" \
- "xchg %rbx, regs+0x18\n\t" \
- "xchg %rbp, regs+0x28\n\t" \
- "xchg %rsi, regs+0x30\n\t" \
- "xchg %rdi, regs+0x38\n\t" \
- "xchg %r8, regs+0x40\n\t" \
- "xchg %r9, regs+0x48\n\t" \
- "xchg %r10, regs+0x50\n\t" \
- "xchg %r11, regs+0x58\n\t" \
- "xchg %r12, regs+0x60\n\t" \
- "xchg %r13, regs+0x68\n\t" \
- "xchg %r14, regs+0x70\n\t" \
- "xchg %r15, regs+0x78\n\t"
-
-#define LOAD_GPR SAVE_GPR
-
#define SAVE_GPR_C \
"xchg %%rax, regs\n\t" \
"xchg %%rcx, regs+0x8\n\t" \
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index ff387ded..83d88480 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -11757,40 +11757,37 @@ static void vmx_cet_test(void)
#define TEST(name) { #name, .v2 = name }
-/* name/init/guest_main/exit_handler/syscall_handler/guest_regs */
+/* name/init/guest_main/exit_handler/guest_regs */
struct vmx_test vmx_tests[] = {
- { "null", NULL, basic_guest_main, basic_exit_handler, NULL, {0} },
- { "vmenter", NULL, vmenter_main, vmenter_exit_handler, NULL, {0} },
+ { "null", NULL, basic_guest_main, basic_exit_handler, {0} },
+ { "vmenter", NULL, vmenter_main, vmenter_exit_handler, {0} },
{ "preemption timer", preemption_timer_init, preemption_timer_main,
- preemption_timer_exit_handler, NULL, {0} },
+ preemption_timer_exit_handler, {0} },
{ "control field PAT", test_ctrl_pat_init, test_ctrl_pat_main,
- test_ctrl_pat_exit_handler, NULL, {0} },
+ test_ctrl_pat_exit_handler, {0} },
{ "control field EFER", test_ctrl_efer_init, test_ctrl_efer_main,
- test_ctrl_efer_exit_handler, NULL, {0} },
+ test_ctrl_efer_exit_handler, {0} },
{ "CR shadowing", NULL, cr_shadowing_main,
- cr_shadowing_exit_handler, NULL, {0} },
+ cr_shadowing_exit_handler, {0} },
{ "I/O bitmap", iobmp_init, iobmp_main, iobmp_exit_handler,
- NULL, {0} },
+ {0} },
{ "instruction intercept", insn_intercept_init, insn_intercept_main,
- insn_intercept_exit_handler, NULL, {0} },
- { "EPT A/D disabled", ept_init, ept_main, ept_exit_handler, NULL, {0} },
- { "EPT A/D enabled", eptad_init, eptad_main, eptad_exit_handler, NULL, {0} },
- { "PML", pml_init, pml_main, pml_exit_handler, NULL, {0} },
- { "interrupt", interrupt_init, interrupt_main,
- interrupt_exit_handler, NULL, {0} },
- { "nmi_hlt", nmi_hlt_init, nmi_hlt_main,
- nmi_hlt_exit_handler, NULL, {0} },
- { "debug controls", dbgctls_init, dbgctls_main, dbgctls_exit_handler,
- NULL, {0} },
+ 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} },
{ "MSR switch", msr_switch_init, msr_switch_main,
- msr_switch_exit_handler, NULL, {0}, msr_switch_entry_failure },
- { "vmmcall", vmmcall_init, vmmcall_main, vmmcall_exit_handler, NULL, {0} },
+ msr_switch_exit_handler, {0}, msr_switch_entry_failure },
+ { "vmmcall", vmmcall_init, vmmcall_main, vmmcall_exit_handler, {0} },
{ "disable RDTSCP", disable_rdtscp_init, disable_rdtscp_main,
- disable_rdtscp_exit_handler, NULL, {0} },
+ disable_rdtscp_exit_handler, {0} },
{ "exit_monitor_from_l2_test", NULL, exit_monitor_from_l2_main,
- exit_monitor_from_l2_handler, NULL, {0} },
+ exit_monitor_from_l2_handler, {0} },
{ "invalid_msr", invalid_msr_init, invalid_msr_main,
- invalid_msr_exit_handler, NULL, {0}, invalid_msr_entry_failure},
+ invalid_msr_exit_handler, {0}, invalid_msr_entry_failure},
/* Basic V2 tests. */
TEST(v2_null_test),
TEST(v2_multiple_entries_test),
@@ -11876,5 +11873,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, NULL, {0} },
+ { NULL, NULL, NULL, NULL, {0} },
};
--
2.54.0.563.g4f69b47b94-goog
next prev 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 ` Sean Christopherson [this message]
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 02/20] x86/vmx: Drop unused guest_regs "support" in nested VMX infrastructure Sean Christopherson
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-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.