From patchwork Fri Mar 13 16:10:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 6006661 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A02A8BF90F for ; Fri, 13 Mar 2015 16:11:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6CFE201F4 for ; Fri, 13 Mar 2015 16:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 025D420211 for ; Fri, 13 Mar 2015 16:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757248AbbCMQLr (ORCPT ); Fri, 13 Mar 2015 12:11:47 -0400 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:48925 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757226AbbCMQLn (ORCPT ); Fri, 13 Mar 2015 12:11:43 -0400 Received: from e106785-lin.cambridge.arm.com ([10.1.203.153]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id t2DGACwu015618; Fri, 13 Mar 2015 16:10:14 GMT From: Andre Przywara To: marc.zyngier@arm.com, christoffer.dall@linaro.org, pbonzini@redhat.com Cc: n.nikolaev@virtualopensystems.com, eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 06/12] KVM: mark kvm->buses as empty once they were destroyed Date: Fri, 13 Mar 2015 16:10:06 +0000 Message-Id: <1426263012-22935-7-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426263012-22935-1-git-send-email-andre.przywara@arm.com> References: <1426263012-22935-1-git-send-email-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In kvm_destroy_vm() we call kvm_io_bus_destroy() pretty early, especially before calling kvm_arch_destroy_vm(). To avoid unregistering devices from the already destroyed bus, let's mark the bus with NULL to let other users know it has been destroyed already. This avoids a crash on a VM shutdown with the VGIC using the kvm_io_bus later (the unregistering is in there to be able to roll back a faulting init). Signed-off-by: Andre Przywara --- virt/kvm/kvm_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8c7ab0b..6f164eb 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -604,8 +604,10 @@ static void kvm_destroy_vm(struct kvm *kvm) list_del(&kvm->vm_list); spin_unlock(&kvm_lock); kvm_free_irq_routing(kvm); - for (i = 0; i < KVM_NR_BUSES; i++) + for (i = 0; i < KVM_NR_BUSES; i++) { kvm_io_bus_destroy(kvm->buses[i]); + kvm->buses[i] = NULL; + } kvm_coalesced_mmio_free(kvm); #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER) mmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm);