From patchwork Wed Jun 10 15:27:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 29308 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 n5AFVTIa010883 for ; Wed, 10 Jun 2009 15:31:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759576AbZFJPbY (ORCPT ); Wed, 10 Jun 2009 11:31:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758374AbZFJPbX (ORCPT ); Wed, 10 Jun 2009 11:31:23 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56485 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751912AbZFJPbX (ORCPT ); Wed, 10 Jun 2009 11:31:23 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5AFVQ3o018592 for ; Wed, 10 Jun 2009 11:31:26 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5AFVOFr021534; Wed, 10 Jun 2009 11:31:24 -0400 Received: from amt.cnet (vpn-10-153.str.redhat.com [10.32.10.153]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5AFVMf1019095; Wed, 10 Jun 2009 11:31:23 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id F1DE0550009; Wed, 10 Jun 2009 12:30:50 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n5AFUi1E011169; Wed, 10 Jun 2009 12:30:44 -0300 Message-Id: <20090610152748.057609281@localhost.localdomain> References: <20090610152702.666650177@localhost.localdomain> User-Agent: quilt/0.46-1 Date: Wed, 10 Jun 2009 12:27:08 -0300 From: Marcelo Tosatti To: avi@redhat.com Cc: kvm@vger.kernel.org, Marcelo Tosatti Subject: [patch 6/6] KVM: MMU audit: largepage handling Content-Disposition: inline; filename=mmu-audit-last-pte X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Make the audit code aware of largepages. Signed-off-by: Marcelo Tosatti Index: kvm/arch/x86/kvm/mmu.c =================================================================== --- kvm.orig/arch/x86/kvm/mmu.c +++ kvm/arch/x86/kvm/mmu.c @@ -3033,12 +3033,11 @@ static void __mmu_spte_walk(struct kvm * u64 ent = sp->spt[i]; if (is_shadow_present_pte(ent)) { - if (sp->role.level > 1 && !is_large_pte(ent)) { + if (!is_last_spte(ent, sp->role.level)) { struct kvm_mmu_page *child; child = page_header(ent & PT64_BASE_ADDR_MASK); __mmu_spte_walk(kvm, child, fn); - } - if (sp->role.level == 1) + } else fn(kvm, sp, &sp->spt[i]); } } @@ -3083,10 +3082,9 @@ static void audit_mappings_page(struct k continue; va = canonicalize(va); - if (level > 1) { - if (is_shadow_present_pte(ent)) - audit_mappings_page(vcpu, ent, va, level - 1); - } else { + if (is_shadow_present_pte(ent) && !is_last_spte(ent, level)) + audit_mappings_page(vcpu, ent, va, level - 1); + else { gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, va); gfn_t gfn = gpa >> PAGE_SHIFT; pfn_t pfn = gfn_to_pfn(vcpu->kvm, gfn); @@ -3183,7 +3181,8 @@ void inspect_spte_has_rmap(struct kvm *k return; } - rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt], 0); + rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt], + is_large_pte(*sptep)); if (!*rmapp) { if (!printk_ratelimit()) return;