[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250220211628.1832258-4-vannapurve@google.com>
Date: Thu, 20 Feb 2025 21:16:27 +0000
From: Vishal Annapurve <vannapurve@...gle.com>
To: x86@...nel.org, linux-kernel@...r.kernel.org, linux-coco@...ts.linux.dev,
virtualization@...ts.linux.dev
Cc: pbonzini@...hat.com, seanjc@...gle.com, erdemaktas@...gle.com,
ackerleytng@...gle.com, jxgao@...gle.com, sagis@...gle.com, oupton@...gle.com,
pgonda@...gle.com, kirill@...temov.name, dave.hansen@...ux.intel.com,
chao.p.peng@...ux.intel.com, isaku.yamahata@...il.com,
sathyanarayanan.kuppuswamy@...ux.intel.com, jgross@...e.com,
ajay.kaher@...adcom.com, alexey.amakhalov@...adcom.com,
Vishal Annapurve <vannapurve@...gle.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: [PATCH V5 3/4] x86/tdx: Emit warning if IRQs are enabled during HLT
#VE handling
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@...ux.intel.com>
Signed-off-by: Vishal Annapurve <vannapurve@...gle.com>
---
arch/x86/coco/tdx/tdx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 7ab427e85bd3..16ac337df9fa 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -393,6 +393,14 @@ static int handle_halt(struct ve_info *ve)
{
const bool irq_disabled = irqs_disabled();
+ /*
+ * HLT with IRQs enabled is unsafe, as an IRQ that is intended to be a
+ * wake event may be consumed before requesting HLT emulation, leaving
+ * the vCPU blocking indefinitely.
+ */
+ if (WARN_ONCE(!irq_disabled, "HLT emulation with IRQs enabled"))
+ return -EIO;
+
if (__halt(irq_disabled))
return -EIO;
--
2.48.1.601.g30ceb7b040-goog
Powered by blists - more mailing lists