Re: [PATCH 3/4] KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"

From: Edgecombe, Rick P

Date: Fri Aug 07 2026 - 16:39:27 EST


On Thu, 2026-08-06 at 14:40 -0700, Sean Christopherson wrote:
> When mapping a private PFN in TDX's post-populate callback, top-up the
> memory caches on every attempt to map the PFN to harden against bugs in the
> map flow that could consume cache entries even if mapping ultimately fails.
> E.g. as pointed out by Sashiko, the in-progress Dynamic PAMT support could
> consume PAMT cache entries on TDX-Module lock contention.

I think it is the same for the other caches consumed by the fault. I guess
"e.g." covers it. But it's not new after DPAMT.

>
> Harden KVM even though consuming an entry on failure is considered a KVM
> bug, as retry is uncommon
>

The locks held by the sole call path will prevent retries from being needed due
to TDX-specific details. So in the place where this code lives, it is a bug. But
can't really be hit. To me "retry is uncommon" sounds like it's a rare case that
is hittable. I guess you mean only in the uncommon case of bugs.

> , top-up is "free" if there's no work to be done,
> and populating a TDX guest's memory is a slow path, i.e. there's no
> meaningful downside to the hardening.
>
> Reported-by: Sashiko Bot <sashiko-bot@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/20260718061050.E17B01F000E9@xxxxxxxxxxxxxxx
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---

Thanks! And...

Reviewed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>