Skip to content

Commit 0f559cd

Browse files
author
Marc Zyngier
committed
KVM: arm64: Finalize ID registers only once per VM
Owing to the ID registers being global to the VM, there is no point in computing them more than once. However, recent changes making use of kvm_set_vm_id_reg() outlined that we repeatedly hammer the ID registers when we shouldn't. Gate the ID reg update on the VM having never run. Fixes: 50e7cce ("KVM: arm64: Limit clearing of ID_{AA64PFR0,PFR1}_EL1.GIC to userspace irqchip") Fixes: 5cb57a1 ("KVM: arm64: Zero ID_AA64PFR0_EL1.GIC when no GICv3 is presented to the guest") Closes: https://lore.kernel.org/r/[email protected] Reported-by: Mark Brown <[email protected]> Tested-by: Mark Brown <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 4af235b commit 0f559cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/arm64/kvm/sys_regs.c

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

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

5612-
if (!irqchip_in_kernel(kvm)) {
5612+
/*
5613+
* This hacks into the ID registers, so only perform it when the
5614+
* first vcpu runs, or the kvm_set_vm_id_reg() helper will scream.
5615+
*/
5616+
if (!irqchip_in_kernel(kvm) && !kvm_vm_has_ran_once(kvm)) {
56135617
u64 val;
56145618

56155619
val = kvm_read_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1) & ~ID_AA64PFR0_EL1_GIC;

0 commit comments

Comments
 (0)