This patch prevents user-space from changing VGIC base addresses
if the vgic already is initialized.

Signed-off-by: Eric Auger <[email protected]>
---
 Documentation/virtual/kvm/devices/arm-vgic.txt | 2 ++
 virt/kvm/arm/vgic.c                            | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/Documentation/virtual/kvm/devices/arm-vgic.txt 
b/Documentation/virtual/kvm/devices/arm-vgic.txt
index 30f5427..8492715 100644
--- a/Documentation/virtual/kvm/devices/arm-vgic.txt
+++ b/Documentation/virtual/kvm/devices/arm-vgic.txt
@@ -19,6 +19,8 @@ Groups:
     KVM_VGIC_V2_ADDR_TYPE_CPU (rw, 64-bit)
       Base address in the guest physical address space of the GIC virtual cpu
       interface register mappings.
+  Errors:
+    -EBUSY: VGIC already is initialized
 
   KVM_DEV_ARM_VGIC_GRP_DIST_REGS
   Attributes:
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 89dca86..652e0bb 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -2427,6 +2427,9 @@ static int vgic_set_attr(struct kvm_device *dev, struct 
kvm_device_attr *attr)
                u64 addr;
                unsigned long type = (unsigned long)attr->attr;
 
+               if (vgic_initialized(dev->kvm))
+                       return -EBUSY;
+
                if (copy_from_user(&addr, uaddr, sizeof(addr)))
                        return -EFAULT;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to