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?

> +             return -EINVAL;
> +     }
> +
> +     mutex_unlock(&kvm->lock);
> +     return r;
> +}
> 

Regards
Dong Aisheng

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to