From patchwork Thu Feb 19 11:18:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 7959 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 n1JBJxJp019378 for ; Thu, 19 Feb 2009 11:20:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754164AbZBSLTK (ORCPT ); Thu, 19 Feb 2009 06:19:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754000AbZBSLTK (ORCPT ); Thu, 19 Feb 2009 06:19:10 -0500 Received: from wa4ehsobe001.messaging.microsoft.com ([216.32.181.11]:20072 "EHLO WA4EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753114AbZBSLTI (ORCPT ); Thu, 19 Feb 2009 06:19:08 -0500 Received: from mail189-wa4-R.bigfish.com (10.8.14.238) by WA4EHSOBE001.bigfish.com (10.8.40.21) with Microsoft SMTP Server id 8.1.340.0; Thu, 19 Feb 2009 11:19:06 +0000 Received: from mail189-wa4 (localhost.localdomain [127.0.0.1]) by mail189-wa4-R.bigfish.com (Postfix) with ESMTP id AE6FD1C18554; Thu, 19 Feb 2009 11:19:06 +0000 (UTC) X-BigFish: VPS3(zzzzzzz32i43j64h) X-Spam-TCS-SCL: 3:0 Received: by mail189-wa4 (MessageSwitch) id 1235042345242572_22418; Thu, 19 Feb 2009 11:19:05 +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 mail189-wa4.bigfish.com (Postfix) with ESMTP id 2C21BB58063; Thu, 19 Feb 2009 11:19:05 +0000 (UTC) Received: from svlb1twp02.amd.com ([139.95.250.35]) by svlb1extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n1JBIxO2014283; Thu, 19 Feb 2009 03:19:02 -0800 X-WSS-ID: 0KFB8RK-04-4HV-01 Received: from SSVLEXBH1.amd.com (ssvlexbh1.amd.com [139.95.53.182]) by svlb1twp02.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2932C1103C1; Thu, 19 Feb 2009 03:18:56 -0800 (PST) Received: from ssvlexmb2.amd.com ([139.95.53.7]) by SSVLEXBH1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Feb 2009 03:18:59 -0800 Received: from SF36EXMB1.amd.com ([172.19.4.24]) by ssvlexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Feb 2009 03:18:59 -0800 Received: from seurexmb1.amd.com ([165.204.82.130]) by SF36EXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Feb 2009 12:18:56 +0100 Received: from lemmy.amd.com ([165.204.85.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Feb 2009 12:18:56 +0100 Received: by lemmy.amd.com (Postfix, from userid 41430) id 838BC5392F; Thu, 19 Feb 2009 12:18:56 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH] kvm mmu: fix another largepage memory leak Date: Thu, 19 Feb 2009 12:18:56 +0100 Message-ID: <1235042336-20101-1-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.6.4 X-OriginalArrivalTime: 19 Feb 2009 11:18:56.0615 (UTC) FILETIME=[DACF2770:01C99283] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In the paging_fetch function rmap_remove is called after setting a large pte to non-present. This causes rmap_remove to not drop the reference to the large page. The result is a memory leak of that page. Signed-off-by: Joerg Roedel --- arch/x86/kvm/paging_tmpl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 7314c09..0f11792 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -306,9 +306,9 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, continue; if (is_large_pte(*sptep)) { + rmap_remove(vcpu->kvm, sptep); set_shadow_pte(sptep, shadow_trap_nonpresent_pte); kvm_flush_remote_tlbs(vcpu->kvm); - rmap_remove(vcpu->kvm, sptep); } if (level == PT_DIRECTORY_LEVEL