[bug-fix] The check overlap action about set GICD/GICC base addr is wrong .

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I use the kernel:
	https://github.com/virtualopensystems/linux-kvm-arm.git
	branch:  kvm-arm-master.

There is the wrong code logic, because the check action will not be execute.
That is, When qemu regist the GICD $ the GICC the same base address, this
action will be success.

	/* the code will not be execute*/
        if ((dist <= cpu && dist + KVM_VGIC_V2_DIST_SIZE > cpu) ||
            (cpu <= dist && cpu + KVM_VGIC_V2_CPU_SIZE > dist))
                return -EBUSY;

Follow the code, in vgic_ioaddr_assign function, there will be check :
   	if (!IS_VGIC_ADDR_UNDEF(*ioaddr))
                return -EEXIST;
If the base address(whatever GICD or GICC) is already set, there be return.

And if the base address is not set, the follow to call the vgic_ioaddr_overlap
function, and in vgic_ioaddr_overlap function, the check will be return 0
(success).

        if (IS_VGIC_ADDR_UNDEF(dist) || IS_VGIC_ADDR_UNDEF(cpu))
                return 0;

So as above said,  the check action will not be execute for ever.

Here is the patch :

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 176b59c..bde2531 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1667,10 +1667,13 @@ static int vgic_ioaddr_assign(struct kvm *kvm, phys_addr_t *ioaddr,
        if (addr + size < addr)
                return -EINVAL;

+       *ioaddr = addr;
        ret = vgic_ioaddr_overlap(kvm);
-       if (ret)
+       if (ret){
+               *ioaddr = VGIC_ADDR_UNDEF;
                return ret;
-       *ioaddr = addr;
+       }
+
        return ret;
 }

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux