ARM: KVM: Support vGICv3 ITS
authorVladimir Murzin <vladimir.murzin@arm.com>
Wed, 2 Nov 2016 11:55:34 +0000 (11:55 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 14 Nov 2016 10:32:54 +0000 (10:32 +0000)
This patch allows to build and use vGICv3 ITS in 32-bit mode.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Documentation/virtual/kvm/api.txt
arch/arm/include/uapi/asm/kvm.h
arch/arm/kvm/Kconfig
arch/arm/kvm/Makefile
arch/arm/kvm/arm.c
arch/arm64/kvm/Kconfig
arch/arm64/kvm/reset.c
virt/kvm/arm/vgic/vgic-kvm-device.c
virt/kvm/arm/vgic/vgic-mmio-v3.c
virt/kvm/arm/vgic/vgic.h

index 739db9ab16b2c973b8a348dcbe657a0c9004e227..2feeae6a4c3f594aee378d80ace0369211df49b0 100644 (file)
@@ -2198,7 +2198,7 @@ after pausing the vcpu, but before it is resumed.
 4.71 KVM_SIGNAL_MSI
 
 Capability: KVM_CAP_SIGNAL_MSI
-Architectures: x86 arm64
+Architectures: x86 arm arm64
 Type: vm ioctl
 Parameters: struct kvm_msi (in)
 Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error
index b38c10c73579ef843dcc938028af96b432901ab6..af05f8e0903e27baccddc00748bf0f75820c9d3d 100644 (file)
@@ -87,9 +87,11 @@ struct kvm_regs {
 /* Supported VGICv3 address types  */
 #define KVM_VGIC_V3_ADDR_TYPE_DIST     2
 #define KVM_VGIC_V3_ADDR_TYPE_REDIST   3
+#define KVM_VGIC_ITS_ADDR_TYPE         4
 
 #define KVM_VGIC_V3_DIST_SIZE          SZ_64K
 #define KVM_VGIC_V3_REDIST_SIZE                (2 * SZ_64K)
+#define KVM_VGIC_V3_ITS_SIZE           (2 * SZ_64K)
 
 #define KVM_ARM_VCPU_POWER_OFF         0 /* CPU is started in OFF state */
 #define KVM_ARM_VCPU_PSCI_0_2          1 /* CPU uses PSCI v0.2 */
index 3e1cd0452d67b0eb761b39fb5094a1efdae183ed..90d0176fb30d3f7e7c5359d5ad084c373bd457e3 100644 (file)
@@ -34,6 +34,7 @@ config KVM
        select HAVE_KVM_IRQFD
        select HAVE_KVM_IRQCHIP
        select HAVE_KVM_IRQ_ROUTING
+       select HAVE_KVM_MSI
        depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
        ---help---
          Support hosting virtualized guest machines.
index f19842ea5418d44b646e432ac59fd245462b206b..d571243ab4d186aba20a12a0d0b076bad58e0cb5 100644 (file)
@@ -32,5 +32,6 @@ obj-y += $(KVM)/arm/vgic/vgic-mmio.o
 obj-y += $(KVM)/arm/vgic/vgic-mmio-v2.o
 obj-y += $(KVM)/arm/vgic/vgic-mmio-v3.o
 obj-y += $(KVM)/arm/vgic/vgic-kvm-device.o
+obj-y += $(KVM)/arm/vgic/vgic-its.o
 obj-y += $(KVM)/irqchip.o
 obj-y += $(KVM)/arm/arch_timer.o
index 19b5f5c1c0ff3ef8fa68300f5ec87fe5564c916e..8f92efa8460e39808368f64f4be97234fa696cc6 100644 (file)
@@ -221,6 +221,12 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_MAX_VCPUS:
                r = KVM_MAX_VCPUS;
                break;
+       case KVM_CAP_MSI_DEVID:
+               if (!kvm)
+                       r = -EINVAL;
+               else
+                       r = kvm->arch.vgic.msis_require_devid;
+               break;
        default:
                r = kvm_arch_dev_ioctl_check_extension(kvm, ext);
                break;
index 6eaf12c1d627ac818e69b4eca988c7131b930fee..52cb7ad9b2fdc5d156fba1d536fa843ddc89b6d6 100644 (file)
@@ -16,9 +16,6 @@ menuconfig VIRTUALIZATION
 
 if VIRTUALIZATION
 
-config KVM_ARM_VGIC_V3_ITS
-       bool
-
 config KVM
        bool "Kernel-based Virtual Machine (KVM) support"
        depends on OF
@@ -34,7 +31,6 @@ config KVM
        select KVM_VFIO
        select HAVE_KVM_EVENTFD
        select HAVE_KVM_IRQFD
-       select KVM_ARM_VGIC_V3_ITS
        select KVM_ARM_PMU if HW_PERF_EVENTS
        select HAVE_KVM_MSI
        select HAVE_KVM_IRQCHIP
index 5bc460884639f1dcf3298393ed92bf75a612d5f2..e95d4f68bf544f652ab9a24005ac57d76c6356ec 100644 (file)
@@ -86,12 +86,6 @@ int kvm_arch_dev_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_VCPU_ATTRIBUTES:
                r = 1;
                break;
-       case KVM_CAP_MSI_DEVID:
-               if (!kvm)
-                       r = -EINVAL;
-               else
-                       r = kvm->arch.vgic.msis_require_devid;
-               break;
        default:
                r = 0;
        }
index ce1f4ed9daf4a68e550f436c1c1fe977876d40ed..fbe87a63d250d95b3b38b3e75a91f2b47c8fdbf6 100644 (file)
@@ -221,11 +221,9 @@ int kvm_register_vgic_device(unsigned long type)
                ret = kvm_register_device_ops(&kvm_arm_vgic_v3_ops,
                                              KVM_DEV_TYPE_ARM_VGIC_V3);
 
-#ifdef CONFIG_KVM_ARM_VGIC_V3_ITS
                if (ret)
                        break;
                ret = kvm_vgic_register_its_device();
-#endif
                break;
        }
 
index 0d3c76a4208ba111b56d20b17bce01f7d5f220d2..50f42f0f8c4f71ff8973b640d8ce92f424a4ae42 100644 (file)
@@ -42,7 +42,6 @@ u64 update_64bit_reg(u64 reg, unsigned int offset, unsigned int len,
        return reg | ((u64)val << lower);
 }
 
-#ifdef CONFIG_KVM_ARM_VGIC_V3_ITS
 bool vgic_has_its(struct kvm *kvm)
 {
        struct vgic_dist *dist = &kvm->arch.vgic;
@@ -52,7 +51,6 @@ bool vgic_has_its(struct kvm *kvm)
 
        return dist->has_its;
 }
-#endif
 
 static unsigned long vgic_mmio_read_v3_misc(struct kvm_vcpu *vcpu,
                                            gpa_t addr, unsigned int len)
index 9d9e014765a236879bc3237efcf8a933f1c3dd61..859f65c6e056b0e043e283f19f69f9affc3034fb 100644 (file)
@@ -84,37 +84,11 @@ int vgic_v3_probe(const struct gic_kvm_info *info);
 int vgic_v3_map_resources(struct kvm *kvm);
 int vgic_register_redist_iodevs(struct kvm *kvm, gpa_t dist_base_address);
 
-#ifdef CONFIG_KVM_ARM_VGIC_V3_ITS
 int vgic_register_its_iodevs(struct kvm *kvm);
 bool vgic_has_its(struct kvm *kvm);
 int kvm_vgic_register_its_device(void);
 void vgic_enable_lpis(struct kvm_vcpu *vcpu);
 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi);
-#else
-static inline int vgic_register_its_iodevs(struct kvm *kvm)
-{
-       return -ENODEV;
-}
-
-static inline bool vgic_has_its(struct kvm *kvm)
-{
-       return false;
-}
-
-static inline int kvm_vgic_register_its_device(void)
-{
-       return -ENODEV;
-}
-
-static inline void vgic_enable_lpis(struct kvm_vcpu *vcpu)
-{
-}
-
-static inline int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
-{
-       return -ENODEV;
-}
-#endif
 
 int kvm_register_vgic_device(unsigned long type);
 int vgic_lazy_init(struct kvm *kvm);