]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: arm64: gic-v3: Only set ICH_HCR traps for v2-on-v3 or v3 guests
authorSascha Bischoff <Sascha.Bischoff@arm.com>
Tue, 7 Oct 2025 16:07:13 +0000 (16:07 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 13 Oct 2025 13:40:33 +0000 (14:40 +0100)
commit3193287ddffbce29fd1a79d812f543c0fe4861d1
treed0362c38d741c6a4198c63a6b84036187323d275
parentd5e6310a0d996493b1af9f3eeec418350523388b
KVM: arm64: gic-v3: Only set ICH_HCR traps for v2-on-v3 or v3 guests

The ICH_HCR_EL2 traps are used when running on GICv3 hardware, or when
running a GICv3-based guest using FEAT_GCIE_LEGACY on GICv5
hardware. When running a GICv2 guest on GICv3 hardware the traps are
used to ensure that the guest never sees any part of GICv3 (only GICv2
is visible to the guest), and when running a GICv3 guest they are used
to trap in specific scenarios. They are not applicable for a
GICv2-native guest, and won't be applicable for a(n upcoming) GICv5
guest.

The traps themselves are configured in the vGIC CPU IF state, which is
stored as a union. Updating the wrong aperture of the union risks
corrupting state, and therefore needs to be avoided at all costs.

Bail early if we're not running a compatible guest (GICv2 on GICv3
hardware, GICv3 native, GICv3 on GICv5 hardware). Trap everything
unconditionally if we're running a GICv2 guest on GICv3
hardware. Otherwise, conditionally set up GICv3-native trapping.

Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-v3.c