* [PATCH] KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter
@ 2026-09-21 23:56 Sean Christopherson
2026-09-22 2:13 ` Binbin Wu
2026-09-22 2:16 ` Xiaoyao Li
0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2026-09-21 23:56 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Xiaoyao Li, Yan Zhao, Binbin Wu, Rick Edgecombe
Add EXIT_REASON_UNDEFINED to track KVM's magic "0xdead" value that's used
to stuff the exit reason on a failed VM-Enter so that the magic can be
reused by TDX, and to make it more obvious that it's an arbitrary, KVM-
defined value (though the whole "dead" thing makes it pretty darn obvious).
Opportunistically add a compile-time assert to ensure the KVM-defined exit
reason never collides with a "real" exit reason.
No functional change intended.
Cc: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Yan Zhao <yan.y.zhao@intel.com>
Cc: Binbin Wu <binbin.wu@linux.intel.com>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/include/asm/vmx.h | 8 ++++++++
arch/x86/kvm/vmx/vmx.c | 4 +++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 3f1b3096ff04..e49b836c7313 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -20,6 +20,14 @@
#include <asm/trapnr.h>
#include <asm/vmxfeatures.h>
+/*
+ * UNDEFINED is a KVM-defined value used to indicate that the basic exit reason
+ * is undefined/invalid, e.g. on VM-Fail or if TDX never attempted VM-Enter.
+ * The value itself is arbitrary, it just needs to not collide with a real exit
+ * reason.
+ */
+#define EXIT_REASON_UNDEFINED 0xdead
+
struct vmcs_hdr {
u32 revision_id:31;
u32 shadow_vmcs:1;
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 612ab07d4100..c897dbf0e954 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6388,6 +6388,8 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
static const int kvm_vmx_max_exit_handlers =
ARRAY_SIZE(kvm_vmx_exit_handlers);
+static_assert(EXIT_REASON_UNDEFINED >= ARRAY_SIZE(kvm_vmx_exit_handlers));
+
void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
u64 *info1, u64 *info2, u32 *intr_info, u32 *error_code)
{
@@ -7474,7 +7476,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
vmx_enable_fb_clear(vmx);
if (unlikely(vmx->fail)) {
- vmx->vt.exit_reason.full = 0xdead;
+ vmx->vt.exit_reason.full = EXIT_REASON_UNDEFINED;
goto out;
}
base-commit: d4b7fb647204f0c81dfeae2d1a708e4d858e0c94
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter
2026-09-21 23:56 [PATCH] KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter Sean Christopherson
@ 2026-09-22 2:13 ` Binbin Wu
2026-09-22 2:16 ` Xiaoyao Li
1 sibling, 0 replies; 3+ messages in thread
From: Binbin Wu @ 2026-09-22 2:13 UTC (permalink / raw)
To: Sean Christopherson
Cc: Paolo Bonzini, kvm, linux-kernel, Xiaoyao Li, Yan Zhao, Rick Edgecombe
On 9/22/2026 7:56 AM, Sean Christopherson wrote:
> Add EXIT_REASON_UNDEFINED to track KVM's magic "0xdead" value that's used
> to stuff the exit reason on a failed VM-Enter so that the magic can be
> reused by TDX, and to make it more obvious that it's an arbitrary, KVM-
> defined value (though the whole "dead" thing makes it pretty darn obvious).
>
> Opportunistically add a compile-time assert to ensure the KVM-defined exit
> reason never collides with a "real" exit reason.
>
> No functional change intended.
>
> Cc: Xiaoyao Li <xiaoyao.li@intel.com>
> Cc: Yan Zhao <yan.y.zhao@intel.com>
> Cc: Binbin Wu <binbin.wu@linux.intel.com>
> Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
> ---
> arch/x86/include/asm/vmx.h | 8 ++++++++
> arch/x86/kvm/vmx/vmx.c | 4 +++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index 3f1b3096ff04..e49b836c7313 100644
> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -20,6 +20,14 @@
> #include <asm/trapnr.h>
> #include <asm/vmxfeatures.h>
>
> +/*
> + * UNDEFINED is a KVM-defined value used to indicate that the basic exit reason
> + * is undefined/invalid, e.g. on VM-Fail or if TDX never attempted VM-Enter.
> + * The value itself is arbitrary, it just needs to not collide with a real exit
> + * reason.
> + */
> +#define EXIT_REASON_UNDEFINED 0xdead
> +
> struct vmcs_hdr {
> u32 revision_id:31;
> u32 shadow_vmcs:1;
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 612ab07d4100..c897dbf0e954 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6388,6 +6388,8 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
> static const int kvm_vmx_max_exit_handlers =
> ARRAY_SIZE(kvm_vmx_exit_handlers);
>
> +static_assert(EXIT_REASON_UNDEFINED >= ARRAY_SIZE(kvm_vmx_exit_handlers));
> +
> void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
> u64 *info1, u64 *info2, u32 *intr_info, u32 *error_code)
> {
> @@ -7474,7 +7476,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
> vmx_enable_fb_clear(vmx);
>
> if (unlikely(vmx->fail)) {
> - vmx->vt.exit_reason.full = 0xdead;
> + vmx->vt.exit_reason.full = EXIT_REASON_UNDEFINED;
> goto out;
> }
>
>
> base-commit: d4b7fb647204f0c81dfeae2d1a708e4d858e0c94
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter
2026-09-21 23:56 [PATCH] KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter Sean Christopherson
2026-09-22 2:13 ` Binbin Wu
@ 2026-09-22 2:16 ` Xiaoyao Li
1 sibling, 0 replies; 3+ messages in thread
From: Xiaoyao Li @ 2026-09-22 2:16 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Yan Zhao, Binbin Wu, Rick Edgecombe
On 9/22/2026 7:56 AM, Sean Christopherson wrote:
> Add EXIT_REASON_UNDEFINED to track KVM's magic "0xdead" value that's used
> to stuff the exit reason on a failed VM-Enter so that the magic can be
> reused by TDX, and to make it more obvious that it's an arbitrary, KVM-
> defined value (though the whole "dead" thing makes it pretty darn obvious).
>
> Opportunistically add a compile-time assert to ensure the KVM-defined exit
> reason never collides with a "real" exit reason.
>
> No functional change intended.
>
> Cc: Xiaoyao Li <xiaoyao.li@intel.com>
> Cc: Yan Zhao <yan.y.zhao@intel.com>
> Cc: Binbin Wu <binbin.wu@linux.intel.com>
> Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-22 2:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 23:56 [PATCH] KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter Sean Christopherson
2026-09-22 2:13 ` Binbin Wu
2026-09-22 2:16 ` Xiaoyao Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®