WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [Patch][SVM]Disable intercepting CR3 writes when nested pagi

To: "'xen-devel@xxxxxxxxxxxxxxxxxxx'" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [Patch][SVM]Disable intercepting CR3 writes when nested paging is enabled
From: Wei Huang <wei.huang2@xxxxxxx>
Date: Wed, 15 Jul 2009 15:34:36 -0500
Delivery-date: Wed, 15 Jul 2009 13:35:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C683CC61.FA1D%keir.fraser@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C683CC61.FA1D%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.17 (X11/20080914)
This patch disables intercepting CR3 writes when nested paging is enabled. For applications which cause excessive CR3 accesses, the patch can increases their performance.

Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
diff -r c31edc59ae5d xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Sat Jul 25 19:31:35 2009 -0500
+++ b/xen/arch/x86/hvm/svm/svm.c        Sat Jul 25 19:31:51 2009 -0500
@@ -1299,6 +1299,8 @@ asmlinkage void svm_vmexit_handler(struc
     eventinj_t eventinj;
     int inst_len, rc;
 
+    if ( paging_mode_hap(v->domain) )
+        v->arch.hvm_vcpu.guest_cr[3] = v->arch.hvm_vcpu.hw_cr[3] = vmcb->cr3;
     /*
      * Before doing anything else, we need to sync up the VLAPIC's TPR with
      * SVM's vTPR. It's OK if the guest doesn't touch CR8 (e.g. 32-bit Windows)
diff -r c31edc59ae5d xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c       Sat Jul 25 19:31:35 2009 -0500
+++ b/xen/arch/x86/hvm/svm/vmcb.c       Sat Jul 25 19:31:51 2009 -0500
@@ -236,10 +236,10 @@ static int construct_vmcb(struct vcpu *v
         vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
 
         /*
-         * No point in intercepting CR3 reads, because the hardware will return
-         * the guest version anyway.
+         * No point in intercepting CR3 reads/writes
          */
         vmcb->cr_intercepts &= ~CR_INTERCEPT_CR3_READ;
+        vmcb->cr_intercepts &= ~CR_INTERCEPT_CR3_WRITE;
 
         /*
          * No point in intercepting INVLPG if we don't have shadow pagetables
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel