Skip to content

Commit e8f4592

Browse files
vishals4ghIngo Molnar
authored andcommitted
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. Signed-off-by: Vishal Annapurve <vannapurve@google.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Tested-by: Ryan Afranji <afranji@google.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: Juergen Gross <jgross@suse.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lore.kernel.org/r/20250228014416.3925664-4-vannapurve@google.com
1 parent 9f98a4f commit e8f4592

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/coco/tdx/tdx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,14 @@ static int handle_halt(struct ve_info *ve)
393393
{
394394
const bool irq_disabled = irqs_disabled();
395395

396+
/*
397+
* HLT with IRQs enabled is unsafe, as an IRQ that is intended to be a
398+
* wake event may be consumed before requesting HLT emulation, leaving
399+
* the vCPU blocking indefinitely.
400+
*/
401+
if (WARN_ONCE(!irq_disabled, "HLT emulation with IRQs enabled"))
402+
return -EIO;
403+
396404
if (__halt(irq_disabled))
397405
return -EIO;
398406

0 commit comments

Comments
 (0)