Re: [PATCH 2/3] KVM: x86/pmu: Always defer PMU reprogramming on SVM nested transitions
From: Yosry Ahmed
Date: Wed Dec 02 2026 - 00:17:10 EST
> > > I strongly prefer we fix the immediate SRCU issue and then do the more agressive
> > > cleanup. I don't want to get into a game of whack-a-mole with stable@ backports,
> > > e.g. if it turns out there's a flaw with always deferring updates.
> >
> > Yeah I figured you might prefer this (and called it out in the cover
> > letter).
> >
> > >
> > > IIUC, it would be this?
> >
> > Actually what I had was more localized, in kvm_pmu_handle_event(). It's
> > consistent with kvm_pmu_trigger_event(), and avoids hiding other bugs.
>
> Well, kvm_pmu_trigger_event() is very different, as it's used from the fastpath
> run loop and we explicitly want to support that. For kvm_pmu_handle_event(),
> its caller(s) really should acquire SCRU.
>
> I'm not opposed to a more precise fix, though if we go that route, I'd vote to
> make it *extremely* precise, e.g. put it in svm_leave_nested() or something.
>
> > I think we generally don't want to hold the SRCU read lock more than
> > needed?
>
> Eh, only if we care about letting flows run in parallel. I suppose it's possible
> userspace would configure memslots and/or I/O buses concurrently with restoring
> vCPU state, but I doubt it's a high priority.
>
> > I can add this as patch #1 in the series for a stable fix, not sure if
> > you'd prefer that we keep it anyway or revert it later in the series:
>
> If we go with a precise fix, revert it. If we smack all of KVM_SET_SREGS, leave
> it there.
I will take your KVM_SET_SREGS patch (and add your SoB), I tested it
and wrote a changelog for it.