Re: [PATCH v8 07/11] x86/tdx: Add HLT support for TDX guest

From: Josh Poimboeuf
Date: Wed Oct 06 2021 - 15:17:24 EST


On Mon, Oct 04, 2021 at 07:52:01PM -0700, Kuppuswamy Sathyanarayanan wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>
> + * Emulate HLT operation via hypercall. More info about ABI
> + * can be found in TDX Guest-Host-Communication Interface
> + * (GHCI), sec 3.8 TDG.VP.VMCALL<Instruction.HLT>.
> + *
> + * The VMM uses the "IRQ disabled" param to understand IRQ
> + * enabled status (RFLAGS.IF) of TD guest and determine
> + * whether or not it should schedule the halted vCPU if an
> + * IRQ becomes pending. E.g. if IRQs are disabled the VMM
> + * can keep the vCPU in virtual HLT, even if an IRQ is
> + * pending, without hanging/breaking the guest.
> + *
> + * do_sti parameter is used by __tdx_hypercall() to decide
> + * whether to call STI instruction before executing TDCALL
> + * instruction.
> + */
> + ret = _tdx_hypercall(EXIT_REASON_HLT, irq_disabled, 0, 0, do_sti, NULL);
> +
> + /*
> + * Use WARN_ONCE() to report the failure. Since tdx_*halt() calls
> + * are also used in pv_ops, #VE error handler cannot be used to
> + * report the failure.
> + */
> + WARN_ONCE(ret, "HLT instruction emulation failed\n");

I'm having trouble following this last comment, does it mean there's no
way to return the error back to the #VE handler when this is called in
#VE context? Seems like that would be any easy problem to solve by
shuffling the functions a bit.

--
Josh