From patchwork Wed Jun 10 15:27:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 29309 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 n5AFVTIb010883 for ; Wed, 10 Jun 2009 15:31:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759348AbZFJPbY (ORCPT ); Wed, 10 Jun 2009 11:31:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757369AbZFJPbY (ORCPT ); Wed, 10 Jun 2009 11:31:24 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56486 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759348AbZFJPbX (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 n5AFVQaM018596 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 n5AFVO5b021533; 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 n5AFVMIn019090; 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 69342550008; Wed, 10 Jun 2009 12:30:44 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n5AFUhjO011168; Wed, 10 Jun 2009 12:30:43 -0300 Message-Id: <20090610152747.962751259@localhost.localdomain> References: <20090610152702.666650177@localhost.localdomain> User-Agent: quilt/0.46-1 Date: Wed, 10 Jun 2009 12:27:07 -0300 From: Marcelo Tosatti To: avi@redhat.com Cc: kvm@vger.kernel.org, Marcelo Tosatti Subject: [patch 5/6] KVM: MMU audit: audit_mappings tweaks Content-Disposition: inline; filename=mmu-audit-4 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 - Fail early in case gfn_to_pfn returns is_error_pfn. - For the pre pte write case, avoid spurious "gva is valid but spte is notrap" messages (the emulation code does the guest write first, so this particular case is OK). 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 @@ -3092,6 +3092,11 @@ static void audit_mappings_page(struct k pfn_t pfn = gfn_to_pfn(vcpu->kvm, gfn); hpa_t hpa = (hpa_t)pfn << PAGE_SHIFT; + if (is_error_pfn(pfn)) { + kvm_release_pfn_clean(pfn); + continue; + } + if (is_shadow_present_pte(ent) && (ent & PT64_BASE_ADDR_MASK) != hpa) printk(KERN_ERR "xx audit error: (%s) levels %d" @@ -3263,7 +3268,8 @@ static void kvm_mmu_audit(struct kvm_vcp audit_msg = msg; audit_rmap(vcpu); audit_write_protection(vcpu); - audit_mappings(vcpu); + if (strcmp("pre pte write", audit_msg) != 0) + audit_mappings(vcpu); audit_writable_sptes_have_rmaps(vcpu); dbg = olddbg; }