]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: arm64: vgic-its: Unmap all vPEs on shutdown gic
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 23 Jun 2025 10:58:18 +0000 (11:58 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 23 Jun 2025 13:20:18 +0000 (15:20 +0200)
We observed systems going dark on kexec, due to corruption of the new
kernel's text (and sometimes the initrd). This was eventually determined
to be caused by the vLPI pending tables used by the GIC in the previous
kernel, which were not being quiesced properly.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/arm64/kvm/arm.c
arch/arm64/kvm/vgic/vgic-v3.c
include/kvm/arm_vgic.h

index 38a91bb5d4c75145daf890ec988288bdcec0ab3e..2b76f506bc2d6042bf1c343a6f1e90e698e998ff 100644 (file)
@@ -2164,6 +2164,11 @@ void kvm_arch_disable_virtualization_cpu(void)
                cpu_hyp_uninit(NULL);
 }
 
+void kvm_arch_shutdown(void)
+{
+       kvm_vgic_v3_shutdown();
+}
+
 #ifdef CONFIG_CPU_PM
 static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
                                    unsigned long cmd,
index b9ad7c42c5b01c9b890132a67c34a16a5ada14c3..6591e8d84855048111057aad28f8816c8450ab34 100644 (file)
@@ -382,6 +382,20 @@ static void map_all_vpes(struct kvm *kvm)
                                                dist->its_vm.vpes[i]->irq));
 }
 
+void kvm_vgic_v3_shutdown(void)
+{
+       struct kvm *kvm;
+
+       if (!kvm_vgic_global_state.has_gicv4_1)
+               return;
+
+       mutex_lock(&kvm_lock);
+       list_for_each_entry(kvm, &vm_list, vm_list) {
+               unmap_all_vpes(kvm);
+       }
+       mutex_unlock(&kvm_lock);
+}
+
 /*
  * vgic_v3_save_pending_tables - Save the pending tables into guest RAM
  * kvm lock and all vcpu lock must be held
index 4a34f7f0a86488a0bda7cc95916e1a4e47b69a07..e850ee860238fffd8fff527c00fd4f1c5e662fe5 100644 (file)
@@ -442,6 +442,8 @@ int vgic_v4_put(struct kvm_vcpu *vcpu);
 
 bool vgic_state_is_nested(struct kvm_vcpu *vcpu);
 
+void kvm_vgic_v3_shutdown(void);
+
 /* CPU HP callbacks */
 void kvm_vgic_cpu_up(void);
 void kvm_vgic_cpu_down(void);