Re: [PATCH v7 4/9] mmu: spp: Add functions to create/destroy SPP bitmap block

From: Yang Weijiang
Date: Thu Nov 21 2019 - 09:43:36 EST


On Thu, Nov 21, 2019 at 11:43:10AM +0100, Paolo Bonzini wrote:
> On 19/11/19 09:49, Yang Weijiang wrote:
> >
> > +/*
> > + * all vcpus share the same SPPT, vcpu->arch.mmu->sppt_root points to same
> > + * SPPT root page, so any vcpu will do.
> > + */
> > +static struct kvm_vcpu *kvm_spp_get_vcpu(struct kvm *kvm)
> > +{
> > + struct kvm_vcpu *vcpu = NULL;
> > + int idx;
>
> Is this true? Perhaps you need one with
> VALID_PAGE(vcpu->arch.mmu->sppt_root) for kvm_spp_set_permission?
>
Yes, I'd like to keep single sppt_root, thank you!

> Also, since vcpu->arch.mmu->sppt_root is the same for all vCPUs, perhaps
> it should be kvm->arch.sppt_root instead?
>
Sure, make sense, will change it.

> If you can get rid of this function, it would be much better (but if you
> cannot, kvm_get_vcpu(kvm, 0) should give the same result).
>
Great, I was not sure if such usage is correct. Thanks.

> >
> > + if (npages > SUBPAGE_MAX_BITMAP)
> > + return -EFAULT;
>
> This is not needed here, the restriction only applies to the ioctl.
>
OK.
> Paolo