Re: [PATCH 1/1] x86/tdx: Route safe halt execution via tdx_safe_halt
From: Vishal Annapurve
Date: Wed Jan 29 2025 - 13:36:33 EST
On Wed, Jan 29, 2025 at 6:00 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> ...
> >
> > I've asked (some time ago) TDX module folks to provide interruptibility
> > state as part of the guest so we can handle STI shadow properly, not as a
> > hack around HLT.
> >
> > The immediate problem can be addressed by fixing the BIOS to not advertise
> > C-states (if I read the situation right).
>
> No, something like Vishal proposed is a better fix. It's still desirable for the
> vCPU to call out to the hypervisor when going idle, otherwise a vCPU that is idle
> for an extended duration will never let the pCPU go idle.
I think Kirill's suggestion will ensure that cpuidle_idle_call() will
invoke default_idle_call() [1] which is correctly patched to call
tdx_safe_halt(), instead of using cpuidle driver subsystem. I am yet
to vet the ACPI cstate configuration for TDX VMs, but unless there is
something critically wrong with exposing cstates to the VM I think
it's better to handle acpi_safe_halt for TDX VMs.
Until there is a better solution to emulate the "sti; hlt;" behavior
for TDX VMs, it's important to deploy warnings as these scenarios are
easy to miss and hard to debug otherwise.
[1] https://elixir.bootlin.com/linux/v6.13/source//kernel/sched/idle.c#L182