All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/3] x86/tdx: Fix HLT logic execution for TDX VMs
@ 2025-02-25  0:47 Vishal Annapurve
  2025-02-25  0:47 ` [PATCH v6 1/3] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT Vishal Annapurve
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Vishal Annapurve @ 2025-02-25  0:47 UTC (permalink / raw)
  To: dave.hansen, kirill.shutemov, jgross, ajay.kaher, ak, tony.luck,
	thomas.lendacky
  Cc: tglx, mingo, bp, hpa, pbonzini, seanjc, kai.huang, chao.p.peng,
	isaku.yamahata, sathyanarayanan.kuppuswamy, erdemaktas,
	ackerleytng, jxgao, sagis, afranji, kees, jikos, peterz, x86,
	linux-kernel, linux-coco, virtualization,
	bcm-kernel-feedback-list, Vishal Annapurve

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. As per current TDX spec, HLT
#VE handler doesn't have access to interruptibility state to selectively
enable interrupts, it ends up enabling interrupts during #VE handling
before the TDCALL is executed.
 
Commit bfe6ed0c6727 ("x86/tdx: Add HLT support for TDX guests")
effectively solved this issue for idle routines by defining TDX specific
idle routine which directly invokes TDCALL while keeping interrupts
disabled, but missed handling arch_safe_halt(). This series intends to fix
arch_safe_halt() execution for TDX VMs.

Changes introduced by the series include:
- Move *halt() variants outside CONFIG_PARAVIRT_XXL and under
  CONFIG_PARAVIRT [1].
- Add explicit dependency on CONFIG_PARAVIRT for TDX VMs.
- Route "sti; hlt" sequences via tdx_safe_halt() for reliability.
- Route "hlt" sequences via tdx_halt() to avoid unnecessary #VEs.
- Warn and fail emulation if HLT #VE emulation executes with interrupts
  enabled.

Changes since v5:
1) Addressed Dave's comments.
2) Dropped the cleanup patch for now, it can be discussed separately.

v5: https://lore.kernel.org/lkml/20250220211628.1832258-1-vannapurve@google.com/

Kirill A. Shutemov (1):
  x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT

Vishal Annapurve (2):
  x86/tdx: Fix arch_safe_halt() execution for TDX VMs
  x86/tdx: Emit warning if IRQs are enabled during HLT #VE handling

 arch/x86/Kconfig                      |  1 +
 arch/x86/coco/tdx/tdx.c               | 34 ++++++++++++++++++++++-
 arch/x86/include/asm/irqflags.h       | 40 +++++++++++++++------------
 arch/x86/include/asm/paravirt.h       | 20 +++++++-------
 arch/x86/include/asm/paravirt_types.h |  3 +-
 arch/x86/include/asm/tdx.h            |  2 +-
 arch/x86/kernel/paravirt.c            | 14 ++++++----
 arch/x86/kernel/process.c             |  2 +-
 8 files changed, 77 insertions(+), 39 deletions(-)

-- 
2.48.1.658.g4767266eb4-goog


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-27 19:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25  0:47 [PATCH v6 0/3] x86/tdx: Fix HLT logic execution for TDX VMs Vishal Annapurve
2025-02-25  0:47 ` [PATCH v6 1/3] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT Vishal Annapurve
2025-02-25  6:44   ` Juergen Gross
2025-02-25  0:47 ` [PATCH v6 2/3] x86/tdx: Fix arch_safe_halt() execution for TDX VMs Vishal Annapurve
2025-02-26 11:49   ` Kirill A. Shutemov
2025-02-27 19:26     ` Vishal Annapurve
2025-02-27 16:19   ` kernel test robot
2025-02-27 19:30     ` Vishal Annapurve
2025-02-25  0:47 ` [PATCH v6 3/3] x86/tdx: Emit warning if IRQs are enabled during HLT #VE handling Vishal Annapurve

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.