arm: Implement an emulation of GICv5 interrupt controller
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest65 patches 22 repliesIn review
- 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 files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/65 | qom/object: Add object_resolve_and_typecheck()include/ qom/ | +40 | 0 replies | |
| 2/65 | hw/core: Permit devices to define an array of link propertieshw/ include/ | +119 | 0 replies | |
| 3/65 | hw/intc: Skeleton of GICv5 IRS classeshw/ hw/ hw/ +3 more | +141 | 1 reply | |
| 4/65 | hw/arm/Kconfig: select ARM_GICV5 for ARM_VIRT boardhw/ | +1 | 1 reply | |
| 5/65 | hw/intc/arm_gicv5: Implement skeleton code for IRS register frameshw/ hw/ hw/ +3 more | +292 | 0 replies | |
| 6/65 | hw/intc/arm_gicv5: Add migration blockerhw/ | +8 | 0 replies | |
| 7/65 | hw/intc/arm_gicv5: Create and validate QOM propertieshw/ hw/ include/ | +108 | 1 reply | |
| 8/65 | hw/intc/arm_gicv5: Create inbound GPIO lines for SPIshw/ hw/ hw/ +1 more | +20 | 1 reply | |
| 9/65 | hw/intc/arm_gicv5: Define macros for config frame registershw/ | +243 | 0 replies | |
| 10/65 | hw/intc/arm_gicv5: Implement IRS ID regshw/ include/ | +153 | 2 replies | |
| 11/65 | hw/intc/arm_gicv5: Add link property for MemoryRegion for DMAhw/ include/ | +12 | 1 reply | |
| 12/65 | hw/intc/arm_gicv5: Implement gicv5_class_name()hw/ include/ | +22 | 1 reply | |
| 13/65 | hw/intc/arm_gicv5: Add defines for GICv5 architected PPIsinclude/ | +20 | 1 reply | |
| 14/65 | target/arm: GICv5 cpuif: Initial skeleton and GSB barrier insnstarget/ target/ target/ +2 more | +54 | 0 replies | |
| 15/65 | target/arm: Set up pointer to GICv5 in each CPUhw/ include/ target/ +1 more | +59 | 1 reply | |
| 16/65 | hw/intc/arm_gicv5: Implement IRS_IST_{BASER, STATUSR, CFGR}hw/ hw/ include/ | +81 | 0 replies | |
| 17/65 | hw/intc/arm_gicv5: Cache LPI IST config in a structhw/ hw/ include/ | +78 | 0 replies | |
| 18/65 | hw/intc/arm_gicv5: Implement gicv5_set_priority()hw/ hw/ include/ +2 more | +274 | 0 replies | |
| 19/65 | target/arm: GICv5 cpuif: Implement the GIC CDPRI instructiontarget/ | +58 | 0 replies | |
| 20/65 | hw/intc/arm_gicv5: Implement IRS_MAP_L2_ISTRhw/ | +40 | 0 replies | |
| 21/65 | hw/intc/arm_gicv5: Implement remaining set-config functionshw/ hw/ include/ +1 more | +239 | 0 replies | |
| 22/65 | target/arm: GICv5 cpuif: Implement GIC CD* insns for setting configtarget/ | +108 | 0 replies | |
| 23/65 | hw/intc/arm_gicv5: Create backing state for SPIshw/ include/ include/ | +71 | 0 replies | |
| 24/65 | hw/intc/arm_gicv5: Make gicv5_set_* update SPI statehw/ include/ | +104 | 2 replies | |
| 25/65 | hw/intc/arm_gicv5: Implement gicv5_request_config()hw/ hw/ include/ | +127 | 2 replies | |
| 26/65 | target/arm: GICv5 cpuif: Implement GIC CDRCFG and ICC_ICSR_EL1target/ target/ | +32 | 0 replies | |
| 27/65 | hw/intc/arm_gicv5: Implement IRS_SPI_{SELR, STATUSR, CFGR, DOMAINR}hw/ hw/ include/ | +78 | 0 replies | |
| 28/65 | hw/intc/arm_gicv5: Update SPI state for CLEAR/SET eventshw/ hw/ | +60 | 0 replies | |
| 29/65 | hw/intc/arm_gicv5: Implement IRS_CR0 and IRS_CR1hw/ hw/ include/ | +17 | 0 replies | |
| 30/65 | hw/intc/arm_gicv5: Implement IRS_SYNCR and IRS_SYNC_STATUSRhw/ | +7 | 0 replies | |
| 31/65 | hw/intc/arm_gicv5: Implement IRS_PE_{CR0, SELR, STATUSR}hw/ hw/ include/ | +41 | 0 replies | |
| 32/65 | hw/intc/arm_gicv5: Implement CoreSight ID registershw/ | +35 | 1 reply | |
| 33/65 | hw/intc/arm_gicv5: Cache pending LPIs in a hash tablehw/ include/ | +112 | 0 replies | |
| 34/65 | target/arm: GICv5 cpuif: Implement ICC_IAFFIDR_EL1hw/ include/ target/ +2 more | +21 | 0 replies | |
| 35/65 | target/arm: GICv5 cpuif: Implement ICC_IDR0_EL1target/ | +17 | 0 replies | |
| 36/65 | target/arm: GICv5 cpuif: Implement GICv5 PPI active set/clear registerstarget/ target/ | +43 | 0 replies | |
| 37/65 | target/arm: GICv5 cpuif: Implement PPI handling mode registertarget/ target/ | +23 | 0 replies | |
| 38/65 | target/arm: GICv5 cpuif: Implement PPI pending status registerstarget/ target/ | +45 | 0 replies | |
| 39/65 | target/arm: GICv5 cpuif: Implement PPI enable registertarget/ target/ | +19 | 0 replies | |
| 40/65 | target/arm: GICv5 cpuif: Implement PPI priority registerstarget/ target/ | +25 | 0 replies | |
| 41/65 | target/arm: GICv5 cpuif: Implement ICC_APR_EL1 and ICC_HAPR_EL1include/ target/ target/ | +64 | 0 replies | |
| 42/65 | target/arm: GICv5 cpuif: Calculate the highest priority PPIinclude/ meson.build target/ +3 more | +89 | 0 replies | |
| 43/65 | hw/intc/arm_gicv5: Calculate HPPI in the IRShw/ hw/ include/ +2 more | +240 | 0 replies | |
| 44/65 | target/arm: GICv5 cpuif: Implement ICC_CR0_EL1target/ target/ | +45 | 0 replies | |
| 45/65 | target/arm: GICv5 cpuif: Implement ICC_PCR_EL1target/ target/ | +32 | 0 replies | |
| 46/65 | target/arm: GICv5 cpuif: Implement ICC_HPPIR_EL1hw/ include/ target/ | +84 | 0 replies | |
| 47/65 | hw/intc/arm_gicv5: Implement Activate commandhw/ hw/ include/ | +82 | 0 replies | |
| 48/65 | target/arm: GICv5 cpuif: Implement GICR CDIA commandtarget/ target/ | +103 | 0 replies | |
| 49/65 | target/arm: GICv5 cpuif: Implement GIC CDEOItarget/ target/ | +22 | 0 replies | |
| 50/65 | hw/intc/arm_gicv5: Implement Deactivate commandhw/ hw/ include/ | +67 | 0 replies | |
| 51/65 | target/arm: GICv5 cpuif: Implement GIC CDDItarget/ target/ | +50 | 0 replies | |
| 52/65 | target/arm: GICv5 cpuif: Signal IRQ or FIQtarget/ target/ | +85 | 0 replies | |
| 53/65 | target/arm: Connect internal interrupt sources up as GICv5 PPIstarget/ target/ target/ +2 more | +62 | 0 replies | |
| 54/65 | target/arm: Add has_gcie property to enable FEAT_GCIEtarget/ target/ target/ | +52 | 0 replies | |
| 55/65 | hw/intc/arm_gicv3_cpuif: Don't allow GICv3 if CPU has GICv5 cpuifhw/ hw/ hw/ | +15 | 0 replies | |
| 56/65 | hw/arm/virt: Remember CPU phandles rather than looking them up by namehw/ include/ | +11 | 0 replies | |
| 57/65 | hw/arm/virt: Move MSI controller creation out of create_gic()hw/ | +13 | 1 reply | |
| 58/65 | hw/arm/virt: Pull "wire CPU interrupts" out of create_gic()hw/ | +68 | 1 reply | |
| 59/65 | hw/arm/virt: Split GICv2 and GICv3/4 creationhw/ | +82 | 0 replies | |
| 60/65 | hw/arm/virt: Create and connect GICv5hw/ include/ | +115 | 1 reply | |
| 61/65 | hw/arm/virt: Advertise GICv5 in the DTBhw/ | +68 | 1 reply | |
| 62/65 | hw/arm/virt: Handle GICv5 in interrupt bindings for PPIshw/ include/ | +29 | 0 replies | |
| 63/65 | hw/arm/virt: Use correct interrupt type for GICv5 SPIs in the DTBhw/ | +20 | 0 replies | |
| 64/65 | hw/arm/virt: Enable GICv5 CPU interface when using GICv5hw/ | +8 | 0 replies | |
| 65/65 | hw/arm/virt: Allow user to select GICv5docs/ hw/ | +27 | 1 reply |
Reviews trailers per patch
All 65 patches have a Reviewed-by or Acked-by.
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
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