From patchwork Tue Jun 2 21:36:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 27562 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 n52LidEq009426 for ; Tue, 2 Jun 2009 21:44:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752986AbZFBVoe (ORCPT ); Tue, 2 Jun 2009 17:44:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752649AbZFBVoe (ORCPT ); Tue, 2 Jun 2009 17:44:34 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45316 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751347AbZFBVoe (ORCPT ); Tue, 2 Jun 2009 17:44:34 -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 n52Liaww028060; Tue, 2 Jun 2009 17:44:36 -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 n52LiY9S021986; Tue, 2 Jun 2009 17:44:34 -0400 Received: from amt.cnet (vpn-10-3.str.redhat.com [10.32.10.3]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n52LiWOl026298; Tue, 2 Jun 2009 17:44:33 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id B90FA274E88; Tue, 2 Jun 2009 18:44:00 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n52LhwWm009744; Tue, 2 Jun 2009 18:43:58 -0300 Message-Id: <20090602214226.983563433@localhost.localdomain> References: <20090602213655.640083007@localhost.localdomain> User-Agent: quilt/0.46-1 Date: Tue, 02 Jun 2009 18:36:57 -0300 From: Marcelo Tosatti To: avi@redhat.com, sheng@linux.intel.com Cc: kvm@vger.kernel.org, Marcelo Tosatti Subject: [patch 2/4] KVM: MMU audit: update audit_write_protection Content-Disposition: inline; filename=mmu-audit-2 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 - Unsync pages contain writable sptes in the rmap. - rmaps do not exclusively contain writable sptes anymore. 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 @@ -3228,20 +3228,28 @@ static void audit_write_protection(struc struct kvm_mmu_page *sp; struct kvm_memory_slot *slot; unsigned long *rmapp; + u64 *spte; gfn_t gfn; list_for_each_entry(sp, &vcpu->kvm->arch.active_mmu_pages, link) { if (sp->role.direct) continue; + if (sp->unsync) + continue; gfn = unalias_gfn(vcpu->kvm, sp->gfn); slot = gfn_to_memslot_unaliased(vcpu->kvm, sp->gfn); rmapp = &slot->rmap[gfn - slot->base_gfn]; - if (*rmapp) - printk(KERN_ERR "%s: (%s) shadow page has writable" - " mappings: gfn %lx role %x\n", + + spte = rmap_next(vcpu->kvm, rmapp, NULL); + while (spte) { + if (*spte & PT_WRITABLE_MASK) + printk(KERN_ERR "%s: (%s) shadow page has " + "writable mappings: gfn %lx role %x\n", __func__, audit_msg, sp->gfn, sp->role.word); + spte = rmap_next(vcpu->kvm, rmapp, spte); + } } }