Skip to content

Commit 50e7cce

Browse files
author
Marc Zyngier
committed
KVM: arm64: Limit clearing of ID_{AA64PFR0,PFR1}_EL1.GIC to userspace irqchip
Now that the idreg's GIC field is in sync with the irqchip, limit the runtime clearing of these fields to the pathological case where we do not have an in-kernel GIC. While we're at it, use the existing API instead of open-coded accessors to access the ID regs. 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-4-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 8a9866f commit 50e7cce

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5609,11 +5609,13 @@ int kvm_finalize_sys_regs(struct kvm_vcpu *vcpu)
56095609

56105610
guard(mutex)(&kvm->arch.config_lock);
56115611

5612-
if (!(static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) &&
5613-
irqchip_in_kernel(kvm) &&
5614-
kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)) {
5615-
kvm->arch.id_regs[IDREG_IDX(SYS_ID_AA64PFR0_EL1)] &= ~ID_AA64PFR0_EL1_GIC_MASK;
5616-
kvm->arch.id_regs[IDREG_IDX(SYS_ID_PFR1_EL1)] &= ~ID_PFR1_EL1_GIC_MASK;
5612+
if (!irqchip_in_kernel(kvm)) {
5613+
u64 val;
5614+
5615+
val = kvm_read_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1) & ~ID_AA64PFR0_EL1_GIC;
5616+
kvm_set_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1, val);
5617+
val = kvm_read_vm_id_reg(kvm, SYS_ID_PFR1_EL1) & ~ID_PFR1_EL1_GIC;
5618+
kvm_set_vm_id_reg(kvm, SYS_ID_PFR1_EL1, val);
56175619
}
56185620

56195621
if (vcpu_has_nv(vcpu)) {

0 commit comments

Comments
 (0)