From patchwork Wed Feb 18 13:08:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 7752 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1IDOIsh026581 for ; Wed, 18 Feb 2009 13:24:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751492AbZBRNYP (ORCPT ); Wed, 18 Feb 2009 08:24:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751578AbZBRNYP (ORCPT ); Wed, 18 Feb 2009 08:24:15 -0500 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:2989 "EHLO VA3EHSOBE004.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751492AbZBRNYO (ORCPT ); Wed, 18 Feb 2009 08:24:14 -0500 X-Greylist: delayed 901 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Feb 2009 08:24:14 EST Received: from mail78-va3-R.bigfish.com (10.7.14.251) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 8.1.340.0; Wed, 18 Feb 2009 13:09:12 +0000 Received: from mail78-va3 (localhost.localdomain [127.0.0.1]) by mail78-va3-R.bigfish.com (Postfix) with ESMTP id 28E3EE20068; Wed, 18 Feb 2009 13:09:12 +0000 (UTC) X-BigFish: VPS3(zzzzzzz32i43j62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, Received: by mail78-va3 (MessageSwitch) id 1234962550188260_21321; Wed, 18 Feb 2009 13:09:10 +0000 (UCT) Received: from svlb1extmailp02.amd.com (unknown [139.95.251.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail78-va3.bigfish.com (Postfix) with ESMTP id 0A56E160050; Wed, 18 Feb 2009 13:09:09 +0000 (UTC) Received: from svlb1twp01.amd.com ([139.95.250.34]) by svlb1extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n1ID90p6009184; Wed, 18 Feb 2009 05:09:03 -0800 X-WSS-ID: 0KF9J72-03-C6N-01 Received: from SSVLEXBH2.amd.com (ssvlexbh2.amd.com [139.95.53.183]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2140C884941; Wed, 18 Feb 2009 05:09:01 -0800 (PST) Received: from SSVLEXMB1.amd.com ([139.95.53.181]) by SSVLEXBH2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Feb 2009 05:09:05 -0800 Received: from SF30EXMB1.amd.com ([172.20.6.49]) by SSVLEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Feb 2009 05:09:05 -0800 Received: from seurexmb1.amd.com ([165.204.82.130]) by SF30EXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Feb 2009 14:09:00 +0100 Received: from lemmy.amd.com ([165.204.85.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Feb 2009 14:09:00 +0100 Received: by lemmy.amd.com (Postfix, from userid 41430) id 1FA7B24612; Wed, 18 Feb 2009 14:09:00 +0100 (CET) From: Joerg Roedel To: Avi Kivity CC: Marcelo Tosatti , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 1/3] kvm mmu: handle compound pages in kvm_is_mmio_pfn Date: Wed, 18 Feb 2009 14:08:58 +0100 Message-ID: <1234962540-7131-2-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.6.4 In-Reply-To: <1234962540-7131-1-git-send-email-joerg.roedel@amd.com> References: <1234962540-7131-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 18 Feb 2009 13:09:00.0194 (UTC) FILETIME=[106F9820:01C991CA] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The function kvm_is_mmio_pfn is called before put_page is called on a page by KVM. This is a problem when when this function is called on some struct page which is part of a compund page. It does not test the reserved flag of the compound page but of the struct page within the compount page. This is a problem when KVM works with hugepages allocated at boot time. These pages have the reserved bit set in all tail pages. Only the flag in the compount head is cleared. KVM would not put such a page which results in a memory leak. Signed-off-by: Joerg Roedel Acked-by: Marcelo Tosatti --- virt/kvm/kvm_main.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 266bdaf..0ed662d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -535,8 +535,10 @@ static inline int valid_vcpu(int n) inline int kvm_is_mmio_pfn(pfn_t pfn) { - if (pfn_valid(pfn)) - return PageReserved(pfn_to_page(pfn)); + if (pfn_valid(pfn)) { + struct page *page = compound_head(pfn_to_page(pfn)); + return PageReserved(page); + } return true; }