[PATCH v2 4/4] KVM: arm64: Use config_lock to protect vgic state
Oliver Upton
oliver.upton at linux.dev
Thu Mar 23 12:18:05 PDT 2023
On Wed, Mar 22, 2023 at 12:02:15PM +0000, Marc Zyngier wrote:
> On Thu, 16 Mar 2023 21:14:12 +0000,
> Oliver Upton <oliver.upton at linux.dev> wrote:
[...]
> > --- a/arch/arm64/kvm/vgic/vgic-its.c
> > +++ b/arch/arm64/kvm/vgic/vgic-its.c
> > @@ -2043,7 +2043,10 @@ static int vgic_its_attr_regs_access(struct kvm_device *dev,
> > if (offset & align)
> > return -EINVAL;
> >
> > - mutex_lock(&dev->kvm->lock);
> > + if (!lock_all_vcpus(dev->kvm))
> > + return -EBUSY;
> > +
> > + mutex_lock(&dev->kvm->arch.config_lock);
>
> Huh, that's fishy. The whole "lock the VM and the lock the individual
> vcpus" is there to prevent a concurrent creation of a vcpu while we're
> doing stuff that affects them all. Allowing a new vcpu to come online
> while this sequence is happening is ... unexpected.
>
> Why do we need to drop this initial lock? I'd expect them to be
> completely cumulative.
Urgh.. Yes, you're right. I'll go with kvm->lock -> lock_all_vcpus() ->
kvm->config_lock in the next spin to guard against the vCPU creation
race.
--
Thanks,
Oliver
More information about the linux-arm-kernel
mailing list