KVM: arm/arm64: vgic: add init entry to VGIC KVM device
authorEric Auger <eric.auger@linaro.org>
Mon, 15 Dec 2014 17:43:33 +0000 (18:43 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Sun, 11 Jan 2015 13:12:15 +0000 (14:12 +0100)
Since the advent of VGIC dynamic initialization, this latter is
initialized quite late on the first vcpu run or "on-demand", when
injecting an IRQ or when the guest sets its registers.

This initialization could be initiated explicitly much earlier
by the users-space, as soon as it has provided the requested
dimensioning parameters.

This patch adds a new entry to the VGIC KVM device that allows
the user to manually request the VGIC init:
- a new KVM_DEV_ARM_VGIC_GRP_CTRL group is introduced.
- Its first attribute is KVM_DEV_ARM_VGIC_CTRL_INIT

The rationale behind introducing a group is to be able to add other
controls later on, if needed.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Documentation/virtual/kvm/devices/arm-vgic.txt
arch/arm/include/uapi/asm/kvm.h
arch/arm64/include/uapi/asm/kvm.h
virt/kvm/arm/vgic.c

index df8b0c7540b67e415bd798b3eaf3996d511ddfd3..30f5427cf9b0b873756bb7c539bff64eb410d6e4 100644 (file)
@@ -81,3 +81,14 @@ Groups:
     -EINVAL: Value set is out of the expected range
     -EBUSY: Value has already be set, or GIC has already been initialized
             with default values.
+
+  KVM_DEV_ARM_VGIC_GRP_CTRL
+  Attributes:
+    KVM_DEV_ARM_VGIC_CTRL_INIT
+      request the initialization of the VGIC, no additional parameter in
+      kvm_device_attr.addr.
+  Errors:
+    -ENXIO: VGIC not properly configured as required prior to calling
+     this attribute
+    -ENODEV: no online VCPU
+    -ENOMEM: memory shortage when allocating vgic internal data
index 09ee408c1a67621e9c052e53492b61ef308de6f8..0db25bc328643de55ded82f3b9583a748038d97d 100644 (file)
@@ -175,6 +175,8 @@ struct kvm_arch_memory_slot {
 #define   KVM_DEV_ARM_VGIC_OFFSET_SHIFT        0
 #define   KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS   3
+#define KVM_DEV_ARM_VGIC_GRP_CTRL       4
+#define   KVM_DEV_ARM_VGIC_CTRL_INIT    0
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT         24
index 8e38878c87c61dc9145f8950e5b977ee081886d0..480af346106873016d6c0db67052733e241bebb5 100644 (file)
@@ -161,6 +161,8 @@ struct kvm_arch_memory_slot {
 #define   KVM_DEV_ARM_VGIC_OFFSET_SHIFT        0
 #define   KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS   3
+#define KVM_DEV_ARM_VGIC_GRP_CTRL      4
+#define   KVM_DEV_ARM_VGIC_CTRL_INIT   0
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT         24
index b8d57e86cfdc3e020616de013aa47c1a8e8ac096..c84f53dfcd621faa082416048101ec384d5bff7b 100644 (file)
@@ -2302,7 +2302,14 @@ static int vgic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
 
                return ret;
        }
-
+       case KVM_DEV_ARM_VGIC_GRP_CTRL: {
+               switch (attr->attr) {
+               case KVM_DEV_ARM_VGIC_CTRL_INIT:
+                       r = vgic_init(dev->kvm);
+                       return r;
+               }
+               break;
+       }
        }
 
        return -ENXIO;
@@ -2381,6 +2388,11 @@ static int vgic_has_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
                return vgic_has_attr_regs(vgic_cpu_ranges, offset);
        case KVM_DEV_ARM_VGIC_GRP_NR_IRQS:
                return 0;
+       case KVM_DEV_ARM_VGIC_GRP_CTRL:
+               switch (attr->attr) {
+               case KVM_DEV_ARM_VGIC_CTRL_INIT:
+                       return 0;
+               }
        }
        return -ENXIO;
 }