On Wed, Feb 26, 2025 at 3:49 AM Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote: > > On Tue, Feb 25, 2025 at 12:47:03AM +0000, Vishal Annapurve wrote: > > Direct HLT instruction execution causes #VEs for TDX VMs which is routed > > to hypervisor via TDCALL. If HLT is executed in STI-shadow, resulting #VE > > handler will enable interrupts before TDCALL is routed to hypervisor > > leading to missed wakeup events. > > > > Current TDX spec doesn't expose interruptibility state information to > > allow #VE handler to selectively enable interrupts. To bypass this > > issue, TDX VMs need to replace "sti;hlt" execution with direct TDCALL > > followed by explicit interrupt flag update. > > > > Commit bfe6ed0c6727 ("x86/tdx: Add HLT support for TDX guests") > > prevented the idle routines from executing HLT instruction in STI-shadow. > > But it missed the paravirt routine which can be reached like this as an > > example: > > acpi_safe_halt() => > > raw_safe_halt() => > > arch_safe_halt() => > > irq.safe_halt() => > > pv_native_safe_halt() > > I would rather use paravirt spinlock example. It is less controversial. > I still see no point in ACPI cpuidle be a thing in TDX guests. > I will modify the description to include a paravirt spinlock example. > > > > To reliably handle arch_safe_halt() for TDX VMs, introduce explicit > > dependency on CONFIG_PARAVIRT and override paravirt halt()/safe_halt() > > routines with TDX-safe versions that execute direct TDCALL and needed > > interrupt flag updates. Executing direct TDCALL brings in additional > > benefit of avoiding HLT related #VEs altogether. > > > > Cc: stable@xxxxxxxxxxxxxxx > > Fixes: bfe6ed0c6727 ("x86/tdx: Add HLT support for TDX guests") > > Signed-off-by: Vishal Annapurve <vannapurve@xxxxxxxxxx> > > Reviewed-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > > -- > Kiryl Shutsemau / Kirill A. Shutemov