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=1796384756; b=ed/PGVqwvGJ6vRcd9gUZu4c1DptvdDeUydmpAnXt0NbkdiGBGW25VQY8eM9fV7QWRRPM C6fhiAcMz0+9GNbys4NDaPRo6j4h8x4HbmNM1oA6tgqHThlCRP1vyBgaB6uqaWsrJrTQ0 X81qrDTFY+7RQWAM4riWXjotHYqpG4OzeyYDRa2dtehHVOq0gO0ecqplq2daCjy1Fg3Ue qYqvOiZLO17XeUxeYqJOnLUROxM+X/6ALh+MkjD9bbHUbjhQPc6Mcn6uIYiUQdSUqM5F0 rPYu3sG2okVvZTb/5K/FYhiPDll+Sf8VeV9pEgEIk4G6M2hQ4EgNXabX3P3GtTbQYvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384756; 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=E85DhgTIz+OKnmwb9pw+l2Wp7P7UqlVZDMkea0pWD4M=; b=yDZxfAysePdQVxxMgFmk6b4UhByfStImlCzVJRhzWUkSR6LCcc17l8JCHRUGpc4El27m 7hTpaPnFnNxrn4GHGqI/Kyyx7WYbSfi1rLNTHZlyL4Rcnf3JOPk+x5Pgzd82aC8KPxiS5 3oqUogSh4kbZZUIA9vB56vTD6xaVmCny1ljzKgDDy/M2Wd1D3kj579zbgvzF8cFQSLSUA DiYvaavRAOx5VN4q56wph8QNZ8EjVG19mhtRy47Mrqfa35R0s8TPjSnrQpIQE3qm3XiMT Feqkjvu4r4wOlX6WYNr4FOyM9Q6H7VItYYSzHA4ey/qcMGBYUKhjRbkMJj1Ul+qD88A== 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=srn5XPFz; 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 0C274606A322; Fri, 4 Dec 2026 11:45:56 +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=srn5XPFz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FF331F000C2; Fri, 4 Dec 2026 11:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384755; bh=E85DhgTIz+OKnmwb9pw+l2Wp7P7UqlVZDMkea0pWD4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=srn5XPFzviC+odFVmF2EdqN6vf/b9UekS85Gf8w4BgaS3m0wX5WjTdyYd/Z1lRoKS WDah+l6C9sAPZfzLz5W7IwzeYlDby1LEeDPkd8Me3HdzzGN8YX7dnt6SdbHkpBPvXU JMoTc8W2fXuwW52NAKKhJz8TOqQ15+H1698AFT/A= 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.6 0278/1167] KVM: VMX: Formally define KVMs "0xdead" exit reason used for failed VM-Enter Date: Fri, 4 Dec 2026 18:55:05 +0900 Message-ID: <20261204100709.294887152@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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: Placed the new EXIT_REASON_UNDEFINED define after the includes in vmx.h and used the branch's non-vt exit_reason field and static vmx_get_exit_info context. ] 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 0e73616b82f34..ff14badb156ab 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -19,6 +19,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 bf95123701461..81aa80a8e7bc9 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6168,6 +6168,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) @@ -7309,7 +7311,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, vmx_enable_fb_clear(vmx); if (unlikely(vmx->fail)) { - vmx->exit_reason.full = 0xdead; + vmx->exit_reason.full = EXIT_REASON_UNDEFINED; goto out; } -- 2.53.0