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] Reducing LOC (always a good thing) by eliminating duplic

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Reducing LOC (always a good thing) by eliminating duplicated functionality.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 06 Sep 2005 15:32:29 +0000
Delivery-date: Tue, 06 Sep 2005 17:14:41 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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 kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID ef1cd772967698f38ebc5a351fb5c125fb565acb
# Parent  60bf463f79a85d92f55bbe42c45856fc791dd7d7
Reducing LOC (always a good thing) by eliminating duplicated functionality.
vmx_platform.c/inst_copy_from_guest() now uses vmx_copy. Also shored up
vmx_copy to handle copies when paging is enabled and improved its error
handling.

Signed-Off-By: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>

diff -r 60bf463f79a8 -r ef1cd7729676 xen/arch/x86/vmx.c
--- a/xen/arch/x86/vmx.c        Tue Sep  6 09:44:58 2005
+++ b/xen/arch/x86/vmx.c        Tue Sep  6 15:31:34 2005
@@ -730,7 +730,7 @@
 int
 vmx_copy(void *buf, unsigned long laddr, int size, int dir)
 {
-    unsigned long mfn;
+    unsigned long gpa, mfn;
     char *addr;
     int count;
 
@@ -739,8 +739,14 @@
        if (count > size)
            count = size;
 
-       mfn = get_mfn_from_pfn(laddr >> PAGE_SHIFT);
-       /* XXX check whether laddr is valid */
+       if (vmx_paging_enabled(current)) {
+               gpa = gva_to_gpa(laddr);
+               mfn = get_mfn_from_pfn(gpa >> PAGE_SHIFT);
+       } else
+               mfn = get_mfn_from_pfn(laddr >> PAGE_SHIFT);
+       if (mfn == INVALID_MFN)
+               return 0;
+
        addr = (char *)map_domain_page(mfn) + (laddr & ~PAGE_MASK);
 
        if (dir == VMX_COPY_IN)
diff -r 60bf463f79a8 -r ef1cd7729676 xen/arch/x86/vmx_platform.c
--- a/xen/arch/x86/vmx_platform.c       Tue Sep  6 09:44:58 2005
+++ b/xen/arch/x86/vmx_platform.c       Tue Sep  6 15:31:34 2005
@@ -583,49 +583,13 @@
     }
 }
 
-/* XXX use vmx_copy instead */
 int inst_copy_from_guest(unsigned char *buf, unsigned long guest_eip, int 
inst_len)
 {
-    unsigned long gpa;
-    unsigned long mfn;
-    unsigned char *inst_start;
-    int remaining = 0;
-        
-    if ( (inst_len > MAX_INST_LEN) || (inst_len <= 0) )
+    if (inst_len > MAX_INST_LEN || inst_len <= 0)
         return 0;
-
-    if ( vmx_paging_enabled(current) )
-    {
-        gpa = gva_to_gpa(guest_eip);
-        mfn = get_mfn_from_pfn(gpa >> PAGE_SHIFT);
-
-        /* Does this cross a page boundary ? */
-        if ( (guest_eip & PAGE_MASK) != ((guest_eip + inst_len) & PAGE_MASK) )
-        {
-            remaining = (guest_eip + inst_len) & ~PAGE_MASK;
-            inst_len -= remaining;
-        }
-    }
-    else
-    {
-        mfn = get_mfn_from_pfn(guest_eip >> PAGE_SHIFT);
-    }
-
-    inst_start = map_domain_page(mfn);
-    memcpy((char *)buf, inst_start + (guest_eip & ~PAGE_MASK), inst_len);
-    unmap_domain_page(inst_start);
-
-    if ( remaining )
-    {
-        gpa = gva_to_gpa(guest_eip+inst_len+remaining);
-        mfn = get_mfn_from_pfn(gpa >> PAGE_SHIFT);
-
-        inst_start = map_domain_page(mfn);
-        memcpy((char *)buf+inst_len, inst_start, remaining);
-        unmap_domain_page(inst_start);
-    }
-
-    return inst_len+remaining;
+    if (!vmx_copy(buf, guest_eip, inst_len, VMX_COPY_IN))
+        return 0;
+    return inst_len;
 }
 
 void send_mmio_req(unsigned char type, unsigned long gpa, 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Reducing LOC (always a good thing) by eliminating duplicated functionality., Xen patchbot -unstable <=