aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/xencomm.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-08-14 16:01:34 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-08-14 16:01:34 +0100
commit6877a0de293aa9b8054f8b9cd0c9a15e1fa5c8a8 (patch)
tree4d45160393c7d21aa454dffe0785c50ed55c2ed5 /xen/common/xencomm.c
parentad2c8b83e801340d21cca006d66879e90fc7ced6 (diff)
downloadxen-6877a0de293aa9b8054f8b9cd0c9a15e1fa5c8a8.tar.gz
xen-6877a0de293aa9b8054f8b9cd0c9a15e1fa5c8a8.tar.bz2
xen-6877a0de293aa9b8054f8b9cd0c9a15e1fa5c8a8.zip
[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>
Diffstat (limited to 'xen/common/xencomm.c')
-rw-r--r--xen/common/xencomm.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/xen/common/xencomm.c b/xen/common/xencomm.c
index 3ee5d00c25..5d60484c3b 100644
--- a/xen/common/xencomm.c
+++ b/xen/common/xencomm.c
@@ -34,6 +34,15 @@ static int xencomm_debug = 1; /* extremely verbose */
#define xencomm_debug 0
#endif
+static void*
+xencomm_maddr_to_vaddr(unsigned long maddr)
+{
+ if (maddr == 0)
+ return NULL;
+
+ return maddr_to_virt(maddr);
+}
+
static unsigned long
xencomm_inline_from_guest(void *to, const void *from, unsigned int n,
unsigned int skip)
@@ -54,7 +63,7 @@ xencomm_inline_from_guest(void *to, const void *from, unsigned int n,
src_maddr = paddr_to_maddr(src_paddr);
if (xencomm_debug)
printk("%lx[%d] -> %lx\n", src_maddr, bytes, (unsigned long)to);
- memcpy(to, (void *)src_maddr, bytes);
+ memcpy(to, maddr_to_virt(src_maddr), bytes);
src_paddr += bytes;
to += bytes;
n -= bytes;
@@ -89,7 +98,8 @@ xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
return xencomm_inline_from_guest(to, from, n, skip);
/* first we need to access the descriptor */
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)from));
if (desc == NULL)
return n;
@@ -130,7 +140,7 @@ xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
if (xencomm_debug)
printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
- memcpy((void *)dest, (void *)src_maddr, bytes);
+ memcpy((void *)dest, maddr_to_virt(src_maddr), bytes);
from_pos += bytes;
to_pos += bytes;
}
@@ -161,7 +171,7 @@ xencomm_inline_to_guest(void *to, const void *from, unsigned int n,
dest_maddr = paddr_to_maddr(dest_paddr);
if (xencomm_debug)
printk("%lx[%d] -> %lx\n", (unsigned long)from, bytes, dest_maddr);
- memcpy((void *)dest_maddr, (void *)from, bytes);
+ memcpy(maddr_to_virt(dest_maddr), (void *)from, bytes);
dest_paddr += bytes;
from += bytes;
n -= bytes;
@@ -196,7 +206,8 @@ xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
return xencomm_inline_to_guest(to, from, n, skip);
/* first we need to access the descriptor */
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)to));
if (desc == NULL)
return n;
@@ -236,7 +247,7 @@ xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
if (xencomm_debug)
printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
- memcpy((void *)dest_maddr, (void *)source, bytes);
+ memcpy(maddr_to_virt(dest_maddr), (void *)source, bytes);
from_pos += bytes;
to_pos += bytes;
}
@@ -264,7 +275,8 @@ int xencomm_add_offset(void **handle, unsigned int bytes)
return xencomm_inline_add_offset(handle, bytes);
/* first we need to access the descriptor */
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)*handle);
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)*handle));
if (desc == NULL)
return -1;
@@ -310,7 +322,8 @@ int xencomm_handle_is_null(void *handle)
if (xencomm_is_inline(handle))
return xencomm_inline_addr(handle) == 0;
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)handle));
if (desc == NULL)
return 1;