Re: [PATCH v3 25/27] KVM: nSVM: Flush the ASID on nested transitions if shared by L1 and L2

From: Jim Mattson

Date: Thu Oct 15 2026 - 19:42:35 EST


On Mon, Oct 12, 2026 at 4:36 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
>
> If L1 and L2 use the same ASID in hardware, always flush it on nested
> transitions to avoid using L1 TLB entries for L2 or vice versa, since
> from L1's perspective they are two different TLB domains.
>
> This is currently always the case, but KVM will start using separate
> ASIDs for L1 and L2 in most cases soon.
>
> Note that KVM_REQ_TLB_FLUSH_CURRENT is required here, not
> KVM_REQ_TLB_FLUSH_GUEST (used for L1 TLB flush requests). This is
> because KVM could be switching between different NPT roots on the same
> ASID. While this generally requires an ASID flush in the VMCB, which is
> done by both KVM_REQ_TLB_FLUSH_CURRENT and KVM_REQ_TLB_FLUSH_GUEST, it
> also requires a hypercall to specifically flush NPT mappings when
> running on Hyper-V, which is only done with KVM_REQ_TLB_FLUSH_CURRENT
> (as KVM_REQ_TLB_FLUSH_GUEST is only meant to flush translations created
> by the guest).
>
> Note that this is currently a noop as KVM requests
> KVM_REQ_TLB_FLUSH_CURRENT unconditionally on nested transitions, but
> this will soon be removed in favor of conditional flushes.
>
> Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>