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

RE: [Xen-devel] [PATCH] vmx-copy_from_guest.patch

To: "Leendert van Doorn" <leendert@xxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH] vmx-copy_from_guest.patch
From: "Ling, Xiaofeng" <xiaofeng.ling@xxxxxxxxx>
Date: Tue, 6 Sep 2005 22:28:07 +0800
Cc: "Sharma, Arun" <arun.sharma@xxxxxxxxx>, Ian Pratt <Ian.Pratt@xxxxxxxxxxxx>
Delivery-date: Tue, 06 Sep 2005 14:26:11 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcWy5hUYfNf/It7+Ro283hVnXEJtMgACK0xA
Thread-topic: [Xen-devel] [PATCH] vmx-copy_from_guest.patch
seems current vmx_copy can not deal with copy over page boundary?
so remove inst_copy_from_guest will cause problem.

Leendert van Doorn <> wrote:
> 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 23d8580d56b0 xen/arch/x86/vmx.c
> --- a/xen/arch/x86/vmx.c      Fri Sep  2 18:23:57 2005
> +++ b/xen/arch/x86/vmx.c      Mon Sep  5 13:43:59 2005
> @@ -729,7 +735,7 @@
>  int
>  vmx_copy(void *buf, unsigned long laddr, int size, int dir)  {
> -    unsigned long mfn;
> +    unsigned long gpa, mfn;
>      char *addr;
>      int count;
> 
> @@ -738,8 +744,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 23d8580d56b0 xen/arch/x86/vmx_platform.c
> --- a/xen/arch/x86/vmx_platform.c     Fri Sep  2 18:23:57 2005
> +++ b/xen/arch/x86/vmx_platform.c     Mon Sep  5 13:43:59 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-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel

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

<Prev in Thread] Current Thread [Next in Thread>