Re: [PATCH v3 13/27] KVM: nSVM: Add a placeholder ASID for L2

From: Jim Mattson

Date: Thu Oct 15 2026 - 18:22:12 EST


On Thu, Oct 15, 2026 at 3:10 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
>
> On Thu, Oct 15, 2026 at 2:55 PM Jim Mattson <jmattson@xxxxxxxxxx> wrote:
> >
> > On Mon, Oct 12, 2026 at 4:36 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
> > >
> > > In preparation for introducing a separate ASID for L2, introduce a
> > > 'placeholder' ASID that is still the same as L1's ASID. This will
> > > facilitate future changes that need to distinguish L1 and L2's ASIDs,
> > > before actually using a different ASID for L1 and L2.
> > >
> > > On SEV VM migration, copy the new SEV ASID into asid02 and vmcb02, in
> > > case nested was already initialized on the destination vCPU before
> > > migration.
> > >
> > > No functional change intended.
> > >
> > > Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> > > ---
> > > arch/x86/kvm/svm/nested.c | 5 +++--
> > > arch/x86/kvm/svm/sev.c | 9 +++++++++
> > > arch/x86/kvm/svm/svm.h | 2 ++
> > > 3 files changed, 14 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> > > index bfb297b7d71ab..780132725bb79 100644
> > > --- a/arch/x86/kvm/svm/nested.c
> > > +++ b/arch/x86/kvm/svm/nested.c
> > > @@ -701,7 +701,6 @@ static void nested_svm_transition_tlb_flush(struct kvm_vcpu *vcpu)
> > > * - Honor L1's request to flush an ASID on nested VMRUN
> > > * - Sync nested NPT MMU on VMRUN that flushes L2's ASID[*]
> > > * - Don't crush a pending TLB flush in vmcb02 on nested VMRUN
> > > - * - Flush L1's ASID on KVM_REQ_TLB_FLUSH_GUEST
> >
> > Um...How does this patch either do this TODO or render it moot?
>
> L1 now has a separate ASID from L2, and it's the one we're already
> flushing with KVM_REQ_TLB_FLUSH_GUEST. It's kinda already moot because
> we already flush L1's ASID on KVM_REQ_TLB_FLUSH_GUEST.. or maybe it's
> actually *wrong* because KVM_REQ_TLB_FLUSH_GUEST needs to flush the
> current ASID, not always L1's ASID.
>
> I can drop it separately if that helps.

You could just explain it in the commit message.