[PATCH v2 0/5] KVM: arm64: Enable GICv3 guests on GICv5 hosts using FEAT_GCIE_LEGACY

Sascha Bischoff posted 5 patches 3 months, 1 week ago
arch/arm64/kvm/Makefile               |  3 +-
arch/arm64/kvm/hyp/vgic-v3-sr.c       | 51 +++++++++++++++++++++-----
arch/arm64/kvm/sys_regs.c             | 10 +++++-
arch/arm64/kvm/vgic/vgic-init.c       |  9 +++--
arch/arm64/kvm/vgic/vgic-v5.c         | 52 +++++++++++++++++++++++++++
arch/arm64/kvm/vgic/vgic.h            | 13 +++++++
arch/arm64/tools/sysreg               |  6 ++++
drivers/irqchip/irq-gic-v5.c          | 50 ++++++++++++++++++++++++++
include/kvm/arm_vgic.h                |  6 +++-
include/linux/irqchip/arm-vgic-info.h |  4 +++
10 files changed, 191 insertions(+), 13 deletions(-)
create mode 100644 arch/arm64/kvm/vgic/vgic-v5.c
[PATCH v2 0/5] KVM: arm64: Enable GICv3 guests on GICv5 hosts using FEAT_GCIE_LEGACY
Posted by Sascha Bischoff 3 months, 1 week ago
Hi all,

This series introduces support for running GICv3 guests on GICv5 hosts
by leveraging the GICv5 legacy compatibility feature
(FEAT_GCIE_LEGACY). The main motivation is to enable existing GICv3
VMs on GICv5 system without VM or VMM modifications - things should
work out of the box.

The changes are focused on two main areas:

    KVM GIC support: Enabling detection of a GICv5 host and
    configuring it to support GICv3 guests.

    IRQ chip support: Ensuring forwarded PPIs behave consistently with
    GICv3 expectations.

Summary of the patches:

    Ensure injected guest interrupts behave correctly by deferring
    deactivation to the guest, matching GICv3-native behavior.

    Set up the necessary GIC capabilities to advertise
    FEAT_GCIE_LEGACY to KVM.

    Add missing system register required for enabling GICv3 compat
    mode from EL2.

    Enable full support for running GICv3 VMs on a GICv5 host when
    compat mode is present, covering VHE, nVHE, and protected KVM
    configurations (excluding nested virt).

    Introduce a probe routine to enable GICv5 when FEAT_GCIE_LEGACY is
    detected. This consumes the gic_kvm_info populated earlier.

This support has been co-developed with T.Hayes, indicated with
Co-authored-by tags.

This series is based and dependent on [PATCH v6 00/31] Arm GICv5: Host
driver implementation [1].

Feedback welcome!

Thanks,
Sascha

[1] https://lore.kernel.org/all/20250626-gicv5-host-v6-0-48e046af4642@kernel.org/
---
Changes in v2:
- Switched to a lazy-disable approach for compat mode
- Merged compat mode enable into __vgic_v3_restore_vmcr_aprs
- Moved to using GICV5_CPUIF cpucap, where possible
- Cleaned up helper functions
- Added Reviewed-by tag
- Link to v1: https://lore.kernel.org/all/20250620160741.3513940-1-sascha.bischoff@arm.com/
---
Sascha Bischoff (5):
  irqchip/gic-v5: Skip deactivate for forwarded PPI interrupts
  irqchip/gic-v5: Populate struct gic_kvm_info
  arm64/sysreg: Add ICH_VCTLR_EL2
  KVM: arm64: gic-v5: Support GICv3 compat
  KVM: arm64: gic-v5: Probe for GICv5

 arch/arm64/kvm/Makefile               |  3 +-
 arch/arm64/kvm/hyp/vgic-v3-sr.c       | 51 +++++++++++++++++++++-----
 arch/arm64/kvm/sys_regs.c             | 10 +++++-
 arch/arm64/kvm/vgic/vgic-init.c       |  9 +++--
 arch/arm64/kvm/vgic/vgic-v5.c         | 52 +++++++++++++++++++++++++++
 arch/arm64/kvm/vgic/vgic.h            | 13 +++++++
 arch/arm64/tools/sysreg               |  6 ++++
 drivers/irqchip/irq-gic-v5.c          | 50 ++++++++++++++++++++++++++
 include/kvm/arm_vgic.h                |  6 +++-
 include/linux/irqchip/arm-vgic-info.h |  4 +++
 10 files changed, 191 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm64/kvm/vgic/vgic-v5.c

-- 
2.34.1
Re: [PATCH v2 0/5] KVM: arm64: Enable GICv3 guests on GICv5 hosts using FEAT_GCIE_LEGACY
Posted by Oliver Upton 3 months ago
On Fri, 27 Jun 2025 10:09:01 +0000, Sascha Bischoff wrote:
> This series introduces support for running GICv3 guests on GICv5 hosts
> by leveraging the GICv5 legacy compatibility feature
> (FEAT_GCIE_LEGACY). The main motivation is to enable existing GICv3
> VMs on GICv5 system without VM or VMM modifications - things should
> work out of the box.
> 
> The changes are focused on two main areas:
> 
> [...]

I've picked this up now that the GICv5 driver is baking in -next. No
promises that these patches actually land in 6.17 (if the host side
doesn't land) but I'm quite happy with the KVM bits.

Applied to next, thanks!

[1/5] irqchip/gic-v5: Skip deactivate for forwarded PPI interrupts
      https://git.kernel.org/kvmarm/kvmarm/c/244e9a89ca76
[2/5] irqchip/gic-v5: Populate struct gic_kvm_info
      https://git.kernel.org/kvmarm/kvmarm/c/1ec38ce3d024
[3/5] arm64/sysreg: Add ICH_VCTLR_EL2
      https://git.kernel.org/kvmarm/kvmarm/c/b62f4b5dec91
[4/5] KVM: arm64: gic-v5: Support GICv3 compat
      https://git.kernel.org/kvmarm/kvmarm/c/c017e49ed138
[5/5] KVM: arm64: gic-v5: Probe for GICv5
      https://git.kernel.org/kvmarm/kvmarm/c/ff2aa6495d4b

--
Best,
Oliver