Re: [PATCH 2/4] x86/virt/tdx: Pull kexec cache flush logic into arch/x86
From: Edgecombe, Rick P
Date: Mon Mar 09 2026 - 12:23:57 EST
On Mon, 2026-03-09 at 00:23 +0000, Huang, Kai wrote:
> Feel free to add:
>
> Acked-by: Kai Huang <kai.huang@xxxxxxxxx>
>
> Btw, there's a functional change here, and perhaps we should call out
> in changelog:
Yea that makes sense.
>
> - Currently tdx_cpu_flush_cache_for_kexec() is done in
> kvm_disable_virtualization_cpu(), which is also called by KVM's CPUHP
> offline() callback. So tdx_cpu_flush_cache_for_kexec() is explicitly
> done in TDX code in CPU offline.
>
> - With this change, tdx_cpu_flush_cache_for_kexec() is not explicitly
> done in TDX code in CPU offline.
>
> But AFAICT this is fine, since IIUC the WBINVD is always done when
> kernel offlines one CPU (see [*]), i.e., the current
> tdx_cpu_flush_cache_for_kexec() done in KVM's CPUHP is actually
> superfluous.
>
> [*] See:
>
> native_play_dead() ->
> cpuidle_play_dead();
>
> hlt_play_dead();
>
> cpuidle_play_dead() can invoke different enter_dead() callbacks
> depending on what idle driver is being used, but AFAICT eventually it
> ends up calling either acpi_idle_play_dead() or mwait_play_dead(),
> both of which does WBINVD before going to idle.
>
> If cpuidle_play_dead() doesn't idle successfully, the hlt_play_dead()
> will then WBINVD and hlt.
>
> Actually, after looking at multiple commits around here, e.g.,
>
> ea53069231f93 ("x86, hotplug: Use mwait to offline a processor, fix
> the legacy case")
> dfbba2518aac4 ("Revert "ACPI: processor: idle: Only flush cache on
> entering C3")
>
> ... I believe it's a kernel policy to make sure cache is flushed when
> it offlines a CPU (which makes sense anyway of course), I just
> couldn't find the exact commit saying this (or I am not sure whether
> there's such commit).
>
>
Thanks for the analysis.
> Btw2, kinda related to this, could you help review:
>
> https://lore.kernel.org/lkml/20260302102226.7459-1-kai.huang@xxxxxxxxx/
Well I think I wrote the log for it. But I yea I'll add a tag.