Skip to contentSkip to conversation

vITS support

RFC Superseded Eric Auger 2 participants 11 messages Jul 6, 2016 – Jul 29, 2016

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

v4 cover vITS support

This series introduces support for in-kernel GICv3 ITS emulation. It is based on a kernel API which is not yet released.

Tested on Cavium ThunderX with virtio-net-pci and vhost-net.

Kernel dependencies:
- [PATCH v8 00/12] KVM: arm64: GICv3 ITS emulation
http://www.spinics.net/lists/kvm/msg135048.html
- [PATCH v6 0/6] KVM: arm/arm64: gsi routing support

Those kernel series can be found at:
https://github.com/eauger/linux/tree/v4.7-rc6-its-emul-v8-gsi-routing-v6

This QEMU series can be found at:
https://github.com/eauger/qemu/tree/v2.6.0-vITS-v4

Previous version originally written by Pavel:
- [RFC PATCH v3 0/5] vITS support
https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg05197.html

History:

v3 => v4:
- Took into account Peter's comments (at the exception of sub-class operation changes, at the moment)
- rebase on Andre's kernel ITS emulation series v8
- rework KVM init sequence and KVM device creation/settings overall. I do not use kvm_arm_register_device due to the way the kernel API is devises (see discussion on the kernel ML)
- change the computation of the GITS_TRANSLATER base address
- fix compilation issues
- new "target-arm: move gicv3_class_name from machine to kvm_arm.h"

v2 => v3:
- Really added unmigratable flag, was overlooked in v2
- Fixed checkpatch issue with initializing static variable to zero

v1 => v2:
- Added registers and reset method
- Added unmigratable flag
- Rebased on top of current master, use kvm_arch_fixup_msi_route() now

Eric Auger (1):
target-arm: move gicv3_class_name from machine to kvm_arm.h

Pavel Fedin (5):
hw/intc/arm_gicv3_its: Implement ITS base class
linux-headers: update to 4.7-rc6 + ITS emulation and GSI routing target-arm/kvm: Pass requester ID to MSI routing functions hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation arm/virt: Add ITS to the virt board

 hw/arm/virt.c                                      |  47 ++++++-
 hw/intc/Makefile.objs                              |   2 +
 hw/intc/arm_gicv3_its_common.c                     | 155 +++++++++++++++++++++
 hw/intc/arm_gicv3_its_kvm.c                        | 145 +++++++++++++++++++
 include/hw/intc/arm_gicv3_its_common.h             |  75 ++++++++++
 include/standard-headers/linux/input-event-codes.h |  31 +++++
 include/standard-headers/linux/input.h             |   1 +
 linux-headers/asm-arm64/kvm.h                      |   2 +
 linux-headers/linux/kvm.h                          |  12 +-
 target-arm/kvm.c                                   |   6 +
 target-arm/kvm_arm.h                               |  38 ++++-
 target-arm/machine.c                               |  16 ---
 12 files changed, 505 insertions(+), 25 deletions(-)
 create mode 100644 hw/intc/arm_gicv3_its_common.c
 create mode 100644 hw/intc/arm_gicv3_its_kvm.c
 create mode 100644 include/hw/intc/arm_gicv3_its_common.h
Signature · 1 line
2.5.5
author
#1 lore raw

RFC v4 1/6 hw/intc/arm_gicv3_its: Implement ITS base class

From: Pavel Fedin <[email protected]>

This is the basic skeleton for both KVM and software-emulated ITS. Since we already prepare status structure, we also introduce complete VMState description. But, because we currently have no migratable implementations, we also set unmigratable flag.

---

v3 -> v4:
- fix compilation error
- msi_supported -> msi_nonbroken
- streamid -> requester_id
- use PRIx64
- read ops uses _with_attrs form
- 16/32b write access allowed to GITS_TRANSLATER
- move its_class_name in kvm_arm.h and remove #ifdef TARGET_AARCH64
- add new kvm device dev_fd field
- add new gits_translater_gpa field in GICv3ITSState

---
 hw/intc/Makefile.objs                  |   1 +
 hw/intc/arm_gicv3_its_common.c         | 155 +++++++++++++++++++++++++++++++++
 include/hw/intc/arm_gicv3_its_common.h |  75 ++++++++++++++++
 target-arm/kvm_arm.h                   |  19 ++++
 4 files changed, 250 insertions(+)
 create mode 100644 hw/intc/arm_gicv3_its_common.c
 create mode 100644 include/hw/intc/arm_gicv3_its_common.h
hw/intc/Makefile.objs +1 -0
index 530df2e..2f04792 100644
@@ -16,6 +16,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_common.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o
+common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_its_common.o
 common-obj-$(CONFIG_OPENPIC) += openpic.o
 
 obj-$(CONFIG_APIC) += apic.o apic_common.o
hw/intc/arm_gicv3_its_common.c new file +155 -0

155 lines not on this page · raw message

include/hw/intc/arm_gicv3_its_common.h new file +75 -0

75 lines not on this page · raw message

target-arm/kvm_arm.h +19 -0
index a419368..544e404 100644
@@ -255,4 +255,23 @@ struct kvm_guest_debug_arch;
 
 void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
 
+/**
+ * its_class_name
+ *
+ * Return the ITS class name to use depending on whether KVM acceleration
+ * and KVM CAP_SIGNAL_MSI are supported
+ *
+ * Returns: class name to use or NULL
+ */
+static inline const char *its_class_name(void)
+{
+    if (kvm_irqchip_in_kernel()) {
+        /* KVM implementation requires this capability */
+        return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL;
+    } else {
+        /* Software emulation is not implemented yet */
+        return NULL;
+    }
+}
+
 #endif
Signature · 1 line
2.5.5
author
#2 lore raw

RFC v4 2/6 target-arm: move gicv3_class_name from machine to kvm_arm.h

In reply to Eric Auger

Machine.c contains code related to migration. Let's move gicv3_class_name to kvm_arm.h instead.

---

v4: creation

---
 target-arm/kvm_arm.h | 16 +++++++++++++++-
 target-arm/machine.c | 16 ----------------
 2 files changed, 15 insertions(+), 17 deletions(-)
target-arm/kvm_arm.h +15 -1
index 544e404..4fb6d15 100644
@@ -223,7 +223,21 @@ static inline const char *gic_class_name(void)
  *
  * Returns: class name to use
  */
-const char *gicv3_class_name(void);
+static inline const char *gicv3_class_name(void)
+{
+    if (kvm_irqchip_in_kernel()) {
+#ifdef TARGET_AARCH64
+        return "kvm-arm-gicv3";
+#else
+        error_report("KVM GICv3 acceleration is not supported on this "
+                     "platform");
+#endif
+    } else {
+        return "arm-gicv3";
+    }
+
+    exit(1);
+}
 
 /**
  * kvm_arm_handle_debug:
target-arm/machine.c +0 -16
index 2dbeb82..d90943b 100644
@@ -331,19 +331,3 @@ const VMStateDescription vmstate_arm_cpu = {
         NULL
     }
 };
-
-const char *gicv3_class_name(void)
-{
-    if (kvm_irqchip_in_kernel()) {
-#ifdef TARGET_AARCH64
-        return "kvm-arm-gicv3";
-#else
-        error_report("KVM GICv3 acceleration is not supported on this "
-                     "platform");
-#endif
-    } else {
-        return "arm-gicv3";
-    }
-
-    exit(1);
-}
Signature · 1 line
2.5.5
author
#3 lore raw

Re: [Qemu-arm] [RFC v4 2/6] target-arm: move gicv3_class_name from machine to kvm_arm.h

Hi

Quoted 21 lines · Eric Auger

Machine.c contains code related to migration. Let's move gicv3_class_name to kvm_arm.h instead.

---

v4: creation

---
 target-arm/kvm_arm.h | 16 +++++++++++++++-
 target-arm/machine.c | 16 ----------------
 2 files changed, 15 insertions(+), 17 deletions(-)
target-arm/kvm_arm.h +0 -0
index 544e404..4fb6d15 100644
@@ -223,7 +223,21 @@ static inline const char *gic_class_name(void)
  *
  * Returns: class name to use

target-arm/kvm_arm.h static inline const char *gic_class_name(void) · line 233

Quoted 10 lines
target-arm/kvm_arm.h +8 -1
  */
-const char *gicv3_class_name(void);
+static inline const char *gicv3_class_name(void)
+{
+    if (kvm_irqchip_in_kernel()) {
+#ifdef TARGET_AARCH64
+        return "kvm-arm-gicv3";
+#else
+        error_report("KVM GICv3 acceleration is not supported on this "
+                     "platform");

this fails to compile without adding
#include "qemu/error-report.h"

I will correct this on the next version.

Sorry for the oversight.

Best Regards

Eric

Quoted 35 lines
target-arm/kvm_arm.h +7 -0
+#endif
+    } else {
+        return "arm-gicv3";
+    }
+
+    exit(1);
+}
 
 /**
  * kvm_arm_handle_debug:
target-arm/machine.c +0 -16
index 2dbeb82..d90943b 100644
@@ -331,19 +331,3 @@ const VMStateDescription vmstate_arm_cpu = {
         NULL
     }
 };
-
-const char *gicv3_class_name(void)
-{
-    if (kvm_irqchip_in_kernel()) {
-#ifdef TARGET_AARCH64
-        return "kvm-arm-gicv3";
-#else
-        error_report("KVM GICv3 acceleration is not supported on this "
-                     "platform");
-#endif
-    } else {
-        return "arm-gicv3";
-    }
-
-    exit(1);
-}
author
#4 lore raw

RFC v4 3/6 linux-headers: update to 4.7-rc6 + ITS emulation and GSI routing

In reply to Eric Auger

From: Pavel Fedin <[email protected]>

Linux header update for in-kernel ITS emulation and KVM MSI routing.

The kernel can be found at
https://github.com/eauger/linux/tree/v4.7-rc6-its-emul-v7-gsi-routing-v5

---

v4 -> v5:
- upgrade

---
 include/standard-headers/linux/input-event-codes.h | 31 ++++++++++++++++++++++
 include/standard-headers/linux/input.h             |  1 +
 linux-headers/asm-arm64/kvm.h                      |  2 ++
 linux-headers/linux/kvm.h                          | 12 +++++++--
 4 files changed, 44 insertions(+), 2 deletions(-)
include/standard-headers/linux/input-event-codes.h +31 -0
index 354f0de..1f33521 100644
@@ -611,6 +611,37 @@
 #define KEY_KBDINPUTASSIST_ACCEPT		0x264
 #define KEY_KBDINPUTASSIST_CANCEL		0x265
 
+/* Diagonal movement keys */
+#define KEY_RIGHT_UP			0x266
+#define KEY_RIGHT_DOWN			0x267
+#define KEY_LEFT_UP			0x268
+#define KEY_LEFT_DOWN			0x269
+
+#define KEY_ROOT_MENU			0x26a /* Show Device's Root Menu */
+/* Show Top Menu of the Media (e.g. DVD) */
+#define KEY_MEDIA_TOP_MENU		0x26b
+#define KEY_NUMERIC_11			0x26c
+#define KEY_NUMERIC_12			0x26d
+/*
+ * Toggle Audio Description: refers to an audio service that helps blind and
+ * visually impaired consumers understand the action in a program. Note: in
+ * some countries this is referred to as "Video Description".
+ */
+#define KEY_AUDIO_DESC			0x26e
+#define KEY_3D_MODE			0x26f
+#define KEY_NEXT_FAVORITE		0x270
+#define KEY_STOP_RECORD			0x271
+#define KEY_PAUSE_RECORD		0x272
+#define KEY_VOD				0x273 /* Video on Demand */
+#define KEY_UNMUTE			0x274
+#define KEY_FASTREVERSE			0x275
+#define KEY_SLOWREVERSE			0x276
+/*
+ * Control a data application associated with the currently viewed channel,
+ * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
+ */
+#define KEY_DATA			0x275
+
 #define BTN_TRIGGER_HAPPY		0x2c0
 #define BTN_TRIGGER_HAPPY1		0x2c0
 #define BTN_TRIGGER_HAPPY2		0x2c1
include/standard-headers/linux/input.h +1 -0
index a52b202..7361a16 100644
@@ -244,6 +244,7 @@ struct input_mask {
 #define BUS_ATARI		0x1B
 #define BUS_SPI			0x1C
 #define BUS_RMI			0x1D
+#define BUS_CEC			0x1E
 
 /*
  * MT_TOOL types
linux-headers/asm-arm64/kvm.h +2 -0
index 7d82d1f..dc6f750 100644
@@ -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		SZ_64K
 
 #define KVM_ARM_VCPU_POWER_OFF		0 /* CPU is started in OFF state */
 #define KVM_ARM_VCPU_EL1_32BIT		1 /* CPU running a 32bit VM */
linux-headers/linux/kvm.h +10 -2
index e60e21b..37c05e2 100644
@@ -866,6 +866,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_ARM_PMU_V3 126
 #define KVM_CAP_VCPU_ATTRIBUTES 127
 #define KVM_CAP_MAX_VCPU_ID 128
+#define KVM_CAP_MSI_DEVID 129
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -878,7 +879,10 @@ struct kvm_irq_routing_msi {
 	__u32 address_lo;
 	__u32 address_hi;
 	__u32 data;
-	__u32 pad;
+	union {
+		__u32 pad;
+		__u32 devid;
+	};
 };
 
 struct kvm_irq_routing_s390_adapter {
@@ -1024,12 +1028,14 @@ struct kvm_one_reg {
 	__u64 addr;
 };
 
+#define KVM_MSI_VALID_DEVID	(1U << 0)
 struct kvm_msi {
 	__u32 address_lo;
 	__u32 address_hi;
 	__u32 data;
 	__u32 flags;
-	__u8  pad[16];
+	__u32 devid;
+	__u8  pad[12];
 };
 
 struct kvm_arm_device_addr {
@@ -1074,6 +1080,8 @@ enum kvm_device_type {
 #define KVM_DEV_TYPE_FLIC		KVM_DEV_TYPE_FLIC
 	KVM_DEV_TYPE_ARM_VGIC_V3,
 #define KVM_DEV_TYPE_ARM_VGIC_V3	KVM_DEV_TYPE_ARM_VGIC_V3
+	KVM_DEV_TYPE_ARM_VGIC_ITS,
+#define KVM_DEV_TYPE_ARM_VGIC_ITS	KVM_DEV_TYPE_ARM_VGIC_ITS
 	KVM_DEV_TYPE_MAX,
 };
 
Signature · 1 line
2.5.5
author
#5 lore raw

RFC v4 4/6 target-arm/kvm: Pass requester ID to MSI routing functions

In reply to Eric Auger

From: Pavel Fedin <[email protected]>

Introduce global kvm_arm_msi_use_devid flag and pass device IDs in kvm_arch_fixup_msi_route(). Device IDs are required by the ITS.

---

v3 -> v4:
- OR route->flags with KVM_MSI_VALID_DEVID

---
 target-arm/kvm.c     | 6 ++++++
 target-arm/kvm_arm.h | 3 +++
 2 files changed, 9 insertions(+)
target-arm/kvm.c +6 -0
index 5c2bd7a..025449b 100644
@@ -22,6 +22,7 @@
 #include "cpu.h"
 #include "internals.h"
 #include "hw/arm/arm.h"
+#include "hw/pci/pci.h"
 #include "exec/memattrs.h"
 #include "hw/boards.h"
 #include "qemu/log.h"
@@ -31,6 +32,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 };
 
 static bool cap_has_mp_state;
+bool kvm_arm_msi_use_devid;
 
 int kvm_arm_vcpu_init(CPUState *cs)
 {
@@ -619,6 +621,10 @@ int kvm_arm_vgic_probe(void)
 int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
                              uint64_t address, uint32_t data, PCIDevice *dev)
 {
+    if (kvm_arm_msi_use_devid) {
+        route->flags |= KVM_MSI_VALID_DEVID;
+        route->u.msi.devid = pci_requester_id(dev);
+    }
     return 0;
 }
 
target-arm/kvm_arm.h +3 -0
index 4fb6d15..c2ab009 100644
@@ -120,6 +120,9 @@ bool write_kvmstate_to_list(ARMCPU *cpu);
 void kvm_arm_reset_vcpu(ARMCPU *cpu);
 
 #ifdef CONFIG_KVM
+
+extern bool kvm_arm_msi_use_devid;
+
 /**
  * kvm_arm_create_scratch_host_vcpu:
  * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with
Signature · 1 line
2.5.5
author
#6 lore raw

RFC v4 5/6 hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation

In reply to Eric Auger

From: Pavel Fedin <[email protected]>

The ITS control frame is in-kernel emulated while accesses to the GITS_TRANSLATER are mediated through the KVM_SIGNAL_MSI ioctl (MSI direct MSI injection advertised by the CAP_SIGNAL_MSI capability)

the kvm_gsi_direct_mapping is explicitly set to false to emphasize the difference with GICv2M. Direct mapping cannot work with ITS since the content of the MSI data is not the target interrupt ID but an eventd id.

GSI routing is advertised (kvm_gsi_routing_allowed) as well as msi/irqfd signaling (kvm_msi_via_irqfd_allowed).

---

v3 -> v4:
- include "qemu/osdep.h" and "qapi/error.h"
- rename KVM_VGIC_V3_ADDR_TYPE_ITS into KVM_VGIC_ITS_ADDR_TYPE
- reword commit message
- change kvm_msi_via_irqfd_allowed definition (attached to irqfd dynamic availability + MSI controller availability)
- create the ITS KVM device (previously abstracted by the GICv3 KVM device)
- init sequence changed
- absolute GITS_TRANSLATER GPA stored

---
 hw/intc/Makefile.objs       |   1 +
 hw/intc/arm_gicv3_its_kvm.c | 145 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 146 insertions(+)
 create mode 100644 hw/intc/arm_gicv3_its_kvm.c
hw/intc/Makefile.objs +1 -0
index 2f04792..b457369 100644
@@ -22,6 +22,7 @@ common-obj-$(CONFIG_OPENPIC) += openpic.o
 obj-$(CONFIG_APIC) += apic.o apic_common.o
 obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o
 obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_kvm.o
+obj-$(call land,$(CONFIG_ARM_GIC_KVM),$(TARGET_AARCH64)) += arm_gicv3_its_kvm.o
 obj-$(CONFIG_STELLARIS) += armv7m_nvic.o
 obj-$(CONFIG_EXYNOS4) += exynos4210_gic.o exynos4210_combiner.o
 obj-$(CONFIG_GRLIB) += grlib_irqmp.o
hw/intc/arm_gicv3_its_kvm.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.5.5
#7 lore raw

Re: [Qemu-arm] [RFC v4 5/6] hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation

Quoted 8 lines · Eric Auger

+/**
+ *
+ * We currently do not use kvm_arm_register_device to provide
+ * the kernel with the vITS control frame base address since the
+ * KVM_DEV_ARM_VGIC_CTRL_INIT init MUST be called after the
+ * KVM_ARM_SET_DEVICE_ADDR and the kvm_arm_register_device
+ * infra does not allow this.
+ */

So the conclusion on the kvm-arm mailing list was that the kernel ought to permit DEVICE_ADDR to be set after INIT, the same way it does for the GIC proper, right?

thanks
-- PMM

author
#8 lore raw

Re: [Qemu-devel] [RFC v4 5/6] hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation

Hi Peter,

Quoted 10 lines · Peter Maydell
Quoted 8 lines · Eric Auger

+/**
+ *
+ * We currently do not use kvm_arm_register_device to provide
+ * the kernel with the vITS control frame base address since the
+ * KVM_DEV_ARM_VGIC_CTRL_INIT init MUST be called after the
+ * KVM_ARM_SET_DEVICE_ADDR and the kvm_arm_register_device
+ * infra does not allow this.
+ */

Quoted 3 lines

So the conclusion on the kvm-arm mailing list was that the kernel ought to permit DEVICE_ADDR to be set after INIT, the same way it does for the GIC proper, right?

Yes this was indeed evoked but eventually what is in next, right now is the same implementation where KVM_ARM_SET_DEVICE_ADDR is forbidden once init is done:

see virt/kvm/arm/vgic/vgic-its.c
its->initialized set by vgic_its_init_its (KVM_DEV_ARM_VGIC_GRP_CTRL)

case KVM_DEV_ARM_VGIC_GRP_ADDR:
../..

                if (its->initialized)
                        return -EBUSY;

Thanks

Eric

Quoted 4 lines

thanks
-- PMM

#9 lore raw

Re: [Qemu-devel] [RFC v4 5/6] hw/intc/arm_gicv3_its: Implement support for in-kernel ITS emulation

Quoted 12 lines · Auger Eric

Hi Peter,

Quoted 10 lines · Peter Maydell
Quoted 8 lines · Eric Auger

+/**
+ *
+ * We currently do not use kvm_arm_register_device to provide
+ * the kernel with the vITS control frame base address since the
+ * KVM_DEV_ARM_VGIC_CTRL_INIT init MUST be called after the
+ * KVM_ARM_SET_DEVICE_ADDR and the kvm_arm_register_device
+ * infra does not allow this.
+ */

Quoted 6 lines
Quoted 3 lines

So the conclusion on the kvm-arm mailing list was that the kernel ought to permit DEVICE_ADDR to be set after INIT, the same way it does for the GIC proper, right?

Yes this was indeed evoked but eventually what is in next, right now is the same implementation where KVM_ARM_SET_DEVICE_ADDR is forbidden once init is done:

That's bad and we need to fix it, preferably before it hits master.

thanks
-- PMM

author
#10 lore raw

RFC v4 6/6 arm/virt: Add ITS to the virt board

In reply to Eric Auger

From: Pavel Fedin <[email protected]>

If supported by the configuration, ITS will be added automatically.

This patch also renames v2m_phandle to msi_phandle because it's now used by both MSI implementations.

--

v3 -> v4:
- added Peter's R-b

---
 hw/arm/virt.c | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)
hw/arm/virt.c +41 -6
index 6e098af..3832f95 100644
@@ -75,7 +75,7 @@ typedef struct VirtBoardInfo {
     int fdt_size;
     uint32_t clock_phandle;
     uint32_t gic_phandle;
-    uint32_t v2m_phandle;
+    uint32_t msi_phandle;
     bool using_psci;
 } VirtBoardInfo;
 
@@ -421,9 +421,22 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
     }
 }
 
+static void fdt_add_its_gic_node(VirtBoardInfo *vbi)
+{
+    vbi->msi_phandle = qemu_fdt_alloc_phandle(vbi->fdt);
+    qemu_fdt_add_subnode(vbi->fdt, "/intc/its");
+    qemu_fdt_setprop_string(vbi->fdt, "/intc/its", "compatible",
+                            "arm,gic-v3-its");
+    qemu_fdt_setprop(vbi->fdt, "/intc/its", "msi-controller", NULL, 0);
+    qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc/its", "reg",
+                                 2, vbi->memmap[VIRT_GIC_ITS].base,
+                                 2, vbi->memmap[VIRT_GIC_ITS].size);
+    qemu_fdt_setprop_cell(vbi->fdt, "/intc/its", "phandle", vbi->msi_phandle);
+}
+
 static void fdt_add_v2m_gic_node(VirtBoardInfo *vbi)
 {
-    vbi->v2m_phandle = qemu_fdt_alloc_phandle(vbi->fdt);
+    vbi->msi_phandle = qemu_fdt_alloc_phandle(vbi->fdt);
     qemu_fdt_add_subnode(vbi->fdt, "/intc/v2m");
     qemu_fdt_setprop_string(vbi->fdt, "/intc/v2m", "compatible",
                             "arm,gic-v2m-frame");
@@ -431,7 +444,7 @@ static void fdt_add_v2m_gic_node(VirtBoardInfo *vbi)
     qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc/v2m", "reg",
                                  2, vbi->memmap[VIRT_GIC_V2M].base,
                                  2, vbi->memmap[VIRT_GIC_V2M].size);
-    qemu_fdt_setprop_cell(vbi->fdt, "/intc/v2m", "phandle", vbi->v2m_phandle);
+    qemu_fdt_setprop_cell(vbi->fdt, "/intc/v2m", "phandle", vbi->msi_phandle);
 }
 
 static void fdt_add_gic_node(VirtBoardInfo *vbi, int type)
@@ -498,6 +511,26 @@ static void fdt_add_pmu_nodes(const VirtBoardInfo *vbi, int gictype)
     }
 }
 
+static void create_its(VirtBoardInfo *vbi, DeviceState *gicdev)
+{
+    const char *itsclass = its_class_name();
+    DeviceState *dev;
+
+    if (!itsclass) {
+        /* Do nothing if not supported */
+        return;
+    }
+
+    dev = qdev_create(NULL, itsclass);
+
+    object_property_set_link(OBJECT(dev), OBJECT(gicdev), "parent-gicv3",
+                             &error_abort);
+    qdev_init_nofail(dev);
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vbi->memmap[VIRT_GIC_ITS].base);
+
+    fdt_add_its_gic_node(vbi);
+}
+
 static void create_v2m(VirtBoardInfo *vbi, qemu_irq *pic)
 {
     int i;
@@ -581,7 +614,9 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)
 
     fdt_add_gic_node(vbi, type);
 
-    if (type == 2) {
+    if (type == 3) {
+        create_its(vbi, gicdev);
+    } else {
         create_v2m(vbi, pic);
     }
 }
@@ -1023,9 +1058,9 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
                            nr_pcie_buses - 1);
     qemu_fdt_setprop(vbi->fdt, nodename, "dma-coherent", NULL, 0);
 
-    if (vbi->v2m_phandle) {
+    if (vbi->msi_phandle) {
         qemu_fdt_setprop_cells(vbi->fdt, nodename, "msi-parent",
-                               vbi->v2m_phandle);
+                               vbi->msi_phandle);
     }
 
     qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
Signature · 1 line
2.5.5