ia64/xen-unstable

changeset 15755:3db3c4868568

[xen, xencomm] preparetion for xencomm consolidation.
Xen/powerpc runs in real mode so that it uses maddr interchangably
with vaddr. But it isn't the case in xen/ia64. It is necessary to
convert maddr to vaddr to access the page. maddr_to_virt() doesn't
convert on powerpc, so it should work on both archtechture.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kfraser@localhost.localdomain
date Tue Aug 14 16:01:34 2007 +0100 (2007-08-14)
parents 0d367c186e8c
children c98c707a07a8
files xen/common/xencomm.c
line diff
     1.1 --- a/xen/common/xencomm.c	Tue Aug 14 16:01:08 2007 +0100
     1.2 +++ b/xen/common/xencomm.c	Tue Aug 14 16:01:34 2007 +0100
     1.3 @@ -34,6 +34,15 @@ static int xencomm_debug = 1; /* extreme
     1.4  #define xencomm_debug 0
     1.5  #endif
     1.6  
     1.7 +static void*
     1.8 +xencomm_maddr_to_vaddr(unsigned long maddr)
     1.9 +{
    1.10 +    if (maddr == 0)
    1.11 +        return NULL;
    1.12 +    
    1.13 +    return maddr_to_virt(maddr);
    1.14 +}
    1.15 +
    1.16  static unsigned long
    1.17  xencomm_inline_from_guest(void *to, const void *from, unsigned int n,
    1.18          unsigned int skip)
    1.19 @@ -54,7 +63,7 @@ xencomm_inline_from_guest(void *to, cons
    1.20          src_maddr = paddr_to_maddr(src_paddr);
    1.21          if (xencomm_debug)
    1.22              printk("%lx[%d] -> %lx\n", src_maddr, bytes, (unsigned long)to);
    1.23 -        memcpy(to, (void *)src_maddr, bytes);
    1.24 +        memcpy(to, maddr_to_virt(src_maddr), bytes);
    1.25          src_paddr += bytes;
    1.26          to += bytes;
    1.27          n -= bytes;
    1.28 @@ -89,7 +98,8 @@ xencomm_copy_from_guest(void *to, const 
    1.29          return xencomm_inline_from_guest(to, from, n, skip);
    1.30  
    1.31      /* first we need to access the descriptor */
    1.32 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
    1.33 +    desc = (struct xencomm_desc *)
    1.34 +        xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)from));
    1.35      if (desc == NULL)
    1.36          return n;
    1.37  
    1.38 @@ -130,7 +140,7 @@ xencomm_copy_from_guest(void *to, const 
    1.39  
    1.40              if (xencomm_debug)
    1.41                  printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
    1.42 -            memcpy((void *)dest, (void *)src_maddr, bytes);
    1.43 +            memcpy((void *)dest, maddr_to_virt(src_maddr), bytes);
    1.44              from_pos += bytes;
    1.45              to_pos += bytes;
    1.46          }
    1.47 @@ -161,7 +171,7 @@ xencomm_inline_to_guest(void *to, const 
    1.48          dest_maddr = paddr_to_maddr(dest_paddr);
    1.49          if (xencomm_debug)
    1.50              printk("%lx[%d] -> %lx\n", (unsigned long)from, bytes, dest_maddr);
    1.51 -        memcpy((void *)dest_maddr, (void *)from, bytes);
    1.52 +        memcpy(maddr_to_virt(dest_maddr), (void *)from, bytes);
    1.53          dest_paddr += bytes;
    1.54          from += bytes;
    1.55          n -= bytes;
    1.56 @@ -196,7 +206,8 @@ xencomm_copy_to_guest(void *to, const vo
    1.57          return xencomm_inline_to_guest(to, from, n, skip);
    1.58  
    1.59      /* first we need to access the descriptor */
    1.60 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
    1.61 +    desc = (struct xencomm_desc *)
    1.62 +        xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)to));
    1.63      if (desc == NULL)
    1.64          return n;
    1.65  
    1.66 @@ -236,7 +247,7 @@ xencomm_copy_to_guest(void *to, const vo
    1.67  
    1.68              if (xencomm_debug)
    1.69                  printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
    1.70 -            memcpy((void *)dest_maddr, (void *)source, bytes);
    1.71 +            memcpy(maddr_to_virt(dest_maddr), (void *)source, bytes);
    1.72              from_pos += bytes;
    1.73              to_pos += bytes;
    1.74          }
    1.75 @@ -264,7 +275,8 @@ int xencomm_add_offset(void **handle, un
    1.76          return xencomm_inline_add_offset(handle, bytes);
    1.77  
    1.78      /* first we need to access the descriptor */
    1.79 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)*handle);
    1.80 +    desc = (struct xencomm_desc *)
    1.81 +        xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)*handle));
    1.82      if (desc == NULL)
    1.83          return -1;
    1.84  
    1.85 @@ -310,7 +322,8 @@ int xencomm_handle_is_null(void *handle)
    1.86      if (xencomm_is_inline(handle))
    1.87          return xencomm_inline_addr(handle) == 0;
    1.88  
    1.89 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
    1.90 +    desc = (struct xencomm_desc *)
    1.91 +        xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)handle));
    1.92      if (desc == NULL)
    1.93          return 1;
    1.94