From patchwork Fri Mar 12 09:57:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 85229 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2C9tHoe004363 for ; Fri, 12 Mar 2010 09:55:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932248Ab0CLJyp (ORCPT ); Fri, 12 Mar 2010 04:54:45 -0500 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:41273 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932212Ab0CLJyk (ORCPT ); Fri, 12 Mar 2010 04:54:40 -0500 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id AE3A6248227; Fri, 12 Mar 2010 18:54:39 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 9DC6E248225; Fri, 12 Mar 2010 18:54:39 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.19]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id 7E7D011C0B2; Fri, 12 Mar 2010 18:54:39 +0900 (JST) Date: Fri, 12 Mar 2010 18:57:51 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH -v3 1/2] KVM: introduce kvm_uninit_mmu_notifier() Message-Id: <20100312185751.f113f603.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp> References: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Mar 2010 09:55:21 +0000 (UTC) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e758ef7..64b792c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -359,6 +359,11 @@ static int kvm_init_mmu_notifier(struct kvm *kvm) return mmu_notifier_register(&kvm->mmu_notifier, current->mm); } +static void kvm_uninit_mmu_notifier(struct kvm *kvm) +{ + mmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm); +} + #else /* !(CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER) */ static int kvm_init_mmu_notifier(struct kvm *kvm) @@ -366,6 +371,11 @@ static int kvm_init_mmu_notifier(struct kvm *kvm) return 0; } +static void kvm_uninit_mmu_notifier(struct kvm *kvm) +{ + kvm_arch_flush_shadow(kvm); +} + #endif /* CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER */ static struct kvm *kvm_create_vm(void) @@ -485,11 +495,7 @@ static void kvm_destroy_vm(struct kvm *kvm) for (i = 0; i < KVM_NR_BUSES; i++) kvm_io_bus_destroy(kvm->buses[i]); kvm_coalesced_mmio_free(kvm); -#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER) - mmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm); -#else - kvm_arch_flush_shadow(kvm); -#endif + kvm_uninit_mmu_notifier(kvm); kvm_arch_destroy_vm(kvm); hardware_disable_all(); mmdrop(mm);