* [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests
@ 2026-11-18 17:57 Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 01/23] arm64: Propagate IRQ routing initialisation errors Sascha Bischoff
` (22 more replies)
0 siblings, 23 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
This series adds support for GICv5-based VMs to kvmtool. These are
exposed as --irqchip=gicv5 and --irqchip=gicv5-its, where the former
creates a vGICv5 device and the latter adds a GICv5 ITS. The GICv5
specification can be found at [1].
The GICv5 support in KVM needed by --irqchip=gicv5 is available as of
Linux v7.4-rc1. The GICv5 ITS support is described in [2]; using
--irqchip=gicv5-its requires a KVM build with those changes.
The series teaches kvmtool to create the GICv5 irqchip and ITS KVM
devices. It describes the GICv5 CPU interface, IRS and ITS in the
guest DT, updates the timer and PMU interrupt descriptions, and
generates GICv5 interrupt specifiers for platform devices and PCI. It
also maps PCI MSI requester IDs to the ITS. The IRS support is built
and exposed before the ITS support, so the GICv5 irqchip support can
be merged separately from the ITS changes.
Compared with v4 [3]:
* Added Vladimir's Reviewed-by and Tested-by trailers where provided,
and described the MSI helper's use of the global base in patch 3's
commit message.
* Updated to check GICv5 SPI indices passed to KVM_IRQ_LINE against
the 0-255 range that fits kvmtool's 8-bit IRQ storage, while
retaining the 32-255 range for GICv2/v3.
* Restored blank lines inadvertently removed in patches 9 and 12.
* Made GICv5 ITS setup fall through to the common GICv5 IRS setup.
* Replaced PCI MSI property selection with a switch statement.
The v7.4-rc1 header sync includes GICv5 IRS UAPI, but not GICv5 ITS
UAPI. Patch 19 mirrors the ITS definitions from [2]. Once that UAPI
lands upstream, the headers should be resynced against the latest
Linux headers before merging the ITS support.
Thanks,
Sascha
[1] https://developer.arm.com/documentation/aes0070/latest
[2] https://lore.kernel.org/all/20261102194454.4086911-1-sascha.bischoff@arm.com/
[3] https://lore.kernel.org/all/20261102213413.4136118-1-sascha.bischoff@arm.com/
Sascha Bischoff (23):
arm64: Propagate IRQ routing initialisation errors
arm64: Close the ITS descriptor when setup fails
arm64: Split GIC device setup
Sync kernel UAPI headers with v7.4-rc1
arm64: Add GICv5 irqchip device support
arm64: Configure GIC interrupt bases
irq: Allow the initial interrupt line number to be set
arm64: Start GICv5 SPI line allocation at zero
arm64: Configure the GICv5 IRS
arm64: Define GICv5 interrupt types
arm64: Describe the PMU interrupt for GICv5
arm64: Describe timer PPIs for GICv5
arm64: Assign CPU DT phandles
arm64: Describe the GICv5 CPU interface in the DT
arm64: Describe the GICv5 IRS in the DT
arm64: Generate GICv5 SPI specifiers for platform devices
arm64: Generate GICv5 PCI INTx specifiers
arm64: Expose the GICv5 irqchip option
arm64: Add proposed GICv5 ITS UAPI definitions
arm64: Add GICv5 ITS device support
arm64: Describe the GICv5 ITS in the DT
arm64: Map PCI MSI requester IDs to the GICv5 ITS
arm64: Expose the GICv5 ITS irqchip option
arm64/fdt.c | 13 +-
arm64/gic.c | 361 ++++++++++++++++++++++++----
arm64/include/asm/kvm.h | 18 ++
arm64/include/kvm/fdt-arch.h | 1 +
arm64/include/kvm/gic.h | 15 ++
arm64/include/kvm/kvm-arch.h | 16 ++
arm64/include/kvm/kvm-config-arch.h | 2 +-
arm64/pci.c | 24 +-
arm64/pmu.c | 13 +-
arm64/timer.c | 8 +-
include/kvm/irq.h | 1 +
include/linux/kvm.h | 23 ++
include/linux/virtio_console.h | 2 +-
include/linux/virtio_ids.h | 1 +
irq.c | 15 +-
powerpc/include/asm/kvm.h | 18 ++
riscv/include/asm/kvm.h | 17 ++
x86/include/asm/kvm.h | 4 +-
18 files changed, 483 insertions(+), 69 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 01/23] arm64: Propagate IRQ routing initialisation errors
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 02/23] arm64: Close the ITS descriptor when setup fails Sascha Bischoff
` (21 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
irq__routing_init() can fail while allocating entries for the default
routing table. gic__init_gic() currently ignores that error and
continues with a partially populated table. Return the error before
the VGIC is marked as initialised.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index 1e400962..debb0381 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -344,7 +344,9 @@ static int gic__init_gic(struct kvm *kvm)
}
}
- irq__routing_init(kvm);
+ ret = irq__routing_init(kvm);
+ if (ret)
+ return ret;
if (!ioctl(gic_fd, KVM_HAS_DEVICE_ATTR, &vgic_init_attr)) {
ret = ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &vgic_init_attr);
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 02/23] arm64: Close the ITS descriptor when setup fails
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 01/23] arm64: Propagate IRQ routing initialisation errors Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 03/23] arm64: Split GIC device setup Sascha Bischoff
` (20 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
gic__create_its_frame() closes the device fd if the address attribute
is unavailable, but returns without closing it if setting the address
or initialising the ITS fails. Route all errors after device creation
through the same close path.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index debb0381..f8371f50 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -124,17 +124,22 @@ static int gic__create_its_frame(struct kvm *kvm, u64 its_frame_addr)
}
err = ioctl(its_device.fd, KVM_HAS_DEVICE_ATTR, &its_attr);
- if (err) {
- close(its_device.fd);
- its_device.fd = -1;
- return err;
- }
+ if (err)
+ goto out_close;
err = ioctl(its_device.fd, KVM_SET_DEVICE_ATTR, &its_attr);
if (err)
- return err;
+ goto out_close;
- return ioctl(its_device.fd, KVM_SET_DEVICE_ATTR, &its_init_attr);
+ err = ioctl(its_device.fd, KVM_SET_DEVICE_ATTR, &its_init_attr);
+ if (err)
+ goto out_close;
+
+ return 0;
+
+out_close:
+ close(its_device.fd);
+ return err;
}
static int gic__create_msi_frame(struct kvm *kvm, enum irqchip_type type,
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 03/23] arm64: Split GIC device setup
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 01/23] arm64: Propagate IRQ routing initialisation errors Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 02/23] arm64: Close the ITS descriptor when setup fails Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 04/23] Sync kernel UAPI headers with v7.4-rc1 Sascha Bischoff
` (19 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Separate the CPU interface, redistributor and distributor address setup
from GIC device creation. Keep the per-GIC address handling in small
helpers.
Have the existing MSI frame helper use the global MSI base instead of
passing it as an argument.
Use the irqchip enum order to omit the GICv2 PPI CPU mask for GICv3
and later generations.
Suggested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 94 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 62 insertions(+), 32 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index f8371f50..57f3fa02 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -142,52 +142,90 @@ out_close:
return err;
}
-static int gic__create_msi_frame(struct kvm *kvm, enum irqchip_type type,
- u64 msi_frame_addr)
+static int gic__create_msi_frame(struct kvm *kvm, enum irqchip_type type)
{
switch (type) {
case IRQCHIP_GICV2M:
- return gic__create_gicv2m_frame(kvm, msi_frame_addr);
+ return gic__create_gicv2m_frame(kvm, gic_msi_base);
case IRQCHIP_GICV3_ITS:
- return gic__create_its_frame(kvm, msi_frame_addr);
+ return gic__create_its_frame(kvm, gic_msi_base);
default: /* No MSI frame needed */
return 0;
}
}
-static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
+static int gic__set_cpu_if(enum irqchip_type type)
{
- int err;
u64 cpu_if_addr = ARM_GIC_CPUI_BASE;
- u64 dist_addr = ARM_GIC_DIST_BASE;
- struct kvm_create_device gic_device = {
- .flags = 0,
- };
struct kvm_device_attr cpu_if_attr = {
.group = KVM_DEV_ARM_VGIC_GRP_ADDR,
.attr = KVM_VGIC_V2_ADDR_TYPE_CPU,
.addr = (u64)(unsigned long)&cpu_if_addr,
};
- struct kvm_device_attr dist_attr = {
- .group = KVM_DEV_ARM_VGIC_GRP_ADDR,
- .addr = (u64)(unsigned long)&dist_addr,
- };
+
+ switch (type) {
+ case IRQCHIP_GICV2M:
+ case IRQCHIP_GICV2:
+ return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &cpu_if_attr);
+ default: /* No CPU interface needed */
+ return 0;
+ }
+}
+
+static int gic__set_redist(enum irqchip_type type)
+{
struct kvm_device_attr redist_attr = {
.group = KVM_DEV_ARM_VGIC_GRP_ADDR,
.attr = KVM_VGIC_V3_ADDR_TYPE_REDIST,
.addr = (u64)(unsigned long)&gic_redists_base,
};
+ switch (type) {
+ case IRQCHIP_GICV3:
+ case IRQCHIP_GICV3_ITS:
+ return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &redist_attr);
+ default: /* No redistributor needed */
+ return 0;
+ }
+}
+
+static int gic__set_dist(enum irqchip_type type)
+{
+ u64 dist_addr = ARM_GIC_DIST_BASE;
+ struct kvm_device_attr dist_attr = {
+ .group = KVM_DEV_ARM_VGIC_GRP_ADDR,
+ .addr = (u64)(unsigned long)&dist_addr,
+ };
+
+ switch (type) {
+ case IRQCHIP_GICV2M:
+ case IRQCHIP_GICV2:
+ dist_attr.attr = KVM_VGIC_V2_ADDR_TYPE_DIST;
+ return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &dist_attr);
+ case IRQCHIP_GICV3:
+ case IRQCHIP_GICV3_ITS:
+ dist_attr.attr = KVM_VGIC_V3_ADDR_TYPE_DIST;
+ return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &dist_attr);
+ default: /* No distributor needed */
+ return 0;
+ }
+}
+
+static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
+{
+ int err;
+ struct kvm_create_device gic_device = {
+ .flags = 0,
+ };
+
switch (type) {
case IRQCHIP_GICV2M:
case IRQCHIP_GICV2:
gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V2;
- dist_attr.attr = KVM_VGIC_V2_ADDR_TYPE_DIST;
break;
case IRQCHIP_GICV3:
case IRQCHIP_GICV3_ITS:
gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V3;
- dist_attr.attr = KVM_VGIC_V3_ADDR_TYPE_DIST;
break;
case IRQCHIP_AUTO:
return -ENODEV;
@@ -199,26 +237,19 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
gic_fd = gic_device.fd;
- switch (type) {
- case IRQCHIP_GICV2M:
- case IRQCHIP_GICV2:
- err = ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &cpu_if_attr);
- break;
- case IRQCHIP_GICV3_ITS:
- case IRQCHIP_GICV3:
- err = ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &redist_attr);
- break;
- case IRQCHIP_AUTO:
- return -ENODEV;
- }
+ err = gic__set_cpu_if(type);
+ if (err)
+ goto out_err;
+
+ err = gic__set_redist(type);
if (err)
goto out_err;
- err = ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &dist_attr);
+ err = gic__set_dist(type);
if (err)
goto out_err;
- err = gic__create_msi_frame(kvm, type, gic_msi_base);
+ err = gic__create_msi_frame(kvm, type);
if (err)
goto out_err;
@@ -439,8 +470,7 @@ void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
u32 gic__get_fdt_irq_cpumask(struct kvm *kvm)
{
/* Only for GICv2 */
- if (kvm->cfg.arch.irqchip == IRQCHIP_GICV3 ||
- kvm->cfg.arch.irqchip == IRQCHIP_GICV3_ITS)
+ if (kvm->cfg.arch.irqchip >= IRQCHIP_GICV3)
return 0;
if (kvm->nrcpus > 8)
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 04/23] Sync kernel UAPI headers with v7.4-rc1
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (2 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 03/23] arm64: Split GIC device setup Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 05/23] arm64: Add GICv5 irqchip device support Sascha Bischoff
` (18 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Synchronise the headers to pull in the support for the GICv5 IRS that
was added in v7.4-rc1. These changes do not include the GICv5 ITS
changes which are still under review at the time of writing.
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/include/asm/kvm.h | 16 ++++++++++++++++
include/linux/kvm.h | 21 +++++++++++++++++++++
include/linux/virtio_console.h | 2 +-
include/linux/virtio_ids.h | 1 +
powerpc/include/asm/kvm.h | 18 ++++++++++++++++++
riscv/include/asm/kvm.h | 17 +++++++++++++++++
x86/include/asm/kvm.h | 4 ++--
7 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/arm64/include/asm/kvm.h b/arm64/include/asm/kvm.h
index 1c13bfa2..65ee09bd 100644
--- a/arm64/include/asm/kvm.h
+++ b/arm64/include/asm/kvm.h
@@ -97,6 +97,11 @@ struct kvm_regs {
#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K)
#define KVM_VGIC_V3_ITS_SIZE (2 * SZ_64K)
+/* Supported VGICv5 address types */
+#define KVM_VGIC_V5_ADDR_TYPE_IRS 6
+
+#define KVM_VGIC_V5_IRS_SIZE (2 * 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 */
#define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */
@@ -106,6 +111,7 @@ struct kvm_regs {
#define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */
#define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */
#define KVM_ARM_VCPU_HAS_EL2_E2H0 8 /* Limit NV support to E2H RES0 */
+#define KVM_ARM_VCPU_PMU_V3_STRICT 9 /* No default PMU creation */
struct kvm_vcpu_init {
__u32 target;
@@ -417,6 +423,16 @@ enum {
#define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO 7
#define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8
#define KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ 9
+#define KVM_DEV_ARM_VGIC_GRP_IRS_REGS 10
+#define KVM_DEV_ARM_VGIC_GRP_IST 11
+
+struct kvm_vgic_v5_ist {
+ __u64 spi_ist_addr;
+ __u64 spi_ist_size;
+ __u64 lpi_ist_addr;
+ __u64 lpi_ist_size;
+};
+
#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)
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 6c8afa20..8dff2fc1 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -996,6 +996,10 @@ struct kvm_enable_cap {
#define KVM_CAP_S390_USER_OPEREXEC 246
#define KVM_CAP_S390_KEYOP 247
#define KVM_CAP_S390_VSIE_ESAMODE 248
+#define KVM_CAP_S390_HPAGE_2G 249
+#define KVM_CAP_PPC_COMPAT_CAPS 250
+#define KVM_CAP_ARM_PMU_V3_STRICT 251
+#define KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES 252
struct kvm_irq_routing_irqchip {
__u32 irqchip;
@@ -1340,6 +1344,8 @@ struct kvm_s390_keyop {
/* Available with KVM_CAP_COUNTER_OFFSET */
#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO, 0xb5, struct kvm_arm_counter_offset)
#define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO, 0xb6, struct reg_mask_range)
+/* Available with KVM_CAP_PPC_COMPAT_CAPS */
+#define KVM_PPC_GET_COMPAT_CAPS _IO(KVMIO, 0xb8)
/* ioctl for vm fd */
#define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
@@ -1648,6 +1654,21 @@ struct kvm_memory_attributes {
__u64 flags;
};
+/* Available with KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES */
+#define KVM_SET_MEMORY_ATTRIBUTES2 _IOWR(KVMIO, 0xd2, struct kvm_memory_attributes2)
+
+struct kvm_memory_attributes2 {
+ union {
+ __u64 address;
+ __u64 offset;
+ };
+ __u64 size;
+ __u64 attributes;
+ __u64 flags;
+ __u64 error_offset;
+ __u64 reserved[11];
+};
+
#define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3)
#define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd)
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h
index 7e6ec2ff..0506539e 100644
--- a/include/linux/virtio_console.h
+++ b/include/linux/virtio_console.h
@@ -44,7 +44,7 @@
#define VIRTIO_CONSOLE_BAD_ID (~(__u32)0)
struct virtio_console_config {
- /* colums of the screens */
+ /* columns of the screens */
__virtio16 cols;
/* rows of the screens */
__virtio16 rows;
diff --git a/include/linux/virtio_ids.h b/include/linux/virtio_ids.h
index 6c12db16..f9056af0 100644
--- a/include/linux/virtio_ids.h
+++ b/include/linux/virtio_ids.h
@@ -69,6 +69,7 @@
#define VIRTIO_ID_BT 40 /* virtio bluetooth */
#define VIRTIO_ID_GPIO 41 /* virtio gpio */
#define VIRTIO_ID_SPI 45 /* virtio spi */
+#define VIRTIO_ID_MEDIA 48 /* virtio media */
/*
* Virtio Transitional IDs
diff --git a/powerpc/include/asm/kvm.h b/powerpc/include/asm/kvm.h
index 077c5437..913a64b9 100644
--- a/powerpc/include/asm/kvm.h
+++ b/powerpc/include/asm/kvm.h
@@ -437,6 +437,24 @@ struct kvm_ppc_cpu_char {
__u64 behaviour_mask; /* valid bits in behaviour */
};
+/* For KVM_PPC_GET_COMPAT_CAPS */
+struct kvm_ppc_compat_caps {
+ __u64 size; /* Size of this structure */
+ __u64 flags; /* Reserved for future use */
+ __u64 compat_capabilities; /* Capabilities supported by the host */
+};
+#define KVM_PPC_COMPAT_CAPS_SIZE_VER0 24 /* sizeof first published struct */
+
+/*
+ * Capability bits for compat_capabilities field in kvm_ppc_compat_caps.
+ * These bits indicate which processor compatibility modes are supported.
+ */
+#define KVM_PPC_COMPAT_CAP_POWER9 (1ULL << 62)
+#define KVM_PPC_COMPAT_CAP_POWER10 (1ULL << 61)
+#define KVM_PPC_COMPAT_CAP_POWER11 (1ULL << 60)
+#define KVM_PPC_COMPAT_BITMASK (KVM_PPC_COMPAT_CAP_POWER9 | \
+ KVM_PPC_COMPAT_CAP_POWER10 | \
+ KVM_PPC_COMPAT_CAP_POWER11)
/*
* Values for character and character_mask.
* These are identical to the values used by H_GET_CPU_CHARACTERISTICS.
diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
index 504e7330..39b0f3f1 100644
--- a/riscv/include/asm/kvm.h
+++ b/riscv/include/asm/kvm.h
@@ -102,6 +102,11 @@ struct kvm_riscv_smstateen_csr {
unsigned long sstateen0;
};
+/* Zicfiss CSR for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
+struct kvm_riscv_zicfiss_csr {
+ unsigned long ssp;
+};
+
/* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
struct kvm_riscv_timer {
__u64 frequency;
@@ -199,6 +204,12 @@ enum KVM_RISCV_ISA_EXT_ID {
KVM_RISCV_ISA_EXT_ZCLSD,
KVM_RISCV_ISA_EXT_ZILSD,
KVM_RISCV_ISA_EXT_ZALASR,
+ KVM_RISCV_ISA_EXT_ZICFILP,
+ KVM_RISCV_ISA_EXT_ZICFISS,
+ KVM_RISCV_ISA_EXT_ZICCLSM,
+ KVM_RISCV_ISA_EXT_ZICCAMOA,
+ KVM_RISCV_ISA_EXT_ZICCIF,
+ KVM_RISCV_ISA_EXT_ZA64RS,
KVM_RISCV_ISA_EXT_MAX,
};
@@ -240,6 +251,9 @@ struct kvm_riscv_sbi_fwft_feature {
struct kvm_riscv_sbi_fwft {
struct kvm_riscv_sbi_fwft_feature misaligned_deleg;
struct kvm_riscv_sbi_fwft_feature pointer_masking;
+ struct kvm_riscv_sbi_fwft_feature pte_ad_hw_updating;
+ struct kvm_riscv_sbi_fwft_feature landing_pad;
+ struct kvm_riscv_sbi_fwft_feature shadow_stack;
};
/* If you need to interpret the index values, here is the key: */
@@ -263,12 +277,15 @@ struct kvm_riscv_sbi_fwft {
#define KVM_REG_RISCV_CSR_GENERAL (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
#define KVM_REG_RISCV_CSR_AIA (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
#define KVM_REG_RISCV_CSR_SMSTATEEN (0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_CSR_ZICFISS (0x3 << KVM_REG_RISCV_SUBTYPE_SHIFT)
#define KVM_REG_RISCV_CSR_REG(name) \
(offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long))
#define KVM_REG_RISCV_CSR_AIA_REG(name) \
(offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long))
#define KVM_REG_RISCV_CSR_SMSTATEEN_REG(name) \
(offsetof(struct kvm_riscv_smstateen_csr, name) / sizeof(unsigned long))
+#define KVM_REG_RISCV_CSR_ZICFISS_REG(name) \
+ (offsetof(struct kvm_riscv_zicfiss_csr, name) / sizeof(unsigned long))
/* Timer registers are mapped as type 4 */
#define KVM_REG_RISCV_TIMER (0x04 << KVM_REG_RISCV_TYPE_SHIFT)
diff --git a/x86/include/asm/kvm.h b/x86/include/asm/kvm.h
index 5f2b30d0..00ce2653 100644
--- a/x86/include/asm/kvm.h
+++ b/x86/include/asm/kvm.h
@@ -45,9 +45,7 @@
#define __KVM_HAVE_PIT
#define __KVM_HAVE_IOAPIC
#define __KVM_HAVE_IRQ_LINE
-#define __KVM_HAVE_MSI
#define __KVM_HAVE_USER_NMI
-#define __KVM_HAVE_MSIX
#define __KVM_HAVE_MCE
#define __KVM_HAVE_PIT_STATE2
#define __KVM_HAVE_XEN_HVM
@@ -477,6 +475,7 @@ struct kvm_sync_regs {
#define KVM_X86_QUIRK_STUFF_FEATURE_MSRS (1 << 8)
#define KVM_X86_QUIRK_IGNORE_GUEST_PAT (1 << 9)
#define KVM_X86_QUIRK_VMCS12_ALLOW_FREEZE_IN_SMM (1 << 10)
+#define KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT (1 << 11)
#define KVM_STATE_NESTED_FORMAT_VMX 0
#define KVM_STATE_NESTED_FORMAT_SVM 1
@@ -532,6 +531,7 @@ struct kvm_svm_nested_state_data {
struct kvm_svm_nested_state_hdr {
__u64 vmcb_pa;
+ __u64 gpat;
};
/* for KVM_CAP_NESTED_STATE */
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 05/23] arm64: Add GICv5 irqchip device support
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (3 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 04/23] Sync kernel UAPI headers with v7.4-rc1 Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 06/23] arm64: Configure GIC interrupt bases Sascha Bischoff
` (17 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Add IRQCHIP_GICV5 and create KVM_DEV_TYPE_ARM_VGIC_V5 for it. GICv5
has no distributor or redistributor MMIO frame, so omit those address
attributes.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 5 +++++
arm64/include/kvm/gic.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/arm64/gic.c b/arm64/gic.c
index 57f3fa02..51a32159 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -227,6 +227,9 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
case IRQCHIP_GICV3_ITS:
gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V3;
break;
+ case IRQCHIP_GICV5:
+ gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V5;
+ break;
case IRQCHIP_AUTO:
return -ENODEV;
}
@@ -321,6 +324,8 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
gic_redists_base = ARM_GIC_DIST_BASE - gic_redists_size;
gic_msi_base = gic_redists_base - gic_msi_size;
break;
+ case IRQCHIP_GICV5:
+ break;
default:
return -ENODEV;
}
diff --git a/arm64/include/kvm/gic.h b/arm64/include/kvm/gic.h
index 8490cca6..630f0bbd 100644
--- a/arm64/include/kvm/gic.h
+++ b/arm64/include/kvm/gic.h
@@ -29,6 +29,7 @@ enum irqchip_type {
IRQCHIP_GICV2M,
IRQCHIP_GICV3,
IRQCHIP_GICV3_ITS,
+ IRQCHIP_GICV5,
};
struct kvm;
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 06/23] arm64: Configure GIC interrupt bases
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (4 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 05/23] arm64: Add GICv5 irqchip device support Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 07/23] irq: Allow the initial interrupt line number to be set Sascha Bischoff
` (16 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Record the SPI and PPI bases for the selected irqchip and expose getters
to code that does not receive the irqchip type. Configure the bases
after the GIC device and MSI frame have been created.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 48 +++++++++++++++++++++++++++++++++++++++++
arm64/include/kvm/gic.h | 4 ++++
2 files changed, 52 insertions(+)
diff --git a/arm64/gic.c b/arm64/gic.c
index 51a32159..df5689a7 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -21,6 +21,18 @@ static u64 gic_redists_size;
static u64 gic_msi_base;
static u64 gic_msi_size = 0;
static bool vgic_is_init = false;
+static int gic_spi_base = GIC_SPI_IRQ_BASE;
+static int gic_ppi_base = GIC_PPI_IRQ_BASE;
+
+int gic__get_spi_base(void)
+{
+ return gic_spi_base;
+}
+
+int gic__get_ppi_base(void)
+{
+ return gic_ppi_base;
+}
struct kvm_irqfd_line {
unsigned int gsi;
@@ -211,6 +223,34 @@ static int gic__set_dist(enum irqchip_type type)
}
}
+static int gic__set_spi(enum irqchip_type type)
+{
+ switch (type) {
+ case IRQCHIP_GICV5:
+ gic_spi_base = GICV5_SPI_IRQ_BASE;
+ break;
+ default:
+ gic_spi_base = GIC_SPI_IRQ_BASE;
+ break;
+ }
+
+ return 0;
+}
+
+static int gic__set_ppi(enum irqchip_type type)
+{
+ switch (type) {
+ case IRQCHIP_GICV5:
+ gic_ppi_base = GICV5_PPI_IRQ_BASE;
+ break;
+ default:
+ gic_ppi_base = GIC_PPI_IRQ_BASE;
+ break;
+ }
+
+ return 0;
+}
+
static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
{
int err;
@@ -256,6 +296,14 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
if (err)
goto out_err;
+ err = gic__set_spi(type);
+ if (err)
+ goto out_err;
+
+ err = gic__set_ppi(type);
+ if (err)
+ goto out_err;
+
return 0;
out_err:
diff --git a/arm64/include/kvm/gic.h b/arm64/include/kvm/gic.h
index 630f0bbd..c4f78cde 100644
--- a/arm64/include/kvm/gic.h
+++ b/arm64/include/kvm/gic.h
@@ -4,6 +4,8 @@
#define GIC_SGI_IRQ_BASE 0
#define GIC_PPI_IRQ_BASE 16
#define GIC_SPI_IRQ_BASE 32
+#define GICV5_PPI_IRQ_BASE 0
+#define GICV5_SPI_IRQ_BASE 0
#define GIC_FDT_IRQ_NUM_CELLS 3
@@ -34,6 +36,8 @@ enum irqchip_type {
struct kvm;
+int gic__get_spi_base(void);
+int gic__get_ppi_base(void);
int gic__alloc_irqnum(void);
int gic__create(struct kvm *kvm, enum irqchip_type type);
int gic__create_gicv2m_frame(struct kvm *kvm, u64 msi_frame_addr);
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 07/23] irq: Allow the initial interrupt line number to be set
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (5 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 06/23] arm64: Configure GIC interrupt bases Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 08/23] arm64: Start GICv5 SPI line allocation at zero Sascha Bischoff
` (15 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Allow callers to select the initial IRQ line number before allocating
any lines. Track the selected offset when reporting the number of
allocated lines.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
include/kvm/irq.h | 1 +
irq.c | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/kvm/irq.h b/include/kvm/irq.h
index 2a3f8c9d..17113979 100644
--- a/include/kvm/irq.h
+++ b/include/kvm/irq.h
@@ -23,6 +23,7 @@ extern struct msi_routing_ops *msi_routing_ops;
extern struct kvm_irq_routing *irq_routing;
extern int next_gsi;
+int irq__init_irq_offset(u8 offset);
int irq__alloc_line(void);
int irq__get_nr_allocated_lines(void);
diff --git a/irq.c b/irq.c
index cdcf9923..7c4bfec4 100644
--- a/irq.c
+++ b/irq.c
@@ -8,6 +8,7 @@
#include "kvm/irq.h"
#include "kvm/kvm-arch.h"
+static u8 irq_offset = KVM_IRQ_OFFSET;
static u8 next_line = KVM_IRQ_OFFSET;
static int allocated_gsis = 0;
@@ -18,6 +19,18 @@ struct msi_routing_ops *msi_routing_ops = &irq__default_routing_ops;
struct kvm_irq_routing *irq_routing = NULL;
+/* Override the default offset before the first IRQ allocation. */
+int irq__init_irq_offset(u8 offset)
+{
+ if (irq__get_nr_allocated_lines())
+ return -EBUSY;
+
+ irq_offset = offset;
+ next_line = offset;
+
+ return 0;
+}
+
int irq__alloc_line(void)
{
return next_line++;
@@ -25,7 +38,7 @@ int irq__alloc_line(void)
int irq__get_nr_allocated_lines(void)
{
- return next_line - KVM_IRQ_OFFSET;
+ return next_line - irq_offset;
}
int irq__allocate_routing_entry(void)
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 08/23] arm64: Start GICv5 SPI line allocation at zero
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (6 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 07/23] irq: Allow the initial interrupt line number to be set Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS Sascha Bischoff
` (14 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
GICv5 SPIs start at zero, while earlier GICs use an offset of 32.
Select the zero offset before allocating any interrupt lines.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arm64/gic.c b/arm64/gic.c
index df5689a7..58644036 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -234,6 +234,9 @@ static int gic__set_spi(enum irqchip_type type)
break;
}
+ if (gic_spi_base == GICV5_SPI_IRQ_BASE)
+ return irq__init_irq_offset(gic_spi_base);
+
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (7 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 08/23] arm64: Start GICv5 SPI line allocation at zero Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-19 9:40 ` Vladimir Murzin
2026-11-18 17:57 ` [PATCH kvmtool v5 10/23] arm64: Define GICv5 interrupt types Sascha Bischoff
` (13 subsequent siblings)
22 siblings, 1 reply; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Place the IRS CONFIG and SETLPI frames in two 64 KiB regions below the
guest AXI area, and pass the IRS base to KVM through
KVM_VGIC_V5_ADDR_TYPE_IRS.
The GICv5 NR_IRQS attribute counts SPIs without the 32 SGI/PPI lines
included for earlier GICs. Use that count for GICv5 while retaining
the existing count for GICv2/v3. Allow zero-based GICv5 IRQ numbers
when setting the level through KVM_IRQ_LINE.
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 30 ++++++++++++++++++++++++++++--
arm64/include/kvm/kvm-arch.h | 8 ++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index 58644036..5034b034 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -18,6 +18,7 @@
static int gic_fd = -1;
static u64 gic_redists_base;
static u64 gic_redists_size;
+static u64 gicv5_irs_base;
static u64 gic_msi_base;
static u64 gic_msi_size = 0;
static bool vgic_is_init = false;
@@ -201,6 +202,22 @@ static int gic__set_redist(enum irqchip_type type)
}
}
+static int gic__set_irs(enum irqchip_type type)
+{
+ struct kvm_device_attr irs_attr = {
+ .group = KVM_DEV_ARM_VGIC_GRP_ADDR,
+ .attr = KVM_VGIC_V5_ADDR_TYPE_IRS,
+ .addr = (u64)(unsigned long)&gicv5_irs_base,
+ };
+
+ switch (type) {
+ case IRQCHIP_GICV5:
+ return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &irs_attr);
+ default: /* No IRS needed */
+ return 0;
+ }
+}
+
static int gic__set_dist(enum irqchip_type type)
{
u64 dist_addr = ARM_GIC_DIST_BASE;
@@ -291,6 +308,10 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
if (err)
goto out_err;
+ err = gic__set_irs(type);
+ if (err)
+ goto out_err;
+
err = gic__set_dist(type);
if (err)
goto out_err;
@@ -376,6 +397,7 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
gic_msi_base = gic_redists_base - gic_msi_size;
break;
case IRQCHIP_GICV5:
+ gicv5_irs_base = ARM_GICV5_IRS_BASE;
break;
default:
return -ENODEV;
@@ -397,8 +419,9 @@ static int gic__init_gic(struct kvm *kvm)
int ret;
int lines = irq__get_nr_allocated_lines();
- u32 nr_irqs = ALIGN(lines, 32) + GIC_SPI_IRQ_BASE;
u32 maint_irq = GIC_PPI_IRQ_BASE + GIC_MAINT_IRQ;
+ u32 nr_irqs = max(ALIGN(lines, 32), 32);
+
struct kvm_device_attr nr_irqs_attr = {
.group = KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
.addr = (u64)(unsigned long)&nr_irqs,
@@ -412,6 +435,8 @@ static int gic__init_gic(struct kvm *kvm)
.attr = KVM_DEV_ARM_VGIC_CTRL_INIT,
};
+ nr_irqs += gic__get_spi_base();
+
/*
* If we didn't use the KVM_CREATE_DEVICE method, KVM will
* give us some default number of interrupts. The GIC initialization
@@ -540,12 +565,13 @@ u32 gic__get_fdt_irq_cpumask(struct kvm *kvm)
void kvm__irq_line(struct kvm *kvm, int irq, int level)
{
+ int spi_base = gic__get_spi_base();
struct kvm_irq_level irq_level = {
.irq = KVM_IRQCHIP_IRQ(irq),
.level = !!level,
};
- if (irq < GIC_SPI_IRQ_BASE || irq > GIC_MAX_IRQ)
+ if (irq < spi_base || irq > GIC_MAX_IRQ)
pr_warning("Ignoring invalid GIC IRQ %d", irq);
else if (ioctl(kvm->vm_fd, KVM_IRQ_LINE, &irq_level) < 0)
pr_warning("Could not KVM_IRQ_LINE for irq %d", irq);
diff --git a/arm64/include/kvm/kvm-arch.h b/arm64/include/kvm/kvm-arch.h
index e7dd5269..94140364 100644
--- a/arm64/include/kvm/kvm-arch.h
+++ b/arm64/include/kvm/kvm-arch.h
@@ -57,6 +57,14 @@
#define ARM_GIC_CPUI_SIZE 0x20000
+/* GICv5 IRS CONFIG and SETLPI frames occupy the end of the MMIO area. */
+#define ARM_GICV5_IRS_BASE (ARM_AXI_AREA - ARM_GICV5_IRS_SIZE)
+#define ARM_GICV5_IRS_SIZE (ARM_GICV5_IRS_CONFIG_SIZE + ARM_GICV5_IRS_SETLPI_SIZE)
+#define ARM_GICV5_IRS_CONFIG_BASE ARM_GICV5_IRS_BASE
+#define ARM_GICV5_IRS_CONFIG_SIZE 0x10000
+#define ARM_GICV5_IRS_SETLPI_BASE (ARM_GICV5_IRS_CONFIG_BASE + ARM_GICV5_IRS_CONFIG_SIZE)
+#define ARM_GICV5_IRS_SETLPI_SIZE 0x10000
+
#define KVM_PCI_CFG_AREA ARM_AXI_AREA
#define ARM_PCI_CFG_SIZE (1ULL << 28)
#define KVM_PCI_MMIO_AREA (KVM_PCI_CFG_AREA + ARM_PCI_CFG_SIZE)
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 10/23] arm64: Define GICv5 interrupt types
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (8 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 11/23] arm64: Describe the PMU interrupt for GICv5 Sascha Bischoff
` (12 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Define the PPI and SPI type values used by GICv5 interrupt specifiers,
and the type-field shift used to construct a full GICv5 INTID for
KVM's PMU IRQ attribute. Give the FDT type values distinct names while
retaining the same numeric values.
Suggested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 42 +++++++++++++++++++++++++++++++++++++----
arm64/include/kvm/gic.h | 9 +++++++++
2 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index 5034b034..83b034e3 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -24,6 +24,8 @@ static u64 gic_msi_size = 0;
static bool vgic_is_init = false;
static int gic_spi_base = GIC_SPI_IRQ_BASE;
static int gic_ppi_base = GIC_PPI_IRQ_BASE;
+static int gic_spi_fdt_type = GIC_FDT_IRQ_TYPE_SPI;
+static int gic_ppi_fdt_type = GIC_FDT_IRQ_TYPE_PPI;
int gic__get_spi_base(void)
{
@@ -35,6 +37,26 @@ int gic__get_ppi_base(void)
return gic_ppi_base;
}
+int gic__get_spi_fdt_type(void)
+{
+ return gic_spi_fdt_type;
+}
+
+int gic__get_ppi_fdt_type(void)
+{
+ return gic_ppi_fdt_type;
+}
+
+int gic__encode_ppi_irq(enum irqchip_type type, int irq)
+{
+ switch (type) {
+ case IRQCHIP_GICV5:
+ return irq | (GICV5_IRQ_TYPE_PPI << GICV5_IRQ_TYPE_SHIFT);
+ default:
+ return irq;
+ }
+}
+
struct kvm_irqfd_line {
unsigned int gsi;
int trigger_fd;
@@ -242,18 +264,28 @@ static int gic__set_dist(enum irqchip_type type)
static int gic__set_spi(enum irqchip_type type)
{
+ int spi_base, fdt_type;
+ int err;
+
switch (type) {
case IRQCHIP_GICV5:
- gic_spi_base = GICV5_SPI_IRQ_BASE;
+ spi_base = GICV5_SPI_IRQ_BASE;
+ fdt_type = GICV5_FDT_IRQ_TYPE_SPI;
break;
default:
- gic_spi_base = GIC_SPI_IRQ_BASE;
+ spi_base = GIC_SPI_IRQ_BASE;
+ fdt_type = GIC_FDT_IRQ_TYPE_SPI;
break;
}
- if (gic_spi_base == GICV5_SPI_IRQ_BASE)
- return irq__init_irq_offset(gic_spi_base);
+ if (spi_base == GICV5_SPI_IRQ_BASE) {
+ err = irq__init_irq_offset(spi_base);
+ if (err)
+ return err;
+ }
+ gic_spi_base = spi_base;
+ gic_spi_fdt_type = fdt_type;
return 0;
}
@@ -262,9 +294,11 @@ static int gic__set_ppi(enum irqchip_type type)
switch (type) {
case IRQCHIP_GICV5:
gic_ppi_base = GICV5_PPI_IRQ_BASE;
+ gic_ppi_fdt_type = GICV5_FDT_IRQ_TYPE_PPI;
break;
default:
gic_ppi_base = GIC_PPI_IRQ_BASE;
+ gic_ppi_fdt_type = GIC_FDT_IRQ_TYPE_PPI;
break;
}
diff --git a/arm64/include/kvm/gic.h b/arm64/include/kvm/gic.h
index c4f78cde..9f1a3a25 100644
--- a/arm64/include/kvm/gic.h
+++ b/arm64/include/kvm/gic.h
@@ -12,6 +12,12 @@
#define GIC_FDT_IRQ_TYPE_SPI 0
#define GIC_FDT_IRQ_TYPE_PPI 1
+#define GICV5_IRQ_TYPE_PPI 1
+#define GICV5_IRQ_TYPE_SPI 3
+#define GICV5_IRQ_TYPE_SHIFT 29
+#define GICV5_FDT_IRQ_TYPE_PPI GICV5_IRQ_TYPE_PPI
+#define GICV5_FDT_IRQ_TYPE_SPI GICV5_IRQ_TYPE_SPI
+
#define GIC_FDT_IRQ_PPI_CPU_SHIFT 8
#define GIC_FDT_IRQ_PPI_CPU_MASK (0xff << GIC_FDT_IRQ_PPI_CPU_SHIFT)
@@ -38,6 +44,9 @@ struct kvm;
int gic__get_spi_base(void);
int gic__get_ppi_base(void);
+int gic__get_spi_fdt_type(void);
+int gic__get_ppi_fdt_type(void);
+int gic__encode_ppi_irq(enum irqchip_type type, int irq);
int gic__alloc_irqnum(void);
int gic__create(struct kvm *kvm, enum irqchip_type type);
int gic__create_gicv2m_frame(struct kvm *kvm, u64 msi_frame_addr);
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 11/23] arm64: Describe the PMU interrupt for GICv5
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (9 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 10/23] arm64: Define GICv5 interrupt types Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 12/23] arm64: Describe timer PPIs " Sascha Bischoff
` (11 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Use the GICv5 PPI specifier in the DT. KVM also expects the PMU IRQ
attribute to contain the GICv5 interrupt type in the upper bits, so
encode it before setting KVM_ARM_VCPU_PMU_V3_IRQ.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/pmu.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arm64/pmu.c b/arm64/pmu.c
index ef7faca1..b3026d50 100644
--- a/arm64/pmu.c
+++ b/arm64/pmu.c
@@ -214,16 +214,17 @@ static int find_pmu(struct kvm *kvm)
void pmu__generate_fdt_nodes(void *fdt, struct kvm *kvm)
{
const char compatible[] = "arm,armv8-pmuv3";
+ int irq = KVM_ARM_PMUv3_PPI;
+ u32 irq_prop[3];
u32 cpu_mask = gic__get_fdt_irq_cpumask(kvm);
- u32 irq_prop[] = {
- cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI),
- cpu_to_fdt32(KVM_ARM_PMUv3_PPI - 16),
- cpu_to_fdt32(cpu_mask | IRQ_TYPE_LEVEL_HIGH),
- };
if (!kvm->cfg.arch.has_pmuv3)
return;
+ irq_prop[0] = cpu_to_fdt32(gic__get_ppi_fdt_type());
+ irq_prop[1] = cpu_to_fdt32(irq - gic__get_ppi_base());
+ irq_prop[2] = cpu_to_fdt32(cpu_mask | IRQ_TYPE_LEVEL_HIGH);
+
_FDT(fdt_begin_node(fdt, "pmu"));
_FDT(fdt_property(fdt, "compatible", compatible, sizeof(compatible)));
_FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop)));
@@ -248,6 +249,8 @@ int pmu__init(struct kvm *kvm)
}
}
+ irq = gic__encode_ppi_irq(kvm->cfg.arch.irqchip, irq);
+
for (i = 0; i < kvm->nrcpus; i++) {
vcpu = kvm->cpus[i];
set_pmu_attr(vcpu, &irq, KVM_ARM_VCPU_PMU_V3_IRQ);
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 12/23] arm64: Describe timer PPIs for GICv5
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (10 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 11/23] arm64: Describe the PMU interrupt for GICv5 Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 13/23] arm64: Assign CPU DT phandles Sascha Bischoff
` (10 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
GICv5 DT specifiers use absolute PPI numbers due to having separate
namespaces for the different interrupt types. Keep the existing
GICv2/v3 specifiers by subtracting the legacy PPI base for those
irqchips.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/timer.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arm64/timer.c b/arm64/timer.c
index 2ac6144f..5eff1e48 100644
--- a/arm64/timer.c
+++ b/arm64/timer.c
@@ -9,16 +9,18 @@ void timer__generate_fdt_nodes(void *fdt, struct kvm *kvm)
{
const char compatible[] = "arm,armv8-timer\0arm,armv7-timer";
u32 cpu_mask = gic__get_fdt_irq_cpumask(kvm);
- int irqs[5] = {13, 14, 11, 10, 12};
+ const int irqs[5] = { 29, 30, 27, 26, 28 };
int nr = ARRAY_SIZE(irqs);
u32 irq_prop[nr * 3];
+ u32 type = gic__get_ppi_fdt_type();
+ int ppi_base = gic__get_ppi_base();
if (!kvm->cfg.arch.nested_virt)
nr--;
for (int i = 0; i < nr; i++) {
- irq_prop[i * 3 + 0] = cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI);
- irq_prop[i * 3 + 1] = cpu_to_fdt32(irqs[i]);
+ irq_prop[i * 3 + 0] = cpu_to_fdt32(type);
+ irq_prop[i * 3 + 1] = cpu_to_fdt32(irqs[i] - ppi_base);
irq_prop[i * 3 + 2] = cpu_to_fdt32(cpu_mask | IRQ_TYPE_LEVEL_LOW);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 13/23] arm64: Assign CPU DT phandles
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (11 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 12/23] arm64: Describe timer PPIs " Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 14/23] arm64: Describe the GICv5 CPU interface in the DT Sascha Bischoff
` (9 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Assign stable phandles to all arm64 CPU nodes. The GICv5 IRS DT node
uses them to map IAFFIDs to CPUs; they remain unreferenced for earlier
GIC models.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/fdt.c | 1 +
arm64/include/kvm/fdt-arch.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/arm64/fdt.c b/arm64/fdt.c
index 3cbd36e2..5413956d 100644
--- a/arm64/fdt.c
+++ b/arm64/fdt.c
@@ -54,6 +54,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
_FDT(fdt_property_string(fdt, "enable-method", "psci"));
_FDT(fdt_property_cell(fdt, "reg", mpidr));
+ _FDT(fdt_property_cell(fdt, "phandle", PHANDLE_CPU_BASE + cpu));
_FDT(fdt_end_node(fdt));
}
diff --git a/arm64/include/kvm/fdt-arch.h b/arm64/include/kvm/fdt-arch.h
index 8a0a460e..2b667c53 100644
--- a/arm64/include/kvm/fdt-arch.h
+++ b/arm64/include/kvm/fdt-arch.h
@@ -11,4 +11,5 @@ enum phandles {
void generate_dma_region_prop(void *fdt);
+#define PHANDLE_CPU_BASE PHANDLES_MAX
#endif /* ARM__FDT_H */
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 14/23] arm64: Describe the GICv5 CPU interface in the DT
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (12 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 13/23] arm64: Assign CPU DT phandles Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS " Sascha Bischoff
` (8 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Emit an interrupt-controller node for the GICv5 CPU interface. This
provides the interrupt parent and allows guests to use PPIs.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arm64/gic.c b/arm64/gic.c
index 83b034e3..9a8f9916 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -519,6 +519,8 @@ static int gic__init_gic(struct kvm *kvm)
}
late_init(gic__init_gic)
+static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm);
+
void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
{
const char *compatible, *msi_compatible = NULL;
@@ -549,6 +551,8 @@ void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
reg_prop[2] = cpu_to_fdt64(gic_redists_base);
reg_prop[3] = cpu_to_fdt64(gic_redists_size);
break;
+ case IRQCHIP_GICV5:
+ return gic__generate_gicv5_fdt_nodes(fdt, kvm);
default:
return;
}
@@ -582,6 +586,22 @@ void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
_FDT(fdt_end_node(fdt));
}
+static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
+{
+ _FDT(fdt_begin_node(fdt, "gicv5-cpuif"));
+ _FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5"));
+ _FDT(fdt_property_cell(fdt, "#interrupt-cells", GIC_FDT_IRQ_NUM_CELLS));
+ _FDT(fdt_property(fdt, "interrupt-controller", NULL, 0));
+ _FDT(fdt_property_cell(fdt, "#address-cells", 2));
+ _FDT(fdt_property_cell(fdt, "#size-cells", 2));
+ _FDT(fdt_property(fdt, "ranges", NULL, 0));
+
+ /* Use a hard-coded phandle for the GIC to help wire things up */
+ _FDT(fdt_property_cell(fdt, "phandle", PHANDLE_GIC));
+
+ _FDT(fdt_end_node(fdt));
+}
+
u32 gic__get_fdt_irq_cpumask(struct kvm *kvm)
{
/* Only for GICv2 */
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS in the DT
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (13 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 14/23] arm64: Describe the GICv5 CPU interface in the DT Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-19 10:43 ` Vladimir Murzin
2026-11-18 17:57 ` [PATCH kvmtool v5 16/23] arm64: Generate GICv5 SPI specifiers for platform devices Sascha Bischoff
` (7 subsequent siblings)
22 siblings, 1 reply; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Describe the IRS CONFIG and SETLPI frames and associate each CPU
phandle with its IAFFID. This lets the guest discover and configure
the IRS for shared interrupts.
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arm64/gic.c b/arm64/gic.c
index 9a8f9916..e5a26252 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -588,6 +588,16 @@ void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
{
+ char node_at_addr[64];
+ u32 cpus[kvm->nrcpus];
+ u16 iaffids[kvm->nrcpus];
+ u64 irs_reg_prop[] = {
+ cpu_to_fdt64(ARM_GICV5_IRS_CONFIG_BASE),
+ cpu_to_fdt64(ARM_GICV5_IRS_CONFIG_SIZE),
+ cpu_to_fdt64(ARM_GICV5_IRS_SETLPI_BASE),
+ cpu_to_fdt64(ARM_GICV5_IRS_SETLPI_SIZE)
+ };
+
_FDT(fdt_begin_node(fdt, "gicv5-cpuif"));
_FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5"));
_FDT(fdt_property_cell(fdt, "#interrupt-cells", GIC_FDT_IRQ_NUM_CELLS));
@@ -599,6 +609,31 @@ static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
/* Use a hard-coded phandle for the GIC to help wire things up */
_FDT(fdt_property_cell(fdt, "phandle", PHANDLE_GIC));
+ /*
+ * GICv5 IRS node
+ */
+ snprintf(node_at_addr, sizeof(node_at_addr), "irs@%llx",
+ (unsigned long long)ARM_GICV5_IRS_CONFIG_BASE);
+ _FDT(fdt_begin_node(fdt, node_at_addr));
+ _FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5-irs"));
+ _FDT(fdt_property_cell(fdt, "#address-cells", 2));
+ _FDT(fdt_property_cell(fdt, "#size-cells", 2));
+ _FDT(fdt_property(fdt, "ranges", NULL, 0));
+
+ _FDT(fdt_property(fdt, "reg", irs_reg_prop, sizeof(irs_reg_prop)));
+ _FDT(fdt_property(fdt, "reg-names", "ns-config\0ns-setlpi",
+ sizeof("ns-config\0ns-setlpi")));
+
+ for (int cpu = 0; cpu < kvm->nrcpus; cpu++) {
+ cpus[cpu] = cpu_to_fdt32(PHANDLE_CPU_BASE + cpu);
+ iaffids[cpu] = cpu_to_fdt16(cpu);
+ }
+
+ _FDT(fdt_property(fdt, "cpus", cpus, sizeof(u32) * kvm->nrcpus));
+ _FDT(fdt_property(fdt, "arm,iaffids", iaffids, sizeof(u16) * kvm->nrcpus));
+
+ _FDT(fdt_end_node(fdt));
+
_FDT(fdt_end_node(fdt));
}
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 16/23] arm64: Generate GICv5 SPI specifiers for platform devices
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (14 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS " Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 17/23] arm64: Generate GICv5 PCI INTx specifiers Sascha Bischoff
` (6 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Use the GICv5 interrupt type and absolute SPI number for platform
devices. Preserve the legacy GICv2/v3 DT encoding for other VMs.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/fdt.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arm64/fdt.c b/arm64/fdt.c
index 5413956d..e92ae044 100644
--- a/arm64/fdt.c
+++ b/arm64/fdt.c
@@ -63,11 +63,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
static void generate_irq_prop(void *fdt, u8 irq, enum irq_type irq_type)
{
- u32 irq_prop[] = {
- cpu_to_fdt32(GIC_FDT_IRQ_TYPE_SPI),
- cpu_to_fdt32(irq - GIC_SPI_IRQ_BASE),
- cpu_to_fdt32(irq_type)
- };
+ u32 irq_prop[3];
+ u32 type = gic__get_spi_fdt_type();
+ u32 intid = irq - gic__get_spi_base();
+
+ irq_prop[0] = cpu_to_fdt32(type);
+ irq_prop[1] = cpu_to_fdt32(intid);
+ irq_prop[2] = cpu_to_fdt32(irq_type);
_FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop)));
}
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 17/23] arm64: Generate GICv5 PCI INTx specifiers
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (15 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 16/23] arm64: Generate GICv5 SPI specifiers for platform devices Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 18/23] arm64: Expose the GICv5 irqchip option Sascha Bischoff
` (5 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
PCI interrupt-map entries currently use the GICv2/v3 SPI type and an
IRQ number with the SPI base subtracted. GICv5 uses a different SPI
type (matching the hardware) and zero-based SPI numbers. Use the GICv5
encoding for its INTx entries while retaining the existing encoding
for other GICs.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/pci.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arm64/pci.c b/arm64/pci.c
index db87db8b..91265f67 100644
--- a/arm64/pci.c
+++ b/arm64/pci.c
@@ -84,6 +84,8 @@ void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm)
u8 pin = pci_hdr->irq_pin;
u8 irq = pci_hdr->irq_line;
u32 irq_flags = pci_hdr->irq_type;
+ u32 int_type = gic__get_spi_fdt_type();
+ u32 int_id = irq - gic__get_spi_base();
/*
* Avoid adding entries in "interrupt-map" for devices that
@@ -108,8 +110,8 @@ void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm)
.gic_addr_hi = 0,
.gic_addr_lo = 0,
.gic_irq = {
- .type = cpu_to_fdt32(GIC_FDT_IRQ_TYPE_SPI),
- .num = cpu_to_fdt32(irq - GIC_SPI_IRQ_BASE),
+ .type = cpu_to_fdt32(int_type),
+ .num = cpu_to_fdt32(int_id),
.flags = cpu_to_fdt32(irq_flags),
},
};
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 18/23] arm64: Expose the GICv5 irqchip option
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (16 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 17/23] arm64: Generate GICv5 PCI INTx specifiers Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 19/23] arm64: Add proposed GICv5 ITS UAPI definitions Sascha Bischoff
` (4 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Allow --irqchip=gicv5 and prefer GICv5 for automatic irqchip selection
when the kernel supports it. The IRS and guest DT support are now in
place.
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 4 +++-
arm64/include/kvm/kvm-config-arch.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index e5a26252..63e0b979 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -78,6 +78,8 @@ int irqchip_parser(const struct option *opt, const char *arg, int unset)
*type = IRQCHIP_GICV3;
} else if (!strcmp(arg, "gicv3-its")) {
*type = IRQCHIP_GICV3_ITS;
+ } else if (!strcmp(arg, "gicv5")) {
+ *type = IRQCHIP_GICV5;
} else {
pr_err("irqchip: unknown type \"%s\"\n", arg);
return -1;
@@ -405,7 +407,7 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
switch (type) {
case IRQCHIP_AUTO:
- for (try = IRQCHIP_GICV3_ITS; try >= IRQCHIP_GICV2; try--) {
+ for (try = IRQCHIP_GICV5; try >= IRQCHIP_GICV2; try--) {
err = gic__create(kvm, try);
if (!err)
break;
diff --git a/arm64/include/kvm/kvm-config-arch.h b/arm64/include/kvm/kvm-config-arch.h
index d8a8ef7f..46130663 100644
--- a/arm64/include/kvm/kvm-config-arch.h
+++ b/arm64/include/kvm/kvm-config-arch.h
@@ -59,7 +59,7 @@ int sve_vl_parser(const struct option *opt, const char *arg, int unset);
"transport (Deprecated: Use --virtio-transport " \
"option instead)", virtio_transport_parser, kvm), \
OPT_CALLBACK('\0', "irqchip", &(cfg)->irqchip, \
- "[gicv2|gicv2m|gicv3|gicv3-its]", \
+ "[gicv2|gicv2m|gicv3|gicv3-its|gicv5]", \
"Type of interrupt controller to emulate in the guest", \
irqchip_parser, NULL), \
OPT_U64('\0', "firmware-address", &(cfg)->fw_addr, \
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 19/23] arm64: Add proposed GICv5 ITS UAPI definitions
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (17 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 18/23] arm64: Expose the GICv5 irqchip option Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 20/23] arm64: Add GICv5 ITS device support Sascha Bischoff
` (3 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Mirror the GICv5 ITS device type, address type and size from the posted
KVM GICv5 ITS series. These definitions are not part of the v7.4-rc1
UAPI header sync.
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/include/asm/kvm.h | 2 ++
include/linux/kvm.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/arm64/include/asm/kvm.h b/arm64/include/asm/kvm.h
index 65ee09bd..8c701173 100644
--- a/arm64/include/asm/kvm.h
+++ b/arm64/include/asm/kvm.h
@@ -99,8 +99,10 @@ struct kvm_regs {
/* Supported VGICv5 address types */
#define KVM_VGIC_V5_ADDR_TYPE_IRS 6
+#define KVM_VGIC_V5_ADDR_TYPE_ITS 7
#define KVM_VGIC_V5_IRS_SIZE (2 * SZ_64K)
+#define KVM_VGIC_V5_ITS_SIZE (2 * 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 */
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 8dff2fc1..c0e11993 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -1239,6 +1239,8 @@ enum kvm_device_type {
#define KVM_DEV_TYPE_LOONGARCH_DMSINTC KVM_DEV_TYPE_LOONGARCH_DMSINTC
KVM_DEV_TYPE_ARM_VGIC_V5,
#define KVM_DEV_TYPE_ARM_VGIC_V5 KVM_DEV_TYPE_ARM_VGIC_V5
+ KVM_DEV_TYPE_ARM_VGIC_V5_ITS,
+#define KVM_DEV_TYPE_ARM_VGIC_V5_ITS KVM_DEV_TYPE_ARM_VGIC_V5_ITS
KVM_DEV_TYPE_MAX,
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 20/23] arm64: Add GICv5 ITS device support
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (18 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 19/23] arm64: Add proposed GICv5 ITS UAPI definitions Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 21/23] arm64: Describe the GICv5 ITS in the DT Sascha Bischoff
` (2 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Allow the GICv5 ITS irqchip to create a separate KVM ITS device and
place its CONFIG and TRANSLATE frames immediately below the IRS.
Reuse the ITS creation helper for GICv3 and GICv5, selecting the
device and address types for each model.
At this stage, --irqchip=gicv5-its is not yet exposed, and automatic
irqchip selection starts with GICv5.
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 24 ++++++++++++++++++------
arm64/include/kvm/gic.h | 1 +
arm64/include/kvm/kvm-arch.h | 8 ++++++++
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index 63e0b979..f19199a3 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -51,6 +51,7 @@ int gic__encode_ppi_irq(enum irqchip_type type, int irq)
{
switch (type) {
case IRQCHIP_GICV5:
+ case IRQCHIP_GICV5_ITS:
return irq | (GICV5_IRQ_TYPE_PPI << GICV5_IRQ_TYPE_SHIFT);
default:
return irq;
@@ -136,15 +137,15 @@ static int irq__routing_init(struct kvm *kvm)
return 0;
}
-static int gic__create_its_frame(struct kvm *kvm, u64 its_frame_addr)
+static int gic__create_its_frame(struct kvm *kvm, u64 its_frame_addr, const bool v5)
{
struct kvm_create_device its_device = {
- .type = KVM_DEV_TYPE_ARM_VGIC_ITS,
+ .type = v5 ? KVM_DEV_TYPE_ARM_VGIC_V5_ITS : KVM_DEV_TYPE_ARM_VGIC_ITS,
.flags = 0,
};
struct kvm_device_attr its_attr = {
.group = KVM_DEV_ARM_VGIC_GRP_ADDR,
- .attr = KVM_VGIC_ITS_ADDR_TYPE,
+ .attr = v5 ? KVM_VGIC_V5_ADDR_TYPE_ITS : KVM_VGIC_ITS_ADDR_TYPE,
.addr = (u64)(unsigned long)&its_frame_addr,
};
struct kvm_device_attr its_init_attr = {
@@ -155,8 +156,9 @@ static int gic__create_its_frame(struct kvm *kvm, u64 its_frame_addr)
err = ioctl(kvm->vm_fd, KVM_CREATE_DEVICE, &its_device);
if (err) {
- pr_err("GICv3 ITS requested, but kernel does not support it.");
- pr_err("Try --irqchip=gicv3 instead");
+ pr_err("GICv%c ITS requested, but kernel does not support it.",
+ v5 ? '5' : '3');
+ pr_err("Try --irqchip=gicv%c instead", v5 ? '5' : '3');
return err;
}
@@ -185,7 +187,9 @@ static int gic__create_msi_frame(struct kvm *kvm, enum irqchip_type type)
case IRQCHIP_GICV2M:
return gic__create_gicv2m_frame(kvm, gic_msi_base);
case IRQCHIP_GICV3_ITS:
- return gic__create_its_frame(kvm, gic_msi_base);
+ return gic__create_its_frame(kvm, gic_msi_base, false);
+ case IRQCHIP_GICV5_ITS:
+ return gic__create_its_frame(kvm, gic_msi_base, true);
default: /* No MSI frame needed */
return 0;
}
@@ -236,6 +240,7 @@ static int gic__set_irs(enum irqchip_type type)
switch (type) {
case IRQCHIP_GICV5:
+ case IRQCHIP_GICV5_ITS:
return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &irs_attr);
default: /* No IRS needed */
return 0;
@@ -271,6 +276,7 @@ static int gic__set_spi(enum irqchip_type type)
switch (type) {
case IRQCHIP_GICV5:
+ case IRQCHIP_GICV5_ITS:
spi_base = GICV5_SPI_IRQ_BASE;
fdt_type = GICV5_FDT_IRQ_TYPE_SPI;
break;
@@ -295,6 +301,7 @@ static int gic__set_ppi(enum irqchip_type type)
{
switch (type) {
case IRQCHIP_GICV5:
+ case IRQCHIP_GICV5_ITS:
gic_ppi_base = GICV5_PPI_IRQ_BASE;
gic_ppi_fdt_type = GICV5_FDT_IRQ_TYPE_PPI;
break;
@@ -323,6 +330,7 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
case IRQCHIP_GICV3_ITS:
gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V3;
break;
+ case IRQCHIP_GICV5_ITS:
case IRQCHIP_GICV5:
gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V5;
break;
@@ -432,6 +440,10 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
gic_redists_base = ARM_GIC_DIST_BASE - gic_redists_size;
gic_msi_base = gic_redists_base - gic_msi_size;
break;
+ case IRQCHIP_GICV5_ITS:
+ gic_msi_base = ARM_GICV5_ITS_BASE;
+ gic_msi_size = ARM_GICV5_ITS_SIZE;
+ /* fall through */
case IRQCHIP_GICV5:
gicv5_irs_base = ARM_GICV5_IRS_BASE;
break;
diff --git a/arm64/include/kvm/gic.h b/arm64/include/kvm/gic.h
index 9f1a3a25..0a5c70a1 100644
--- a/arm64/include/kvm/gic.h
+++ b/arm64/include/kvm/gic.h
@@ -38,6 +38,7 @@ enum irqchip_type {
IRQCHIP_GICV3,
IRQCHIP_GICV3_ITS,
IRQCHIP_GICV5,
+ IRQCHIP_GICV5_ITS,
};
struct kvm;
diff --git a/arm64/include/kvm/kvm-arch.h b/arm64/include/kvm/kvm-arch.h
index 94140364..3b0ffead 100644
--- a/arm64/include/kvm/kvm-arch.h
+++ b/arm64/include/kvm/kvm-arch.h
@@ -65,6 +65,14 @@
#define ARM_GICV5_IRS_SETLPI_BASE (ARM_GICV5_IRS_CONFIG_BASE + ARM_GICV5_IRS_CONFIG_SIZE)
#define ARM_GICV5_IRS_SETLPI_SIZE 0x10000
+/* GICv5 ITS CONFIG and TRANSLATE frames precede the IRS frames. */
+#define ARM_GICV5_ITS_BASE (ARM_GICV5_IRS_BASE - ARM_GICV5_ITS_SIZE)
+#define ARM_GICV5_ITS_SIZE (ARM_GICV5_ITS_CONFIG_SIZE + ARM_GICV5_ITS_TRANSL_SIZE)
+#define ARM_GICV5_ITS_CONFIG_BASE ARM_GICV5_ITS_BASE
+#define ARM_GICV5_ITS_CONFIG_SIZE 0x10000
+#define ARM_GICV5_ITS_TRANSL_BASE (ARM_GICV5_ITS_CONFIG_BASE + ARM_GICV5_ITS_CONFIG_SIZE)
+#define ARM_GICV5_ITS_TRANSL_SIZE 0x10000
+
#define KVM_PCI_CFG_AREA ARM_AXI_AREA
#define ARM_PCI_CFG_SIZE (1ULL << 28)
#define KVM_PCI_MMIO_AREA (KVM_PCI_CFG_AREA + ARM_PCI_CFG_SIZE)
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 21/23] arm64: Describe the GICv5 ITS in the DT
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (19 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 20/23] arm64: Add GICv5 ITS device support Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 22/23] arm64: Map PCI MSI requester IDs to the GICv5 ITS Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 23/23] arm64: Expose the GICv5 ITS irqchip option Sascha Bischoff
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Add an ITS node below the GICv5 IRS node with the CONFIG frame as its
register region. Add an MSI controller child node for the TRANSLATE
frame, with a phandle and one MSI cell carrying the DeviceID.
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/arm64/gic.c b/arm64/gic.c
index f19199a3..1f837049 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -565,6 +565,7 @@ void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
reg_prop[2] = cpu_to_fdt64(gic_redists_base);
reg_prop[3] = cpu_to_fdt64(gic_redists_size);
break;
+ case IRQCHIP_GICV5_ITS:
case IRQCHIP_GICV5:
return gic__generate_gicv5_fdt_nodes(fdt, kvm);
default:
@@ -612,6 +613,16 @@ static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
cpu_to_fdt64(ARM_GICV5_IRS_SETLPI_SIZE)
};
+ u64 its_config_reg_prop[] = {
+ cpu_to_fdt64(ARM_GICV5_ITS_CONFIG_BASE),
+ cpu_to_fdt64(ARM_GICV5_ITS_CONFIG_SIZE),
+ };
+
+ u64 its_trans_reg_prop[] = {
+ cpu_to_fdt64(ARM_GICV5_ITS_TRANSL_BASE),
+ cpu_to_fdt64(ARM_GICV5_ITS_TRANSL_SIZE)
+ };
+
_FDT(fdt_begin_node(fdt, "gicv5-cpuif"));
_FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5"));
_FDT(fdt_property_cell(fdt, "#interrupt-cells", GIC_FDT_IRQ_NUM_CELLS));
@@ -646,6 +657,36 @@ static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
_FDT(fdt_property(fdt, "cpus", cpus, sizeof(u32) * kvm->nrcpus));
_FDT(fdt_property(fdt, "arm,iaffids", iaffids, sizeof(u16) * kvm->nrcpus));
+ if (kvm->cfg.arch.irqchip == IRQCHIP_GICV5_ITS) {
+ /*
+ * GICv5 ITS node
+ */
+ snprintf(node_at_addr, sizeof(node_at_addr), "its@%llx",
+ (unsigned long long)ARM_GICV5_ITS_CONFIG_BASE);
+ _FDT(fdt_begin_node(fdt, node_at_addr));
+ _FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5-its"));
+ _FDT(fdt_property_cell(fdt, "#address-cells", 2));
+ _FDT(fdt_property_cell(fdt, "#size-cells", 2));
+ _FDT(fdt_property(fdt, "ranges", NULL, 0));
+
+ _FDT(fdt_property(fdt, "reg", its_config_reg_prop, sizeof(its_config_reg_prop)));
+ _FDT(fdt_property_string(fdt, "reg-names", "ns-config"));
+
+ snprintf(node_at_addr, sizeof(node_at_addr), "msi-controller@%llx",
+ (unsigned long long)ARM_GICV5_ITS_TRANSL_BASE);
+ _FDT(fdt_begin_node(fdt, node_at_addr));
+ _FDT(fdt_property_cell(fdt, "phandle", PHANDLE_MSI));
+ _FDT(fdt_property(fdt, "msi-controller", NULL, 0));
+ _FDT(fdt_property_cell(fdt, "#msi-cells", 1));
+
+ _FDT(fdt_property(fdt, "reg", its_trans_reg_prop, sizeof(its_trans_reg_prop)));
+ _FDT(fdt_property_string(fdt, "reg-names", "ns-translate"));
+
+ _FDT(fdt_end_node(fdt));
+
+ _FDT(fdt_end_node(fdt));
+ }
+
_FDT(fdt_end_node(fdt));
_FDT(fdt_end_node(fdt));
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 22/23] arm64: Map PCI MSI requester IDs to the GICv5 ITS
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (20 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 21/23] arm64: Describe the GICv5 ITS in the DT Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 23/23] arm64: Expose the GICv5 ITS irqchip option Sascha Bischoff
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
The GICv5 ITS MSI controller requires one MSI cell carrying the
DeviceID. Describe an identity mapping from the 16-bit PCI requester
ID to the ITS DeviceID with msi-map. Keep the existing msi-parent
property for GICv2m and GICv3 ITS.
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/pci.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/arm64/pci.c b/arm64/pci.c
index 91265f67..69e180b5 100644
--- a/arm64/pci.c
+++ b/arm64/pci.c
@@ -32,6 +32,12 @@ void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm)
unsigned nentries = 0;
/* Bus range */
u32 bus_range[] = { cpu_to_fdt32(0), cpu_to_fdt32(0), };
+ u32 msi_map[] = {
+ cpu_to_fdt32(0),
+ cpu_to_fdt32(PHANDLE_MSI),
+ cpu_to_fdt32(0),
+ cpu_to_fdt32(0x10000),
+ };
/* Configuration Space */
u64 cfg_reg_prop[] = { cpu_to_fdt64(KVM_PCI_CFG_AREA),
cpu_to_fdt64(ARM_PCI_CFG_SIZE), };
@@ -70,8 +76,18 @@ void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm)
_FDT(fdt_property(fdt, "reg", &cfg_reg_prop, sizeof(cfg_reg_prop)));
_FDT(fdt_property(fdt, "ranges", ranges, sizeof(ranges)));
- if (irqchip == IRQCHIP_GICV2M || irqchip == IRQCHIP_GICV3_ITS)
+ switch (irqchip) {
+ case IRQCHIP_GICV2M:
+ case IRQCHIP_GICV3_ITS:
_FDT(fdt_property_cell(fdt, "msi-parent", PHANDLE_MSI));
+ break;
+ case IRQCHIP_GICV5_ITS:
+ _FDT(fdt_property(fdt, "msi-map", msi_map, sizeof(msi_map)));
+ break;
+ default:
+ /* No MSI */
+ break;
+ }
generate_dma_region_prop(fdt);
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH kvmtool v5 23/23] arm64: Expose the GICv5 ITS irqchip option
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
` (21 preceding siblings ...)
2026-11-18 17:57 ` [PATCH kvmtool v5 22/23] arm64: Map PCI MSI requester IDs to the GICv5 ITS Sascha Bischoff
@ 2026-11-18 17:57 ` Sascha Bischoff
22 siblings, 0 replies; 26+ messages in thread
From: Sascha Bischoff @ 2026-11-18 17:57 UTC (permalink / raw)
To: will, julien.thierry.kdev
Cc: vladimir.murzin, maz, kvm, kvmarm, timothy.hayes, Peter Maydell
Allow --irqchip=gicv5-its now that the ITS DT nodes and PCI MSI
requester mapping are in place. Start automatic irqchip selection at
GICv5 ITS so it is preferred ahead of base GICv5 and older models.
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
arm64/gic.c | 4 +++-
arm64/include/kvm/kvm-config-arch.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arm64/gic.c b/arm64/gic.c
index 1f837049..774a503b 100644
--- a/arm64/gic.c
+++ b/arm64/gic.c
@@ -81,6 +81,8 @@ int irqchip_parser(const struct option *opt, const char *arg, int unset)
*type = IRQCHIP_GICV3_ITS;
} else if (!strcmp(arg, "gicv5")) {
*type = IRQCHIP_GICV5;
+ } else if (!strcmp(arg, "gicv5-its")) {
+ *type = IRQCHIP_GICV5_ITS;
} else {
pr_err("irqchip: unknown type \"%s\"\n", arg);
return -1;
@@ -415,7 +417,7 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
switch (type) {
case IRQCHIP_AUTO:
- for (try = IRQCHIP_GICV5; try >= IRQCHIP_GICV2; try--) {
+ for (try = IRQCHIP_GICV5_ITS; try >= IRQCHIP_GICV2; try--) {
err = gic__create(kvm, try);
if (!err)
break;
diff --git a/arm64/include/kvm/kvm-config-arch.h b/arm64/include/kvm/kvm-config-arch.h
index 46130663..936b142d 100644
--- a/arm64/include/kvm/kvm-config-arch.h
+++ b/arm64/include/kvm/kvm-config-arch.h
@@ -59,7 +59,7 @@ int sve_vl_parser(const struct option *opt, const char *arg, int unset);
"transport (Deprecated: Use --virtio-transport " \
"option instead)", virtio_transport_parser, kvm), \
OPT_CALLBACK('\0', "irqchip", &(cfg)->irqchip, \
- "[gicv2|gicv2m|gicv3|gicv3-its|gicv5]", \
+ "[gicv2|gicv2m|gicv3|gicv3-its|gicv5|gicv5-its]", \
"Type of interrupt controller to emulate in the guest", \
irqchip_parser, NULL), \
OPT_U64('\0', "firmware-address", &(cfg)->fw_addr, \
--
2.34.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS
2026-11-18 17:57 ` [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS Sascha Bischoff
@ 2026-11-19 9:40 ` Vladimir Murzin
0 siblings, 0 replies; 26+ messages in thread
From: Vladimir Murzin @ 2026-11-19 9:40 UTC (permalink / raw)
To: Sascha Bischoff, will, julien.thierry.kdev
Cc: maz, kvm, kvmarm, timothy.hayes, Peter Maydell
On 11/18/26 17:57, Sascha Bischoff wrote:
> Place the IRS CONFIG and SETLPI frames in two 64 KiB regions below the
> guest AXI area, and pass the IRS base to KVM through
> KVM_VGIC_V5_ADDR_TYPE_IRS.
>
> The GICv5 NR_IRQS attribute counts SPIs without the 32 SGI/PPI lines
> included for earlier GICs. Use that count for GICv5 while retaining
> the existing count for GICv2/v3. Allow zero-based GICv5 IRQ numbers
> when setting the level through KVM_IRQ_LINE.
>
> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
> Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
> ---
> arm64/gic.c | 30 ++++++++++++++++++++++++++++--
> arm64/include/kvm/kvm-arch.h | 8 ++++++++
> 2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/arm64/gic.c b/arm64/gic.c
> index 58644036..5034b034 100644
> --- a/arm64/gic.c
> +++ b/arm64/gic.c
> @@ -18,6 +18,7 @@
> static int gic_fd = -1;
> static u64 gic_redists_base;
> static u64 gic_redists_size;
> +static u64 gicv5_irs_base;
> static u64 gic_msi_base;
> static u64 gic_msi_size = 0;
> static bool vgic_is_init = false;
> @@ -201,6 +202,22 @@ static int gic__set_redist(enum irqchip_type type)
> }
> }
>
> +static int gic__set_irs(enum irqchip_type type)
> +{
> + struct kvm_device_attr irs_attr = {
> + .group = KVM_DEV_ARM_VGIC_GRP_ADDR,
> + .attr = KVM_VGIC_V5_ADDR_TYPE_IRS,
> + .addr = (u64)(unsigned long)&gicv5_irs_base,
> + };
> +
> + switch (type) {
> + case IRQCHIP_GICV5:
> + return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &irs_attr);
> + default: /* No IRS needed */
> + return 0;
> + }
> +}
> +
> static int gic__set_dist(enum irqchip_type type)
> {
> u64 dist_addr = ARM_GIC_DIST_BASE;
> @@ -291,6 +308,10 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
> if (err)
> goto out_err;
>
> + err = gic__set_irs(type);
> + if (err)
> + goto out_err;
> +
> err = gic__set_dist(type);
> if (err)
> goto out_err;
> @@ -376,6 +397,7 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
> gic_msi_base = gic_redists_base - gic_msi_size;
> break;
> case IRQCHIP_GICV5:
> + gicv5_irs_base = ARM_GICV5_IRS_BASE;
> break;
> default:
> return -ENODEV;
> @@ -397,8 +419,9 @@ static int gic__init_gic(struct kvm *kvm)
> int ret;
>
> int lines = irq__get_nr_allocated_lines();
> - u32 nr_irqs = ALIGN(lines, 32) + GIC_SPI_IRQ_BASE;
> u32 maint_irq = GIC_PPI_IRQ_BASE + GIC_MAINT_IRQ;
> + u32 nr_irqs = max(ALIGN(lines, 32), 32);
> +
> struct kvm_device_attr nr_irqs_attr = {
> .group = KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> .addr = (u64)(unsigned long)&nr_irqs,
> @@ -412,6 +435,8 @@ static int gic__init_gic(struct kvm *kvm)
> .attr = KVM_DEV_ARM_VGIC_CTRL_INIT,
> };
>
> + nr_irqs += gic__get_spi_base();
> +
> /*
> * If we didn't use the KVM_CREATE_DEVICE method, KVM will
> * give us some default number of interrupts. The GIC initialization
> @@ -540,12 +565,13 @@ u32 gic__get_fdt_irq_cpumask(struct kvm *kvm)
>
> void kvm__irq_line(struct kvm *kvm, int irq, int level)
> {
> + int spi_base = gic__get_spi_base();
> struct kvm_irq_level irq_level = {
> .irq = KVM_IRQCHIP_IRQ(irq),
> .level = !!level,
> };
>
> - if (irq < GIC_SPI_IRQ_BASE || irq > GIC_MAX_IRQ)
> + if (irq < spi_base || irq > GIC_MAX_IRQ)
> pr_warning("Ignoring invalid GIC IRQ %d", irq);
> else if (ioctl(kvm->vm_fd, KVM_IRQ_LINE, &irq_level) < 0)
> pr_warning("Could not KVM_IRQ_LINE for irq %d", irq);
> diff --git a/arm64/include/kvm/kvm-arch.h b/arm64/include/kvm/kvm-arch.h
> index e7dd5269..94140364 100644
> --- a/arm64/include/kvm/kvm-arch.h
> +++ b/arm64/include/kvm/kvm-arch.h
> @@ -57,6 +57,14 @@
> #define ARM_GIC_CPUI_SIZE 0x20000
>
>
> +/* GICv5 IRS CONFIG and SETLPI frames occupy the end of the MMIO area. */
> +#define ARM_GICV5_IRS_BASE (ARM_AXI_AREA - ARM_GICV5_IRS_SIZE)
> +#define ARM_GICV5_IRS_SIZE (ARM_GICV5_IRS_CONFIG_SIZE + ARM_GICV5_IRS_SETLPI_SIZE)
> +#define ARM_GICV5_IRS_CONFIG_BASE ARM_GICV5_IRS_BASE
> +#define ARM_GICV5_IRS_CONFIG_SIZE 0x10000
> +#define ARM_GICV5_IRS_SETLPI_BASE (ARM_GICV5_IRS_CONFIG_BASE + ARM_GICV5_IRS_CONFIG_SIZE)
> +#define ARM_GICV5_IRS_SETLPI_SIZE 0x10000
> +
> #define KVM_PCI_CFG_AREA ARM_AXI_AREA
> #define ARM_PCI_CFG_SIZE (1ULL << 28)
> #define KVM_PCI_MMIO_AREA (KVM_PCI_CFG_AREA + ARM_PCI_CFG_SIZE)
> -- 2.34.1
>
FWIW,
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS in the DT
2026-11-18 17:57 ` [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS " Sascha Bischoff
@ 2026-11-19 10:43 ` Vladimir Murzin
0 siblings, 0 replies; 26+ messages in thread
From: Vladimir Murzin @ 2026-11-19 10:43 UTC (permalink / raw)
To: Sascha Bischoff, will, julien.thierry.kdev
Cc: maz, kvm, kvmarm, timothy.hayes, Peter Maydell
On 11/18/26 17:57, Sascha Bischoff wrote:
> Describe the IRS CONFIG and SETLPI frames and associate each CPU
> phandle with its IAFFID. This lets the guest discover and configure
> the IRS for shared interrupts.
>
> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
> Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
> ---
> arm64/gic.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/arm64/gic.c b/arm64/gic.c
> index 9a8f9916..e5a26252 100644
> --- a/arm64/gic.c
> +++ b/arm64/gic.c
> @@ -588,6 +588,16 @@ void gic__generate_fdt_nodes(void *fdt, struct kvm *kvm)
>
> static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
> {
> + char node_at_addr[64];
> + u32 cpus[kvm->nrcpus];
> + u16 iaffids[kvm->nrcpus];
> + u64 irs_reg_prop[] = {
> + cpu_to_fdt64(ARM_GICV5_IRS_CONFIG_BASE),
> + cpu_to_fdt64(ARM_GICV5_IRS_CONFIG_SIZE),
> + cpu_to_fdt64(ARM_GICV5_IRS_SETLPI_BASE),
> + cpu_to_fdt64(ARM_GICV5_IRS_SETLPI_SIZE)
> + };
> +
> _FDT(fdt_begin_node(fdt, "gicv5-cpuif"));
> _FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5"));
> _FDT(fdt_property_cell(fdt, "#interrupt-cells", GIC_FDT_IRQ_NUM_CELLS));
> @@ -599,6 +609,31 @@ static void gic__generate_gicv5_fdt_nodes(void *fdt, struct kvm *kvm)
> /* Use a hard-coded phandle for the GIC to help wire things up */
> _FDT(fdt_property_cell(fdt, "phandle", PHANDLE_GIC));
>
> + /*
> + * GICv5 IRS node
> + */
> + snprintf(node_at_addr, sizeof(node_at_addr), "irs@%llx",
> + (unsigned long long)ARM_GICV5_IRS_CONFIG_BASE);
> + _FDT(fdt_begin_node(fdt, node_at_addr));
> + _FDT(fdt_property_string(fdt, "compatible", "arm,gic-v5-irs"));
> + _FDT(fdt_property_cell(fdt, "#address-cells", 2));
> + _FDT(fdt_property_cell(fdt, "#size-cells", 2));
> + _FDT(fdt_property(fdt, "ranges", NULL, 0));
> +
> + _FDT(fdt_property(fdt, "reg", irs_reg_prop, sizeof(irs_reg_prop)));
> + _FDT(fdt_property(fdt, "reg-names", "ns-config\0ns-setlpi",
> + sizeof("ns-config\0ns-setlpi")));
> +
> + for (int cpu = 0; cpu < kvm->nrcpus; cpu++) {
> + cpus[cpu] = cpu_to_fdt32(PHANDLE_CPU_BASE + cpu);
> + iaffids[cpu] = cpu_to_fdt16(cpu);
> + }
> +
> + _FDT(fdt_property(fdt, "cpus", cpus, sizeof(u32) * kvm->nrcpus));
> + _FDT(fdt_property(fdt, "arm,iaffids", iaffids, sizeof(u16) * kvm->nrcpus));
> +
> + _FDT(fdt_end_node(fdt));
> +
> _FDT(fdt_end_node(fdt));
> }
>
> -- 2.34.1
>
With SETLPI dropped form DT (and commit message) as agreed [1], feel free to add
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
[1] https://lore.kernel.org/kvmarm/d0e948c8-0d25-4207-bc04-01bc2bb6b7ec@arm.com/T/#m0dd67277b59609783e294e30cc681ee1a97a966a
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2026-11-19 10:43 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 01/23] arm64: Propagate IRQ routing initialisation errors Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 02/23] arm64: Close the ITS descriptor when setup fails Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 03/23] arm64: Split GIC device setup Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 04/23] Sync kernel UAPI headers with v7.4-rc1 Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 05/23] arm64: Add GICv5 irqchip device support Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 06/23] arm64: Configure GIC interrupt bases Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 07/23] irq: Allow the initial interrupt line number to be set Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 08/23] arm64: Start GICv5 SPI line allocation at zero Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS Sascha Bischoff
2026-11-19 9:40 ` Vladimir Murzin
2026-11-18 17:57 ` [PATCH kvmtool v5 10/23] arm64: Define GICv5 interrupt types Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 11/23] arm64: Describe the PMU interrupt for GICv5 Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 12/23] arm64: Describe timer PPIs " Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 13/23] arm64: Assign CPU DT phandles Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 14/23] arm64: Describe the GICv5 CPU interface in the DT Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS " Sascha Bischoff
2026-11-19 10:43 ` Vladimir Murzin
2026-11-18 17:57 ` [PATCH kvmtool v5 16/23] arm64: Generate GICv5 SPI specifiers for platform devices Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 17/23] arm64: Generate GICv5 PCI INTx specifiers Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 18/23] arm64: Expose the GICv5 irqchip option Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 19/23] arm64: Add proposed GICv5 ITS UAPI definitions Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 20/23] arm64: Add GICv5 ITS device support Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 21/23] arm64: Describe the GICv5 ITS in the DT Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 22/23] arm64: Map PCI MSI requester IDs to the GICv5 ITS Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 23/23] arm64: Expose the GICv5 ITS irqchip option Sascha Bischoff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox