Le Lundi 21 Août 2006 11:41, Keir Fraser a écrit : > On 21/8/06 10:20 am, "Tristan Gingold" <[EMAIL PROTECTED]> wrote: > >> Fine in principle. Specific comments: > >> * powerpc should be cleaned up at the same time to use the common > >> infrastructure. I don't want duplicated code hanging around in > >> arch/powerpc > > > > I have attached a blindly-made patch again powerpc files. > > If ppc people could check this, I'd be happy. > > > >> * The code you add to common/ should obey the coding style of other > >> files in that directory > >> * Arguably we should have an asm-generic for the xencomm guest-access > >> macros. That's a Linux-ism which I think fits well in this particular > >> case. > > > > Taken into account in this updated patch. > > Looks better. I assume you'll resend with signed-off-by when you want these > applied. Hi,
here are the signed-off-by patches for xen. I took the liberty to add Hollis Blanchard in signed-off-by of the first patch because he is the primary author of these files. I don't know wether or not these patches should be put off beacause of the freeze, but they are a no-op for x86. Tristan.
# HG changeset patch # User [EMAIL PROTECTED] # Node ID cbe47a6938d17983c29d6baab5b6f81b9485451a # Parent 91169603a8e8dded9eba6cb6c3421b5d58a85a97 Xencomm in common code. Signed-off-by: Tristan Gingold <[EMAIL PROTECTED]> Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> diff -r 91169603a8e8 -r cbe47a6938d1 xen/common/Makefile --- a/xen/common/Makefile Tue Aug 22 14:45:49 2006 -0600 +++ b/xen/common/Makefile Wed Aug 23 08:08:14 2006 +0200 @@ -26,6 +26,8 @@ obj-y += vsprintf.o obj-y += vsprintf.o obj-y += xmalloc.o +obj-$(HAS_XENCOMM) += xencomm.o + obj-$(perfc) += perfc.o obj-$(crash_debug) += gdbstub.o diff -r 91169603a8e8 -r cbe47a6938d1 xen/include/public/xencomm.h --- a/xen/include/public/xencomm.h Tue Aug 22 14:45:49 2006 -0600 +++ b/xen/include/public/xencomm.h Wed Aug 23 08:08:14 2006 +0200 @@ -34,4 +34,15 @@ struct xencomm_desc { uint64_t address[0]; }; +/* Inline Xencomm. + If the inline flag is set, the descriptor is simply a the flagged + physical address of the buffer which is known to be contiguous in + physical memory. Because the kernels are often 1:1 mapped, this is + interesting for kernel issued hypercalls. */ +/* These macros should be defined by arch-xxx.h: + XENCOMM_IS_INLINE(addr): true if ADDR is an inline address. + XENCOMM_INLINE_ADDR(addr): extract the physical address (as an unsigned). + XENCOMM_INLINE_MAKE(addr): flag ADDR and returns an unsigned. +*/ + #endif /* _XEN_XENCOMM_H_ */ diff -r 91169603a8e8 -r cbe47a6938d1 xen/common/xencomm.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/common/xencomm.c Wed Aug 23 08:08:14 2006 +0200 @@ -0,0 +1,348 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright (C) IBM Corp. 2006 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + * Tristan Gingold <[EMAIL PROTECTED]> + */ + +#include <xen/config.h> +#include <xen/mm.h> +#include <xen/sched.h> +#include <asm/current.h> +#include <asm-generic/xencomm_access.h> +#include <public/xen.h> +#include <public/xencomm.h> +#include <xen/errno.h> + +#undef DEBUG +#ifdef DEBUG +static int xencomm_debug = 1; /* extremely verbose */ +#else +#define xencomm_debug 0 +#endif + +/** + * xencomm_copy_from_guest: Copy a block of data from domain space. + * @to: Machine address. + * @from: Physical address to a xencomm buffer descriptor. + * @n: Number of bytes to copy. + * @skip: Number of bytes from the start to skip. + * + * Copy data from domain to hypervisor. + * + * Returns number of bytes that could not be copied. + * On success, this will be zero. + */ +unsigned long +xencomm_copy_from_guest( + void *to, + const void *from, + unsigned int n, + unsigned int skip) +{ + struct xencomm_desc *desc; + unsigned long desc_addr; + unsigned int from_pos = 0; + unsigned int to_pos = 0; + unsigned int i = 0; + + if ( xencomm_debug ) + printf("xencomm_copy_from_guest: from=%lx+%u n=%u\n", + (unsigned long)from, skip, n); + + if ( XENCOMM_IS_INLINE (from) ) + { + unsigned long src_paddr = XENCOMM_INLINE_ADDR(from); + + src_paddr += skip; + + while ( n > 0 ) + { + unsigned int chunksz; + unsigned long src_maddr; + unsigned int bytes; + + chunksz = PAGE_SIZE - (src_paddr % PAGE_SIZE); + + bytes = min(chunksz, n); + + src_maddr = xencomm_paddr_to_maddr(src_paddr); + if ( xencomm_debug > 1 ) + printk("%lx[%d] -> %lx\n", + src_maddr, bytes, (unsigned long)to); + if ( src_maddr == 0 ) + return -EFAULT; + + memcpy(to, (void *)src_maddr, bytes); + src_paddr += bytes; + to += bytes; + n -= bytes; + } + + /* Always successful. */ + return 0; + } + + /* first we need to access the descriptor */ + desc_addr = xencomm_paddr_to_maddr((unsigned long)from); + if ( desc_addr == 0 ) + return -EFAULT; + + desc = (struct xencomm_desc *)desc_addr; + if (desc->magic != XENCOMM_MAGIC) + { + printk("%s: error: %p magic was 0x%x\n", + __func__, desc, desc->magic); + return -EFAULT; + } + + /* iterate through the descriptor, copying up to a page at a time */ + while ( (to_pos < n) && (i < desc->nr_addrs) ) + { + unsigned long src_paddr = desc->address[i]; + unsigned int pgoffset; + unsigned int chunksz; + unsigned int chunk_skip; + + if ( src_paddr == XENCOMM_INVALID ) + { + i++; + continue; + } + + pgoffset = src_paddr % PAGE_SIZE; + chunksz = PAGE_SIZE - pgoffset; + + chunk_skip = min(chunksz, skip); + from_pos += chunk_skip; + chunksz -= chunk_skip; + skip -= chunk_skip; + + if ( skip == 0 ) + { + unsigned long src_maddr; + unsigned long dest = (unsigned long)to + to_pos; + unsigned int bytes = min(chunksz, n - to_pos); + + if ( xencomm_debug > 1 ) + printf ("src_paddr=%lx i=%d, skip=%d\n", + src_paddr, i, chunk_skip); + + src_maddr = xencomm_paddr_to_maddr(src_paddr + chunk_skip); + if ( xencomm_debug > 1 ) + printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest); + if ( src_maddr == 0 ) + return -EFAULT; + + memcpy((void *)dest, (void *)src_maddr, bytes); + from_pos += bytes; + to_pos += bytes; + } + + i++; + } + + return n - to_pos; +} + +/** + * xencomm_copy_to_guest: Copy a block of data to domain space. + * @to: Physical address to xencomm buffer descriptor. + * @from: Machine address. + * @n: Number of bytes to copy. + * @skip: Number of bytes from the start to skip. + * + * Copy data from hypervisor to domain. + * + * Returns number of bytes that could not be copied. + * On success, this will be zero. + */ +unsigned long +xencomm_copy_to_guest( + void *to, + const void *from, + unsigned int n, + unsigned int skip) +{ + struct xencomm_desc *desc; + unsigned long desc_addr; + unsigned int from_pos = 0; + unsigned int to_pos = 0; + unsigned int i = 0; + + if ( xencomm_debug ) + printf ("xencomm_copy_to_guest: to=%lx+%u n=%u\n", + (unsigned long)to, skip, n); + + if ( XENCOMM_IS_INLINE(to) ) + { + unsigned long dest_paddr = XENCOMM_INLINE_ADDR(to); + + dest_paddr += skip; + + while ( n > 0 ) + { + unsigned int chunksz; + unsigned long dest_maddr; + unsigned int bytes; + + chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE); + + bytes = min(chunksz, n); + + dest_maddr = xencomm_paddr_to_maddr(dest_paddr); + if ( xencomm_debug > 1 ) + printk("%lx[%d] -> %lx\n", + (unsigned long)from, bytes, dest_maddr); + if ( dest_maddr == 0 ) + return -EFAULT; + + memcpy((void *)dest_maddr, (void *)from, bytes); + dest_paddr += bytes; + from += bytes; + n -= bytes; + } + + /* Always successful. */ + return 0; + } + + /* first we need to access the descriptor */ + desc_addr = xencomm_paddr_to_maddr((unsigned long)to); + if ( desc_addr == 0 ) + return -EFAULT; + + desc = (struct xencomm_desc *)desc_addr; + if (desc->magic != XENCOMM_MAGIC) { + printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic); + return -EFAULT; + } + + /* iterate through the descriptor, copying up to a page at a time */ + while ( (from_pos < n) && (i < desc->nr_addrs) ) + { + unsigned long dest_paddr = desc->address[i]; + unsigned int pgoffset; + unsigned int chunksz; + unsigned int chunk_skip; + + if ( dest_paddr == XENCOMM_INVALID ) + { + i++; + continue; + } + + pgoffset = dest_paddr % PAGE_SIZE; + chunksz = PAGE_SIZE - pgoffset; + + chunk_skip = min(chunksz, skip); + to_pos += chunk_skip; + chunksz -= chunk_skip; + skip -= chunk_skip; + + if ( skip == 0 ) + { + unsigned long dest_maddr; + unsigned long source = (unsigned long)from + from_pos; + unsigned int bytes = min(chunksz, n - from_pos); + + dest_maddr = xencomm_paddr_to_maddr(dest_paddr + chunk_skip); + if ( xencomm_debug > 1 ) + printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr); + if ( dest_maddr == 0 ) + return -EFAULT; + + memcpy((void *)dest_maddr, (void *)source, bytes); + from_pos += bytes; + to_pos += bytes; + } + + i++; + } + + return n - from_pos; +} + +/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely + * exhausted pages to XENCOMM_INVALID. */ +void * +xencomm_add_offset( + void *handle, + unsigned int bytes) +{ + struct xencomm_desc *desc; + unsigned long desc_addr; + int i = 0; + + if ( XENCOMM_IS_INLINE(handle) ) + return (void *)((unsigned long)handle + bytes); + + /* first we need to access the descriptor */ + desc_addr = xencomm_paddr_to_maddr((unsigned long)handle); + if ( desc_addr == 0 ) + return NULL; + + desc = (struct xencomm_desc *)desc_addr; + if ( desc->magic != XENCOMM_MAGIC ) + { + printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic); + return NULL; + } + + /* iterate through the descriptor incrementing addresses */ + while ( (bytes > 0) && (i < desc->nr_addrs) ) + { + unsigned long dest_paddr = desc->address[i]; + unsigned int pgoffset; + unsigned int chunksz; + unsigned int chunk_skip; + + pgoffset = dest_paddr % PAGE_SIZE; + chunksz = PAGE_SIZE - pgoffset; + + chunk_skip = min(chunksz, bytes); + if ( chunk_skip == chunksz ) + { + /* exhausted this page */ + desc->address[i] = XENCOMM_INVALID; + } else { + desc->address[i] += chunk_skip; + } + bytes -= chunk_skip; + } + return handle; +} + +int +xencomm_handle_is_null( + void *ptr) +{ + if ( XENCOMM_IS_INLINE(ptr) ) + return XENCOMM_INLINE_ADDR(ptr) == 0; + else + { + struct xencomm_desc *desc; + unsigned long desc_addr; + + desc_addr = xencomm_paddr_to_maddr((unsigned long)ptr); + if ( desc_addr == 0 ) + return 1; + + desc = (struct xencomm_desc *)desc_addr; + return (desc->address[0] == XENCOMM_INVALID); + } +} diff -r 91169603a8e8 -r cbe47a6938d1 xen/include/asm-generic/xencomm_access.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/include/asm-generic/xencomm_access.h Wed Aug 23 08:08:14 2006 +0200 @@ -0,0 +1,107 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright (C) IBM Corp. 2006 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + * Tristan Gingold <[EMAIL PROTECTED]> + */ + +#ifndef __ASM_GUEST_ACCESS_H__ +#define __ASM_GUEST_ACCESS_H__ + +extern unsigned long xencomm_copy_to_guest(void *to, const void *from, + unsigned int len, unsigned int skip); +extern unsigned long xencomm_copy_from_guest(void *to, const void *from, + unsigned int len, unsigned int skip); +extern void *xencomm_add_offset(void *handle, unsigned int bytes); +extern int xencomm_handle_is_null(void *ptr); + + +/* Is the guest handle a NULL reference? */ +#define guest_handle_is_null(hnd) \ + ((hnd).p == NULL || xencomm_handle_is_null((hnd).p)) + +/* Offset the given guest handle into the array it refers to. */ +#define guest_handle_add_offset(hnd, nr) ({ \ + const typeof((hnd).p) _ptr = (hnd).p; \ + (hnd).p = xencomm_add_offset(_ptr, nr * sizeof(*_ptr)); \ +}) + +/* Cast a guest handle to the specified type of handle. */ +#define guest_handle_cast(hnd, type) ({ \ + type *_x = (hnd).p; \ + XEN_GUEST_HANDLE(type) _y; \ + set_xen_guest_handle(_y, _x); \ + _y; \ +}) + + +/* Since we run in real mode, we can safely access all addresses. That also + * means our __routines are identical to our "normal" routines. */ +#define guest_handle_okay(hnd, nr) 1 + +/* + * Copy an array of objects to guest context via a guest handle. + * Optionally specify an offset into the guest array. + */ +#define copy_to_guest_offset(hnd, idx, ptr, nr) \ + __copy_to_guest_offset(hnd, idx, ptr, nr) + +/* Copy sub-field of a structure to guest context via a guest handle. */ +#define copy_field_to_guest(hnd, ptr, field) \ + __copy_field_to_guest(hnd, ptr, field) + +/* + * Copy an array of objects from guest context via a guest handle. + * Optionally specify an offset into the guest array. + */ +#define copy_from_guest_offset(ptr, hnd, idx, nr) \ + __copy_from_guest_offset(ptr, hnd, idx, nr) + +/* Copy sub-field of a structure from guest context via a guest handle. */ +#define copy_field_from_guest(ptr, hnd, field) \ + __copy_field_from_guest(ptr, hnd, field) + +#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({ \ + const typeof(ptr) _d = (hnd).p; \ + const typeof(ptr) _s = (ptr); \ + xencomm_copy_to_guest(_d, _s, sizeof(*_s)*(nr), sizeof(*_s)*(idx)); \ +}) + +#define __copy_field_to_guest(hnd, ptr, field) ({ \ + const int _off = offsetof(typeof(*ptr), field); \ + const typeof(ptr) _d = (hnd).p; \ + const typeof(&(ptr)->field) _s = &(ptr)->field; \ + xencomm_copy_to_guest(_d, _s, sizeof(*_s), _off); \ +}) + +#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({ \ + const typeof(ptr) _s = (hnd).p; \ + const typeof(ptr) _d = (ptr); \ + xencomm_copy_from_guest(_d, _s, sizeof(*_s)*(nr), sizeof(*_s)*(idx)); \ +}) + +#define __copy_field_from_guest(ptr, hnd, field) ({ \ + const int _off = offsetof(typeof(*ptr), field); \ + const typeof(ptr) _s = (hnd).p; \ + const typeof(&(ptr)->field) _d = &(ptr)->field; \ + xencomm_copy_from_guest(_d, _s, sizeof(*_d), _off); \ +}) + +/* Internal use only: returns 0 in case of bad address. */ +extern unsigned long xencomm_paddr_to_maddr (unsigned long paddr); + +#endif /* __ASM_GUEST_ACCESS_H__ */
# HG changeset patch # User [EMAIL PROTECTED] # Node ID 38947373a0fad500aacb3f28b82f35f95ead73f9 # Parent cbe47a6938d17983c29d6baab5b6f81b9485451a Use common xencomm code. Signed-off-by: Tristan Gingold <[EMAIL PROTECTED]> diff -r cbe47a6938d1 -r 38947373a0fa xen/arch/powerpc/Rules.mk --- a/xen/arch/powerpc/Rules.mk Wed Aug 23 08:08:14 2006 +0200 +++ b/xen/arch/powerpc/Rules.mk Wed Aug 23 08:10:22 2006 +0200 @@ -1,4 +1,5 @@ HAS_PPC64 := y HAS_PPC64 := y +HAS_XENCOMM := y CC := $(CROSS_COMPILE)gcc LD := $(CROSS_COMPILE)ld diff -r cbe47a6938d1 -r 38947373a0fa xen/arch/powerpc/usercopy.c --- a/xen/arch/powerpc/usercopy.c Wed Aug 23 08:08:14 2006 +0200 +++ b/xen/arch/powerpc/usercopy.c Wed Aug 23 08:10:22 2006 +0200 @@ -26,15 +26,8 @@ #include <public/xen.h> #include <public/xencomm.h> -#undef DEBUG -#ifdef DEBUG -static int xencomm_debug = 1; /* extremely verbose */ -#else -#define xencomm_debug 0 -#endif - /* XXX need to return error, not panic, if domain passed a bad pointer */ -static unsigned long paddr_to_maddr(unsigned long paddr) +unsigned long xencomm_paddr_to_maddr (unsigned long paddr) { struct vcpu *v = get_current(); struct domain *d = v->domain; @@ -61,182 +54,3 @@ static unsigned long paddr_to_maddr(unsi return pa; } - -/** - * xencomm_copy_from_guest: Copy a block of data from domain space. - * @to: Machine address. - * @from: Physical address to a xencomm buffer descriptor. - * @n: Number of bytes to copy. - * @skip: Number of bytes from the start to skip. - * - * Copy data from domain to hypervisor. - * - * Returns number of bytes that could not be copied. - * On success, this will be zero. - */ -unsigned long -xencomm_copy_from_guest(void *to, const void *from, unsigned int n, - unsigned int skip) -{ - struct xencomm_desc *desc; - unsigned int from_pos = 0; - unsigned int to_pos = 0; - unsigned int i = 0; - - /* first we need to access the descriptor */ - desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from); - if (desc->magic != XENCOMM_MAGIC) { - printk("%s: error: %p magic was 0x%x\n", - __func__, desc, desc->magic); - return n; - } - - /* iterate through the descriptor, copying up to a page at a time */ - while ((to_pos < n) && (i < desc->nr_addrs)) { - unsigned long src_paddr = desc->address[i]; - unsigned int pgoffset; - unsigned int chunksz; - unsigned int chunk_skip; - - if (src_paddr == XENCOMM_INVALID) { - i++; - continue; - } - - pgoffset = src_paddr % PAGE_SIZE; - chunksz = PAGE_SIZE - pgoffset; - - chunk_skip = min(chunksz, skip); - from_pos += chunk_skip; - chunksz -= chunk_skip; - skip -= chunk_skip; - - if (skip == 0) { - unsigned long src_maddr; - unsigned long dest = (unsigned long)to + to_pos; - unsigned int bytes = min(chunksz, n - to_pos); - - src_maddr = paddr_to_maddr(src_paddr + chunk_skip); - if (xencomm_debug) - printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest); - memcpy((void *)dest, (void *)src_maddr, bytes); - from_pos += bytes; - to_pos += bytes; - } - - i++; - } - - return n - to_pos; -} - -/** - * xencomm_copy_to_guest: Copy a block of data to domain space. - * @to: Physical address to xencomm buffer descriptor. - * @from: Machine address. - * @n: Number of bytes to copy. - * @skip: Number of bytes from the start to skip. - * - * Copy data from hypervisor to domain. - * - * Returns number of bytes that could not be copied. - * On success, this will be zero. - */ -unsigned long -xencomm_copy_to_guest(void *to, const void *from, unsigned int n, - unsigned int skip) -{ - struct xencomm_desc *desc; - unsigned int from_pos = 0; - unsigned int to_pos = 0; - unsigned int i = 0; - - /* first we need to access the descriptor */ - desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to); - if (desc->magic != XENCOMM_MAGIC) { - printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic); - return n; - } - - /* iterate through the descriptor, copying up to a page at a time */ - while ((from_pos < n) && (i < desc->nr_addrs)) { - unsigned long dest_paddr = desc->address[i]; - unsigned int pgoffset; - unsigned int chunksz; - unsigned int chunk_skip; - - if (dest_paddr == XENCOMM_INVALID) { - i++; - continue; - } - - pgoffset = dest_paddr % PAGE_SIZE; - chunksz = PAGE_SIZE - pgoffset; - - chunk_skip = min(chunksz, skip); - to_pos += chunk_skip; - chunksz -= chunk_skip; - skip -= chunk_skip; - - if (skip == 0) { - unsigned long dest_maddr; - unsigned long source = (unsigned long)from + from_pos; - unsigned int bytes = min(chunksz, n - from_pos); - - dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip); - if (xencomm_debug) - printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr); - memcpy((void *)dest_maddr, (void *)source, bytes); - from_pos += bytes; - to_pos += bytes; - } - - i++; - } - - return n - from_pos; -} - -/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely - * exhausted pages to XENCOMM_INVALID. */ -void xencomm_add_offset(void *handle, unsigned int bytes) -{ - struct xencomm_desc *desc; - int i = 0; - - /* first we need to access the descriptor */ - desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle); - if (desc->magic != XENCOMM_MAGIC) { - printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic); - return; - } - - /* iterate through the descriptor incrementing addresses */ - while ((bytes > 0) && (i < desc->nr_addrs)) { - unsigned long dest_paddr = desc->address[i]; - unsigned int pgoffset; - unsigned int chunksz; - unsigned int chunk_skip; - - pgoffset = dest_paddr % PAGE_SIZE; - chunksz = PAGE_SIZE - pgoffset; - - chunk_skip = min(chunksz, bytes); - if (chunk_skip == chunksz) { - /* exhausted this page */ - desc->address[i] = XENCOMM_INVALID; - } else { - desc->address[i] += chunk_skip; - } - bytes -= chunk_skip; - } -} - -int xencomm_handle_is_null(void *ptr) -{ - struct xencomm_desc *desc; - - desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)ptr); - - return (desc->address[0] == XENCOMM_INVALID); -} diff -r cbe47a6938d1 -r 38947373a0fa xen/include/asm-powerpc/guest_access.h --- a/xen/include/asm-powerpc/guest_access.h Wed Aug 23 08:08:14 2006 +0200 +++ b/xen/include/asm-powerpc/guest_access.h Wed Aug 23 08:10:22 2006 +0200 @@ -21,82 +21,6 @@ #ifndef __PPC_GUEST_ACCESS_H__ #define __PPC_GUEST_ACCESS_H__ -extern unsigned long xencomm_copy_to_guest(void *to, const void *from, - unsigned int len, unsigned int skip); -extern unsigned long xencomm_copy_from_guest(void *to, const void *from, - unsigned int len, unsigned int skip); -extern void xencomm_add_offset(void *handle, unsigned int bytes); -extern int xencomm_handle_is_null(void *ptr); - - -/* Is the guest handle a NULL reference? */ -#define guest_handle_is_null(hnd) \ - ((hnd).p == NULL || xencomm_handle_is_null((hnd).p)) - -/* Offset the given guest handle into the array it refers to. */ -#define guest_handle_add_offset(hnd, nr) ({ \ - const typeof((hnd).p) _ptr = (hnd).p; \ - xencomm_add_offset(_ptr, nr * sizeof(*_ptr)); \ -}) - -/* Cast a guest handle to the specified type of handle. */ -#define guest_handle_cast(hnd, type) ({ \ - type *_x = (hnd).p; \ - XEN_GUEST_HANDLE(type) _y; \ - set_xen_guest_handle(_y, _x); \ - _y; \ -}) - -/* Since we run in real mode, we can safely access all addresses. That also - * means our __routines are identical to our "normal" routines. */ -#define guest_handle_okay(hnd, nr) 1 - -/* - * Copy an array of objects to guest context via a guest handle. - * Optionally specify an offset into the guest array. - */ -#define copy_to_guest_offset(hnd, idx, ptr, nr) \ - __copy_to_guest_offset(hnd, idx, ptr, nr) - -/* Copy sub-field of a structure to guest context via a guest handle. */ -#define copy_field_to_guest(hnd, ptr, field) \ - __copy_field_to_guest(hnd, ptr, field) - -/* - * Copy an array of objects from guest context via a guest handle. - * Optionally specify an offset into the guest array. - */ -#define copy_from_guest_offset(ptr, hnd, idx, nr) \ - __copy_from_guest_offset(ptr, hnd, idx, nr) - -/* Copy sub-field of a structure from guest context via a guest handle. */ -#define copy_field_from_guest(ptr, hnd, field) \ - __copy_field_from_guest(ptr, hnd, field) - -#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({ \ - const typeof(ptr) _x = (hnd).p; \ - const typeof(ptr) _y = (ptr); \ - xencomm_copy_to_guest(_x, _y, sizeof(*_x)*(nr), sizeof(*_x)*(idx)); \ -}) - -#define __copy_field_to_guest(hnd, ptr, field) ({ \ - const int _off = offsetof(typeof(*ptr), field); \ - const typeof(&(ptr)->field) _x = &(hnd).p->field; \ - const typeof(&(ptr)->field) _y = &(ptr)->field; \ - xencomm_copy_to_guest(_x, _y, sizeof(*_x), sizeof(*_x)*(_off)); \ -}) - -#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({ \ - const typeof(ptr) _x = (hnd).p; \ - const typeof(ptr) _y = (ptr); \ - xencomm_copy_from_guest(_y, _x, sizeof(*_x)*(nr), sizeof(*_x)*(idx)); \ -}) - -#define __copy_field_from_guest(ptr, hnd, field) ({ \ - const int _off = offsetof(typeof(*ptr), field); \ - const typeof(&(ptr)->field) _x = &(hnd).p->field; \ - const typeof(&(ptr)->field) _y = &(ptr)->field; \ - xencomm_copy_to_guest(_y, _x, sizeof(*_x), sizeof(*_x)*(_off)); \ -}) +#include <asm-generic/xencomm_access.h> #endif /* __PPC_GUEST_ACCESS_H__ */ diff -r cbe47a6938d1 -r 38947373a0fa xen/include/public/arch-powerpc.h --- a/xen/include/public/arch-powerpc.h Wed Aug 23 08:08:14 2006 +0200 +++ b/xen/include/public/arch-powerpc.h Wed Aug 23 08:10:22 2006 +0200 @@ -114,6 +114,12 @@ struct arch_vcpu_info { /* Support for multi-processor guests. */ #define MAX_VIRT_CPUS 32 + +/* Currently powerpc doesn't use inline xencomm. */ +#define XENCOMM_IS_INLINE(addr) 0 +#define XENCOMM_INLINE_ADDR(addr) 0 +#define XENCOMM_INLINE_CREATE(addr) 0 + #endif #endif
_______________________________________________ Xen-ppc-devel mailing list Xen-ppc-devel@lists.xensource.com http://lists.xensource.com/xen-ppc-devel