Skip to content

Commit 562e530

Browse files
author
Marc Zyngier
committed
KVM: arm64: Force ID_AA64PFR0_EL1.GIC=1 when exposing a virtual GICv3
Until now, we always let ID_AA64PFR0_EL1.GIC reflect the value visible on the host, even if we were running a GICv2-enabled VM on a GICv3+compat host. That's fine, but we also now have the case of a host that does not expose ID_AA64PFR0_EL1.GIC==1 despite having a vGIC. Yes, this is confusing. Thank you M1. Let's go back to first principles and expose ID_AA64PFR0_EL1.GIC=1 when a GICv3 is exposed to the guest. This also hides a GICv4.1 CPU interface from the guest which has no business knowing about the v4.1 extension. Reviewed-by: Alexandru Elisei <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9e1ff30 commit 562e530

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,11 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,
10751075
val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64PFR0_CSV2), (u64)vcpu->kvm->arch.pfr0_csv2);
10761076
val &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_CSV3);
10771077
val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64PFR0_CSV3), (u64)vcpu->kvm->arch.pfr0_csv3);
1078+
if (irqchip_in_kernel(vcpu->kvm) &&
1079+
vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
1080+
val &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_GIC);
1081+
val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64PFR0_GIC), 1);
1082+
}
10781083
break;
10791084
case SYS_ID_AA64PFR1_EL1:
10801085
val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_MTE);

0 commit comments

Comments
 (0)