Re: [PATCH v2] KVM: SEV: Mark nested locking of vcpu->mutex

From: Peter Gonda
Date: Thu Apr 07 2022 - 16:41:25 EST


On Wed, Apr 6, 2022 at 12:06 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Tue, Apr 05, 2022, Peter Gonda wrote:
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index 75fa6dd268f0..673e1ee2cfc9 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -1591,14 +1591,21 @@ static void sev_unlock_two_vms(struct kvm *dst_kvm, struct kvm *src_kvm)
> > atomic_set_release(&src_sev->migration_in_progress, 0);
> > }
> >
> > +#define SEV_MIGRATION_SOURCE 0
> > +#define SEV_MIGRATION_TARGET 1
> >
> > -static int sev_lock_vcpus_for_migration(struct kvm *kvm)
> > +/*
> > + * To avoid lockdep warnings callers should pass @vm argument with either
>
> I think it's important to call that these are false positives, saying "avoid
> lockdep warnings" suggests we're intentionally not fixing bugs :-)
>
> > + * SEV_MIGRATION_SOURCE or SEV_MIGRATE_TARGET. This allows subclassing of all
> > + * vCPU mutex locks.
> > + */
>
> If we use an enum, that'll make the param self-documenting. And we can also use
> that to eliminate the remaining magic number '2'. E.g. this as fixup.

Sounds good. I took this fixup into the V3. Thanks.