All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Vishal Annapurve <vannapurve@google.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	linux-coco@lists.linux.dev, virtualization@lists.linux.dev
Cc: pbonzini@redhat.com, seanjc@google.com, erdemaktas@google.com,
	ackerleytng@google.com, jxgao@google.com, sagis@google.com,
	oupton@google.com, pgonda@google.com, kirill@shutemov.name,
	dave.hansen@linux.intel.com, chao.p.peng@linux.intel.com,
	isaku.yamahata@gmail.com,
	sathyanarayanan.kuppuswamy@linux.intel.com, jgross@suse.com,
	ajay.kaher@broadcom.com, alexey.amakhalov@broadcom.com,
	stable@vger.kernel.org
Subject: Re: [PATCH V5 2/4] x86/tdx: Route safe halt execution via tdx_safe_halt()
Date: Thu, 20 Feb 2025 15:00:43 -0800	[thread overview]
Message-ID: <9053a4ef-2de6-47b4-a2f7-62d3ded24cfa@intel.com> (raw)
In-Reply-To: <20250220211628.1832258-3-vannapurve@google.com>

On 2/20/25 13:16, Vishal Annapurve wrote:
> 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.

This isn't quite true. There's only one paravirt safe_halt() and it
doesn't do HLT or STI.

I think it's more true to say that "safe" halts are entered with IRQs
disabled. They logically do the halt operation and then enable
interrupts before returning.

> So "sti;hlt" sequence needs to be replaced for TDX VMs with "TDCALL;
> *_irq_enable()" to keep interrupts disabled during TDCALL execution.
But this isn't new. TDX already tried to avoid "sti;hlt". It just
screwed up the implementation.

> Commit bfe6ed0c6727 ("x86/tdx: Add HLT support for TDX guests")
> prevented the idle routines from using "sti;hlt". 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()

This, on the other hand, *is* important.

> Modify tdx_safe_halt() to implement the sequence "TDCALL;
> raw_local_irq_enable()" and invoke tdx_halt() from idle routine which just
> executes TDCALL without toggling interrupt state. Introduce dependency
> on CONFIG_PARAVIRT and override paravirt halt()/safe_halt() routines for
> TDX VMs.

This changelog glosses over one of the key points: Why *MUST* TDX use
paravirt? It further confuses the reasoning by alluding to the idea that
"Direct HLT instruction execution ... is routed to hypervisor via TDCALL".

It gives background and a solution, but it's not obvious what the
problem is or how the solution _fixes_ the problem.

What must TDX now depend on PARAVIRT?

Why not just route the HLT to a TDXCALL via the #VE code?



  reply	other threads:[~2025-02-20 23:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20 21:16 [PATCH V5 0/4] x86/tdx: Fix HLT logic execution for TDX VMs Vishal Annapurve
2025-02-20 21:16 ` [PATCH V5 1/4] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT Vishal Annapurve
2025-02-20 21:47   ` Dave Hansen
2025-02-20 23:17     ` Vishal Annapurve
2025-02-28 21:47   ` Konrad Rzeszutek Wilk
2025-03-03  9:54     ` Jürgen Groß
2025-02-20 21:16 ` [PATCH V5 2/4] x86/tdx: Route safe halt execution via tdx_safe_halt() Vishal Annapurve
2025-02-20 23:00   ` Dave Hansen [this message]
2025-02-20 23:51     ` Vishal Annapurve
2025-02-20 21:16 ` [PATCH V5 3/4] x86/tdx: Emit warning if IRQs are enabled during HLT #VE handling Vishal Annapurve
2025-02-20 21:16 ` [PATCH V5 4/4] x86/tdx: Remove TDX specific idle routine Vishal Annapurve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9053a4ef-2de6-47b4-a2f7-62d3ded24cfa@intel.com \
    --to=dave.hansen@intel.com \
    --cc=ackerleytng@google.com \
    --cc=ajay.kaher@broadcom.com \
    --cc=alexey.amakhalov@broadcom.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=erdemaktas@google.com \
    --cc=isaku.yamahata@gmail.com \
    --cc=jgross@suse.com \
    --cc=jxgao@google.com \
    --cc=kirill@shutemov.name \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=sagis@google.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=stable@vger.kernel.org \
    --cc=vannapurve@google.com \
    --cc=virtualization@lists.linux.dev \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.