From patchwork Tue Jul 8 13:01:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tangchen X-Patchwork-Id: 4504811 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8B64D9F392 for ; Tue, 8 Jul 2014 13:02:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDE21202F8 for ; Tue, 8 Jul 2014 13:02:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E421320218 for ; Tue, 8 Jul 2014 13:02:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754775AbaGHNAr (ORCPT ); Tue, 8 Jul 2014 09:00:47 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:29969 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754254AbaGHNAp (ORCPT ); Tue, 8 Jul 2014 09:00:45 -0400 X-IronPort-AV: E=Sophos;i="5.00,856,1396972800"; d="scan'208";a="32994964" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Jul 2014 20:58:00 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s68D0geo030911; Tue, 8 Jul 2014 21:00:42 +0800 Received: from G08FNSTD090432.fnst.cn.fujitsu.com (10.167.226.99) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 8 Jul 2014 21:00:47 +0800 From: Tang Chen To: , , CC: , , , , , Subject: [PATCH v2 3/5] kvm, mem-hotplug: Do not pin ept identity pagetable in memory. Date: Tue, 8 Jul 2014 21:01:30 +0800 Message-ID: <1404824492-30095-4-git-send-email-tangchen@cn.fujitsu.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1404824492-30095-1-git-send-email-tangchen@cn.fujitsu.com> References: <1404824492-30095-1-git-send-email-tangchen@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.99] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 ept identity page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, this page is not necessary to be pinned. When it is migrated, mmu_notifier_invalidate_page() in try_to_unmap_one() will invalidate the ept entry so that the guest won't be able to access the page. And in the next ept violation, the new page will be found by ept violation handler. This patch just unpin the ept identity page because it is not necessary. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 3 ++- arch/x86/kvm/x86.c | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 0e1117c..0918635e 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4018,7 +4018,8 @@ static int alloc_identity_pagetable(struct kvm *kvm) if (r) goto out; - page = gfn_to_page(kvm, kvm->arch.ept_identity_map_addr >> PAGE_SHIFT); + page = gfn_to_page_no_pin(kvm, + kvm->arch.ept_identity_map_addr >> PAGE_SHIFT); if (is_error_page(page)) { r = -EFAULT; goto out; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f32a025..ffbe557 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7177,8 +7177,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm) kvm_free_vcpus(kvm); if (kvm->arch.apic_access_page) put_page(kvm->arch.apic_access_page); - if (kvm->arch.ept_identity_pagetable) - put_page(kvm->arch.ept_identity_pagetable); kfree(rcu_dereference_check(kvm->arch.apic_map, 1)); }