KVM: arm64: vgic-its: KVM_DEV_ARM_VGIC_GRP_ITS_REGS group
authorEric Auger <eric.auger@redhat.com>
Tue, 20 Dec 2016 06:36:35 +0000 (01:36 -0500)
committerChristoffer Dall <cdall@linaro.org>
Mon, 8 May 2017 12:33:08 +0000 (14:33 +0200)
The ITS KVM device exposes a new KVM_DEV_ARM_VGIC_GRP_ITS_REGS
group which allows the userspace to save/restore ITS registers.

At this stage the get/set/has operations are not yet implemented.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Christoffer Dall <cdall@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm/include/uapi/asm/kvm.h
arch/arm64/include/uapi/asm/kvm.h
virt/kvm/arm/vgic/vgic-its.c

index a5838d605e7b0dbb4450625a49bdfc5d57bf8267..ee183fcd1c82944b84d08bf0871d656f47de651a 100644 (file)
@@ -194,6 +194,7 @@ struct kvm_arch_memory_slot {
 #define KVM_DEV_ARM_VGIC_GRP_REDIST_REGS 5
 #define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6
 #define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO  7
+#define KVM_DEV_ARM_VGIC_GRP_ITS_REGS  8
 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10
 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \
                        (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT)
index cd6bea495e637d21b6cf2d6b642993d7005fe3c4..ee4a0ad44359dbc9cb17aa2aae9580dc43313d5d 100644 (file)
@@ -214,6 +214,7 @@ struct kvm_arch_memory_slot {
 #define KVM_DEV_ARM_VGIC_GRP_REDIST_REGS 5
 #define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6
 #define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO  7
+#define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8
 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10
 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \
                        (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT)
index 3ffcbbe97523f618c9eb8e534cc5db9c8eb0fead..f687e91741f0c59467c674216a7700d37829470e 100644 (file)
@@ -1466,6 +1466,19 @@ static void vgic_its_destroy(struct kvm_device *kvm_dev)
        kfree(its);
 }
 
+int vgic_its_has_attr_regs(struct kvm_device *dev,
+                          struct kvm_device_attr *attr)
+{
+       return -ENXIO;
+}
+
+int vgic_its_attr_regs_access(struct kvm_device *dev,
+                             struct kvm_device_attr *attr,
+                             u64 *reg, bool is_write)
+{
+       return -ENXIO;
+}
+
 static int vgic_its_has_attr(struct kvm_device *dev,
                             struct kvm_device_attr *attr)
 {
@@ -1482,6 +1495,8 @@ static int vgic_its_has_attr(struct kvm_device *dev,
                        return 0;
                }
                break;
+       case KVM_DEV_ARM_VGIC_GRP_ITS_REGS:
+               return vgic_its_has_attr_regs(dev, attr);
        }
        return -ENXIO;
 }
@@ -1521,6 +1536,15 @@ static int vgic_its_set_attr(struct kvm_device *dev,
                        return 0;
                }
                break;
+       case KVM_DEV_ARM_VGIC_GRP_ITS_REGS: {
+               u64 __user *uaddr = (u64 __user *)(long)attr->addr;
+               u64 reg;
+
+               if (get_user(reg, uaddr))
+                       return -EFAULT;
+
+               return vgic_its_attr_regs_access(dev, attr, &reg, true);
+       }
        }
        return -ENXIO;
 }
@@ -1541,10 +1565,20 @@ static int vgic_its_get_attr(struct kvm_device *dev,
                if (copy_to_user(uaddr, &addr, sizeof(addr)))
                        return -EFAULT;
                break;
+       }
+       case KVM_DEV_ARM_VGIC_GRP_ITS_REGS: {
+               u64 __user *uaddr = (u64 __user *)(long)attr->addr;
+               u64 reg;
+               int ret;
+
+               ret = vgic_its_attr_regs_access(dev, attr, &reg, false);
+               if (ret)
+                       return ret;
+               return put_user(reg, uaddr);
+       }
        default:
                return -ENXIO;
        }
-       }
 
        return 0;
 }