* [PATCH v2 1/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 10:48 ` Xiaoyao Li
2026-08-26 17:12 ` [PATCH v2 2/8] KVM: VMX: Move the shared NMI handler/trampoline " Sean Christopherson
` (7 subsequent siblings)
8 siblings, 1 reply; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Move vmx_handle_exit_irqoff() and its helpers to common.h / main.c to
capture that it's a common handler and to allow guarding against incorrectly
using to_vmx().
Opportunistically use a "vt" prefix instead of "vmx" to communicate that
it's a shared handler.
No functional change intended.
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Binbin Wu <binbin.wu@linux.intel.com>
Cc: Kai Huang <kai.huang@intel.com>
Cc: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/common.h | 6 ++++
arch/x86/kvm/vmx/main.c | 71 +++++++++++++++++++++++++++++++++++-
arch/x86/kvm/vmx/vmx.c | 74 --------------------------------------
arch/x86/kvm/vmx/x86_ops.h | 1 -
4 files changed, 76 insertions(+), 76 deletions(-)
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index 08005676702c..88f637c81353 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -74,6 +74,12 @@ static __always_inline bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false; }
#endif
+static inline bool is_xfd_nm_fault(struct kvm_vcpu *vcpu)
+{
+ return vcpu->arch.guest_fpu.fpstate->xfd &&
+ !kvm_is_cr0_bit_set(vcpu, X86_CR0_TS);
+}
+
static inline bool vt_is_tdx_private_gpa(struct kvm *kvm, gpa_t gpa)
{
/* For TDX the direct mask is the shared mask. */
diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
index 4c52ab8d0786..274200b0a307 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/entry-common.h>
#include <linux/moduleparam.h>
#include "x86_ops.h"
@@ -876,6 +877,74 @@ static int vt_gmem_max_mapping_level(struct kvm *kvm, kvm_pfn_t pfn,
#define vt_op_tdx_only(name) NULL
#endif /* CONFIG_KVM_INTEL_TDX */
+static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu)
+{
+ /*
+ * Save xfd_err to guest_fpu before interrupt is enabled, so the
+ * MSR value is not clobbered by the host activity before the guest
+ * has chance to consume it.
+ *
+ * Update the guest's XFD_ERR if and only if XFD is enabled, as the #NM
+ * interception may have been caused by L1 interception. Per the SDM,
+ * XFD_ERR is not modified for non-XFD #NM, i.e. if CR0.TS=1.
+ *
+ * Note, XFD_ERR is updated _before_ the #NM interception check, i.e.
+ * unlike CR2 and DR6, the value is not a payload that is attached to
+ * the #NM exception.
+ */
+ if (is_xfd_nm_fault(vcpu))
+ rdmsrq(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err);
+}
+
+static void handle_exception_irqoff(struct kvm_vcpu *vcpu, u32 intr_info)
+{
+ /* if exit due to PF check for async PF */
+ if (is_page_fault(intr_info))
+ vcpu->arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags();
+ /* if exit due to NM, handle before interrupts are enabled */
+ else if (is_nm_fault(intr_info))
+ handle_nm_fault_irqoff(vcpu);
+ /* Handle machine checks before interrupts are enabled */
+ else if (is_machine_check(intr_info))
+ kvm_machine_check();
+}
+
+static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu,
+ u32 intr_info)
+{
+ unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK;
+
+ if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm,
+ "unexpected VM-Exit interrupt info: 0x%x", intr_info))
+ return;
+
+ kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ);
+ x86_entry_from_kvm(EVENT_TYPE_EXTINT, vector);
+ kvm_after_interrupt(vcpu);
+
+ vcpu->arch.at_instruction_boundary = true;
+}
+
+static void vt_handle_exit_irqoff(struct kvm_vcpu *vcpu)
+{
+ if (to_vt(vcpu)->emulation_required)
+ return;
+
+ switch (vmx_get_exit_reason(vcpu).basic) {
+ case EXIT_REASON_EXTERNAL_INTERRUPT:
+ handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu));
+ break;
+ case EXIT_REASON_EXCEPTION_NMI:
+ handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu));
+ break;
+ case EXIT_REASON_MCE_DURING_VMENTRY:
+ kvm_machine_check();
+ break;
+ default:
+ break;
+ }
+}
+
#define VMX_REQUIRED_APICV_INHIBITS \
(BIT(APICV_INHIBIT_REASON_DISABLED) | \
BIT(APICV_INHIBIT_REASON_ABSENT) | \
@@ -1000,7 +1069,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
.load_mmu_pgd = vt_op(load_mmu_pgd),
.check_intercept = vmx_check_intercept,
- .handle_exit_irqoff = vmx_handle_exit_irqoff,
+ .handle_exit_irqoff = vt_handle_exit_irqoff,
.update_cpu_dirty_logging = vt_op(update_cpu_dirty_logging),
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 504630f0eb40..adf2bc13bed2 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -5379,12 +5379,6 @@ bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu)
(kvm_get_rflags(vcpu) & X86_EFLAGS_AC);
}
-static bool is_xfd_nm_fault(struct kvm_vcpu *vcpu)
-{
- return vcpu->arch.guest_fpu.fpstate->xfd &&
- !kvm_is_cr0_bit_set(vcpu, X86_CR0_TS);
-}
-
static int vmx_handle_page_fault(struct kvm_vcpu *vcpu, u32 error_code)
{
unsigned long cr2 = vmx_get_exit_qual(vcpu);
@@ -7143,74 +7137,6 @@ void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
vmcs_write64(EOI_EXIT_BITMAP3, eoi_exit_bitmap[3]);
}
-static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu)
-{
- /*
- * Save xfd_err to guest_fpu before interrupt is enabled, so the
- * MSR value is not clobbered by the host activity before the guest
- * has chance to consume it.
- *
- * Update the guest's XFD_ERR if and only if XFD is enabled, as the #NM
- * interception may have been caused by L1 interception. Per the SDM,
- * XFD_ERR is not modified for non-XFD #NM, i.e. if CR0.TS=1.
- *
- * Note, XFD_ERR is updated _before_ the #NM interception check, i.e.
- * unlike CR2 and DR6, the value is not a payload that is attached to
- * the #NM exception.
- */
- if (is_xfd_nm_fault(vcpu))
- rdmsrq(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err);
-}
-
-static void handle_exception_irqoff(struct kvm_vcpu *vcpu, u32 intr_info)
-{
- /* if exit due to PF check for async PF */
- if (is_page_fault(intr_info))
- vcpu->arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags();
- /* if exit due to NM, handle before interrupts are enabled */
- else if (is_nm_fault(intr_info))
- handle_nm_fault_irqoff(vcpu);
- /* Handle machine checks before interrupts are enabled */
- else if (is_machine_check(intr_info))
- kvm_machine_check();
-}
-
-static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu,
- u32 intr_info)
-{
- unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK;
-
- if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm,
- "unexpected VM-Exit interrupt info: 0x%x", intr_info))
- return;
-
- kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ);
- x86_entry_from_kvm(EVENT_TYPE_EXTINT, vector);
- kvm_after_interrupt(vcpu);
-
- vcpu->arch.at_instruction_boundary = true;
-}
-
-void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)
-{
- if (to_vt(vcpu)->emulation_required)
- return;
-
- switch (vmx_get_exit_reason(vcpu).basic) {
- case EXIT_REASON_EXTERNAL_INTERRUPT:
- handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu));
- break;
- case EXIT_REASON_EXCEPTION_NMI:
- handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu));
- break;
- case EXIT_REASON_MCE_DURING_VMENTRY:
- kvm_machine_check();
- break;
- default:
- break;
- }
-}
-
/*
* The kvm parameter can be NULL (module initialization, or invocation before
* VM creation). Be sure to check the kvm parameter before using it.
diff --git a/arch/x86/kvm/vmx/x86_ops.h b/arch/x86/kvm/vmx/x86_ops.h
index 054fd14bb2e1..7ac02c68457f 100644
--- a/arch/x86/kvm/vmx/x86_ops.h
+++ b/arch/x86/kvm/vmx/x86_ops.h
@@ -27,7 +27,6 @@ void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event);
void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
void vmx_vcpu_put(struct kvm_vcpu *vcpu);
int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath);
-void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu);
int vmx_skip_emulated_instruction(struct kvm_vcpu *vcpu);
void vmx_update_emulated_instruction(struct kvm_vcpu *vcpu);
bool vmx_unhandleable_emulation_required(struct kvm_vcpu *vcpu);
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH v2 1/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code
2026-08-26 17:12 ` [PATCH v2 1/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code Sean Christopherson
@ 2026-08-27 10:48 ` Xiaoyao Li
2026-08-27 19:34 ` Sean Christopherson
0 siblings, 1 reply; 25+ messages in thread
From: Xiaoyao Li @ 2026-08-27 10:48 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Binbin Wu, Kai Huang, Yan Zhao
On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> Move vmx_handle_exit_irqoff() and its helpers to common.h / main.c to
> capture that it's a common handler and
> to allow guarding against incorrectly using to_vmx().
For this purpose, it seems better to put patch 3 as the first patch?
> Opportunistically use a "vt" prefix instead of "vmx" to communicate that
> it's a shared handler.
>
> No functional change intended.
>
> Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
> Cc: Xiaoyao Li <xiaoyao.li@intel.com>
> Cc: Binbin Wu <binbin.wu@linux.intel.com>
> Cc: Kai Huang <kai.huang@intel.com>
> Cc: Yan Zhao <yan.y.zhao@intel.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 1/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code
2026-08-27 10:48 ` Xiaoyao Li
@ 2026-08-27 19:34 ` Sean Christopherson
0 siblings, 0 replies; 25+ messages in thread
From: Sean Christopherson @ 2026-08-27 19:34 UTC (permalink / raw)
To: Xiaoyao Li
Cc: Paolo Bonzini, kvm, linux-kernel, Rick Edgecombe, Binbin Wu,
Kai Huang, Yan Zhao
On Thu, Aug 27, 2026, Xiaoyao Li wrote:
> On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> > Move vmx_handle_exit_irqoff() and its helpers to common.h / main.c to
> > capture that it's a common handler and
>
> > to allow guarding against incorrectly using to_vmx().
>
> For this purpose, it seems better to put patch 3 as the first patch?
Huh, yes. I have no idea why I didn't do that in the first place.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 2/8] KVM: VMX: Move the shared NMI handler/trampoline to common code
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
2026-08-26 17:12 ` [PATCH v2 1/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 11:20 ` Xiaoyao Li
2026-08-26 17:12 ` [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code Sean Christopherson
` (6 subsequent siblings)
8 siblings, 1 reply; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Move vmx_handle_nmi() to main.c to capture that it's a common handler and
to allow guarding against incorrectly using to_vmx().
Opportunistically use a "vt" prefix instead of "vmx" to communicate that
it's a shared handler.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/common.h | 2 +-
arch/x86/kvm/vmx/main.c | 11 +++++++++++
arch/x86/kvm/vmx/tdx.c | 2 +-
arch/x86/kvm/vmx/vmx.c | 13 +------------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index 88f637c81353..4b1d46eafd0f 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -189,6 +189,6 @@ static inline void __vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
kvm_vcpu_trigger_posted_interrupt(vcpu, POSTED_INTR_VECTOR);
}
-noinstr void vmx_handle_nmi(struct kvm_vcpu *vcpu);
+noinstr void vt_handle_nmi(struct kvm_vcpu *vcpu);
#endif /* __KVM_X86_VMX_COMMON_H */
diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
index 274200b0a307..684b87692864 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -945,6 +945,17 @@ static void vt_handle_exit_irqoff(struct kvm_vcpu *vcpu)
}
}
+noinstr void vt_handle_nmi(struct kvm_vcpu *vcpu)
+{
+ if ((u16)vmx_get_exit_reason(vcpu).basic != EXIT_REASON_EXCEPTION_NMI ||
+ !is_nmi(vmx_get_intr_info(vcpu)))
+ return;
+
+ kvm_before_interrupt(vcpu, KVM_HANDLING_NMI);
+ x86_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR);
+ kvm_after_interrupt(vcpu);
+}
+
#define VMX_REQUIRED_APICV_INHIBITS \
(BIT(APICV_INHIBIT_REASON_DISABLED) | \
BIT(APICV_INHIBIT_REASON_ABSENT) | \
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index b272c20586a7..46b0e798f8b9 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -974,7 +974,7 @@ static noinstr void tdx_vcpu_enter_exit(struct kvm_vcpu *vcpu)
tdx->exit_gpa = tdx->vp_enter_args.r8;
vt->exit_intr_info = tdx->vp_enter_args.r9;
- vmx_handle_nmi(vcpu);
+ vt_handle_nmi(vcpu);
guest_state_exit_irqoff();
}
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index adf2bc13bed2..a06dd2d77f10 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -7363,17 +7363,6 @@ static fastpath_t vmx_exit_handlers_fastpath(struct kvm_vcpu *vcpu,
}
}
-noinstr void vmx_handle_nmi(struct kvm_vcpu *vcpu)
-{
- if ((u16)vmx_get_exit_reason(vcpu).basic != EXIT_REASON_EXCEPTION_NMI ||
- !is_nmi(vmx_get_intr_info(vcpu)))
- return;
-
- kvm_before_interrupt(vcpu, KVM_HANDLING_NMI);
- x86_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR);
- kvm_after_interrupt(vcpu);
-}
-
static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
unsigned int flags)
{
@@ -7406,7 +7395,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
if (likely(!vmx_get_exit_reason(vcpu).failed_vmentry))
vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
- vmx_handle_nmi(vcpu);
+ vt_handle_nmi(vcpu);
out:
guest_state_exit_irqoff();
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
2026-08-26 17:12 ` [PATCH v2 1/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code Sean Christopherson
2026-08-26 17:12 ` [PATCH v2 2/8] KVM: VMX: Move the shared NMI handler/trampoline " Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 2:32 ` Huang, Kai
2026-08-27 11:21 ` Xiaoyao Li
2026-08-26 17:12 ` [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt" Sean Christopherson
` (5 subsequent siblings)
8 siblings, 2 replies; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Poison to_vmx() in main.c and posted_intr.c so that attempting to interpret
the vCPU as a VMX vCPU will fail at compile time, as opposed to failing at
runtime, or worse corrupting state without outright failing.
Note, to_tdx() is buried in tdx.c, i.e. isn't broadly reachable, and so
doesn't need the same treatment as to_vmx().
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/main.c | 2 ++
arch/x86/kvm/vmx/posted_intr.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
index 684b87692864..b1069a8e30a7 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -11,6 +11,8 @@
#include "tdx.h"
#include "tdx_arch.h"
+#pragma GCC poison to_vmx
+
#ifdef CONFIG_KVM_INTEL_TDX
static_assert(offsetof(struct vcpu_vmx, vt) == offsetof(struct vcpu_tdx, vt));
diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c
index 4a6d9a17da23..24221ba553be 100644
--- a/arch/x86/kvm/vmx/posted_intr.c
+++ b/arch/x86/kvm/vmx/posted_intr.c
@@ -14,6 +14,8 @@
#include "vmx.h"
#include "tdx.h"
+#pragma GCC poison to_vmx
+
/*
* Maintain a per-CPU list of vCPUs that need to be awakened by wakeup_handler()
* when a WAKEUP_VECTOR interrupted is posted. vCPUs are added to the list when
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code
2026-08-26 17:12 ` [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code Sean Christopherson
@ 2026-08-27 2:32 ` Huang, Kai
2026-08-27 11:21 ` Xiaoyao Li
1 sibling, 0 replies; 25+ messages in thread
From: Huang, Kai @ 2026-08-27 2:32 UTC (permalink / raw)
To: pbonzini@redhat.com, seanjc@google.com
Cc: Li, Xiaoyao, kvm@vger.kernel.org, Zhao, Yan Y,
linux-kernel@vger.kernel.org, Edgecombe, Rick P,
binbin.wu@linux.intel.com
On Wed, 2026-08-26 at 10:12 -0700, Sean Christopherson wrote:
> Poison to_vmx() in main.c and posted_intr.c so that attempting to interpret
> the vCPU as a VMX vCPU will fail at compile time, as opposed to failing at
> runtime, or worse corrupting state without outright failing.
>
> Note, to_tdx() is buried in tdx.c, i.e. isn't broadly reachable, and so
> doesn't need the same treatment as to_vmx().
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
>
Nit: as Binbin mentioned in v1:
"Disallowing" -> "Disallow" in short-log.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code
2026-08-26 17:12 ` [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code Sean Christopherson
2026-08-27 2:32 ` Huang, Kai
@ 2026-08-27 11:21 ` Xiaoyao Li
1 sibling, 0 replies; 25+ messages in thread
From: Xiaoyao Li @ 2026-08-27 11:21 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Binbin Wu, Kai Huang, Yan Zhao
On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> Poison to_vmx() in main.c and posted_intr.c so that attempting to interpret
> the vCPU as a VMX vCPU will fail at compile time, as opposed to failing at
> runtime, or worse corrupting state without outright failing.
>
> Note, to_tdx() is buried in tdx.c, i.e. isn't broadly reachable, and so
> doesn't need the same treatment as to_vmx().
>
> Signed-off-by: Sean Christopherson<seanjc@google.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
` (2 preceding siblings ...)
2026-08-26 17:12 ` [PATCH v2 3/8] KVM: VMX: Disallowing using to_vmx() in common VT code Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-26 17:22 ` sashiko-bot
` (2 more replies)
2026-08-26 17:12 ` [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix " Sean Christopherson
` (4 subsequent siblings)
8 siblings, 3 replies; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Rename all common posted interrupt APIs that use a "vmx" prefix to instead
use a "vt" prefix to capture that they are used for both VMX and TDX vCPUs.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/common.h | 4 ++--
arch/x86/kvm/vmx/main.c | 4 ++--
arch/x86/kvm/vmx/posted_intr.c | 18 +++++++++---------
arch/x86/kvm/vmx/posted_intr.h | 8 ++++----
arch/x86/kvm/vmx/tdx.c | 6 +++---
arch/x86/kvm/vmx/vmx.c | 6 +++---
6 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index 4b1d46eafd0f..ff4f6a2b6402 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -170,8 +170,8 @@ static inline void kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu,
* Post an interrupt to a vCPU's PIR and trigger the vCPU to process the
* interrupt if necessary.
*/
-static inline void __vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
- struct pi_desc *pi_desc, int vector)
+static inline void __vt_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
+ struct pi_desc *pi_desc, int vector)
{
if (pi_test_and_set_pir(vector, pi_desc))
return;
diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
index b1069a8e30a7..8ac6ea58b481 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -1086,8 +1086,8 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
.update_cpu_dirty_logging = vt_op(update_cpu_dirty_logging),
- .pi_update_irte = vmx_pi_update_irte,
- .pi_start_bypass = vmx_pi_start_bypass,
+ .pi_update_irte = vt_pi_update_irte,
+ .pi_start_bypass = vt_pi_start_bypass,
#ifdef CONFIG_X86_64
.set_hv_timer = vt_op(set_hv_timer),
diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c
index 24221ba553be..359ef3e6ebbe 100644
--- a/arch/x86/kvm/vmx/posted_intr.c
+++ b/arch/x86/kvm/vmx/posted_intr.c
@@ -56,7 +56,7 @@ static int pi_try_set_control(struct pi_desc *pi_desc, u64 *pold, u64 new)
return 0;
}
-void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
+void vt_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
{
struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
struct vcpu_vt *vt = to_vt(vcpu);
@@ -146,11 +146,11 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
pi_set_on(pi_desc);
}
-static bool vmx_can_use_vtd_pi(struct kvm *kvm)
+static bool vt_can_use_vtd_pi(struct kvm *kvm)
{
/*
* Note, reading the number of possible bypass IRQs can race with a
- * bypass IRQ being attached to the VM. vmx_pi_start_bypass() ensures
+ * bypass IRQ being attached to the VM. vt_pi_start_bypass() ensures
* blockng vCPUs will see an elevated count or get KVM_REQ_UNBLOCK.
*/
return irqchip_in_kernel(kvm) && kvm_arch_has_irq_bypass() &&
@@ -219,10 +219,10 @@ static bool vmx_needs_pi_wakeup(struct kvm_vcpu *vcpu)
* back to the pi_wakeup_handler() function.
*/
return (vmx_can_use_ipiv(vcpu) && !is_td_vcpu(vcpu)) ||
- vmx_can_use_vtd_pi(vcpu->kvm);
+ vt_can_use_vtd_pi(vcpu->kvm);
}
-void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
+void vt_vcpu_pi_put(struct kvm_vcpu *vcpu)
{
struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
@@ -294,17 +294,17 @@ bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu)
/*
* Kick all vCPUs when the first possible bypass IRQ is attached to a VM, as
* blocking vCPUs may scheduled out without reconfiguring PID.NV to the wakeup
- * vector, i.e. if the bypass IRQ came along after vmx_vcpu_pi_put().
+ * vector, i.e. if the bypass IRQ came along after vt_vcpu_pi_put().
*/
-void vmx_pi_start_bypass(struct kvm *kvm)
+void vt_pi_start_bypass(struct kvm *kvm)
{
- if (WARN_ON_ONCE(!vmx_can_use_vtd_pi(kvm)))
+ if (WARN_ON_ONCE(!vt_can_use_vtd_pi(kvm)))
return;
kvm_make_all_cpus_request(kvm, KVM_REQ_UNBLOCK);
}
-int vmx_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
+int vt_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
unsigned int host_irq, uint32_t guest_irq,
struct kvm_vcpu *vcpu, u32 vector)
{
diff --git a/arch/x86/kvm/vmx/posted_intr.h b/arch/x86/kvm/vmx/posted_intr.h
index a4af39948cf0..c5860ea828ae 100644
--- a/arch/x86/kvm/vmx/posted_intr.h
+++ b/arch/x86/kvm/vmx/posted_intr.h
@@ -8,16 +8,16 @@
#include <asm/posted_intr.h>
-void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
-void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);
+void vt_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
+void vt_vcpu_pi_put(struct kvm_vcpu *vcpu);
void pi_wakeup_handler(void);
void __init pi_init_cpu(int cpu);
void pi_apicv_pre_state_restore(struct kvm_vcpu *vcpu);
bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu);
-int vmx_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
+int vt_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
unsigned int host_irq, uint32_t guest_irq,
struct kvm_vcpu *vcpu, u32 vector);
-void vmx_pi_start_bypass(struct kvm *kvm);
+void vt_pi_start_bypass(struct kvm *kvm);
static inline int pi_find_highest_vector(struct pi_desc *pi_desc)
{
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 46b0e798f8b9..36578d4c00ff 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -716,7 +716,7 @@ void tdx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
{
struct vcpu_tdx *tdx = to_tdx(vcpu);
- vmx_vcpu_pi_load(vcpu, cpu);
+ vt_vcpu_pi_load(vcpu, cpu);
if (vcpu->cpu == cpu || !is_hkid_assigned(to_kvm_tdx(vcpu->kvm)))
return;
@@ -826,7 +826,7 @@ static void tdx_prepare_switch_to_host(struct kvm_vcpu *vcpu)
void tdx_vcpu_put(struct kvm_vcpu *vcpu)
{
- vmx_vcpu_pi_put(vcpu);
+ vt_vcpu_pi_put(vcpu);
tdx_prepare_switch_to_host(vcpu);
}
@@ -1895,7 +1895,7 @@ void tdx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode,
struct vcpu_tdx *tdx = to_tdx(vcpu);
/* TDX supports only posted interrupt. No lapic emulation. */
- __vmx_deliver_posted_interrupt(vcpu, &tdx->vt.pi_desc, vector);
+ __vt_deliver_posted_interrupt(vcpu, &tdx->vt.pi_desc, vector);
trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, trig_mode, vector);
}
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index a06dd2d77f10..506be74e3e0f 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1577,12 +1577,12 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
vmx_vcpu_load_vmcs(vcpu, cpu);
- vmx_vcpu_pi_load(vcpu, cpu);
+ vt_vcpu_pi_load(vcpu, cpu);
}
void vmx_vcpu_put(struct kvm_vcpu *vcpu)
{
- vmx_vcpu_pi_put(vcpu);
+ vt_vcpu_pi_put(vcpu);
vmx_prepare_switch_to_host(to_vmx(vcpu));
}
@@ -4424,7 +4424,7 @@ static int vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, int vector)
if (!vcpu->arch.apic->apicv_active)
return -1;
- __vmx_deliver_posted_interrupt(vcpu, &vt->pi_desc, vector);
+ __vt_deliver_posted_interrupt(vcpu, &vt->pi_desc, vector);
return 0;
}
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
2026-08-26 17:12 ` [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt" Sean Christopherson
@ 2026-08-26 17:22 ` sashiko-bot
2026-08-26 18:38 ` Sean Christopherson
2026-08-27 2:35 ` Huang, Kai
2026-08-27 11:38 ` Xiaoyao Li
2 siblings, 1 reply; 25+ messages in thread
From: sashiko-bot @ 2026-08-26 17:22 UTC (permalink / raw)
To: Sean Christopherson; +Cc: kvm
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incomplete refactoring: The common helper function `vmx_needs_pi_wakeup` was not renamed to `vt_needs_pi_wakeup`.
--
commit 3f6ac2d22873c9d6eb23bb3aab8ab0ad05bd4863
Author: Sean Christopherson <seanjc@google.com>
KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
This commit renames posted interrupt APIs that are shared between VMX and TDX
to use the "vt" prefix instead of "vmx". This is a non-functional change.
> diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c
> index 24221ba553be1..359ef3e6ebbe4 100644
> --- a/arch/x86/kvm/vmx/posted_intr.c
> +++ b/arch/x86/kvm/vmx/posted_intr.c
[ ... ]
> @@ -219,10 +219,10 @@ static bool vmx_needs_pi_wakeup(struct kvm_vcpu *vcpu)
> * back to the pi_wakeup_handler() function.
> */
> return (vmx_can_use_ipiv(vcpu) && !is_td_vcpu(vcpu)) ||
> - vmx_can_use_vtd_pi(vcpu->kvm);
> + vt_can_use_vtd_pi(vcpu->kvm);
> }
[Severity: Low]
This isn't a bug, but does vmx_needs_pi_wakeup() also need to be renamed to
vt_needs_pi_wakeup()?
The "vmx_" prefix is left on a function that is actively shared with TDX
(it checks is_td_vcpu()) and is used by the common vt_vcpu_pi_put() API
below, missing the stated goal of the patch to rename all common posted
interrupt APIs.
>
> -void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
> +void vt_vcpu_pi_put(struct kvm_vcpu *vcpu)
> {
> struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826171246.777729-1-seanjc@google.com?part=4
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
2026-08-26 17:22 ` sashiko-bot
@ 2026-08-26 18:38 ` Sean Christopherson
0 siblings, 0 replies; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 18:38 UTC (permalink / raw)
To: sashiko-reviews; +Cc: kvm
On Wed, Aug 26, 2026, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Incomplete refactoring: The common helper function `vmx_needs_pi_wakeup` was not renamed to `vt_needs_pi_wakeup`.
> --
>
> commit 3f6ac2d22873c9d6eb23bb3aab8ab0ad05bd4863
> Author: Sean Christopherson <seanjc@google.com>
>
> KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
>
> This commit renames posted interrupt APIs that are shared between VMX and TDX
> to use the "vt" prefix instead of "vmx". This is a non-functional change.
>
> > diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c
> > index 24221ba553be1..359ef3e6ebbe4 100644
> > --- a/arch/x86/kvm/vmx/posted_intr.c
> > +++ b/arch/x86/kvm/vmx/posted_intr.c
> [ ... ]
> > @@ -219,10 +219,10 @@ static bool vmx_needs_pi_wakeup(struct kvm_vcpu *vcpu)
> > * back to the pi_wakeup_handler() function.
> > */
> > return (vmx_can_use_ipiv(vcpu) && !is_td_vcpu(vcpu)) ||
> > - vmx_can_use_vtd_pi(vcpu->kvm);
> > + vt_can_use_vtd_pi(vcpu->kvm);
> > }
>
> [Severity: Low]
> This isn't a bug, but does vmx_needs_pi_wakeup() also need to be renamed to
> vt_needs_pi_wakeup()?
Doh, yes. I meant to change it, but got distracted by vmx_can_use_ipiv(), which
_is_ VMX specific, and forgot to revisit vmx_needs_pi_wakeup().
If there are no other issues in the series, I'll just fix this one up when
applying.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
2026-08-26 17:12 ` [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt" Sean Christopherson
2026-08-26 17:22 ` sashiko-bot
@ 2026-08-27 2:35 ` Huang, Kai
2026-08-27 11:38 ` Xiaoyao Li
2 siblings, 0 replies; 25+ messages in thread
From: Huang, Kai @ 2026-08-27 2:35 UTC (permalink / raw)
To: pbonzini@redhat.com, seanjc@google.com
Cc: Li, Xiaoyao, kvm@vger.kernel.org, Zhao, Yan Y,
linux-kernel@vger.kernel.org, Edgecombe, Rick P,
binbin.wu@linux.intel.com
On Wed, 2026-08-26 at 10:12 -0700, Sean Christopherson wrote:
> -int vmx_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
> +int vt_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
> unsigned int host_irq, uint32_t guest_irq,
> struct kvm_vcpu *vcpu, u32 vector)
> {
Nit: seems the second and the third line of function parameters need to be re-
aligned after the renaming (one character shorter).
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
2026-08-26 17:12 ` [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt" Sean Christopherson
2026-08-26 17:22 ` sashiko-bot
2026-08-27 2:35 ` Huang, Kai
@ 2026-08-27 11:38 ` Xiaoyao Li
2026-08-27 14:17 ` Sean Christopherson
2 siblings, 1 reply; 25+ messages in thread
From: Xiaoyao Li @ 2026-08-27 11:38 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Binbin Wu, Kai Huang, Yan Zhao
On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> Rename all common posted interrupt APIs that use a "vmx" prefix to instead
> use a "vt" prefix to capture that they are used for both VMX and TDX vCPUs.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
With renaming vmx_needs_pi_wakeup() to vt_needs_pi_wakeup(),
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> arch/x86/kvm/vmx/common.h | 4 ++--
> arch/x86/kvm/vmx/main.c | 4 ++--
> arch/x86/kvm/vmx/posted_intr.c | 18 +++++++++---------
> arch/x86/kvm/vmx/posted_intr.h | 8 ++++----
> arch/x86/kvm/vmx/tdx.c | 6 +++---
> arch/x86/kvm/vmx/vmx.c | 6 +++---
> 6 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
> index 4b1d46eafd0f..ff4f6a2b6402 100644
> --- a/arch/x86/kvm/vmx/common.h
> +++ b/arch/x86/kvm/vmx/common.h
> @@ -170,8 +170,8 @@ static inline void kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu,
> * Post an interrupt to a vCPU's PIR and trigger the vCPU to process the
> * interrupt if necessary.
> */
> -static inline void __vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
> - struct pi_desc *pi_desc, int vector)
> +static inline void __vt_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
> + struct pi_desc *pi_desc, int vector)
Nit: Maybe we can just name it vt_deliver_posted_interrupt() without
underscore since no collide with vmx_deliver_posted_interrupt() anymore?
But it's OK to keep the underscore to indicate it's an common inner helper.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
2026-08-27 11:38 ` Xiaoyao Li
@ 2026-08-27 14:17 ` Sean Christopherson
0 siblings, 0 replies; 25+ messages in thread
From: Sean Christopherson @ 2026-08-27 14:17 UTC (permalink / raw)
To: Xiaoyao Li
Cc: Paolo Bonzini, kvm, linux-kernel, Rick Edgecombe, Binbin Wu,
Kai Huang, Yan Zhao
On Thu, Aug 27, 2026, Xiaoyao Li wrote:
> On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> > diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
> > index 4b1d46eafd0f..ff4f6a2b6402 100644
> > --- a/arch/x86/kvm/vmx/common.h
> > +++ b/arch/x86/kvm/vmx/common.h
> > @@ -170,8 +170,8 @@ static inline void kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu,
> > * Post an interrupt to a vCPU's PIR and trigger the vCPU to process the
> > * interrupt if necessary.
> > */
> > -static inline void __vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
> > - struct pi_desc *pi_desc, int vector)
> > +static inline void __vt_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
> > + struct pi_desc *pi_desc, int vector)
>
> Nit: Maybe we can just name it vt_deliver_posted_interrupt() without
> underscore since no collide with vmx_deliver_posted_interrupt() anymore?
>
> But it's OK to keep the underscore to indicate it's an common inner helper.
Yeah, I went through pretty much the exact same sequence of thoughts. I'll keep
the underscores unless someone feels strongly that they do more harm than good.
They're a bit odd, here and in the EPT violation handler, but I do think it helps
communicate/capture that VMX/TDX-specific code needs to run before/after invoking
the inner helper.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix from "vmx" to "vt"
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
` (3 preceding siblings ...)
2026-08-26 17:12 ` [PATCH v2 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt" Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 2:36 ` Huang, Kai
2026-08-27 11:48 ` Xiaoyao Li
2026-08-26 17:12 ` [PATCH v2 6/8] KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu() Sean Christopherson
` (3 subsequent siblings)
8 siblings, 2 replies; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Rename __vmx_handle_ept_violation() to __vt_handle_ept_violation to capture
that it is shared between VMX and TDX.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/common.h | 4 ++--
arch/x86/kvm/vmx/tdx.c | 2 +-
arch/x86/kvm/vmx/vmx.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index ff4f6a2b6402..35b54938a5f5 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -86,8 +86,8 @@ static inline bool vt_is_tdx_private_gpa(struct kvm *kvm, gpa_t gpa)
return !kvm_is_addr_direct(kvm, gpa);
}
-static inline int __vmx_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t gpa,
- unsigned long exit_qualification)
+static inline int __vt_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t gpa,
+ unsigned long exit_qualification)
{
u64 error_code;
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 36578d4c00ff..a3d6f0fb5951 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -1987,7 +1987,7 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)
while (1) {
struct kvm_memory_slot *slot;
- ret = __vmx_handle_ept_violation(vcpu, gpa, exit_qual);
+ ret = __vt_handle_ept_violation(vcpu, gpa, exit_qual);
if (ret != RET_PF_RETRY || !local_retry)
break;
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 506be74e3e0f..2532a9b8e92e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -5991,7 +5991,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
if (unlikely(allow_smaller_maxphyaddr && !kvm_vcpu_is_legal_gpa(vcpu, gpa)))
return kvm_emulate_instruction(vcpu, 0);
- return __vmx_handle_ept_violation(vcpu, gpa, exit_qualification);
+ return __vt_handle_ept_violation(vcpu, gpa, exit_qualification);
}
static int handle_ept_misconfig(struct kvm_vcpu *vcpu)
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix from "vmx" to "vt"
2026-08-26 17:12 ` [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix " Sean Christopherson
@ 2026-08-27 2:36 ` Huang, Kai
2026-08-27 11:48 ` Xiaoyao Li
1 sibling, 0 replies; 25+ messages in thread
From: Huang, Kai @ 2026-08-27 2:36 UTC (permalink / raw)
To: pbonzini@redhat.com, seanjc@google.com
Cc: Li, Xiaoyao, kvm@vger.kernel.org, Zhao, Yan Y,
linux-kernel@vger.kernel.org, Edgecombe, Rick P,
binbin.wu@linux.intel.com
On Wed, 2026-08-26 at 10:12 -0700, Sean Christopherson wrote:
> Rename __vmx_handle_ept_violation() to __vt_handle_ept_violation to capture
> that it is shared between VMX and TDX.
Nit: __vt_handle_ept_violation -> __vt_handle_ept_violation() ?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix from "vmx" to "vt"
2026-08-26 17:12 ` [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix " Sean Christopherson
2026-08-27 2:36 ` Huang, Kai
@ 2026-08-27 11:48 ` Xiaoyao Li
1 sibling, 0 replies; 25+ messages in thread
From: Xiaoyao Li @ 2026-08-27 11:48 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Binbin Wu, Kai Huang, Yan Zhao
On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> Rename __vmx_handle_ept_violation() to __vt_handle_ept_violation to capture
> that it is shared between VMX and TDX.
Similar nit as what for __vt_deliver_posted_interrupt() in patch 4,
maybe just name it vt_handle_ept_violation()?
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> arch/x86/kvm/vmx/common.h | 4 ++--
> arch/x86/kvm/vmx/tdx.c | 2 +-
> arch/x86/kvm/vmx/vmx.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
> index ff4f6a2b6402..35b54938a5f5 100644
> --- a/arch/x86/kvm/vmx/common.h
> +++ b/arch/x86/kvm/vmx/common.h
> @@ -86,8 +86,8 @@ static inline bool vt_is_tdx_private_gpa(struct kvm *kvm, gpa_t gpa)
> return !kvm_is_addr_direct(kvm, gpa);
> }
>
> -static inline int __vmx_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t gpa,
> - unsigned long exit_qualification)
> +static inline int __vt_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t gpa,
> + unsigned long exit_qualification)
> {
> u64 error_code;
>
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 36578d4c00ff..a3d6f0fb5951 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -1987,7 +1987,7 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)
> while (1) {
> struct kvm_memory_slot *slot;
>
> - ret = __vmx_handle_ept_violation(vcpu, gpa, exit_qual);
> + ret = __vt_handle_ept_violation(vcpu, gpa, exit_qual);
>
> if (ret != RET_PF_RETRY || !local_retry)
> break;
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 506be74e3e0f..2532a9b8e92e 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -5991,7 +5991,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
> if (unlikely(allow_smaller_maxphyaddr && !kvm_vcpu_is_legal_gpa(vcpu, gpa)))
> return kvm_emulate_instruction(vcpu, 0);
>
> - return __vmx_handle_ept_violation(vcpu, gpa, exit_qualification);
> + return __vt_handle_ept_violation(vcpu, gpa, exit_qualification);
> }
>
> static int handle_ept_misconfig(struct kvm_vcpu *vcpu)
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 6/8] KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu()
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
` (4 preceding siblings ...)
2026-08-26 17:12 ` [PATCH v2 5/8] KVM: VMX: Rename EPT violation handler prefix " Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 11:58 ` Xiaoyao Li
2026-08-26 17:12 ` [PATCH v2 7/8] KVM: VMX: Move common VT getters/converters to common.h Sean Christopherson
` (2 subsequent siblings)
8 siblings, 1 reply; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Define a combined vcpu_vmx_tdx structure to represent the common layout of
vcpu_vmx and vcpu_tdx, instead of having vcpu_tdx piggyback vcpu_vmx. I.e.
require VMX and TDX to match the common definition, not for TDX to match
VMX. This will allow moving to_vt() and vt_to_vcpu() to common.h where
they belong.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/main.c | 4 +++-
arch/x86/kvm/vmx/vmx.h | 9 +++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
index 8ac6ea58b481..0151baa56598 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -13,8 +13,10 @@
#pragma GCC poison to_vmx
+static_assert(offsetof(struct vcpu_vmx_tdx, vt) == offsetof(struct vcpu_vmx, vt));
+
#ifdef CONFIG_KVM_INTEL_TDX
-static_assert(offsetof(struct vcpu_vmx, vt) == offsetof(struct vcpu_tdx, vt));
+static_assert(offsetof(struct vcpu_vmx_tdx, vt) == offsetof(struct vcpu_tdx, vt));
static void vt_disable_virtualization_cpu(void)
{
diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
index dc8517f15bc4..0415d328e1a5 100644
--- a/arch/x86/kvm/vmx/vmx.h
+++ b/arch/x86/kvm/vmx/vmx.h
@@ -304,14 +304,19 @@ struct kvm_vmx {
u64 *pid_table;
};
+struct vcpu_vmx_tdx {
+ struct kvm_vcpu vcpu;
+ struct vcpu_vt vt;
+};
+
static __always_inline struct vcpu_vt *to_vt(struct kvm_vcpu *vcpu)
{
- return &(container_of(vcpu, struct vcpu_vmx, vcpu)->vt);
+ return &(container_of(vcpu, struct vcpu_vmx_tdx, vcpu)->vt);
}
static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt)
{
- return &(container_of(vt, struct vcpu_vmx, vt)->vcpu);
+ return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu);
}
static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kvm_vcpu *vcpu)
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH v2 6/8] KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu()
2026-08-26 17:12 ` [PATCH v2 6/8] KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu() Sean Christopherson
@ 2026-08-27 11:58 ` Xiaoyao Li
0 siblings, 0 replies; 25+ messages in thread
From: Xiaoyao Li @ 2026-08-27 11:58 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Binbin Wu, Kai Huang, Yan Zhao
On 8/27/2026 1:12 AM, Sean Christopherson wrote:
> Define a combined vcpu_vmx_tdx structure to represent the common layout of
> vcpu_vmx and vcpu_tdx, instead of having vcpu_tdx piggyback vcpu_vmx. I.e.
> require VMX and TDX to match the common definition, not for TDX to match
> VMX. This will allow moving to_vt() and vt_to_vcpu() to common.h where
> they belong.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 7/8] KVM: VMX: Move common VT getters/converters to common.h
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
` (5 preceding siblings ...)
2026-08-26 17:12 ` [PATCH v2 6/8] KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu() Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 12:02 ` Xiaoyao Li
2026-08-26 17:12 ` [PATCH v2 8/8] KVM: VMX: Rename common exit info getters prefixes from "vmx" to "vt" Sean Christopherson
2026-08-27 2:53 ` [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Huang, Kai
8 siblings, 1 reply; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Move the "to" vCPU converters and common exit information getters from
vmx.h to common.h to capture that they are indeed common VT code. Defer
renaming their prefixes to isolate the code movement from the massive
churn that will result from said renaming.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/common.h | 44 +++++++++++++++++++++++++++++++++++++++
arch/x86/kvm/vmx/vmx.h | 42 -------------------------------------
2 files changed, 44 insertions(+), 42 deletions(-)
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index 35b54938a5f5..c9ca0824734a 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -2,10 +2,12 @@
#ifndef __KVM_X86_VMX_COMMON_H
#define __KVM_X86_VMX_COMMON_H
+#include <linux/container_of.h>
#include <linux/kvm_host.h>
#include <asm/posted_intr.h>
#include "mmu.h"
+#include "vmx_ops.h"
union vmx_exit_reason {
struct {
@@ -74,6 +76,48 @@ static __always_inline bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false; }
#endif
+struct vcpu_vmx_tdx {
+ struct kvm_vcpu vcpu;
+ struct vcpu_vt vt;
+};
+
+static __always_inline struct vcpu_vt *to_vt(struct kvm_vcpu *vcpu)
+{
+ return &(container_of(vcpu, struct vcpu_vmx_tdx, vcpu)->vt);
+}
+
+static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt)
+{
+ return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu);
+}
+
+static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kvm_vcpu *vcpu)
+{
+ return to_vt(vcpu)->exit_reason;
+}
+
+static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vcpu)
+{
+ struct vcpu_vt *vt = to_vt(vcpu);
+
+ if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_1) &&
+ !WARN_ON_ONCE(is_td_vcpu(vcpu)))
+ vt->exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
+
+ return vt->exit_qualification;
+}
+
+static __always_inline u32 vmx_get_intr_info(struct kvm_vcpu *vcpu)
+{
+ struct vcpu_vt *vt = to_vt(vcpu);
+
+ if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_2) &&
+ !WARN_ON_ONCE(is_td_vcpu(vcpu)))
+ vt->exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
+
+ return vt->exit_intr_info;
+}
+
static inline bool is_xfd_nm_fault(struct kvm_vcpu *vcpu)
{
return vcpu->arch.guest_fpu.fpstate->xfd &&
diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
index 0415d328e1a5..3247b55b3484 100644
--- a/arch/x86/kvm/vmx/vmx.h
+++ b/arch/x86/kvm/vmx/vmx.h
@@ -304,48 +304,6 @@ struct kvm_vmx {
u64 *pid_table;
};
-struct vcpu_vmx_tdx {
- struct kvm_vcpu vcpu;
- struct vcpu_vt vt;
-};
-
-static __always_inline struct vcpu_vt *to_vt(struct kvm_vcpu *vcpu)
-{
- return &(container_of(vcpu, struct vcpu_vmx_tdx, vcpu)->vt);
-}
-
-static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt)
-{
- return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu);
-}
-
-static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kvm_vcpu *vcpu)
-{
- return to_vt(vcpu)->exit_reason;
-}
-
-static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vcpu)
-{
- struct vcpu_vt *vt = to_vt(vcpu);
-
- if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_1) &&
- !WARN_ON_ONCE(is_td_vcpu(vcpu)))
- vt->exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
-
- return vt->exit_qualification;
-}
-
-static __always_inline u32 vmx_get_intr_info(struct kvm_vcpu *vcpu)
-{
- struct vcpu_vt *vt = to_vt(vcpu);
-
- if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_2) &&
- !WARN_ON_ONCE(is_td_vcpu(vcpu)))
- vt->exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
-
- return vt->exit_intr_info;
-}
-
void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu);
int allocate_vpid(void);
void free_vpid(int vpid);
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* [PATCH v2 8/8] KVM: VMX: Rename common exit info getters prefixes from "vmx" to "vt"
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
` (6 preceding siblings ...)
2026-08-26 17:12 ` [PATCH v2 7/8] KVM: VMX: Move common VT getters/converters to common.h Sean Christopherson
@ 2026-08-26 17:12 ` Sean Christopherson
2026-08-27 12:09 ` Xiaoyao Li
2026-08-27 2:53 ` [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Huang, Kai
8 siblings, 1 reply; 25+ messages in thread
From: Sean Christopherson @ 2026-08-26 17:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Rick Edgecombe, Xiaoyao Li, Binbin Wu,
Kai Huang, Yan Zhao
Rename all common prefixes for the APIs that get exit information common to
VMX and TDX from "vmx" to "vt" to capture that they are used for both VMX
and TDX vCPUs.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/common.h | 6 ++--
arch/x86/kvm/vmx/main.c | 10 +++----
arch/x86/kvm/vmx/nested.c | 36 +++++++++++------------
arch/x86/kvm/vmx/tdx.c | 22 +++++++-------
arch/x86/kvm/vmx/vmx.c | 60 +++++++++++++++++++--------------------
5 files changed, 67 insertions(+), 67 deletions(-)
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index c9ca0824734a..3e68fa12aca6 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -91,12 +91,12 @@ static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt)
return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu);
}
-static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kvm_vcpu *vcpu)
+static __always_inline union vmx_exit_reason vt_get_exit_reason(struct kvm_vcpu *vcpu)
{
return to_vt(vcpu)->exit_reason;
}
-static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vcpu)
+static __always_inline unsigned long vt_get_exit_qual(struct kvm_vcpu *vcpu)
{
struct vcpu_vt *vt = to_vt(vcpu);
@@ -107,7 +107,7 @@ static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vcpu)
return vt->exit_qualification;
}
-static __always_inline u32 vmx_get_intr_info(struct kvm_vcpu *vcpu)
+static __always_inline u32 vt_get_intr_info(struct kvm_vcpu *vcpu)
{
struct vcpu_vt *vt = to_vt(vcpu);
diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
index 0151baa56598..6e0b3959d73a 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -934,12 +934,12 @@ static void vt_handle_exit_irqoff(struct kvm_vcpu *vcpu)
if (to_vt(vcpu)->emulation_required)
return;
- switch (vmx_get_exit_reason(vcpu).basic) {
+ switch (vt_get_exit_reason(vcpu).basic) {
case EXIT_REASON_EXTERNAL_INTERRUPT:
- handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu));
+ handle_external_interrupt_irqoff(vcpu, vt_get_intr_info(vcpu));
break;
case EXIT_REASON_EXCEPTION_NMI:
- handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu));
+ handle_exception_irqoff(vcpu, vt_get_intr_info(vcpu));
break;
case EXIT_REASON_MCE_DURING_VMENTRY:
kvm_machine_check();
@@ -951,8 +951,8 @@ static void vt_handle_exit_irqoff(struct kvm_vcpu *vcpu)
noinstr void vt_handle_nmi(struct kvm_vcpu *vcpu)
{
- if ((u16)vmx_get_exit_reason(vcpu).basic != EXIT_REASON_EXCEPTION_NMI ||
- !is_nmi(vmx_get_intr_info(vcpu)))
+ if ((u16)vt_get_exit_reason(vcpu).basic != EXIT_REASON_EXCEPTION_NMI ||
+ !is_nmi(vt_get_intr_info(vcpu)))
return;
kvm_before_interrupt(vcpu, KVM_HANDLING_NMI);
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 151873407abd..47599e7312cf 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -446,7 +446,7 @@ static void nested_ept_inject_page_fault(struct kvm_vcpu *vcpu,
* "NMI unblocking due to IRET", i.e. the bit can be propagated
* as-is from the original EXIT_QUALIFICATION.
*/
- exit_qualification = vmx_get_exit_qual(vcpu) & INTR_INFO_UNBLOCK_NMI;
+ exit_qualification = vt_get_exit_qual(vcpu) & INTR_INFO_UNBLOCK_NMI;
} else {
if (fault->error_code & PFERR_RSVD_MASK) {
vm_exit_reason = EXIT_REASON_EPT_MISCONFIG;
@@ -472,7 +472,7 @@ static void nested_ept_inject_page_fault(struct kvm_vcpu *vcpu,
* and walks the faulting GPA.
*/
if (from_hardware)
- exit_qualification |= vmx_get_exit_qual(vcpu) & mask;
+ exit_qualification |= vt_get_exit_qual(vcpu) & mask;
else
exit_qualification |= fault->exit_qualification & mask;
@@ -4747,7 +4747,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
{
/* update exit information fields: */
vmcs12->vm_exit_reason = vm_exit_reason;
- if (vmx_get_exit_reason(vcpu).enclave_mode)
+ if (vt_get_exit_reason(vcpu).enclave_mode)
vmcs12->vm_exit_reason |= VMX_EXIT_REASONS_SGX_ENCLAVE_MODE;
vmcs12->exit_qualification = exit_qualification;
@@ -5373,7 +5373,7 @@ static int nested_vmx_get_vmptr(struct kvm_vcpu *vcpu, gpa_t *vmpointer,
struct x86_exception e;
int r;
- if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu),
+ if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu),
vmcs_read32(VMX_INSTRUCTION_INFO), false,
sizeof(*vmpointer), &gva)) {
*ret = 1;
@@ -5665,7 +5665,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
{
struct vmcs12 *vmcs12 = is_guest_mode(vcpu) ? get_shadow_vmcs12(vcpu)
: get_vmcs12(vcpu);
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);
struct vcpu_vmx *vmx = to_vmx(vcpu);
struct x86_exception e;
@@ -5771,7 +5771,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
{
struct vmcs12 *vmcs12 = is_guest_mode(vcpu) ? get_shadow_vmcs12(vcpu)
: get_vmcs12(vcpu);
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);
struct vcpu_vmx *vmx = to_vmx(vcpu);
struct x86_exception e;
@@ -5960,7 +5960,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
/* Emulate the VMPTRST instruction */
static int handle_vmptrst(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qual = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qual = vt_get_exit_qual(vcpu);
u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);
gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
struct x86_exception e;
@@ -6021,7 +6021,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
/* According to the Intel VMX instruction reference, the memory
* operand is read even if it isn't needed (e.g., for type==global)
*/
- if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu),
+ if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu),
vmx_instruction_info, false, sizeof(operand), &gva))
return 1;
r = kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e);
@@ -6104,7 +6104,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
/* according to the intel vmx instruction reference, the memory
* operand is read even if it isn't needed (e.g., for type==global)
*/
- if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu),
+ if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu),
vmx_instruction_info, false, sizeof(operand), &gva))
return 1;
r = kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e);
@@ -6236,8 +6236,8 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu)
* EXIT_REASON_VMFUNC as the exit reason.
*/
nested_vmx_vmexit(vcpu, vmx->vt.exit_reason.full,
- vmx_get_intr_info(vcpu),
- vmx_get_exit_qual(vcpu));
+ vt_get_intr_info(vcpu),
+ vt_get_exit_qual(vcpu));
return 1;
}
@@ -6288,7 +6288,7 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,
if (!nested_cpu_has(vmcs12, CPU_BASED_USE_IO_BITMAPS))
return nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING);
- exit_qualification = vmx_get_exit_qual(vcpu);
+ exit_qualification = vt_get_exit_qual(vcpu);
port = exit_qualification >> 16;
size = (exit_qualification & 7) + 1;
@@ -6314,7 +6314,7 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vcpu *vcpu,
if (exit_reason.basic == EXIT_REASON_MSR_READ_IMM ||
exit_reason.basic == EXIT_REASON_MSR_WRITE_IMM)
- msr_index = vmx_get_exit_qual(vcpu);
+ msr_index = vt_get_exit_qual(vcpu);
else
msr_index = kvm_ecx_read(vcpu);
@@ -6350,7 +6350,7 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vcpu *vcpu,
static bool nested_vmx_exit_handled_cr(struct kvm_vcpu *vcpu,
struct vmcs12 *vmcs12)
{
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
int cr = exit_qualification & 15;
int reg;
unsigned long val;
@@ -6484,7 +6484,7 @@ static bool nested_vmx_l0_wants_exit(struct kvm_vcpu *vcpu,
switch ((u16)exit_reason.basic) {
case EXIT_REASON_EXCEPTION_NMI:
- intr_info = vmx_get_intr_info(vcpu);
+ intr_info = vt_get_intr_info(vcpu);
if (is_nmi(intr_info))
return true;
else if (is_page_fault(intr_info))
@@ -6567,7 +6567,7 @@ static bool nested_vmx_l1_wants_exit(struct kvm_vcpu *vcpu,
switch ((u16)exit_reason.basic) {
case EXIT_REASON_EXCEPTION_NMI:
- intr_info = vmx_get_intr_info(vcpu);
+ intr_info = vt_get_intr_info(vcpu);
if (is_nmi(intr_info))
return true;
else if (is_page_fault(intr_info))
@@ -6737,14 +6737,14 @@ bool nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu)
* need to be synthesized by querying the in-kernel LAPIC, but external
* interrupts are never reflected to L1 so it's a non-issue.
*/
- exit_intr_info = vmx_get_intr_info(vcpu);
+ exit_intr_info = vt_get_intr_info(vcpu);
if (is_exception_with_error_code(exit_intr_info)) {
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
vmcs12->vm_exit_intr_error_code =
vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
}
- exit_qual = vmx_get_exit_qual(vcpu);
+ exit_qual = vt_get_exit_qual(vcpu);
reflect_vmexit:
nested_vmx_vmexit(vcpu, exit_reason.full, exit_intr_info, exit_qual);
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index a3d6f0fb5951..efbb1ac6f51e 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -741,7 +741,7 @@ bool tdx_interrupt_allowed(struct kvm_vcpu *vcpu)
* interrupt is always allowed unless TDX guest calls TDVMCALL with HLT,
* which passes the interrupt blocked flag.
*/
- return vmx_get_exit_reason(vcpu).basic != EXIT_REASON_HLT ||
+ return vt_get_exit_reason(vcpu).basic != EXIT_REASON_HLT ||
!to_tdx(vcpu)->vp_enter_args.r12;
}
@@ -759,7 +759,7 @@ static bool tdx_protected_apic_has_interrupt(struct kvm_vcpu *vcpu)
* otherwise the interrupt would have been serviced at the instruction
* boundary.
*/
- if (vmx_get_exit_reason(vcpu).basic != EXIT_REASON_HLT ||
+ if (vt_get_exit_reason(vcpu).basic != EXIT_REASON_HLT ||
to_tdx(vcpu)->vp_enter_args.r12)
return false;
@@ -981,8 +981,8 @@ static noinstr void tdx_vcpu_enter_exit(struct kvm_vcpu *vcpu)
static bool tdx_failed_vmentry(struct kvm_vcpu *vcpu)
{
- return vmx_get_exit_reason(vcpu).failed_vmentry &&
- vmx_get_exit_reason(vcpu).full != -1u;
+ return vt_get_exit_reason(vcpu).failed_vmentry &&
+ vt_get_exit_reason(vcpu).full != -1u;
}
static fastpath_t tdx_exit_handlers_fastpath(struct kvm_vcpu *vcpu)
@@ -1131,7 +1131,7 @@ void tdx_inject_nmi(struct kvm_vcpu *vcpu)
static int tdx_handle_exception_nmi(struct kvm_vcpu *vcpu)
{
- u32 intr_info = vmx_get_intr_info(vcpu);
+ u32 intr_info = vt_get_intr_info(vcpu);
/*
* Machine checks are handled by handle_exception_irqoff(), or by
@@ -1903,7 +1903,7 @@ void tdx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode,
static inline bool tdx_is_sept_violation_unexpected_pending(struct kvm_vcpu *vcpu)
{
u64 eeq_type = to_tdx(vcpu)->ext_exit_qualification & TDX_EXT_EXIT_QUAL_TYPE_MASK;
- u64 eq = vmx_get_exit_qual(vcpu);
+ u64 eq = vt_get_exit_qual(vcpu);
if (eeq_type != TDX_EXT_EXIT_QUAL_TYPE_PENDING_EPT_VIOLATION)
return false;
@@ -1939,7 +1939,7 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)
/* Only private GPA triggers zero-step mitigation */
local_retry = true;
} else {
- exit_qual = vmx_get_exit_qual(vcpu);
+ exit_qual = vt_get_exit_qual(vcpu);
/*
* EPT violation due to instruction fetch should never be
* triggered from shared memory in TDX guest. If such EPT
@@ -2021,7 +2021,7 @@ int tdx_complete_emulated_msr(struct kvm_vcpu *vcpu, int err)
return 1;
}
- if (vmx_get_exit_reason(vcpu).basic == EXIT_REASON_MSR_READ)
+ if (vt_get_exit_reason(vcpu).basic == EXIT_REASON_MSR_READ)
tdvmcall_set_return_val(vcpu, kvm_read_edx_eax(vcpu));
return 1;
@@ -2032,7 +2032,7 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
{
struct vcpu_tdx *tdx = to_tdx(vcpu);
u64 vp_enter_ret = tdx->vp_enter_ret;
- union vmx_exit_reason exit_reason = vmx_get_exit_reason(vcpu);
+ union vmx_exit_reason exit_reason = vt_get_exit_reason(vcpu);
if (fastpath != EXIT_FASTPATH_NONE)
return 1;
@@ -2142,9 +2142,9 @@ void tdx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
*reason = tdx->vt.exit_reason.full;
if (*reason != -1u) {
- *info1 = vmx_get_exit_qual(vcpu);
+ *info1 = vt_get_exit_qual(vcpu);
*info2 = tdx->ext_exit_qualification;
- *intr_info = vmx_get_intr_info(vcpu);
+ *intr_info = vt_get_intr_info(vcpu);
} else {
*info1 = 0;
*info2 = 0;
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 2532a9b8e92e..7e35c2d03c69 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1791,7 +1791,7 @@ int vmx_check_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
* so that guest userspace can't DoS the guest simply by triggering
* emulation (enclaves are CPL3 only).
*/
- if (vmx_get_exit_reason(vcpu).enclave_mode) {
+ if (vt_get_exit_reason(vcpu).enclave_mode) {
kvm_queue_exception(vcpu, UD_VECTOR);
return X86EMUL_PROPAGATE_FAULT;
}
@@ -1806,7 +1806,7 @@ int vmx_check_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type,
static int skip_emulated_instruction(struct kvm_vcpu *vcpu)
{
- union vmx_exit_reason exit_reason = vmx_get_exit_reason(vcpu);
+ union vmx_exit_reason exit_reason = vt_get_exit_reason(vcpu);
unsigned long rip, orig_rip;
u32 instr_len;
@@ -5381,7 +5381,7 @@ bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu)
static int vmx_handle_page_fault(struct kvm_vcpu *vcpu, u32 error_code)
{
- unsigned long cr2 = vmx_get_exit_qual(vcpu);
+ unsigned long cr2 = vt_get_exit_qual(vcpu);
if (vcpu->arch.apf.host_apf_flags)
goto handle_pf;
@@ -5429,7 +5429,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
u32 vect_info;
vect_info = vmx->idt_vectoring_info;
- intr_info = vmx_get_intr_info(vcpu);
+ intr_info = vt_get_intr_info(vcpu);
/*
* Machine checks are handled by handle_exception_irqoff(), or by
@@ -5510,7 +5510,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
switch (ex_no) {
case DB_VECTOR:
- dr6 = vmx_get_exit_qual(vcpu);
+ dr6 = vt_get_exit_qual(vcpu);
if (!(vcpu->guest_debug &
(KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) {
/*
@@ -5586,7 +5586,7 @@ static int handle_io(struct kvm_vcpu *vcpu)
int size, in, string;
unsigned port;
- exit_qualification = vmx_get_exit_qual(vcpu);
+ exit_qualification = vt_get_exit_qual(vcpu);
string = (exit_qualification & 16) != 0;
++vcpu->stat.io_exits;
@@ -5675,7 +5675,7 @@ static int handle_cr(struct kvm_vcpu *vcpu)
int err;
int ret;
- exit_qualification = vmx_get_exit_qual(vcpu);
+ exit_qualification = vt_get_exit_qual(vcpu);
cr = exit_qualification & 15;
reg = (exit_qualification >> 8) & 15;
switch ((exit_qualification >> 4) & 3) {
@@ -5753,7 +5753,7 @@ static int handle_dr(struct kvm_vcpu *vcpu)
int dr, dr7, reg;
int err = 1;
- exit_qualification = vmx_get_exit_qual(vcpu);
+ exit_qualification = vt_get_exit_qual(vcpu);
dr = exit_qualification & DEBUG_REG_ACCESS_NUM;
/* First, if DR does not exist, trigger UD */
@@ -5849,7 +5849,7 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu)
static int handle_invlpg(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
kvm_mmu_invlpg(vcpu, exit_qualification);
return kvm_skip_emulated_instruction(vcpu);
@@ -5858,7 +5858,7 @@ static int handle_invlpg(struct kvm_vcpu *vcpu)
static int handle_apic_access(struct kvm_vcpu *vcpu)
{
if (likely(fasteoi)) {
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
int access_type, offset;
access_type = exit_qualification & APIC_ACCESS_TYPE;
@@ -5879,7 +5879,7 @@ static int handle_apic_access(struct kvm_vcpu *vcpu)
static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
int vector = exit_qualification & 0xff;
/* EOI-induced VM exit is trap-like and thus no need to adjust IP */
@@ -5889,7 +5889,7 @@ static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu)
static int handle_apic_write(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
/*
* APIC-write VM-Exit is trap-like, KVM doesn't need to advance RIP and
@@ -5917,7 +5917,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
idt_index = (vmx->idt_vectoring_info & VECTORING_INFO_VECTOR_MASK);
type = (vmx->idt_vectoring_info & VECTORING_INFO_TYPE_MASK);
- exit_qualification = vmx_get_exit_qual(vcpu);
+ exit_qualification = vt_get_exit_qual(vcpu);
reason = (u32)exit_qualification >> 30;
if (reason == TASK_SWITCH_GATE && idt_v) {
@@ -5963,7 +5963,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
static int handle_ept_violation(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
gpa_t gpa;
/*
@@ -6154,7 +6154,7 @@ static int handle_invpcid(struct kvm_vcpu *vcpu)
/* According to the Intel instruction reference, the memory operand
* is read even if it isn't needed (e.g., for type==all)
*/
- if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu),
+ if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu),
vmx_instruction_info, false,
sizeof(operand), &gva))
return 1;
@@ -6168,7 +6168,7 @@ static int handle_pml_full(struct kvm_vcpu *vcpu)
trace_kvm_pml_full(vcpu->vcpu_id);
- exit_qualification = vmx_get_exit_qual(vcpu);
+ exit_qualification = vt_get_exit_qual(vcpu);
/*
* PML buffer FULL happened while executing iret from NMI,
@@ -6272,7 +6272,7 @@ static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
static int handle_notify(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qual = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qual = vt_get_exit_qual(vcpu);
bool context_invalid = exit_qual & NOTIFY_VM_CONTEXT_INVALID;
++vcpu->stat.notify_window_exits;
@@ -6303,13 +6303,13 @@ static int vmx_get_msr_imm_reg(struct kvm_vcpu *vcpu)
static int handle_rdmsr_imm(struct kvm_vcpu *vcpu)
{
- return kvm_emulate_rdmsr_imm(vcpu, vmx_get_exit_qual(vcpu),
+ return kvm_emulate_rdmsr_imm(vcpu, vt_get_exit_qual(vcpu),
vmx_get_msr_imm_reg(vcpu));
}
static int handle_wrmsr_imm(struct kvm_vcpu *vcpu)
{
- return kvm_emulate_wrmsr_imm(vcpu, vmx_get_exit_qual(vcpu),
+ return kvm_emulate_wrmsr_imm(vcpu, vt_get_exit_qual(vcpu),
vmx_get_msr_imm_reg(vcpu));
}
@@ -6386,10 +6386,10 @@ void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
struct vcpu_vmx *vmx = to_vmx(vcpu);
*reason = vmx->vt.exit_reason.full;
- *info1 = vmx_get_exit_qual(vcpu);
+ *info1 = vt_get_exit_qual(vcpu);
if (!(vmx->vt.exit_reason.failed_vmentry)) {
*info2 = vmx->idt_vectoring_info;
- *intr_info = vmx_get_intr_info(vcpu);
+ *intr_info = vt_get_intr_info(vcpu);
if (is_exception_with_error_code(*intr_info))
*error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
else
@@ -6700,7 +6700,7 @@ void dump_vmcs(struct kvm_vcpu *vcpu)
static int __vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
- union vmx_exit_reason exit_reason = vmx_get_exit_reason(vcpu);
+ union vmx_exit_reason exit_reason = vt_get_exit_reason(vcpu);
u32 vectoring_info = vmx->idt_vectoring_info;
u16 exit_handler_index;
@@ -6864,7 +6864,7 @@ int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
* Exit to user space when bus lock detected to inform that there is
* a bus lock in guest.
*/
- if (vmx_get_exit_reason(vcpu).bus_lock_detected) {
+ if (vt_get_exit_reason(vcpu).bus_lock_detected) {
if (ret > 0)
vcpu->run->exit_reason = KVM_EXIT_X86_BUS_LOCK;
@@ -7176,7 +7176,7 @@ static void vmx_recover_nmi_blocking(struct vcpu_vmx *vmx)
if (vmx->loaded_vmcs->nmi_known_unmasked)
return;
- exit_intr_info = vmx_get_intr_info(&vmx->vcpu);
+ exit_intr_info = vt_get_intr_info(&vmx->vcpu);
unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0;
vector = exit_intr_info & INTR_INFO_VECTOR_MASK;
/*
@@ -7343,14 +7343,14 @@ static fastpath_t vmx_exit_handlers_fastpath(struct kvm_vcpu *vcpu,
* the fastpath even, all other exits must use the slow path.
*/
if (is_guest_mode(vcpu) &&
- vmx_get_exit_reason(vcpu).basic != EXIT_REASON_PREEMPTION_TIMER)
+ vt_get_exit_reason(vcpu).basic != EXIT_REASON_PREEMPTION_TIMER)
return EXIT_FASTPATH_NONE;
- switch (vmx_get_exit_reason(vcpu).basic) {
+ switch (vt_get_exit_reason(vcpu).basic) {
case EXIT_REASON_MSR_WRITE:
return handle_fastpath_wrmsr(vcpu);
case EXIT_REASON_MSR_WRITE_IMM:
- return handle_fastpath_wrmsr_imm(vcpu, vmx_get_exit_qual(vcpu),
+ return handle_fastpath_wrmsr_imm(vcpu, vt_get_exit_qual(vcpu),
vmx_get_msr_imm_reg(vcpu));
case EXIT_REASON_PREEMPTION_TIMER:
return handle_fastpath_preemption_timer(vcpu, force_immediate_exit);
@@ -7392,7 +7392,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
}
vmx->vt.exit_reason.full = vmcs_read32(VM_EXIT_REASON);
- if (likely(!vmx_get_exit_reason(vcpu).failed_vmentry))
+ if (likely(!vt_get_exit_reason(vcpu).failed_vmentry))
vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
vt_handle_nmi(vcpu);
@@ -7532,7 +7532,7 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags)
* checking.
*/
if (vcpu->arch.nested_run_pending &&
- !vmx_get_exit_reason(vcpu).failed_vmentry)
+ !vt_get_exit_reason(vcpu).failed_vmentry)
++vcpu->stat.nested_run;
vcpu->arch.nested_run_pending = 0;
@@ -7543,7 +7543,7 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags)
trace_kvm_exit(vcpu, KVM_ISA_VMX);
- if (unlikely(vmx_get_exit_reason(vcpu).failed_vmentry))
+ if (unlikely(vt_get_exit_reason(vcpu).failed_vmentry))
return EXIT_FASTPATH_NONE;
vmx->loaded_vmcs->launched = 1;
--
2.55.0.887.g758fc8c411-goog
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx
2026-08-26 17:12 [PATCH v2 0/8] KVM: VMX: Harden against interpreting TDX vCPU as vcpu_vmx Sean Christopherson
` (7 preceding siblings ...)
2026-08-26 17:12 ` [PATCH v2 8/8] KVM: VMX: Rename common exit info getters prefixes from "vmx" to "vt" Sean Christopherson
@ 2026-08-27 2:53 ` Huang, Kai
8 siblings, 0 replies; 25+ messages in thread
From: Huang, Kai @ 2026-08-27 2:53 UTC (permalink / raw)
To: pbonzini@redhat.com, seanjc@google.com
Cc: Li, Xiaoyao, kvm@vger.kernel.org, Zhao, Yan Y,
linux-kernel@vger.kernel.org, Edgecombe, Rick P,
binbin.wu@linux.intel.com
On Wed, 2026-08-26 at 10:12 -0700, Sean Christopherson wrote:
> Move and rename "all" (read: everything I could find) common helpers out of
> vmx.c and/or replace their vmx_ prefix with vt_, and then poison to_vmx() for
> all common .c files to harden KVM against misinterpreting a TDX vCPU as a VMX
> vCPU, i.e. consuming to_vmx() on a TDX vCPU. Spotted when working through
> the bus lock series.
>
> As with v1, the TDX changes are compile-tested only.
Sanity tested creating/destroying/short-running both VMX and TDX guests worked
fine on one GNR machine. For this series:
Reviewed-by: Kai Huang <kai.huang@intel.com>
Tested-by: Kai Huang <kai.huang@intel.com>
^ permalink raw reply [flat|nested] 25+ messages in thread