From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387389; b=ZcPIM9inyXylftLZnFXhFo//HvhRxWkoYHEEf7IiMU7q2waP5BSYpkHPp2q+wzMD/dnp Was2SNcqo+oiLnJXdOozHdpCNPKX4Tx4TiegxQ9IFBvsK++C1CHczPsVjp9EVtZT4nPy9 UlX81L7Gb//Rtak04inDVI6i+bgX6M6KDZd7LUZuWPjY+NGAW+UMy37UyAFZyyWIAnLfe eTH8PX2QvLbKQWRVpqTYfc2yYPxbFOeCiV1qw/3QOAw4JaB1+8x6OtmEcmqzu9hsfuyO3 WVFv1EkN4Rl/WWl/PFQpwfI1YIMc9zm7xYuhlVF1GJlRzkhaKkKvg9Raq4mccHZ0XCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387389; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=P8hVwQGJAyO6UFHhP8rsct3M9kA/m4xsNjOcuz+eywc=; b=xIVUWGi6F/R7YWZdTj4+kU+LmaGk8/p5Zxoy9m5tt+RAAZ+LGu/cN1Y+k5UerOJVMaNS lpBgTYPOW4fFXGDG+Qrs95l00lcE9DafmSWJWIrjxQe20huTcCypzCDnRENShPJ+aP3ae G1Pk/9tFdYe/kCbVBIzfu53gx2GwY7dGRt7KgbZTeh1DoAS/vU0GFCkP/Bx2rVKmbR6m9 5KmP81JliKNgQwakVA4Rbh49Uub7HkaiQ8iVBKXpD7wCNu3UwG2Bx7tCErIxA8sfyfMqg GJ3dFeRIfd4hStNlxd4K4kq1um6P4AP8d+zm2hmGyS2FJM6qv4XRmnNt1Qss/hTVtKw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=i6qShO5F; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92772606A322; Fri, 4 Dec 2026 12:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=i6qShO5F Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9E391F00931; Fri, 4 Dec 2026 12:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387389; bh=P8hVwQGJAyO6UFHhP8rsct3M9kA/m4xsNjOcuz+eywc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i6qShO5FhfF9hvs0nR+LdDrpPdG1uhWExiSX4JAIj7woJZc5kx9JXrT2Mpn90xzNG pI32aEfH5FOPClKQoJiUY8SqszmDNKZP4Nrc2GvN4C8j5DnEg10LqTlPzAvzCeOPAX +0ffJkM7F1WfvT0bUPdE+/z0jNpxsmESx3+yQqA0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiaoyao Li , Yan Zhao , Binbin Wu , Rick Edgecombe , Sean Christopherson , Sasha Levin Subject: [PATCH 6.1 0223/1059] KVM: VMX: Formally define KVMs "0xdead" exit reason used for failed VM-Enter Date: Fri, 4 Dec 2026 18:55:54 +0900 Message-ID: <20261204100650.052058547@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Christopherson [ Upstream commit d85f7dc8cf3c91a131946dae4c3aa8d9c97322d7 ] 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 Cc: Yan Zhao Cc: Binbin Wu Cc: Rick Edgecombe Cc: stable@vger.kernel.org Reviewed-by: Binbin Wu Reviewed-by: Xiaoyao Li Link: https://patch.msgid.link/20260921235656.1107929-1-seanjc@google.com Signed-off-by: Sean Christopherson [ sashal: Adapted the vmx.h define placement and moved the 0xdead replacement into vmx_vcpu_run() with vmx->exit_reason.full, since vmx_vcpu_enter_exit() and vmx->vt don't exist here. ] Signed-off-by: Sasha Levin --- 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 498dc600bd5c8..0830867e08cb0 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -17,6 +17,14 @@ #include #include +/* + * 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 + #define VMCS_CONTROL_BIT(x) BIT(VMX_FEATURE_##x & 0x1f) /* diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 9fa2eb33d54d1..9f916cf791f54 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6085,6 +6085,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)); + static void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason, u64 *info1, u64 *info2, u32 *intr_info, u32 *error_code) @@ -7338,7 +7340,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) vmx->idt_vectoring_info = 0; if (unlikely(vmx->fail)) { - vmx->exit_reason.full = 0xdead; + vmx->exit_reason.full = EXIT_REASON_UNDEFINED; return EXIT_FASTPATH_NONE; } -- 2.53.0