From: David Woodhouse Date: Mon, 23 Jun 2025 10:58:18 +0000 (+0100) Subject: KVM: arm64: vgic-its: Unmap all vPEs on shutdown X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fgic;p=users%2Fdwmw2%2Flinux.git KVM: arm64: vgic-its: Unmap all vPEs on shutdown 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 --- diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 38a91bb5d4c75..2b76f506bc2d6 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -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, diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index b9ad7c42c5b01..6591e8d848550 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -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 diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 4a34f7f0a8648..e850ee860238f 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -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);