Skip to content

arm: Implement an emulation of GICv5 interrupt controller

Peter Maydell qemu-arm qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest65 patches 22 repliesIn review
  2. v165 patches 76 repliesSuperseded

Changes in v2 from the cover letter

* minor tidyups to line wrap, etc, in various patches
* patch 1 is split into 2 patches but otherwise unchanged
* 3: define FRAME_OP_ENTRY macro to avoid duplication in writing out entries of the config_frame_ops[] array
* 9: fixed IRS_IDR0 PA_RANGE field length
* 10: also zero IDR0 VIRT_ONE_N field for the EL3 domain
* 18, 21, 24, 25, 47, 50: use switch on IRQ type instead of if() in gicv5_set_priority() and similar functions
* old 55 ("hw/arm/virt: Update error message for bad gic-version option") is now upstream, so dropped from v2

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/65qom/object: Add object_resolve_and_typecheck()include/qom/object.h qom/object.c+40 -180 replies
2/65hw/core: Permit devices to define an array of link propertieshw/core/qdev-properties.c include/hw/core/qdev-properties.h+119 -00 replies
3/65hw/intc: Skeleton of GICv5 IRS classeshw/intc/Kconfig hw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c +3 more+141 -01 reply
4/65hw/arm/Kconfig: select ARM_GICV5 for ARM_VIRT boardhw/arm/Kconfig+1 -01 reply
5/65hw/intc/arm_gicv5: Implement skeleton code for IRS register frameshw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c hw/intc/trace-events +3 more+292 -00 replies
6/65hw/intc/arm_gicv5: Add migration blockerhw/intc/arm_gicv5.c+8 -00 replies
7/65hw/intc/arm_gicv5: Create and validate QOM propertieshw/intc/arm_gicv5_common.c hw/intc/trace-events include/hw/intc/arm_gicv5_common.h+108 -01 reply
8/65hw/intc/arm_gicv5: Create inbound GPIO lines for SPIshw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c hw/intc/trace-events +1 more+20 -11 reply
9/65hw/intc/arm_gicv5: Define macros for config frame registershw/intc/arm_gicv5.c+243 -00 replies
10/65hw/intc/arm_gicv5: Implement IRS ID regshw/intc/arm_gicv5.c include/hw/intc/arm_gicv5_common.h+153 -02 replies
11/65hw/intc/arm_gicv5: Add link property for MemoryRegion for DMAhw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h+12 -01 reply
12/65hw/intc/arm_gicv5: Implement gicv5_class_name()hw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h+22 -01 reply
13/65hw/intc/arm_gicv5: Add defines for GICv5 architected PPIsinclude/hw/intc/arm_gicv5_types.h+20 -01 reply
14/65target/arm: GICv5 cpuif: Initial skeleton and GSB barrier insnstarget/arm/cpu-features.h target/arm/helper.c target/arm/internals.h +2 more+54 -00 replies
15/65target/arm: Set up pointer to GICv5 in each CPUhw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_stream.h target/arm/cpu.c +1 more+59 -01 reply
16/65hw/intc/arm_gicv5: Implement IRS_IST_{BASER, STATUSR, CFGR}hw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h+81 -00 replies
17/65hw/intc/arm_gicv5: Cache LPI IST config in a structhw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5.h+78 -00 replies
18/65hw/intc/arm_gicv5: Implement gicv5_set_priority()hw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5.h +2 more+274 -00 replies
19/65target/arm: GICv5 cpuif: Implement the GIC CDPRI instructiontarget/arm/tcg/gicv5-cpuif.c+58 -00 replies
20/65hw/intc/arm_gicv5: Implement IRS_MAP_L2_ISTRhw/intc/arm_gicv5.c+40 -00 replies
21/65hw/intc/arm_gicv5: Implement remaining set-config functionshw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5_stream.h +1 more+239 -00 replies
22/65target/arm: GICv5 cpuif: Implement GIC CD* insns for setting configtarget/arm/tcg/gicv5-cpuif.c+108 -00 replies
23/65hw/intc/arm_gicv5: Create backing state for SPIshw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h include/hw/intc/arm_gicv5_types.h+71 -00 replies
24/65hw/intc/arm_gicv5: Make gicv5_set_* update SPI statehw/intc/arm_gicv5.c include/hw/intc/arm_gicv5_common.h+104 -02 replies
25/65hw/intc/arm_gicv5: Implement gicv5_request_config()hw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5_stream.h+127 -02 replies
26/65target/arm: GICv5 cpuif: Implement GIC CDRCFG and ICC_ICSR_EL1target/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+32 -00 replies
27/65hw/intc/arm_gicv5: Implement IRS_SPI_{SELR, STATUSR, CFGR, DOMAINR}hw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h+78 -00 replies
28/65hw/intc/arm_gicv5: Update SPI state for CLEAR/SET eventshw/intc/arm_gicv5.c hw/intc/trace-events+60 -00 replies
29/65hw/intc/arm_gicv5: Implement IRS_CR0 and IRS_CR1hw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h+17 -00 replies
30/65hw/intc/arm_gicv5: Implement IRS_SYNCR and IRS_SYNC_STATUSRhw/intc/arm_gicv5.c+7 -00 replies
31/65hw/intc/arm_gicv5: Implement IRS_PE_{CR0, SELR, STATUSR}hw/intc/arm_gicv5.c hw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_common.h+41 -00 replies
32/65hw/intc/arm_gicv5: Implement CoreSight ID registershw/intc/arm_gicv5.c+35 -01 reply
33/65hw/intc/arm_gicv5: Cache pending LPIs in a hash tablehw/intc/arm_gicv5.c include/hw/intc/arm_gicv5.h+112 -60 replies
34/65target/arm: GICv5 cpuif: Implement ICC_IAFFIDR_EL1hw/intc/arm_gicv5_common.c include/hw/intc/arm_gicv5_stream.h target/arm/cpu.c +2 more+21 -50 replies
35/65target/arm: GICv5 cpuif: Implement ICC_IDR0_EL1target/arm/tcg/gicv5-cpuif.c+17 -00 replies
36/65target/arm: GICv5 cpuif: Implement GICv5 PPI active set/clear registerstarget/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+43 -00 replies
37/65target/arm: GICv5 cpuif: Implement PPI handling mode registertarget/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+23 -00 replies
38/65target/arm: GICv5 cpuif: Implement PPI pending status registerstarget/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+45 -00 replies
39/65target/arm: GICv5 cpuif: Implement PPI enable registertarget/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+19 -00 replies
40/65target/arm: GICv5 cpuif: Implement PPI priority registerstarget/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+25 -00 replies
41/65target/arm: GICv5 cpuif: Implement ICC_APR_EL1 and ICC_HAPR_EL1include/hw/intc/arm_gicv5_types.h target/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+64 -00 replies
42/65target/arm: GICv5 cpuif: Calculate the highest priority PPIinclude/hw/intc/arm_gicv5_types.h meson.build target/arm/cpu.h +3 more+89 -00 replies
43/65hw/intc/arm_gicv5: Calculate HPPI in the IRShw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5.h +2 more+240 -00 replies
44/65target/arm: GICv5 cpuif: Implement ICC_CR0_EL1target/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+45 -00 replies
45/65target/arm: GICv5 cpuif: Implement ICC_PCR_EL1target/arm/cpu.h target/arm/tcg/gicv5-cpuif.c+32 -00 replies
46/65target/arm: GICv5 cpuif: Implement ICC_HPPIR_EL1hw/intc/arm_gicv5.c include/hw/intc/arm_gicv5_stream.h target/arm/tcg/gicv5-cpuif.c+84 -00 replies
47/65hw/intc/arm_gicv5: Implement Activate commandhw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5_stream.h+82 -00 replies
48/65target/arm: GICv5 cpuif: Implement GICR CDIA commandtarget/arm/tcg/gicv5-cpuif.c target/arm/tcg/trace-events+103 -00 replies
49/65target/arm: GICv5 cpuif: Implement GIC CDEOItarget/arm/tcg/gicv5-cpuif.c target/arm/tcg/trace-events+22 -00 replies
50/65hw/intc/arm_gicv5: Implement Deactivate commandhw/intc/arm_gicv5.c hw/intc/trace-events include/hw/intc/arm_gicv5_stream.h+67 -00 replies
51/65target/arm: GICv5 cpuif: Implement GIC CDDItarget/arm/tcg/gicv5-cpuif.c target/arm/tcg/trace-events+50 -00 replies
52/65target/arm: GICv5 cpuif: Signal IRQ or FIQtarget/arm/tcg/gicv5-cpuif.c target/arm/tcg/trace-events+85 -30 replies
53/65target/arm: Connect internal interrupt sources up as GICv5 PPIstarget/arm/cpregs-pmu.c target/arm/helper.c target/arm/internals.h +2 more+62 -20 replies
54/65target/arm: Add has_gcie property to enable FEAT_GCIEtarget/arm/cpu-features.h target/arm/cpu.c target/arm/cpu.h+52 -00 replies
55/65hw/intc/arm_gicv3_cpuif: Don't allow GICv3 if CPU has GICv5 cpuifhw/intc/arm_gicv3.c hw/intc/arm_gicv3_cpuif.c hw/intc/gicv3_internal.h+15 -30 replies
56/65hw/arm/virt: Remember CPU phandles rather than looking them up by namehw/arm/virt.c include/hw/arm/virt.h+11 -90 replies
57/65hw/arm/virt: Move MSI controller creation out of create_gic()hw/arm/virt.c+13 -21 reply
58/65hw/arm/virt: Pull "wire CPU interrupts" out of create_gic()hw/arm/virt.c+68 -581 reply
59/65hw/arm/virt: Split GICv2 and GICv3/4 creationhw/arm/virt.c+82 -550 replies
60/65hw/arm/virt: Create and connect GICv5hw/arm/virt.c include/hw/arm/virt.h+115 -01 reply
61/65hw/arm/virt: Advertise GICv5 in the DTBhw/arm/virt.c+68 -01 reply
62/65hw/arm/virt: Handle GICv5 in interrupt bindings for PPIshw/arm/virt.c include/hw/arm/fdt.h+29 -40 replies
63/65hw/arm/virt: Use correct interrupt type for GICv5 SPIs in the DTBhw/arm/virt.c+20 -90 replies
64/65hw/arm/virt: Enable GICv5 CPU interface when using GICv5hw/arm/virt.c+8 -00 replies
65/65hw/arm/virt: Allow user to select GICv5docs/system/arm/virt.rst hw/arm/virt.c+27 -31 reply

Reviews trailers per patch

All 65 patches have a Reviewed-by or Acked-by.

PatchJonathan CameronPhilippe Mathieu-Daudé
1/65R-b
2/65R-b
3/65R-b R-b
4/65R-b R-b
5/65R-b
6/65R-b
7/65R-b R-b
8/65R-b R-b
9/65R-b
10/65R-b
11/65R-b R-b
12/65R-b R-b
13/65R-b R-b
14/65R-b
15/65R-b R-b
16/65R-b
17/65R-b
18/65R-b
19/65R-b
20/65R-b
21/65R-b
22/65R-b
23/65R-b
24/65R-b
25/65R-b
26/65R-b
27/65R-b
28/65R-b
29/65R-b
30/65R-b
31/65R-b
32/65R-b
33/65R-b
34/65R-b
35/65R-b
36/65R-b
37/65R-b
38/65R-b
39/65R-b
40/65R-b
41/65R-b
42/65R-b
43/65R-b
44/65R-b
45/65R-b
46/65R-b
47/65R-b
48/65R-b
49/65R-b
50/65R-b
51/65R-b
52/65R-b
53/65R-b
54/65R-b
55/65R-b
56/65R-b
57/65R-b R-b
58/65R-b R-b
59/65R-b
60/65R-b R-b
61/65R-b R-b
62/65R-b
63/65R-b
64/65R-b
65/65R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/65] arm: Implement an emulation of GICv5 interrupt controller

This patchset implements initial support of emulation of Arm's new interrupt controller architecture, GICv5.

I've incorporated the review feedback from v1, so I figured I might as well send this out, though obviously there's no huge rush to review given we're in freeze.

Patches still needing review: 10 24 25 32

Changes v1->v2:
* minor tidyups to line wrap, etc, in various patches
* patch 1 is split into 2 patches but otherwise unchanged
* 3: define FRAME_OP_ENTRY macro to avoid duplication in writing out entries of the config_frame_ops[] array
* 9: fixed IRS_IDR0 PA_RANGE field length
* 10: also zero IDR0 VIRT_ONE_N field for the EL3 domain
* 18, 21, 24, 25, 47, 50: use switch on IRQ type instead of if() in gicv5_set_priority() and similar functions
* old 55 ("hw/arm/virt: Update error message for bad gic-version option") is now upstream, so dropped from v2

(Everything below here is the same as from v1's cover letter; repeated for context.)

The most recent version of the GICv5 spec (currently 00EAC0) is at:
https://developer.arm.com/documentation/aes0070/latest/

The emulation is at an "experimental" level, both because the GICv5 specification is still at an early-access level and minor changes are possible, and also because this emulation is missing some functionality which I plan to add later but which would have made this initial patchset even larger and later. To quote the docs patch:

- guest-visible behaviour may change when the final version of the specification is released and QEMU implements it
- migration support is not yet implemented
- the GICv5 is not exposed to the guest via ACPI tables, only via DTB
- the way the interrupt controller is exposed to the guest and the command line syntax for enabling it may change

The current implementation supports only an EL1 guest (no EL2 or EL3 and no Realm support), and does not implement the ITS (no MSI support).

The GICv5 is supported by the "virt" board, and can be enabled with "-machine gic-version=x-5" (the 'x' standing for "experimental").

Like the GICv3/v4, the GICv5 has both a system component part (the Interrupt Routing Service, IRS), and a part in the CPU itself (the CPU interface). Our GICv3 model puts both of these into code in hw/intc/, and has the cpuif part install itself into an existing CPU object by adding new system registers there. This works, but in retrospect I feel that it's a bit awkward and we would have done better to make our design a bit closer to the hardware setup, where the CPU interface is really part of the CPU and talks to the system component over an architected protocol. So for GICv5 I have taken that route: the IRS is in hw/intc/arm_gicv5.c, and the CPU interface is in target/arm/tcg/gicv5-cpuif.c. They communicate via a set of functions which loosely match the "stream protocol" defined in the GICv5 architecture spec (with some simplifications that result from QEMU being strictly synchronous because we always hold the BQL when executing any GICv5 emulation code; the hardware has to handle the IRS and the CPU executing in parallel and the communications channel not being instantaneous transmission).

Although the EL2/EL3/Realm functionality is not present in this patchset, I have implemented some of the foundations for it where I thought it made sense, to avoid having to refactor it later. Similarly, the class structure makes the usual "common baseclass + TCG subclass" split, as we are going to want a KVM subclass when we add KVM support.

In a few places I have noted possible opportunities for performance optimisation; these are probably best left until we've done some analysis that shows them to be necessary.

This patchset is sufficient to be able to boot a Linux guest at EL1 (directly via -kernel): all the kernel support for GICv5 is upstream as of Linux 6.19.

thanks
-- PMM

Peter Maydell (65):
qom/object: Add object_resolve_and_typecheck()
hw/core: Permit devices to define an array of link properties hw/intc: Skeleton of GICv5 IRS classes
hw/arm/Kconfig: select ARM_GICV5 for ARM_VIRT board hw/intc/arm_gicv5: Implement skeleton code for IRS register frames hw/intc/arm_gicv5: Add migration blocker hw/intc/arm_gicv5: Create and validate QOM properties hw/intc/arm_gicv5: Create inbound GPIO lines for SPIs hw/intc/arm_gicv5: Define macros for config frame registers hw/intc/arm_gicv5: Implement IRS ID regs hw/intc/arm_gicv5: Add link property for MemoryRegion for DMA hw/intc/arm_gicv5: Implement gicv5_class_name() hw/intc/arm_gicv5: Add defines for GICv5 architected PPIs target/arm: GICv5 cpuif: Initial skeleton and GSB barrier insns target/arm: Set up pointer to GICv5 in each CPU hw/intc/arm_gicv5: Implement IRS_IST_{BASER, STATUSR, CFGR} hw/intc/arm_gicv5: Cache LPI IST config in a struct hw/intc/arm_gicv5: Implement gicv5_set_priority() target/arm: GICv5 cpuif: Implement the GIC CDPRI instruction hw/intc/arm_gicv5: Implement IRS_MAP_L2_ISTR hw/intc/arm_gicv5: Implement remaining set-config functions target/arm: GICv5 cpuif: Implement GIC CD* insns for setting config hw/intc/arm_gicv5: Create backing state for SPIs hw/intc/arm_gicv5: Make gicv5_set_* update SPI state hw/intc/arm_gicv5: Implement gicv5_request_config() target/arm: GICv5 cpuif: Implement GIC CDRCFG and ICC_ICSR_EL1 hw/intc/arm_gicv5: Implement IRS_SPI_{SELR,STATUSR,CFGR,DOMAINR} hw/intc/arm_gicv5: Update SPI state for CLEAR/SET events hw/intc/arm_gicv5: Implement IRS_CR0 and IRS_CR1 hw/intc/arm_gicv5: Implement IRS_SYNCR and IRS_SYNC_STATUSR hw/intc/arm_gicv5: Implement IRS_PE_{CR0,SELR,STATUSR} hw/intc/arm_gicv5: Implement CoreSight ID registers hw/intc/arm_gicv5: Cache pending LPIs in a hash table target/arm: GICv5 cpuif: Implement ICC_IAFFIDR_EL1 target/arm: GICv5 cpuif: Implement ICC_IDR0_EL1 target/arm: GICv5 cpuif: Implement GICv5 PPI active set/clear
registers
target/arm: GICv5 cpuif: Implement PPI handling mode register target/arm: GICv5 cpuif: Implement PPI pending status registers target/arm: GICv5 cpuif: Implement PPI enable register target/arm: GICv5 cpuif: Implement PPI priority registers target/arm: GICv5 cpuif: Implement ICC_APR_EL1 and ICC_HAPR_EL1 target/arm: GICv5 cpuif: Calculate the highest priority PPI hw/intc/arm_gicv5: Calculate HPPI in the IRS
target/arm: GICv5 cpuif: Implement ICC_CR0_EL1
target/arm: GICv5 cpuif: Implement ICC_PCR_EL1
target/arm: GICv5 cpuif: Implement ICC_HPPIR_EL1 hw/intc/arm_gicv5: Implement Activate command
target/arm: GICv5 cpuif: Implement GICR CDIA command target/arm: GICv5 cpuif: Implement GIC CDEOI hw/intc/arm_gicv5: Implement Deactivate command target/arm: GICv5 cpuif: Implement GIC CDDI
target/arm: GICv5 cpuif: Signal IRQ or FIQ
target/arm: Connect internal interrupt sources up as GICv5 PPIs target/arm: Add has_gcie property to enable FEAT_GCIE hw/intc/arm_gicv3_cpuif: Don't allow GICv3 if CPU has GICv5 cpuif hw/arm/virt: Remember CPU phandles rather than looking them up by name hw/arm/virt: Move MSI controller creation out of create_gic() hw/arm/virt: Pull "wire CPU interrupts" out of create_gic() hw/arm/virt: Split GICv2 and GICv3/4 creation
hw/arm/virt: Create and connect GICv5
hw/arm/virt: Advertise GICv5 in the DTB
hw/arm/virt: Handle GICv5 in interrupt bindings for PPIs hw/arm/virt: Use correct interrupt type for GICv5 SPIs in the DTB hw/arm/virt: Enable GICv5 CPU interface when using GICv5 hw/arm/virt: Allow user to select GICv5

 docs/system/arm/virt.rst           |   19 +
 hw/arm/Kconfig                     |    1 +
 hw/arm/virt.c                      |  525 ++++++--
 hw/core/qdev-properties.c          |   78 ++
 hw/intc/Kconfig                    |    4 +
 hw/intc/arm_gicv3.c                |    2 +-
 hw/intc/arm_gicv3_cpuif.c          |   14 +-
 hw/intc/arm_gicv5.c                | 1962 ++++++++++++++++++++++++++++
 hw/intc/arm_gicv5_common.c         |  227 ++++
 hw/intc/gicv3_internal.h           |    2 +-
 hw/intc/meson.build                |    4 +
 hw/intc/trace-events               |   23 +
 include/hw/arm/fdt.h               |   10 +
 include/hw/arm/virt.h              |   15 +
 include/hw/core/qdev-properties.h  |   41 +
 include/hw/intc/arm_gicv5.h        |   51 +
 include/hw/intc/arm_gicv5_common.h |  236 ++++
 include/hw/intc/arm_gicv5_stream.h |  228 ++++
 include/hw/intc/arm_gicv5_types.h  |  110 ++
 include/qom/object.h               |   17 +
 meson.build                        |    1 +
 qom/object.c                       |   41 +-
 target/arm/cpregs-pmu.c            |    9 +-
 target/arm/cpu-features.h          |   11 +
 target/arm/cpu.c                   |   62 +
 target/arm/cpu.h                   |   28 +
 target/arm/helper.c                |   21 +
 target/arm/internals.h             |    9 +
 target/arm/tcg/gicv5-cpuif.c       |  952 ++++++++++++++
 target/arm/tcg/meson.build         |    1 +
 target/arm/tcg/trace-events        |   11 +
 target/arm/tcg/trace.h             |    1 +
 32 files changed, 4559 insertions(+), 157 deletions(-)
 create mode 100644 hw/intc/arm_gicv5.c
 create mode 100644 hw/intc/arm_gicv5_common.c
 create mode 100644 include/hw/intc/arm_gicv5.h
 create mode 100644 include/hw/intc/arm_gicv5_common.h
 create mode 100644 include/hw/intc/arm_gicv5_stream.h
 create mode 100644 include/hw/intc/arm_gicv5_types.h
 create mode 100644 target/arm/tcg/gicv5-cpuif.c
 create mode 100644 target/arm/tcg/trace-events
 create mode 100644 target/arm/tcg/trace.h
Signature · 1 line
2.43.0