All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Decouple computation of the GICv5 trap registers from FEAT_FGT
@ 2026-10-20 10:41 Gustavo Romero
  2026-10-20 10:53 ` sashiko-bot
  2026-10-20 12:45 ` Sascha Bischoff
  0 siblings, 2 replies; 7+ messages in thread
From: Gustavo Romero @ 2026-10-20 10:41 UTC (permalink / raw)
  To: gromero, kvmarm, fuad.tabba, Sascha.Bischoff
  Cc: maz, oupton, eric.auger, seott

Currently, kvm_vcpu_load_fgt() returns early when the CPU lacks FEAT_FGT,
so the per-vCPU ICH_HFGRTR_EL2, ICH_HFGWTR_EL2 and ICH_HFGITR_EL2 values
are never computed and stay 0, meaning any access to several GICv5
registers will trap, like an access to ICC_PPI_PRIORITYR0_EL1.

On the other hand, __activate_traps_ich_hfgxtr() is gated only on the
GICv5 CPU interface and writes them on every guest entry, which is
correct.

Returning early when the CPU lacks FEAT_FGT and leaving the GICv5 traps
enabled can lead to a KVM "Unsupported guest access at" error when a
GICv5 register access by the guest traps to KVM, because the register
has no emulation handler.

A real machine with no FEAT_FGT and with GICv5 support enabled is
unlikely to exist, but such a setup can happen on some simulators, like
FVP with the following flags:

-C cluster0.has_arm_v8-5=1
-C bp.is_gicv5_used=1

Hence, because the ICH trap registers are part of FEAT_GCIE, not part of
FEAT_FGT, compute them before the FGT check, making this computation
independent of FEAT_FGT.

Fixes: 9d6d9514c08f ("KVM: arm64: gic-v5: Support GICv5 FGTs & FGUs")
Signed-off-by: Gustavo Romero <gromero@redhat.com>
---
 arch/arm64/kvm/config.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kvm/config.c b/arch/arm64/kvm/config.c
index 1053676551af..8a526704af59 100644
--- a/arch/arm64/kvm/config.c
+++ b/arch/arm64/kvm/config.c
@@ -1744,6 +1744,12 @@ static void __compute_ich_hfgwtr(struct kvm_vcpu *vcpu)
 
 void kvm_vcpu_load_fgt(struct kvm_vcpu *vcpu)
 {
+	if (cpus_have_final_cap(ARM64_HAS_GICV5_CPUIF)) {
+		__compute_ich_hfgrtr(vcpu);
+		__compute_ich_hfgwtr(vcpu);
+		__compute_fgt(vcpu, ICH_HFGITR_EL2);
+	}
+
 	if (!cpus_have_final_cap(ARM64_HAS_FGT))
 		return;
 
@@ -1761,10 +1767,4 @@ void kvm_vcpu_load_fgt(struct kvm_vcpu *vcpu)
 		__compute_fgt(vcpu, HDFGRTR2_EL2);
 		__compute_fgt(vcpu, HDFGWTR2_EL2);
 	}
-
-	if (cpus_have_final_cap(ARM64_HAS_GICV5_CPUIF)) {
-		__compute_ich_hfgrtr(vcpu);
-		__compute_ich_hfgwtr(vcpu);
-		__compute_fgt(vcpu, ICH_HFGITR_EL2);
-	}
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-20 14:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 10:41 [PATCH] KVM: arm64: Decouple computation of the GICv5 trap registers from FEAT_FGT Gustavo Romero
2026-10-20 10:53 ` sashiko-bot
2026-10-20 12:33   ` Gustavo Romero
2026-10-20 12:45 ` Sascha Bischoff
2026-10-20 14:03   ` Gustavo Romero
2026-10-20 14:15     ` Marc Zyngier
2026-10-20 14:32       ` Gustavo Romero

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.