Skip to content

x86/tdx: Fix HLT logic execution for TDX VMs

Vishal Annapurve linux-coco lkml stable virtualization 7 versions – Applied

Status from this message: The following commit has been merged into the x86/tdx branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest3 patches 2 repliesApplied
  2. v63 patches 4 repliesSuperseded
  3. v54 patches 6 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v44 patches4 repliesSuperseded
v32 patches6 repliesSuperseded
v21 patch15 repliesSuperseded
v11 patch8 repliesSuperseded

Changes in v7 from the cover letter

1) Addressed Kirills's comments.
2) Fixed a build failure.

Patches in v7 Applied

#Subject and filesSizeRepliesApplied
1/3x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRTarch/x86/include/asm/irqflags.h arch/x86/include/asm/paravirt.h arch/x86/include/asm/paravirt_types.h +1 more+41 -360 replies
2/3x86/tdx: Fix arch_safe_halt() execution for TDX VMsarch/x86/Kconfig arch/x86/coco/tdx/tdx.c arch/x86/include/asm/tdx.h +1 more+29 -40 replies
3/3x86/tdx: Emit warning if IRQs are enabled during HLT #VE handlingarch/x86/coco/tdx/tdx.c+8 -00 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchAndi KleenTony LuckJuergen GrossKirill A. ShutemovRyan Afranji
SeriesT-b
1/3R-b R-b R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v7 thread

Cover letter [PATCH v7 0/3] x86/tdx: Fix HLT logic execution for TDX VMs

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 v6:
1) Addressed Kirills's comments.
2) Fixed a build failure.

v6: https://lore.kernel.org/lkml/[email protected]/

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            |  4 +--
 arch/x86/kernel/paravirt.c            | 14 ++++++----
 arch/x86/kernel/process.c             |  2 +-
 8 files changed, 78 insertions(+), 40 deletions(-)
Signature · 1 line
2.48.1.711.g2feabab25a-goog