[PATCH v4 05/13] ARM: KVM: VGIC accept vcpu and dist base addresses from user space

Christoffer Dall c.dall at virtualopensystems.com
Tue Nov 13 08:35:01 EST 2012


On Mon, Nov 12, 2012 at 3:56 AM, Dong Aisheng <b29396 at freescale.com> wrote:
> On Sat, Nov 10, 2012 at 04:44:51PM +0100, Christoffer Dall wrote:
> [...]
>> +int kvm_vgic_set_addr(struct kvm *kvm, unsigned long type, u64 addr)
>> +{
>> +     int r = 0;
>> +     struct vgic_dist *vgic = &kvm->arch.vgic;
>> +
>> +     if (addr & ~KVM_PHYS_MASK)
>> +             return -E2BIG;
>> +
>> +     if (addr & ~PAGE_MASK)
>> +             return -EINVAL;
>> +
>> +     mutex_lock(&kvm->lock);
>> +     switch (type) {
>> +     case KVM_VGIC_V2_ADDR_TYPE_DIST:
>> +             if (!IS_VGIC_ADDR_UNDEF(vgic->vgic_dist_base))
>> +                     return -EEXIST;
>> +             if (addr + VGIC_DIST_SIZE < addr)
>> +                     return -EINVAL;
>> +             kvm->arch.vgic.vgic_dist_base = addr;
>> +             break;
>> +     case KVM_VGIC_V2_ADDR_TYPE_CPU:
>> +             if (!IS_VGIC_ADDR_UNDEF(vgic->vgic_cpu_base))
>> +                     return -EEXIST;
>> +             if (addr + VGIC_CPU_SIZE < addr)
>> +                     return -EINVAL;
>> +             kvm->arch.vgic.vgic_cpu_base = addr;
>> +             break;
>> +     default:
>> +             r = -ENODEV;
>> +     }
>> +
>> +     if (vgic_ioaddr_overlap(kvm)) {
>> +             kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF;
>> +             kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
>
> Missing mutex_unlock?

indeed, should be r = -EINVAL.

nice catch!



More information about the linux-arm-kernel mailing list