From patchwork Sat Mar 25 11:14:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Herongguang (Stephen)" X-Patchwork-Id: 9644511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2057060327 for ; Sat, 25 Mar 2017 11:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E5A9265B9 for ; Sat, 25 Mar 2017 11:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1216026907; Sat, 25 Mar 2017 11:15:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79839265B9 for ; Sat, 25 Mar 2017 11:15:52 +0000 (UTC) Received: from localhost ([::1]:36725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crjfj-0000Nk-Mj for patchwork-qemu-devel@patchwork.kernel.org; Sat, 25 Mar 2017 07:15:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crjfA-0000Nf-1m for qemu-devel@nongnu.org; Sat, 25 Mar 2017 07:15:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crjf6-0008Ge-TJ for qemu-devel@nongnu.org; Sat, 25 Mar 2017 07:15:16 -0400 Received: from [45.249.212.187] (port=3015 helo=dggrg01-dlp.huawei.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1crjf6-0008Bz-Fv for qemu-devel@nongnu.org; Sat, 25 Mar 2017 07:15:12 -0400 Received: from 172.30.72.56 (EHLO DGGEML403-HUB.china.huawei.com) ([172.30.72.56]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ALL07896; Sat, 25 Mar 2017 19:14:51 +0800 (CST) Received: from localhost (10.177.19.20) by DGGEML403-HUB.china.huawei.com (10.3.17.33) with Microsoft SMTP Server id 14.3.301.0; Sat, 25 Mar 2017 19:14:38 +0800 From: herongguang To: , , Date: Sat, 25 Mar 2017 19:14:24 +0800 Message-ID: <20170325111424.21752-1-herongguang.he@huawei.com> X-Mailer: git-send-email 2.8.3.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.19.20] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.58D6512C.05A0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1d84c048f06cd87d0a3cc2c0b07df92c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.187 Subject: [Qemu-devel] [PATCH] KVM: unmap SMM memslots in vt-d table X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wangxinxin.wang@huawei.com, qemu-devel@nongnu.org, herongguang.he@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP or pages are not unmaped and freed Signed-off-by: herongguang --- arch/x86/kvm/iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Well, do we should change pci-assign to not map SMM slots instead? Like vfio. diff --git a/arch/x86/kvm/iommu.c b/arch/x86/kvm/iommu.c index b181426..5b931bb 100644 --- a/arch/x86/kvm/iommu.c +++ b/arch/x86/kvm/iommu.c @@ -320,15 +320,17 @@ void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot) static int kvm_iommu_unmap_memslots(struct kvm *kvm) { int idx; - struct kvm_memslots *slots; + struct kvm_memslots *slots, *smm_slots; struct kvm_memory_slot *memslot; idx = srcu_read_lock(&kvm->srcu); slots = kvm_memslots(kvm); - kvm_for_each_memslot(memslot, slots) kvm_iommu_unmap_pages(kvm, memslot); + smm_slots = __kvm_memslots(kvm, 1); + kvm_for_each_memslot(memslot, smm_slots) + kvm_iommu_unmap_pages(kvm, memslot); srcu_read_unlock(&kvm->srcu, idx); if (kvm->arch.iommu_noncoherent)