mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vishal Annapurve <vannapurve@google.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: pbonzini@redhat.com, seanjc@google.com, erdemaktas@google.com,
	 ackerleytng@google.com, jxgao@google.com, sagis@google.com,
	oupton@google.com,  pgonda@google.com, kirill@shutemov.name,
	dave.hansen@linux.intel.com,  linux-coco@lists.linux.dev,
	chao.p.peng@linux.intel.com,  isaku.yamahata@gmail.com,
	Vishal Annapurve <vannapurve@google.com>,
	 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCH V3 2/2] x86/tdx: Emit warning if IRQs are enabled during HLT #VE handling
Date: Thu,  6 Feb 2025 22:27:13 +0000	[thread overview]
Message-ID: <20250206222714.1079059-2-vannapurve@google.com> (raw)
In-Reply-To: <20250206222714.1079059-1-vannapurve@google.com>

Direct HLT instruction execution causes #VEs for TDX VMs which is routed
to hypervisor via TDCALL. safe_halt() routines execute HLT in STI-shadow
so IRQs need to remain disabled until the TDCALL to ensure that pending
IRQs are correctly treated as wake events.

Emit warning and fail emulation if IRQs are enabled during HLT #VE handling
to avoid running into scenarios where IRQ wake events are lost resulting in
indefinite HLT execution times.

Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>@linux.intel.com>
Signed-off-by: Vishal Annapurve <vannapurve@google.com>
---
 arch/x86/coco/tdx/tdx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 5e68758666a4..ed6738ea225c 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -393,6 +393,11 @@ static int handle_halt(struct ve_info *ve)
 {
 	const bool irq_disabled = irqs_disabled();
 
+	if (!irq_disabled) {
+		WARN_ONCE(1, "HLT instruction emulation unsafe with irqs enabled\n");
+		return -EIO;
+	}
+
 	if (__halt(irq_disabled))
 		return -EIO;
 
-- 
2.48.1.502.g6dc24dfdaf-goog


  reply	other threads:[~2025-02-06 22:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06 22:27 [PATCH V3 1/2] x86/tdx: Route safe halt execution via tdx_safe_halt() Vishal Annapurve
2025-02-06 22:27 ` Vishal Annapurve [this message]
2025-02-07 15:22   ` [PATCH V3 2/2] x86/tdx: Emit warning if IRQs are enabled during HLT #VE handling Sean Christopherson
2025-02-10 18:08     ` Vishal Annapurve
2025-02-11  8:32 ` [PATCH V3 1/2] x86/tdx: Route safe halt execution via tdx_safe_halt() Kirill A. Shutemov
2025-02-11 23:37   ` Vishal Annapurve
2025-02-11 23:46   ` Dave Hansen
2025-02-12  0:22     ` Vishal Annapurve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250206222714.1079059-2-vannapurve@google.com \
    --to=vannapurve@google.com \
    --cc=ackerleytng@google.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=erdemaktas@google.com \
    --cc=isaku.yamahata@gmail.com \
    --cc=jxgao@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=sagis@google.com \
    --cc=seanjc@google.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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®