Skip to content

Commit 8a9866f

Browse files
author
Marc Zyngier
committed
KVM: arm64: Set ID_{AA64PFR0,PFR1}_EL1.GIC when GICv3 is configured
Drive the idreg fields indicating the presence of GICv3 directly from the vgic code. This avoids having to do any sort of runtime clearing of the idreg. Fixes: 5cb57a1 ("KVM: arm64: Zero ID_AA64PFR0_EL1.GIC when no GICv3 is presented to the guest") Reviewed-by: Oliver Upton <oupton@kernel.org> Link: https://patch.msgid.link/20251030122707.2033690-3-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 3f9eacf commit 8a9866f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/arm64/kvm/vgic/vgic-init.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu, u32 type);
7171
int kvm_vgic_create(struct kvm *kvm, u32 type)
7272
{
7373
struct kvm_vcpu *vcpu;
74+
u64 aa64pfr0, pfr1;
7475
unsigned long i;
7576
int ret;
7677

@@ -161,10 +162,19 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
161162

162163
kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF;
163164

164-
if (type == KVM_DEV_TYPE_ARM_VGIC_V2)
165+
aa64pfr0 = kvm_read_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1) & ~ID_AA64PFR0_EL1_GIC;
166+
pfr1 = kvm_read_vm_id_reg(kvm, SYS_ID_PFR1_EL1) & ~ID_PFR1_EL1_GIC;
167+
168+
if (type == KVM_DEV_TYPE_ARM_VGIC_V2) {
165169
kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
166-
else
170+
} else {
167171
INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions);
172+
aa64pfr0 |= SYS_FIELD_PREP_ENUM(ID_AA64PFR0_EL1, GIC, IMP);
173+
pfr1 |= SYS_FIELD_PREP_ENUM(ID_PFR1_EL1, GIC, GICv3);
174+
}
175+
176+
kvm_set_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1, aa64pfr0);
177+
kvm_set_vm_id_reg(kvm, SYS_ID_PFR1_EL1, pfr1);
168178

169179
if (type == KVM_DEV_TYPE_ARM_VGIC_V3)
170180
kvm->arch.vgic.nassgicap = system_supports_direct_sgis();

0 commit comments

Comments
 (0)