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-changelog

[Xen-changelog] [xen-unstable] vmx realmode: __hvm_copy() should not hvm

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] vmx realmode: __hvm_copy() should not hvm_get_segment_register() when
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 13 Feb 2008 15:10:10 -0800
Delivery-date: Wed, 13 Feb 2008 15:10:26 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1202920551 0
# Node ID ec1fa84147ad8c72018f976c953341a5fb657eac
# Parent  4c64376d439d3237e81f56b0fdfac7fe6601ec82
vmx realmode: __hvm_copy() should not hvm_get_segment_register() when
we are emulating. Firstly it is bogus, since VMCS segment state is
stale in this context. Secondly, real mode and real->protected
contexts are rather unlikely tohappen with SS.DPL == 3.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff -r 4c64376d439d -r ec1fa84147ad xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Wed Feb 13 16:28:38 2008 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Wed Feb 13 16:35:51 2008 +0000
@@ -1386,6 +1386,7 @@ static enum hvm_copy_result __hvm_copy(
 static enum hvm_copy_result __hvm_copy(
     void *buf, paddr_t addr, int size, int dir, int virt, int fetch)
 {
+    struct vcpu *curr = current;
     unsigned long gfn, mfn;
     p2m_type_t p2mt;
     char *p;
@@ -1394,12 +1395,22 @@ static enum hvm_copy_result __hvm_copy(
 
     if ( virt )
     {
-        struct segment_register sreg;
-        hvm_get_segment_register(current, x86_seg_ss, &sreg);
-        if ( sreg.attr.fields.dpl == 3 )
-            pfec |= PFEC_user_mode;
+        /*
+         * We cannot use hvm_get_segment_register() while executing in
+         * vmx_realmode() as segment register state is cached. Furthermore,
+         * VMREADs on every data access hurts emulation performance.
+         */
+        if ( !curr->arch.hvm_vmx.vmxemul )
+        {
+            struct segment_register sreg;
+            hvm_get_segment_register(curr, x86_seg_ss, &sreg);
+            if ( sreg.attr.fields.dpl == 3 )
+                pfec |= PFEC_user_mode;
+        }
+
         if ( dir ) 
             pfec |= PFEC_write_access;
+
         if ( fetch ) 
             pfec |= PFEC_insn_fetch;
     }
@@ -1411,7 +1422,7 @@ static enum hvm_copy_result __hvm_copy(
 
         if ( virt )
         {
-            gfn = paging_gva_to_gfn(current, addr, &pfec);
+            gfn = paging_gva_to_gfn(curr, addr, &pfec);
             if ( gfn == INVALID_GFN )
             {
                 if ( virt == 2 ) /* 2 means generate a fault */
@@ -1435,7 +1446,7 @@ static enum hvm_copy_result __hvm_copy(
         if ( dir )
         {
             memcpy(p, buf, count); /* dir == TRUE:  *to* guest */
-            paging_mark_dirty(current->domain, mfn);
+            paging_mark_dirty(curr->domain, mfn);
         }
         else
             memcpy(buf, p, count); /* dir == FALSE: *from guest */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] vmx realmode: __hvm_copy() should not hvm_get_segment_register() when, Xen patchbot-unstable <=