ia64/xen-unstable

changeset 9142:64f11b0e2e7d

Merged.
author emellor@leeni.uk.xensource.com
date Sat Mar 04 19:16:36 2006 +0100 (2006-03-04)
parents f43f094467f6 2d87e2747973
children 42f93cc190b7
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Sat Mar 04 19:15:36 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Sat Mar 04 19:16:36 2006 +0100
     1.3 @@ -948,9 +948,25 @@ void xenbus_probe(void *unused)
     1.4  }
     1.5  
     1.6  
     1.7 +static struct file_operations xsd_kva_fops;
     1.8  static struct proc_dir_entry *xsd_kva_intf;
     1.9  static struct proc_dir_entry *xsd_port_intf;
    1.10  
    1.11 +static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
    1.12 +{
    1.13 +	size_t size = vma->vm_end - vma->vm_start;
    1.14 +
    1.15 +	if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
    1.16 +		return -EINVAL;
    1.17 +
    1.18 +	vma->vm_pgoff = mfn_to_pfn(xen_start_info->store_mfn);
    1.19 +
    1.20 +	if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
    1.21 +			    size, vma->vm_page_prot))
    1.22 +		return -EAGAIN;
    1.23 +
    1.24 +	return 0;
    1.25 +}
    1.26  
    1.27  static int xsd_kva_read(char *page, char **start, off_t off,
    1.28                          int count, int *eof, void *data)
    1.29 @@ -1024,9 +1040,14 @@ static int __init xenbus_probe_init(void
    1.30  		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
    1.31  
    1.32  		/* And finally publish the above info in /proc/xen */
    1.33 -		if((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400)))
    1.34 +		if ((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400))) {
    1.35 +			memcpy(&xsd_kva_fops, xsd_kva_intf->proc_fops,
    1.36 +			       sizeof(xsd_kva_fops));
    1.37 +			xsd_kva_fops.mmap = xsd_kva_mmap;
    1.38 +			xsd_kva_intf->proc_fops = &xsd_kva_fops;
    1.39  			xsd_kva_intf->read_proc = xsd_kva_read;
    1.40 -		if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
    1.41 +		}
    1.42 +		if ((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
    1.43  			xsd_port_intf->read_proc = xsd_port_read;
    1.44  	}
    1.45  
     2.1 --- a/tools/firmware/vmxassist/setup.c	Sat Mar 04 19:15:36 2006 +0100
     2.2 +++ b/tools/firmware/vmxassist/setup.c	Sat Mar 04 19:16:36 2006 +0100
     2.3 @@ -123,6 +123,8 @@ setup_paging(void)
     2.4  void
     2.5  setup_gdt(void)
     2.6  {
     2.7 +	unsigned long long addr = (unsigned long long) &tss;
     2.8 +
     2.9  	/* setup task state segment */
    2.10  	memset(&tss, 0, sizeof(tss));
    2.11  	tss.ss0 = DATA_SELECTOR;
    2.12 @@ -130,8 +132,7 @@ setup_gdt(void)
    2.13  	tss.iomap_base = offsetof(struct tss, iomap);
    2.14  
    2.15  	/* initialize gdt's tss selector */
    2.16 -	unsigned long long addr = (unsigned long long) &tss;
    2.17 -        gdt[TSS_SELECTOR / sizeof(gdt[0])] |=
    2.18 +	gdt[TSS_SELECTOR / sizeof(gdt[0])] |=
    2.19  		((addr & 0xFF000000) << (56-24)) |
    2.20  		((addr & 0x00FF0000) << (32-16)) |
    2.21  		((addr & 0x0000FFFF) << (16)) |
     3.1 --- a/tools/ioemu/audio/audio.c	Sat Mar 04 19:15:36 2006 +0100
     3.2 +++ b/tools/ioemu/audio/audio.c	Sat Mar 04 19:16:36 2006 +0100
     3.3 @@ -713,7 +713,7 @@ int AUD_calc_elapsed (SWVoice *sw)
     3.4      delta = now - sw->old_ticks;
     3.5      bytes = (delta * sw->bytes_per_second) / ticks_per_sec;
     3.6      if (delta < 0) {
     3.7 -        dolog ("whoops delta(<0)=%lld\n", delta);
     3.8 +        dolog ("whoops delta(<0)=%"PRId64"\n", delta);
     3.9          return 0;
    3.10      }
    3.11  
     4.1 --- a/tools/ioemu/hw/i8254.c	Sat Mar 04 19:15:36 2006 +0100
     4.2 +++ b/tools/ioemu/hw/i8254.c	Sat Mar 04 19:16:36 2006 +0100
     4.3 @@ -249,7 +249,7 @@ void pit_reset_hvm_vectors()
     4.4      req->u.data |= (irq << 16);
     4.5      req->u.data |= (hvm_channel << 24);
     4.6      req->u.data |= ((s->rw_mode) << 26);
     4.7 -    fprintf(logfile, "HVM_PIT:pass info 0x%llx to HV!\n", req->u.data);
     4.8 +    fprintf(logfile, "HVM_PIT:pass info 0x%"PRIx64" to HV!\n", req->u.data);
     4.9  }
    4.10  
    4.11  static inline void pit_load_count(PITChannelState *s, int val)
     5.1 --- a/tools/ioemu/monitor.c	Sat Mar 04 19:15:36 2006 +0100
     5.2 +++ b/tools/ioemu/monitor.c	Sat Mar 04 19:16:36 2006 +0100
     5.3 @@ -676,19 +676,19 @@ static void monitor_handle_command(const
     5.4              break;
     5.5          case '-':
     5.6              {
     5.7 -                int has_option;
     5.8 +                long has_option;
     5.9                  /* option */
    5.10 -                
    5.11 +
    5.12                  c = *typestr++;
    5.13                  if (c == '\0')
    5.14                      goto bad_type;
    5.15 -                while (isspace(*p)) 
    5.16 +                while (isspace(*p))
    5.17                      p++;
    5.18                  has_option = 0;
    5.19                  if (*p == '-') {
    5.20                      p++;
    5.21                      if (*p != c) {
    5.22 -                        term_printf("%s: unsupported option -%c\n", 
    5.23 +                        term_printf("%s: unsupported option -%c\n",
    5.24                                      cmdname, *p);
    5.25                          goto fail;
    5.26                      }
     6.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Sat Mar 04 19:15:36 2006 +0100
     6.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Sat Mar 04 19:16:36 2006 +0100
     6.3 @@ -138,11 +138,11 @@ void sp_info()
     6.4          req = &(shared_page->vcpu_iodata[i].vp_ioreq);
     6.5          term_printf("vcpu %d: event port %d\n",
     6.6                      i, shared_page->vcpu_iodata[i].vp_eport);
     6.7 -        term_printf("  req state: %x, pvalid: %x, addr: %llx, "
     6.8 -                    "data: %llx, count: %llx, size: %llx\n",
     6.9 +        term_printf("  req state: %x, pvalid: %x, addr: %"PRIx64", "
    6.10 +                    "data: %"PRIx64", count: %"PRIx64", size: %"PRIx64"\n",
    6.11                      req->state, req->pdata_valid, req->addr,
    6.12                      req->u.data, req->count, req->size);
    6.13 -        term_printf("  IO totally occurred on this vcpu: %llx\n",
    6.14 +        term_printf("  IO totally occurred on this vcpu: %"PRIx64"\n",
    6.15                      req->io_count);
    6.16      }
    6.17  }
    6.18 @@ -158,8 +158,8 @@ static ioreq_t* __cpu_get_ioreq(int vcpu
    6.19          return req;
    6.20  
    6.21      fprintf(logfile, "False I/O request ... in-service already: "
    6.22 -                     "%x, pvalid: %x, port: %llx, "
    6.23 -                     "data: %llx, count: %llx, size: %llx\n",
    6.24 +                     "%x, pvalid: %x, port: %"PRIx64", "
    6.25 +                     "data: %"PRIx64", count: %"PRIx64", size: %"PRIx64"\n",
    6.26                       req->state, req->pdata_valid, req->addr,
    6.27                       req->u.data, req->count, req->size);
    6.28      return NULL;
    6.29 @@ -460,12 +460,6 @@ int main_loop(void)
    6.30          FD_ZERO(&wakeup_rfds);
    6.31          FD_SET(evtchn_fd, &wakeup_rfds);
    6.32  
    6.33 -#if __WORDSIZE == 32
    6.34 -#define ULONGLONG_MAX   0xffffffffffffffffULL
    6.35 -#else
    6.36 -#define ULONGLONG_MAX   ULONG_MAX
    6.37 -#endif
    6.38 -
    6.39          tun_receive_handler(&rfds);
    6.40          if ( FD_ISSET(evtchn_fd, &rfds) ) {
    6.41              cpu_handle_ioreq(env);
     7.1 --- a/tools/ioemu/vl.c	Sat Mar 04 19:15:36 2006 +0100
     7.2 +++ b/tools/ioemu/vl.c	Sat Mar 04 19:16:36 2006 +0100
     7.3 @@ -2672,6 +2672,7 @@ int main(int argc, char **argv)
     7.4      char qemu_dm_logfilename[64];
     7.5      const char *loadvm = NULL;
     7.6      unsigned long nr_pages, extra_pages, ram_pages, *page_array;
     7.7 +    xc_dominfo_t info;
     7.8      extern void *shared_page;
     7.9      extern void *shared_vram;
    7.10  
    7.11 @@ -3132,7 +3133,7 @@ int main(int argc, char **argv)
    7.12  
    7.13      ram_pages = ram_size/PAGE_SIZE;
    7.14  #if defined(__i386__) || defined(__x86_64__)
    7.15 -    vgaram_pages =  (vga_ram_size -1)/PAGE_SIZE + 1;
    7.16 +    vgaram_pages =  (vga_ram_size -1) / PAGE_SIZE + 1;
    7.17      free_pages = vgaram_pages / L1_PAGETABLE_ENTRIES;
    7.18      extra_pages = vgaram_pages + free_pages;
    7.19  #else
    7.20 @@ -3142,7 +3143,6 @@ int main(int argc, char **argv)
    7.21  
    7.22      xc_handle = xc_interface_open();
    7.23  
    7.24 -    xc_dominfo_t info;
    7.25      xc_domain_getinfo(xc_handle, domid, 1, &info);
    7.26  
    7.27      nr_pages = info.nr_pages + extra_pages;
     8.1 --- a/tools/xenstore/hashtable.c	Sat Mar 04 19:15:36 2006 +0100
     8.2 +++ b/tools/xenstore/hashtable.c	Sat Mar 04 19:16:36 2006 +0100
     8.3 @@ -6,6 +6,7 @@
     8.4  #include <stdio.h>
     8.5  #include <string.h>
     8.6  #include <math.h>
     8.7 +#include <stdint.h>
     8.8  
     8.9  /*
    8.10  Credit for primes table: Aaron Krowne
    8.11 @@ -22,7 +23,7 @@ 50331653, 100663319, 201326611, 40265318
    8.12  805306457, 1610612741
    8.13  };
    8.14  const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]);
    8.15 -const float max_load_factor = 0.65;
    8.16 +const unsigned int max_load_factor = 65; /* percentage */
    8.17  
    8.18  /*****************************************************************************/
    8.19  struct hashtable *
    8.20 @@ -48,7 +49,7 @@ create_hashtable(unsigned int minsize,
    8.21      h->entrycount   = 0;
    8.22      h->hashfn       = hashf;
    8.23      h->eqfn         = eqf;
    8.24 -    h->loadlimit    = (unsigned int) ceil(size * max_load_factor);
    8.25 +    h->loadlimit    = (unsigned int)(((uint64_t)size * max_load_factor) / 100);
    8.26      return h;
    8.27  }
    8.28  
    8.29 @@ -121,7 +122,8 @@ hashtable_expand(struct hashtable *h)
    8.30          }
    8.31      }
    8.32      h->tablelength = newsize;
    8.33 -    h->loadlimit   = (unsigned int) ceil(newsize * max_load_factor);
    8.34 +    h->loadlimit   = (unsigned int)
    8.35 +        (((uint64_t)newsize * max_load_factor) / 100);
    8.36      return -1;
    8.37  }
    8.38  
     9.1 --- a/tools/xenstore/xenstored_domain.c	Sat Mar 04 19:15:36 2006 +0100
     9.2 +++ b/tools/xenstore/xenstored_domain.c	Sat Mar 04 19:16:36 2006 +0100
     9.3 @@ -27,7 +27,6 @@
     9.4  #include <sys/types.h>
     9.5  #include <sys/stat.h>
     9.6  #include <fcntl.h>
     9.7 -#include <paths.h>
     9.8  
     9.9  //#define DEBUG
    9.10  #include "utils.h"
    9.11 @@ -466,22 +465,9 @@ static int dom0_init(void)
    9.12  { 
    9.13  	int rc, fd;
    9.14  	evtchn_port_t port; 
    9.15 -	unsigned long kva; 
    9.16  	char str[20]; 
    9.17  	struct domain *dom0; 
    9.18  
    9.19 -	fd = open(XENSTORED_PROC_KVA, O_RDONLY); 
    9.20 -	if (fd == -1)
    9.21 -		return -1;
    9.22 -
    9.23 -	rc = read(fd, str, sizeof(str)); 
    9.24 -	if (rc == -1)
    9.25 -		goto outfd;
    9.26 -	str[rc] = '\0'; 
    9.27 -	kva = strtoul(str, NULL, 0); 
    9.28 -
    9.29 -	close(fd); 
    9.30 -
    9.31  	fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
    9.32  	if (fd == -1)
    9.33  		return -1;
    9.34 @@ -496,12 +482,12 @@ static int dom0_init(void)
    9.35  
    9.36  	dom0 = new_domain(NULL, 0, port); 
    9.37  
    9.38 -	fd = open(_PATH_KMEM, O_RDWR);
    9.39 +	fd = open(XENSTORED_PROC_KVA, O_RDWR);
    9.40  	if (fd == -1)
    9.41  		return -1;
    9.42  
    9.43  	dom0->interface = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
    9.44 -			       MAP_SHARED, fd, kva);
    9.45 +			       MAP_SHARED, fd, 0);
    9.46  	if (dom0->interface == MAP_FAILED)
    9.47  		goto outfd;
    9.48  
    10.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Sat Mar 04 19:15:36 2006 +0100
    10.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Sat Mar 04 19:16:36 2006 +0100
    10.3 @@ -16,10 +16,11 @@
    10.4  #include <asm/pdb.h>
    10.5  #include <xen/trace.h>
    10.6  #include <xen/console.h>
    10.7 +#include <xen/guest_access.h>
    10.8  #include <public/sched_ctl.h>
    10.9  #include <asm/vmx.h>
   10.10  
   10.11 -long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
   10.12 +long arch_do_dom0_op(dom0_op_t *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
   10.13  {
   10.14      long ret = 0;
   10.15  
   10.16 @@ -64,7 +65,7 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.17  
   10.18          put_domain(d);
   10.19  
   10.20 -        copy_to_user(u_dom0_op, op, sizeof(*op));
   10.21 +        copy_to_guest(u_dom0_op, op, 1);
   10.22      }
   10.23      break;
   10.24  
   10.25 @@ -74,7 +75,6 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.26          int n,j;
   10.27          int num = op->u.getpageframeinfo2.num;
   10.28          domid_t dom = op->u.getpageframeinfo2.domain;
   10.29 -        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
   10.30          struct domain *d;
   10.31          unsigned long *l_arr;
   10.32          ret = -ESRCH;
   10.33 @@ -95,7 +95,8 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.34          {
   10.35              int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
   10.36  
   10.37 -            if ( copy_from_user(l_arr, &s_ptr[n], k*sizeof(unsigned long)) )
   10.38 +            if ( copy_from_guest_offset(l_arr, op->u.getpageframeinfo2.array,
   10.39 +                                        n, k) )
   10.40              {
   10.41                  ret = -EINVAL;
   10.42                  break;
   10.43 @@ -135,7 +136,8 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.44  
   10.45              }
   10.46  
   10.47 -            if ( copy_to_user(&s_ptr[n], l_arr, k*sizeof(unsigned long)) )
   10.48 +            if ( copy_to_guest_offset(op->u.getpageframeinfo2.array,
   10.49 +                                      n, l_arr, k) )
   10.50              {
   10.51                  ret = -EINVAL;
   10.52                  break;
   10.53 @@ -160,7 +162,6 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.54          unsigned long start_page = op->u.getmemlist.max_pfns >> 32;
   10.55          unsigned long nr_pages = op->u.getmemlist.max_pfns & 0xffffffff;
   10.56          unsigned long mfn;
   10.57 -        unsigned long *buffer = op->u.getmemlist.buffer;
   10.58  
   10.59          ret = -EINVAL;
   10.60          if ( d != NULL )
   10.61 @@ -180,16 +181,16 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.62              {
   10.63                  mfn = gmfn_to_mfn_foreign(d, i);
   10.64  
   10.65 -                if ( put_user(mfn, buffer) )
   10.66 +                if ( copy_to_guest_offset(op->u.getmemlist.buffer,
   10.67 +                                          i - start_page, &mfn, 1) )
   10.68                  {
   10.69                      ret = -EFAULT;
   10.70                      break;
   10.71                  }
   10.72 -                buffer++;
   10.73              }
   10.74  
   10.75              op->u.getmemlist.num_pfns = i - start_page;
   10.76 -            copy_to_user(u_dom0_op, op, sizeof(*op));
   10.77 +            copy_to_guest(u_dom0_op, op, 1);
   10.78              
   10.79              put_domain(d);
   10.80          }
   10.81 @@ -211,7 +212,7 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   10.82          memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
   10.83          //memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
   10.84          ret = 0;
   10.85 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
   10.86 +        if ( copy_to_guest(u_dom0_op, op, 1) )
   10.87              ret = -EFAULT;
   10.88      }
   10.89      break;
    11.1 --- a/xen/arch/x86/dom0_ops.c	Sat Mar 04 19:15:36 2006 +0100
    11.2 +++ b/xen/arch/x86/dom0_ops.c	Sat Mar 04 19:16:36 2006 +0100
    11.3 @@ -10,6 +10,7 @@
    11.4  #include <xen/types.h>
    11.5  #include <xen/lib.h>
    11.6  #include <xen/mm.h>
    11.7 +#include <xen/guest_access.h>
    11.8  #include <public/dom0_ops.h>
    11.9  #include <xen/sched.h>
   11.10  #include <xen/event.h>
   11.11 @@ -48,7 +49,7 @@ static void read_msr_for(void *unused)
   11.12          (void)rdmsr_safe(msr_addr, msr_lo, msr_hi);
   11.13  }
   11.14  
   11.15 -long arch_do_dom0_op(struct dom0_op *op, struct dom0_op *u_dom0_op)
   11.16 +long arch_do_dom0_op(struct dom0_op *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
   11.17  {
   11.18      long ret = 0;
   11.19  
   11.20 @@ -75,7 +76,7 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.21  
   11.22              op->u.msr.out1 = msr_lo;
   11.23              op->u.msr.out2 = msr_hi;
   11.24 -            copy_to_user(u_dom0_op, op, sizeof(*op));
   11.25 +            copy_to_guest(u_dom0_op, op, 1);
   11.26          }
   11.27          ret = 0;
   11.28      }
   11.29 @@ -90,7 +91,7 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.30          {
   11.31              ret = shadow_mode_control(d, &op->u.shadow_control);
   11.32              put_domain(d);
   11.33 -            copy_to_user(u_dom0_op, op, sizeof(*op));
   11.34 +            copy_to_guest(u_dom0_op, op, 1);
   11.35          } 
   11.36      }
   11.37      break;
   11.38 @@ -102,10 +103,11 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.39              op->u.add_memtype.nr_mfns,
   11.40              op->u.add_memtype.type,
   11.41              1);
   11.42 -        if (ret > 0)
   11.43 +        if ( ret > 0 )
   11.44          {
   11.45 -            (void)__put_user(0, &u_dom0_op->u.add_memtype.handle);
   11.46 -            (void)__put_user(ret, &u_dom0_op->u.add_memtype.reg);
   11.47 +            op->u.add_memtype.handle = 0;
   11.48 +            op->u.add_memtype.reg    = ret;
   11.49 +            (void)copy_to_guest(u_dom0_op, op, 1);
   11.50              ret = 0;
   11.51          }
   11.52      }
   11.53 @@ -136,9 +138,10 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.54          if ( op->u.read_memtype.reg < num_var_ranges )
   11.55          {
   11.56              mtrr_if->get(op->u.read_memtype.reg, &mfn, &nr_mfns, &type);
   11.57 -            (void)__put_user(mfn, &u_dom0_op->u.read_memtype.mfn);
   11.58 -            (void)__put_user(nr_mfns, &u_dom0_op->u.read_memtype.nr_mfns);
   11.59 -            (void)__put_user(type, &u_dom0_op->u.read_memtype.type);
   11.60 +            op->u.read_memtype.mfn     = mfn;
   11.61 +            op->u.read_memtype.nr_mfns = nr_mfns;
   11.62 +            op->u.read_memtype.type    = type;
   11.63 +            (void)copy_to_guest(u_dom0_op, op, 1);
   11.64              ret = 0;
   11.65          }
   11.66      }
   11.67 @@ -147,7 +150,7 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.68      case DOM0_MICROCODE:
   11.69      {
   11.70          extern int microcode_update(void *buf, unsigned long len);
   11.71 -        ret = microcode_update(op->u.microcode.data, op->u.microcode.length);
   11.72 +        ret = microcode_update(op->u.microcode.data.p, op->u.microcode.length);
   11.73      }
   11.74      break;
   11.75  
   11.76 @@ -195,7 +198,7 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.77          memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
   11.78          memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
   11.79          ret = 0;
   11.80 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
   11.81 +        if ( copy_to_guest(u_dom0_op, op, 1) )
   11.82              ret = -EFAULT;
   11.83      }
   11.84      break;
   11.85 @@ -245,7 +248,7 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.86  
   11.87          put_domain(d);
   11.88  
   11.89 -        copy_to_user(u_dom0_op, op, sizeof(*op));
   11.90 +        copy_to_guest(u_dom0_op, op, 1);
   11.91      }
   11.92      break;
   11.93  
   11.94 @@ -255,7 +258,6 @@ long arch_do_dom0_op(struct dom0_op *op,
   11.95          int n,j;
   11.96          int num = op->u.getpageframeinfo2.num;
   11.97          domid_t dom = op->u.getpageframeinfo2.domain;
   11.98 -        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
   11.99          struct domain *d;
  11.100          unsigned long *l_arr;
  11.101          ret = -ESRCH;
  11.102 @@ -277,7 +279,8 @@ long arch_do_dom0_op(struct dom0_op *op,
  11.103          {
  11.104              int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
  11.105  
  11.106 -            if ( copy_from_user(l_arr, &s_ptr[n], k*sizeof(unsigned long)) )
  11.107 +            if ( copy_from_guest_offset(l_arr, op->u.getpageframeinfo2.array,
  11.108 +                                        n, k) )
  11.109              {
  11.110                  ret = -EINVAL;
  11.111                  break;
  11.112 @@ -320,7 +323,8 @@ long arch_do_dom0_op(struct dom0_op *op,
  11.113  
  11.114              }
  11.115  
  11.116 -            if ( copy_to_user(&s_ptr[n], l_arr, k*sizeof(unsigned long)) )
  11.117 +            if ( copy_to_guest_offset(op->u.getpageframeinfo2.array,
  11.118 +                                      n, l_arr, k) )
  11.119              {
  11.120                  ret = -EINVAL;
  11.121                  break;
  11.122 @@ -341,7 +345,6 @@ long arch_do_dom0_op(struct dom0_op *op,
  11.123          struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
  11.124          unsigned long max_pfns = op->u.getmemlist.max_pfns;
  11.125          unsigned long mfn;
  11.126 -        unsigned long *buffer = op->u.getmemlist.buffer;
  11.127          struct list_head *list_ent;
  11.128  
  11.129          ret = -EINVAL;
  11.130 @@ -353,19 +356,20 @@ long arch_do_dom0_op(struct dom0_op *op,
  11.131              list_ent = d->page_list.next;
  11.132              for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
  11.133              {
  11.134 -                mfn = page_to_mfn(list_entry(list_ent, struct page_info, list));
  11.135 -                if ( put_user(mfn, buffer) )
  11.136 +                mfn = page_to_mfn(list_entry(
  11.137 +                    list_ent, struct page_info, list));
  11.138 +                if ( copy_to_guest_offset(op->u.getmemlist.buffer,
  11.139 +                                          i, &mfn, 1) )
  11.140                  {
  11.141                      ret = -EFAULT;
  11.142                      break;
  11.143                  }
  11.144 -                buffer++;
  11.145                  list_ent = mfn_to_page(mfn)->list.next;
  11.146              }
  11.147              spin_unlock(&d->page_alloc_lock);
  11.148  
  11.149              op->u.getmemlist.num_pfns = i;
  11.150 -            copy_to_user(u_dom0_op, op, sizeof(*op));
  11.151 +            copy_to_guest(u_dom0_op, op, 1);
  11.152              
  11.153              put_domain(d);
  11.154          }
  11.155 @@ -401,13 +405,12 @@ long arch_do_dom0_op(struct dom0_op *op,
  11.156              entry.start  = e820.map[i].addr;
  11.157              entry.end    = e820.map[i].addr + e820.map[i].size;
  11.158              entry.is_ram = (e820.map[i].type == E820_RAM);
  11.159 -            (void)copy_to_user(
  11.160 -                &op->u.physical_memory_map.memory_map[i],
  11.161 -                &entry, sizeof(entry));
  11.162 +            (void)copy_to_guest_offset(
  11.163 +                op->u.physical_memory_map.memory_map, i, &entry, 1);
  11.164          }
  11.165  
  11.166          op->u.physical_memory_map.nr_map_entries = i;
  11.167 -        (void)copy_to_user(u_dom0_op, op, sizeof(*op));
  11.168 +        (void)copy_to_guest(u_dom0_op, op, 1);
  11.169      }
  11.170      break;
  11.171  
    12.1 --- a/xen/arch/x86/mm.c	Sat Mar 04 19:15:36 2006 +0100
    12.2 +++ b/xen/arch/x86/mm.c	Sat Mar 04 19:16:36 2006 +0100
    12.3 @@ -2788,7 +2788,7 @@ long do_update_descriptor(u64 pa, u64 de
    12.4  }
    12.5  
    12.6  
    12.7 -long arch_memory_op(int op, guest_handle(void) arg)
    12.8 +long arch_memory_op(int op, GUEST_HANDLE(void) arg)
    12.9  {
   12.10      struct xen_reserved_phys_area xrpa;
   12.11      unsigned long pfn;
    13.1 --- a/xen/arch/x86/shadow32.c	Sat Mar 04 19:15:36 2006 +0100
    13.2 +++ b/xen/arch/x86/shadow32.c	Sat Mar 04 19:16:36 2006 +0100
    13.3 @@ -29,6 +29,7 @@
    13.4  #include <xen/event.h>
    13.5  #include <xen/sched.h>
    13.6  #include <xen/trace.h>
    13.7 +#include <xen/guest_access.h>
    13.8  
    13.9  #define MFN_PINNED(_x) (mfn_to_page(_x)->u.inuse.type_info & PGT_pinned)
   13.10  #define va_to_l1mfn(_ed, _va) \
   13.11 @@ -1508,14 +1509,14 @@ static int shadow_mode_table_op(
   13.12          d->arch.shadow_fault_count       = 0;
   13.13          d->arch.shadow_dirty_count       = 0;
   13.14   
   13.15 -        if ( (sc->dirty_bitmap == NULL) || 
   13.16 +        if ( guest_handle_is_null(sc->dirty_bitmap) ||
   13.17               (d->arch.shadow_dirty_bitmap == NULL) )
   13.18          {
   13.19              rc = -EINVAL;
   13.20              break;
   13.21          }
   13.22  
   13.23 -        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   13.24 +        if ( sc->pages > d->arch.shadow_dirty_bitmap_size )
   13.25              sc->pages = d->arch.shadow_dirty_bitmap_size; 
   13.26  
   13.27  #define chunk (8*1024) /* Transfer and clear in 1kB chunks for L1 cache. */
   13.28 @@ -1524,10 +1525,10 @@ static int shadow_mode_table_op(
   13.29              int bytes = ((((sc->pages - i) > chunk) ?
   13.30                            chunk : (sc->pages - i)) + 7) / 8;
   13.31       
   13.32 -            if (copy_to_user(
   13.33 -                    sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
   13.34 -                    d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   13.35 -                    bytes))
   13.36 +            if ( copy_to_guest_offset(
   13.37 +                sc->dirty_bitmap, i/(8*sizeof(unsigned long)),
   13.38 +                d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   13.39 +                (bytes+sizeof(unsigned long)-1) / sizeof(unsigned long)) )
   13.40              {
   13.41                  rc = -EINVAL;
   13.42                  break;
   13.43 @@ -1544,18 +1545,20 @@ static int shadow_mode_table_op(
   13.44          sc->stats.fault_count       = d->arch.shadow_fault_count;
   13.45          sc->stats.dirty_count       = d->arch.shadow_dirty_count;
   13.46  
   13.47 -        if ( (sc->dirty_bitmap == NULL) || 
   13.48 +        if ( guest_handle_is_null(sc->dirty_bitmap) ||
   13.49               (d->arch.shadow_dirty_bitmap == NULL) )
   13.50          {
   13.51              rc = -EINVAL;
   13.52              break;
   13.53          }
   13.54   
   13.55 -        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   13.56 +        if ( sc->pages > d->arch.shadow_dirty_bitmap_size )
   13.57              sc->pages = d->arch.shadow_dirty_bitmap_size; 
   13.58  
   13.59 -        if (copy_to_user(sc->dirty_bitmap, 
   13.60 -                         d->arch.shadow_dirty_bitmap, (sc->pages+7)/8))
   13.61 +        if ( copy_to_guest(sc->dirty_bitmap, 
   13.62 +                           d->arch.shadow_dirty_bitmap,
   13.63 +                           (((sc->pages+7)/8)+sizeof(unsigned long)-1) /
   13.64 +                           sizeof(unsigned long)) )
   13.65          {
   13.66              rc = -EINVAL;
   13.67              break;
    14.1 --- a/xen/arch/x86/shadow_public.c	Sat Mar 04 19:15:36 2006 +0100
    14.2 +++ b/xen/arch/x86/shadow_public.c	Sat Mar 04 19:16:36 2006 +0100
    14.3 @@ -29,6 +29,7 @@
    14.4  #include <xen/event.h>
    14.5  #include <xen/sched.h>
    14.6  #include <xen/trace.h>
    14.7 +#include <xen/guest_access.h>
    14.8  #include <asm/shadow_64.h>
    14.9  
   14.10  static int alloc_p2m_table(struct domain *d);
   14.11 @@ -1267,14 +1268,14 @@ static int shadow_mode_table_op(
   14.12          d->arch.shadow_fault_count       = 0;
   14.13          d->arch.shadow_dirty_count       = 0;
   14.14   
   14.15 -        if ( (sc->dirty_bitmap == NULL) || 
   14.16 +        if ( guest_handle_is_null(sc->dirty_bitmap) ||
   14.17               (d->arch.shadow_dirty_bitmap == NULL) )
   14.18          {
   14.19              rc = -EINVAL;
   14.20              break;
   14.21          }
   14.22  
   14.23 -        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   14.24 +        if ( sc->pages > d->arch.shadow_dirty_bitmap_size )
   14.25              sc->pages = d->arch.shadow_dirty_bitmap_size; 
   14.26  
   14.27  #define chunk (8*1024) /* Transfer and clear in 1kB chunks for L1 cache. */
   14.28 @@ -1283,10 +1284,10 @@ static int shadow_mode_table_op(
   14.29              int bytes = ((((sc->pages - i) > chunk) ?
   14.30                            chunk : (sc->pages - i)) + 7) / 8;
   14.31  
   14.32 -            if (copy_to_user(
   14.33 -                sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
   14.34 +            if ( copy_to_guest_offset(
   14.35 +                sc->dirty_bitmap, i/(8*sizeof(unsigned long)),
   14.36                  d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   14.37 -                bytes))
   14.38 +                (bytes+sizeof(unsigned long)-1) / sizeof(unsigned long)) )
   14.39              {
   14.40                  rc = -EINVAL;
   14.41                  break;
   14.42 @@ -1302,18 +1303,20 @@ static int shadow_mode_table_op(
   14.43          sc->stats.fault_count       = d->arch.shadow_fault_count;
   14.44          sc->stats.dirty_count       = d->arch.shadow_dirty_count;
   14.45   
   14.46 -        if ( (sc->dirty_bitmap == NULL) || 
   14.47 +        if ( guest_handle_is_null(sc->dirty_bitmap) ||
   14.48               (d->arch.shadow_dirty_bitmap == NULL) )
   14.49          {
   14.50              rc = -EINVAL;
   14.51              break;
   14.52          }
   14.53   
   14.54 -        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   14.55 +        if ( sc->pages > d->arch.shadow_dirty_bitmap_size )
   14.56              sc->pages = d->arch.shadow_dirty_bitmap_size; 
   14.57  
   14.58 -        if (copy_to_user(sc->dirty_bitmap, 
   14.59 -                         d->arch.shadow_dirty_bitmap, (sc->pages+7)/8))
   14.60 +        if ( copy_to_guest(sc->dirty_bitmap, 
   14.61 +                           d->arch.shadow_dirty_bitmap,
   14.62 +                           (((sc->pages+7)/8)+sizeof(unsigned long)-1) /
   14.63 +                           sizeof(unsigned long)) )
   14.64          {
   14.65              rc = -EINVAL;
   14.66              break;
    15.1 --- a/xen/arch/x86/x86_32/mm.c	Sat Mar 04 19:15:36 2006 +0100
    15.2 +++ b/xen/arch/x86/x86_32/mm.c	Sat Mar 04 19:16:36 2006 +0100
    15.3 @@ -192,7 +192,7 @@ void subarch_init_memory(struct domain *
    15.4      }
    15.5  }
    15.6  
    15.7 -long subarch_memory_op(int op, guest_handle(void) arg)
    15.8 +long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
    15.9  {
   15.10      struct xen_machphys_mfn_list xmml;
   15.11      unsigned long mfn;
    16.1 --- a/xen/arch/x86/x86_64/mm.c	Sat Mar 04 19:15:36 2006 +0100
    16.2 +++ b/xen/arch/x86/x86_64/mm.c	Sat Mar 04 19:16:36 2006 +0100
    16.3 @@ -183,7 +183,7 @@ void subarch_init_memory(struct domain *
    16.4      }
    16.5  }
    16.6  
    16.7 -long subarch_memory_op(int op, guest_handle(void) arg)
    16.8 +long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
    16.9  {
   16.10      struct xen_machphys_mfn_list xmml;
   16.11      l3_pgentry_t l3e;
    17.1 --- a/xen/common/dom0_ops.c	Sat Mar 04 19:15:36 2006 +0100
    17.2 +++ b/xen/common/dom0_ops.c	Sat Mar 04 19:16:36 2006 +0100
    17.3 @@ -17,13 +17,14 @@
    17.4  #include <xen/trace.h>
    17.5  #include <xen/console.h>
    17.6  #include <xen/iocap.h>
    17.7 +#include <xen/guest_access.h>
    17.8  #include <asm/current.h>
    17.9  #include <public/dom0_ops.h>
   17.10  #include <public/sched_ctl.h>
   17.11  #include <acm/acm_hooks.h>
   17.12  
   17.13  extern long arch_do_dom0_op(
   17.14 -    struct dom0_op *op, struct dom0_op *u_dom0_op);
   17.15 +    struct dom0_op *op, GUEST_HANDLE(dom0_op_t) u_dom0_op);
   17.16  extern void arch_getdomaininfo_ctxt(
   17.17      struct vcpu *, struct vcpu_guest_context *);
   17.18  
   17.19 @@ -89,7 +90,7 @@ static void getdomaininfo(struct domain 
   17.20      memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
   17.21  }
   17.22  
   17.23 -long do_dom0_op(struct dom0_op *u_dom0_op)
   17.24 +long do_dom0_op(GUEST_HANDLE(dom0_op_t) u_dom0_op)
   17.25  {
   17.26      long ret = 0;
   17.27      struct dom0_op curop, *op = &curop;
   17.28 @@ -99,7 +100,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.29      if ( !IS_PRIV(current->domain) )
   17.30          return -EPERM;
   17.31  
   17.32 -    if ( copy_from_user(op, u_dom0_op, sizeof(*op)) )
   17.33 +    if ( copy_from_guest(op, u_dom0_op, 1) )
   17.34          return -EFAULT;
   17.35  
   17.36      if ( op->interface_version != DOM0_INTERFACE_VERSION )
   17.37 @@ -239,7 +240,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.38          ret = 0;
   17.39  
   17.40          op->u.createdomain.domain = d->domain_id;
   17.41 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
   17.42 +        if ( copy_to_guest(u_dom0_op, op, 1) )
   17.43              ret = -EFAULT;
   17.44      }
   17.45      break;
   17.46 @@ -357,7 +358,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.47      case DOM0_SCHEDCTL:
   17.48      {
   17.49          ret = sched_ctl(&op->u.schedctl);
   17.50 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
   17.51 +        if ( copy_to_guest(u_dom0_op, op, 1) )
   17.52              ret = -EFAULT;
   17.53      }
   17.54      break;
   17.55 @@ -365,7 +366,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.56      case DOM0_ADJUSTDOM:
   17.57      {
   17.58          ret = sched_adjdom(&op->u.adjustdom);
   17.59 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
   17.60 +        if ( copy_to_guest(u_dom0_op, op, 1) )
   17.61              ret = -EFAULT;
   17.62      }
   17.63      break;
   17.64 @@ -398,20 +399,17 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.65  
   17.66          getdomaininfo(d, &op->u.getdomaininfo);
   17.67  
   17.68 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
   17.69 +        if ( copy_to_guest(u_dom0_op, op, 1) )
   17.70              ret = -EFAULT;
   17.71  
   17.72          put_domain(d);
   17.73      }
   17.74      break;
   17.75  
   17.76 -
   17.77 -
   17.78      case DOM0_GETDOMAININFOLIST:
   17.79      { 
   17.80          struct domain *d;
   17.81          dom0_getdomaininfo_t info;
   17.82 -        dom0_getdomaininfo_t *buffer = op->u.getdomaininfolist.buffer;
   17.83          u32 num_domains = 0;
   17.84  
   17.85          read_lock(&domlist_lock);
   17.86 @@ -432,13 +430,13 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.87  
   17.88              put_domain(d);
   17.89  
   17.90 -            if ( copy_to_user(buffer, &info, sizeof(dom0_getdomaininfo_t)) )
   17.91 +            if ( copy_to_guest_offset(op->u.getdomaininfolist.buffer,
   17.92 +                                      num_domains, &info, 1) )
   17.93              {
   17.94                  ret = -EFAULT;
   17.95                  break;
   17.96              }
   17.97              
   17.98 -            buffer++;
   17.99              num_domains++;
  17.100          }
  17.101          
  17.102 @@ -449,7 +447,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.103          
  17.104          op->u.getdomaininfolist.num_domains = num_domains;
  17.105  
  17.106 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
  17.107 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.108              ret = -EFAULT;
  17.109      }
  17.110      break;
  17.111 @@ -489,12 +487,12 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.112          if ( v != current )
  17.113              vcpu_unpause(v);
  17.114  
  17.115 -        if ( copy_to_user(op->u.getvcpucontext.ctxt, c, sizeof(*c)) )
  17.116 +        if ( copy_to_guest(op->u.getvcpucontext.ctxt, c, 1) )
  17.117              ret = -EFAULT;
  17.118  
  17.119          xfree(c);
  17.120  
  17.121 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
  17.122 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.123              ret = -EFAULT;
  17.124  
  17.125      getvcpucontext_out:
  17.126 @@ -534,7 +532,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.127                     (int)sizeof(op->u.getvcpuinfo.cpumap)));
  17.128          ret = 0;
  17.129  
  17.130 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
  17.131 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.132              ret = -EFAULT;
  17.133  
  17.134      getvcpuinfo_out:
  17.135 @@ -554,7 +552,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.136      case DOM0_TBUFCONTROL:
  17.137      {
  17.138          ret = tb_control(&op->u.tbufcontrol);
  17.139 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
  17.140 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.141              ret = -EFAULT;
  17.142      }
  17.143      break;
  17.144 @@ -562,10 +560,10 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.145      case DOM0_READCONSOLE:
  17.146      {
  17.147          ret = read_console_ring(
  17.148 -            &op->u.readconsole.buffer, 
  17.149 +            op->u.readconsole.buffer, 
  17.150              &op->u.readconsole.count,
  17.151              op->u.readconsole.clear); 
  17.152 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
  17.153 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.154              ret = -EFAULT;
  17.155      }
  17.156      break;
  17.157 @@ -573,7 +571,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.158      case DOM0_SCHED_ID:
  17.159      {
  17.160          op->u.sched_id.sched_id = sched_id();
  17.161 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
  17.162 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.163              ret = -EFAULT;
  17.164          else
  17.165              ret = 0;
  17.166 @@ -678,15 +676,15 @@ long do_dom0_op(struct dom0_op *u_dom0_o
  17.167      {
  17.168          extern int perfc_control(dom0_perfccontrol_t *);
  17.169          ret = perfc_control(&op->u.perfccontrol);
  17.170 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
  17.171 +        if ( copy_to_guest(u_dom0_op, op, 1) )
  17.172              ret = -EFAULT;
  17.173      }
  17.174      break;
  17.175  #endif
  17.176  
  17.177      default:
  17.178 -        ret = arch_do_dom0_op(op,u_dom0_op);
  17.179 -
  17.180 +        ret = arch_do_dom0_op(op, u_dom0_op);
  17.181 +        break;
  17.182      }
  17.183  
  17.184      spin_unlock(&dom0_lock);
    18.1 --- a/xen/common/domain.c	Sat Mar 04 19:15:36 2006 +0100
    18.2 +++ b/xen/common/domain.c	Sat Mar 04 19:16:36 2006 +0100
    18.3 @@ -17,6 +17,7 @@
    18.4  #include <xen/softirq.h>
    18.5  #include <xen/domain_page.h>
    18.6  #include <xen/rangeset.h>
    18.7 +#include <xen/guest_access.h>
    18.8  #include <asm/debugger.h>
    18.9  #include <public/dom0_ops.h>
   18.10  #include <public/sched.h>
   18.11 @@ -380,7 +381,7 @@ int set_info_guest(struct domain *d, dom
   18.12      domain_pause(d);
   18.13  
   18.14      rc = -EFAULT;
   18.15 -    if ( copy_from_user(c, setvcpucontext->ctxt, sizeof(*c)) == 0 )
   18.16 +    if ( copy_from_guest(c, setvcpucontext->ctxt, 1) == 0 )
   18.17          rc = arch_set_info_guest(v, c);
   18.18  
   18.19      domain_unpause(d);
    19.1 --- a/xen/common/memory.c	Sat Mar 04 19:15:36 2006 +0100
    19.2 +++ b/xen/common/memory.c	Sat Mar 04 19:16:36 2006 +0100
    19.3 @@ -31,7 +31,7 @@
    19.4  static long
    19.5  increase_reservation(
    19.6      struct domain *d, 
    19.7 -    guest_handle(ulong) extent_list,
    19.8 +    GUEST_HANDLE(ulong) extent_list,
    19.9      unsigned int   nr_extents,
   19.10      unsigned int   extent_order,
   19.11      unsigned int   flags,
   19.12 @@ -80,7 +80,7 @@ increase_reservation(
   19.13  static long
   19.14  populate_physmap(
   19.15      struct domain *d, 
   19.16 -    guest_handle(ulong) extent_list,
   19.17 +    GUEST_HANDLE(ulong) extent_list,
   19.18      unsigned int  nr_extents,
   19.19      unsigned int  extent_order,
   19.20      unsigned int  flags,
   19.21 @@ -141,7 +141,7 @@ populate_physmap(
   19.22  static long
   19.23  decrease_reservation(
   19.24      struct domain *d,
   19.25 -    guest_handle(ulong) extent_list,
   19.26 +    GUEST_HANDLE(ulong) extent_list,
   19.27      unsigned int   nr_extents,
   19.28      unsigned int   extent_order,
   19.29      unsigned int   flags,
   19.30 @@ -198,7 +198,7 @@ decrease_reservation(
   19.31  
   19.32  static long
   19.33  translate_gpfn_list(
   19.34 -    guest_handle(xen_translate_gpfn_list_t) uop, unsigned long *progress)
   19.35 +    GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
   19.36  {
   19.37      struct xen_translate_gpfn_list op;
   19.38      unsigned long i, gpfn, mfn;
   19.39 @@ -257,7 +257,7 @@ translate_gpfn_list(
   19.40      return 0;
   19.41  }
   19.42  
   19.43 -long do_memory_op(unsigned long cmd, guest_handle(void) arg)
   19.44 +long do_memory_op(unsigned long cmd, GUEST_HANDLE(void) arg)
   19.45  {
   19.46      struct domain *d;
   19.47      int rc, op, flags = 0, preempted = 0;
    20.1 --- a/xen/common/perfc.c	Sat Mar 04 19:15:36 2006 +0100
    20.2 +++ b/xen/common/perfc.c	Sat Mar 04 19:16:36 2006 +0100
    20.3 @@ -5,9 +5,10 @@
    20.4  #include <xen/perfc.h>
    20.5  #include <xen/keyhandler.h> 
    20.6  #include <xen/spinlock.h>
    20.7 +#include <xen/mm.h>
    20.8 +#include <xen/guest_access.h>
    20.9  #include <public/dom0_ops.h>
   20.10  #include <asm/uaccess.h>
   20.11 -#include <xen/mm.h>
   20.12  
   20.13  #undef  PERFCOUNTER
   20.14  #undef  PERFCOUNTER_CPU
   20.15 @@ -131,12 +132,12 @@ void perfc_reset(unsigned char key)
   20.16  
   20.17  static dom0_perfc_desc_t perfc_d[NR_PERFCTRS];
   20.18  static int               perfc_init = 0;
   20.19 -static int perfc_copy_info(dom0_perfc_desc_t *desc)
   20.20 +static int perfc_copy_info(GUEST_HANDLE(dom0_perfc_desc_t) desc)
   20.21  {
   20.22      unsigned int i, j;
   20.23      atomic_t *counters = (atomic_t *)&perfcounters;
   20.24  
   20.25 -    if ( desc == NULL )
   20.26 +    if ( guest_handle_is_null(desc) )
   20.27          return 0;
   20.28  
   20.29      /* We only copy the name and array-size information once. */
   20.30 @@ -196,7 +197,7 @@ static int perfc_copy_info(dom0_perfc_de
   20.31          }
   20.32      }
   20.33  
   20.34 -    return (copy_to_user(desc, perfc_d, NR_PERFCTRS * sizeof(*desc)) ?
   20.35 +    return (copy_to_guest(desc, (dom0_perfc_desc_t *)perfc_d, NR_PERFCTRS) ?
   20.36              -EFAULT : 0);
   20.37  }
   20.38  
    21.1 --- a/xen/drivers/char/console.c	Sat Mar 04 19:15:36 2006 +0100
    21.2 +++ b/xen/drivers/char/console.c	Sat Mar 04 19:16:36 2006 +0100
    21.3 @@ -20,6 +20,7 @@
    21.4  #include <xen/keyhandler.h>
    21.5  #include <xen/mm.h>
    21.6  #include <xen/delay.h>
    21.7 +#include <xen/guest_access.h>
    21.8  #include <asm/current.h>
    21.9  #include <asm/uaccess.h>
   21.10  #include <asm/debugger.h>
   21.11 @@ -221,9 +222,8 @@ static void putchar_console_ring(int c)
   21.12          conringc = conringp - CONRING_SIZE;
   21.13  }
   21.14  
   21.15 -long read_console_ring(char **pstr, u32 *pcount, int clear)
   21.16 +long read_console_ring(GUEST_HANDLE(char) str, u32 *pcount, int clear)
   21.17  {
   21.18 -    char *str = *pstr;
   21.19      unsigned int idx, len, max, sofar, c;
   21.20      unsigned long flags;
   21.21  
   21.22 @@ -239,7 +239,7 @@ long read_console_ring(char **pstr, u32 
   21.23              len = CONRING_SIZE - idx;
   21.24          if ( (sofar + len) > max )
   21.25              len = max - sofar;
   21.26 -        if ( copy_to_user(str + sofar, &conring[idx], len) )
   21.27 +        if ( copy_to_guest_offset(str, sofar, &conring[idx], len) )
   21.28              return -EFAULT;
   21.29          sofar += len;
   21.30          c += len;
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/xen/include/asm-ia64/guest_access.h	Sat Mar 04 19:16:36 2006 +0100
    22.3 @@ -0,0 +1,63 @@
    22.4 +/******************************************************************************
    22.5 + * guest_access.h
    22.6 + * 
    22.7 + * Copyright (c) 2006, K A Fraser
    22.8 + */
    22.9 +
   22.10 +#ifndef __ASM_IA64_GUEST_ACCESS_H__
   22.11 +#define __ASM_IA64_GUEST_ACCESS_H__
   22.12 +
   22.13 +#include <asm/uaccess.h>
   22.14 +
   22.15 +/* Is the guest handle a NULL reference? */
   22.16 +#define guest_handle_is_null(hnd)        ((hnd).p == NULL)
   22.17 +
   22.18 +/* Offset the given guest handle into the array it refers to. */
   22.19 +#define guest_handle_add_offset(hnd, nr) ((hnd).p += (nr))
   22.20 +
   22.21 +/* Cast a guest handle to the specified type of handle. */
   22.22 +#define guest_handle_cast(hnd, type) ({         \
   22.23 +    type *_x = (hnd).p;                         \
   22.24 +    (GUEST_HANDLE(type)) { _x };                \
   22.25 +})
   22.26 +
   22.27 +/*
   22.28 + * Copy an array of objects to guest context via a guest handle,
   22.29 + * specifying an offset into the guest array.
   22.30 + */
   22.31 +#define copy_to_guest_offset(hnd, off, ptr, nr) ({      \
   22.32 +    const typeof(ptr) _x = (hnd).p;                     \
   22.33 +    const typeof(ptr) _y = (ptr);                       \
   22.34 +    copy_to_user(_x+(off), _y, sizeof(*_x)*(nr));       \
   22.35 +})
   22.36 +
   22.37 +/*
   22.38 + * Copy an array of objects from guest context via a guest handle,
   22.39 + * specifying an offset into the guest array.
   22.40 + */
   22.41 +#define copy_from_guest_offset(ptr, hnd, off, nr) ({    \
   22.42 +    const typeof(ptr) _x = (hnd).p;                     \
   22.43 +    const typeof(ptr) _y = (ptr);                       \
   22.44 +    copy_from_user(_y, _x+(off), sizeof(*_x)*(nr));     \
   22.45 +})
   22.46 +
   22.47 +/*
   22.48 + * Pre-validate a guest handle.
   22.49 + * Allows use of faster __copy_* functions.
   22.50 + */
   22.51 +#define guest_handle_okay(hnd, nr)                      \
   22.52 +    array_access_ok((hnd).p, (nr), sizeof(*(hnd).p))
   22.53 +
   22.54 +#define __copy_to_guest_offset(hnd, off, ptr, nr) ({    \
   22.55 +    const typeof(ptr) _x = (hnd).p;                     \
   22.56 +    const typeof(ptr) _y = (ptr);                       \
   22.57 +    __copy_to_user(_x+(off), _y, sizeof(*_x)*(nr));     \
   22.58 +})
   22.59 +
   22.60 +#define __copy_from_guest_offset(ptr, hnd, off, nr) ({  \
   22.61 +    const typeof(ptr) _x = (hnd).p;                     \
   22.62 +    const typeof(ptr) _y = (ptr);                       \
   22.63 +    __copy_from_user(_y, _x+(off), sizeof(*_x)*(nr));   \
   22.64 +})
   22.65 +
   22.66 +#endif /* __ASM_IA64_GUEST_ACCESS_H__ */
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/xen/include/asm-x86/guest_access.h	Sat Mar 04 19:16:36 2006 +0100
    23.3 @@ -0,0 +1,63 @@
    23.4 +/******************************************************************************
    23.5 + * guest_access.h
    23.6 + * 
    23.7 + * Copyright (c) 2006, K A Fraser
    23.8 + */
    23.9 +
   23.10 +#ifndef __ASM_X86_GUEST_ACCESS_H__
   23.11 +#define __ASM_X86_GUEST_ACCESS_H__
   23.12 +
   23.13 +#include <asm/uaccess.h>
   23.14 +
   23.15 +/* Is the guest handle a NULL reference? */
   23.16 +#define guest_handle_is_null(hnd)        ((hnd).p == NULL)
   23.17 +
   23.18 +/* Offset the given guest handle into the array it refers to. */
   23.19 +#define guest_handle_add_offset(hnd, nr) ((hnd).p += (nr))
   23.20 +
   23.21 +/* Cast a guest handle to the specified type of handle. */
   23.22 +#define guest_handle_cast(hnd, type) ({         \
   23.23 +    type *_x = (hnd).p;                         \
   23.24 +    (GUEST_HANDLE(type)) { _x };                \
   23.25 +})
   23.26 +
   23.27 +/*
   23.28 + * Copy an array of objects to guest context via a guest handle,
   23.29 + * specifying an offset into the guest array.
   23.30 + */
   23.31 +#define copy_to_guest_offset(hnd, off, ptr, nr) ({      \
   23.32 +    const typeof(ptr) _x = (hnd).p;                     \
   23.33 +    const typeof(ptr) _y = (ptr);                       \
   23.34 +    copy_to_user(_x+(off), _y, sizeof(*_x)*(nr));       \
   23.35 +})
   23.36 +
   23.37 +/*
   23.38 + * Copy an array of objects from guest context via a guest handle,
   23.39 + * specifying an offset into the guest array.
   23.40 + */
   23.41 +#define copy_from_guest_offset(ptr, hnd, off, nr) ({    \
   23.42 +    const typeof(ptr) _x = (hnd).p;                     \
   23.43 +    const typeof(ptr) _y = (ptr);                       \
   23.44 +    copy_from_user(_y, _x+(off), sizeof(*_x)*(nr));     \
   23.45 +})
   23.46 +
   23.47 +/*
   23.48 + * Pre-validate a guest handle.
   23.49 + * Allows use of faster __copy_* functions.
   23.50 + */
   23.51 +#define guest_handle_okay(hnd, nr)                      \
   23.52 +    array_access_ok((hnd).p, (nr), sizeof(*(hnd).p))
   23.53 +
   23.54 +#define __copy_to_guest_offset(hnd, off, ptr, nr) ({    \
   23.55 +    const typeof(ptr) _x = (hnd).p;                     \
   23.56 +    const typeof(ptr) _y = (ptr);                       \
   23.57 +    __copy_to_user(_x+(off), _y, sizeof(*_x)*(nr));     \
   23.58 +})
   23.59 +
   23.60 +#define __copy_from_guest_offset(ptr, hnd, off, nr) ({  \
   23.61 +    const typeof(ptr) _x = (hnd).p;                     \
   23.62 +    const typeof(ptr) _y = (ptr);                       \
   23.63 +    __copy_from_user(_y, _x+(off), sizeof(*_x)*(nr));   \
   23.64 +})
   23.65 +
   23.66 +#endif /* __ASM_X86_GUEST_ACCESS_H__ */
    24.1 --- a/xen/include/asm-x86/mm.h	Sat Mar 04 19:15:36 2006 +0100
    24.2 +++ b/xen/include/asm-x86/mm.h	Sat Mar 04 19:16:36 2006 +0100
    24.3 @@ -380,7 +380,7 @@ void propagate_page_fault(unsigned long 
    24.4  int __sync_lazy_execstate(void);
    24.5  
    24.6  /* Arch-specific portion of memory_op hypercall. */
    24.7 -long arch_memory_op(int op, guest_handle(void) arg);
    24.8 -long subarch_memory_op(int op, guest_handle(void) arg);
    24.9 +long arch_memory_op(int op, GUEST_HANDLE(void) arg);
   24.10 +long subarch_memory_op(int op, GUEST_HANDLE(void) arg);
   24.11  
   24.12  #endif /* __ASM_X86_MM_H__ */
    25.1 --- a/xen/include/public/arch-ia64.h	Sat Mar 04 19:15:36 2006 +0100
    25.2 +++ b/xen/include/public/arch-ia64.h	Sat Mar 04 19:16:36 2006 +0100
    25.3 @@ -7,6 +7,28 @@
    25.4  #ifndef __HYPERVISOR_IF_IA64_H__
    25.5  #define __HYPERVISOR_IF_IA64_H__
    25.6  
    25.7 +#ifdef __XEN__
    25.8 +#define __DEFINE_GUEST_HANDLE(name, type) \
    25.9 +    typedef struct { type *p; } __guest_handle_ ## name
   25.10 +#else
   25.11 +#define __DEFINE_GUEST_HANDLE(name, type) \
   25.12 +    typedef type * __guest_handle_ ## name
   25.13 +#endif
   25.14 +
   25.15 +#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
   25.16 +#define GUEST_HANDLE(name)        __guest_handle_ ## name
   25.17 +
   25.18 +#ifndef __ASSEMBLY__
   25.19 +/* Guest handles for primitive C types. */
   25.20 +__DEFINE_GUEST_HANDLE(uchar, unsigned char);
   25.21 +__DEFINE_GUEST_HANDLE(uint,  unsigned int);
   25.22 +__DEFINE_GUEST_HANDLE(ulong, unsigned long);
   25.23 +DEFINE_GUEST_HANDLE(char);
   25.24 +DEFINE_GUEST_HANDLE(int);
   25.25 +DEFINE_GUEST_HANDLE(long);
   25.26 +DEFINE_GUEST_HANDLE(void);
   25.27 +#endif
   25.28 +
   25.29  /* Maximum number of virtual CPUs in multi-processor guests. */
   25.30  /* WARNING: before changing this, check that shared_info fits on a page */
   25.31  #define MAX_VIRT_CPUS 4
   25.32 @@ -298,6 +320,7 @@ typedef struct vcpu_guest_context {
   25.33      arch_initrd_info_t initrd;
   25.34      char cmdline[IA64_COMMAND_LINE_SIZE];
   25.35  } vcpu_guest_context_t;
   25.36 +DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
   25.37  
   25.38  #endif /* !__ASSEMBLY__ */
   25.39  
    26.1 --- a/xen/include/public/arch-x86_32.h	Sat Mar 04 19:15:36 2006 +0100
    26.2 +++ b/xen/include/public/arch-x86_32.h	Sat Mar 04 19:16:36 2006 +0100
    26.3 @@ -9,6 +9,28 @@
    26.4  #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
    26.5  #define __XEN_PUBLIC_ARCH_X86_32_H__
    26.6  
    26.7 +#ifdef __XEN__
    26.8 +#define __DEFINE_GUEST_HANDLE(name, type) \
    26.9 +    typedef struct { type *p; } __guest_handle_ ## name
   26.10 +#else
   26.11 +#define __DEFINE_GUEST_HANDLE(name, type) \
   26.12 +    typedef type * __guest_handle_ ## name
   26.13 +#endif
   26.14 +
   26.15 +#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
   26.16 +#define GUEST_HANDLE(name)        __guest_handle_ ## name
   26.17 +
   26.18 +#ifndef __ASSEMBLY__
   26.19 +/* Guest handles for primitive C types. */
   26.20 +__DEFINE_GUEST_HANDLE(uchar, unsigned char);
   26.21 +__DEFINE_GUEST_HANDLE(uint,  unsigned int);
   26.22 +__DEFINE_GUEST_HANDLE(ulong, unsigned long);
   26.23 +DEFINE_GUEST_HANDLE(char);
   26.24 +DEFINE_GUEST_HANDLE(int);
   26.25 +DEFINE_GUEST_HANDLE(long);
   26.26 +DEFINE_GUEST_HANDLE(void);
   26.27 +#endif
   26.28 +
   26.29  /*
   26.30   * SEGMENT DESCRIPTOR TABLES
   26.31   */
   26.32 @@ -130,6 +152,7 @@ typedef struct vcpu_guest_context {
   26.33      unsigned long failsafe_callback_eip;
   26.34      unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
   26.35  } vcpu_guest_context_t;
   26.36 +DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
   26.37  
   26.38  typedef struct arch_shared_info {
   26.39      unsigned long max_pfn;                  /* max pfn that appears in table */
    27.1 --- a/xen/include/public/arch-x86_64.h	Sat Mar 04 19:15:36 2006 +0100
    27.2 +++ b/xen/include/public/arch-x86_64.h	Sat Mar 04 19:16:36 2006 +0100
    27.3 @@ -9,6 +9,28 @@
    27.4  #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
    27.5  #define __XEN_PUBLIC_ARCH_X86_64_H__
    27.6  
    27.7 +#ifdef __XEN__
    27.8 +#define __DEFINE_GUEST_HANDLE(name, type) \
    27.9 +    typedef struct { type *p; } __guest_handle_ ## name
   27.10 +#else
   27.11 +#define __DEFINE_GUEST_HANDLE(name, type) \
   27.12 +    typedef type * __guest_handle_ ## name
   27.13 +#endif
   27.14 +
   27.15 +#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
   27.16 +#define GUEST_HANDLE(name)        __guest_handle_ ## name
   27.17 +
   27.18 +#ifndef __ASSEMBLY__
   27.19 +/* Guest handles for primitive C types. */
   27.20 +__DEFINE_GUEST_HANDLE(uchar, unsigned char);
   27.21 +__DEFINE_GUEST_HANDLE(uint,  unsigned int);
   27.22 +__DEFINE_GUEST_HANDLE(ulong, unsigned long);
   27.23 +DEFINE_GUEST_HANDLE(char);
   27.24 +DEFINE_GUEST_HANDLE(int);
   27.25 +DEFINE_GUEST_HANDLE(long);
   27.26 +DEFINE_GUEST_HANDLE(void);
   27.27 +#endif
   27.28 +
   27.29  /*
   27.30   * SEGMENT DESCRIPTOR TABLES
   27.31   */
   27.32 @@ -215,6 +237,7 @@ typedef struct vcpu_guest_context {
   27.33      uint64_t      gs_base_kernel;
   27.34      uint64_t      gs_base_user;
   27.35  } vcpu_guest_context_t;
   27.36 +DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
   27.37  
   27.38  typedef struct arch_shared_info {
   27.39      unsigned long max_pfn;                  /* max pfn that appears in table */
    28.1 --- a/xen/include/public/dom0_ops.h	Sat Mar 04 19:15:36 2006 +0100
    28.2 +++ b/xen/include/public/dom0_ops.h	Sat Mar 04 19:16:36 2006 +0100
    28.3 @@ -28,18 +28,21 @@ typedef struct dom0_getmemlist {
    28.4      /* IN variables. */
    28.5      domid_t       domain;
    28.6      unsigned long max_pfns;
    28.7 -    void         *buffer;
    28.8 +    GUEST_HANDLE(ulong) buffer;
    28.9      /* OUT variables. */
   28.10      unsigned long num_pfns;
   28.11  } dom0_getmemlist_t;
   28.12 +DEFINE_GUEST_HANDLE(dom0_getmemlist_t);
   28.13  
   28.14  #define DOM0_SCHEDCTL          6
   28.15   /* struct sched_ctl_cmd is from sched-ctl.h   */
   28.16  typedef struct sched_ctl_cmd dom0_schedctl_t;
   28.17 +DEFINE_GUEST_HANDLE(dom0_schedctl_t);
   28.18  
   28.19  #define DOM0_ADJUSTDOM         7
   28.20  /* struct sched_adjdom_cmd is from sched-ctl.h */
   28.21  typedef struct sched_adjdom_cmd dom0_adjustdom_t;
   28.22 +DEFINE_GUEST_HANDLE(dom0_adjustdom_t);
   28.23  
   28.24  #define DOM0_CREATEDOMAIN      8
   28.25  typedef struct dom0_createdomain {
   28.26 @@ -50,24 +53,28 @@ typedef struct dom0_createdomain {
   28.27      /* Identifier for new domain (auto-allocate if zero is specified). */
   28.28      domid_t domain;
   28.29  } dom0_createdomain_t;
   28.30 +DEFINE_GUEST_HANDLE(dom0_createdomain_t);
   28.31  
   28.32  #define DOM0_DESTROYDOMAIN     9
   28.33  typedef struct dom0_destroydomain {
   28.34      /* IN variables. */
   28.35      domid_t domain;
   28.36  } dom0_destroydomain_t;
   28.37 +DEFINE_GUEST_HANDLE(dom0_destroydomain_t);
   28.38  
   28.39  #define DOM0_PAUSEDOMAIN      10
   28.40  typedef struct dom0_pausedomain {
   28.41      /* IN parameters. */
   28.42      domid_t domain;
   28.43  } dom0_pausedomain_t;
   28.44 +DEFINE_GUEST_HANDLE(dom0_pausedomain_t);
   28.45  
   28.46  #define DOM0_UNPAUSEDOMAIN    11
   28.47  typedef struct dom0_unpausedomain {
   28.48      /* IN parameters. */
   28.49      domid_t domain;
   28.50  } dom0_unpausedomain_t;
   28.51 +DEFINE_GUEST_HANDLE(dom0_unpausedomain_t);
   28.52  
   28.53  #define DOM0_GETDOMAININFO    12
   28.54  typedef struct dom0_getdomaininfo {
   28.55 @@ -93,6 +100,7 @@ typedef struct dom0_getdomaininfo {
   28.56      uint32_t ssidref;
   28.57      xen_domain_handle_t handle;
   28.58  } dom0_getdomaininfo_t;
   28.59 +DEFINE_GUEST_HANDLE(dom0_getdomaininfo_t);
   28.60  
   28.61  #define DOM0_SETVCPUCONTEXT   13
   28.62  typedef struct dom0_setvcpucontext {
   28.63 @@ -100,8 +108,9 @@ typedef struct dom0_setvcpucontext {
   28.64      domid_t               domain;
   28.65      uint32_t              vcpu;
   28.66      /* IN/OUT parameters */
   28.67 -    vcpu_guest_context_t *ctxt;
   28.68 +    GUEST_HANDLE(vcpu_guest_context_t) ctxt;
   28.69  } dom0_setvcpucontext_t;
   28.70 +DEFINE_GUEST_HANDLE(dom0_setvcpucontext_t);
   28.71  
   28.72  #define DOM0_MSR              15
   28.73  typedef struct dom0_msr {
   28.74 @@ -115,6 +124,7 @@ typedef struct dom0_msr {
   28.75      uint32_t out1;
   28.76      uint32_t out2;
   28.77  } dom0_msr_t;
   28.78 +DEFINE_GUEST_HANDLE(dom0_msr_t);
   28.79  
   28.80  /*
   28.81   * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
   28.82 @@ -127,6 +137,7 @@ typedef struct dom0_settime {
   28.83      uint32_t nsecs;
   28.84      uint64_t system_time;
   28.85  } dom0_settime_t;
   28.86 +DEFINE_GUEST_HANDLE(dom0_settime_t);
   28.87  
   28.88  #define DOM0_GETPAGEFRAMEINFO 18
   28.89  #define NOTAB 0         /* normal page */
   28.90 @@ -147,6 +158,7 @@ typedef struct dom0_getpageframeinfo {
   28.91      /* Is the page PINNED to a type? */
   28.92      uint32_t type;         /* see above type defs */
   28.93  } dom0_getpageframeinfo_t;
   28.94 +DEFINE_GUEST_HANDLE(dom0_getpageframeinfo_t);
   28.95  
   28.96  /*
   28.97   * Read console content from Xen buffer ring.
   28.98 @@ -154,11 +166,12 @@ typedef struct dom0_getpageframeinfo {
   28.99  #define DOM0_READCONSOLE      19
  28.100  typedef struct dom0_readconsole {
  28.101      /* IN variables. */
  28.102 -    uint32_t clear;        /* Non-zero -> clear after reading. */
  28.103 +    uint32_t clear;            /* Non-zero -> clear after reading. */
  28.104      /* IN/OUT variables. */
  28.105 -    char    *buffer;       /* In: Buffer start; Out: Used buffer start */
  28.106 -    uint32_t count;        /* In: Buffer size;  Out: Used buffer size  */
  28.107 +    GUEST_HANDLE(char) buffer; /* In: Buffer start; Out: Used buffer start */
  28.108 +    uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
  28.109  } dom0_readconsole_t;
  28.110 +DEFINE_GUEST_HANDLE(dom0_readconsole_t);
  28.111  
  28.112  /* 
  28.113   * Set which physical cpus a vcpu can execute on.
  28.114 @@ -170,6 +183,7 @@ typedef struct dom0_setvcpuaffinity {
  28.115      uint32_t  vcpu;
  28.116      cpumap_t  cpumap;
  28.117  } dom0_setvcpuaffinity_t;
  28.118 +DEFINE_GUEST_HANDLE(dom0_setvcpuaffinity_t);
  28.119  
  28.120  /* Get trace buffers machine base address */
  28.121  #define DOM0_TBUFCONTROL       21
  28.122 @@ -189,6 +203,7 @@ typedef struct dom0_tbufcontrol {
  28.123      unsigned long buffer_mfn;
  28.124      uint32_t size;
  28.125  } dom0_tbufcontrol_t;
  28.126 +DEFINE_GUEST_HANDLE(dom0_tbufcontrol_t);
  28.127  
  28.128  /*
  28.129   * Get physical information about the host machine
  28.130 @@ -204,6 +219,7 @@ typedef struct dom0_physinfo {
  28.131      unsigned long free_pages;
  28.132      uint32_t hw_cap[8];
  28.133  } dom0_physinfo_t;
  28.134 +DEFINE_GUEST_HANDLE(dom0_physinfo_t);
  28.135  
  28.136  /*
  28.137   * Get the ID of the current scheduler.
  28.138 @@ -213,6 +229,7 @@ typedef struct dom0_sched_id {
  28.139      /* OUT variable */
  28.140      uint32_t sched_id;
  28.141  } dom0_sched_id_t;
  28.142 +DEFINE_GUEST_HANDLE(dom0_sched_id_t);
  28.143  
  28.144  /* 
  28.145   * Control shadow pagetables operation
  28.146 @@ -234,17 +251,19 @@ typedef struct dom0_shadow_control_stats
  28.147      uint32_t dirty_net_count;     
  28.148      uint32_t dirty_block_count;     
  28.149  } dom0_shadow_control_stats_t;
  28.150 +DEFINE_GUEST_HANDLE(dom0_shadow_control_stats_t);
  28.151  
  28.152  typedef struct dom0_shadow_control {
  28.153      /* IN variables. */
  28.154      domid_t        domain;
  28.155      uint32_t       op;
  28.156 -    unsigned long *dirty_bitmap; /* pointer to locked buffer */
  28.157 +    GUEST_HANDLE(ulong) dirty_bitmap;
  28.158      /* IN/OUT variables. */
  28.159      unsigned long  pages;        /* size of buffer, updated with actual size */
  28.160      /* OUT variables. */
  28.161      dom0_shadow_control_stats_t stats;
  28.162  } dom0_shadow_control_t;
  28.163 +DEFINE_GUEST_HANDLE(dom0_shadow_control_t);
  28.164  
  28.165  #define DOM0_SETDOMAINMAXMEM   28
  28.166  typedef struct dom0_setdomainmaxmem {
  28.167 @@ -252,6 +271,7 @@ typedef struct dom0_setdomainmaxmem {
  28.168      domid_t       domain;
  28.169      unsigned long max_memkb;
  28.170  } dom0_setdomainmaxmem_t;
  28.171 +DEFINE_GUEST_HANDLE(dom0_setdomainmaxmem_t);
  28.172  
  28.173  #define DOM0_GETPAGEFRAMEINFO2 29   /* batched interface */
  28.174  typedef struct dom0_getpageframeinfo2 {
  28.175 @@ -259,8 +279,9 @@ typedef struct dom0_getpageframeinfo2 {
  28.176      domid_t        domain;
  28.177      unsigned long  num;
  28.178      /* IN/OUT variables. */
  28.179 -    unsigned long *array;
  28.180 +    GUEST_HANDLE(ulong) array;
  28.181  } dom0_getpageframeinfo2_t;
  28.182 +DEFINE_GUEST_HANDLE(dom0_getpageframeinfo2_t);
  28.183  
  28.184  /*
  28.185   * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
  28.186 @@ -279,6 +300,7 @@ typedef struct dom0_add_memtype {
  28.187      uint32_t      handle;
  28.188      uint32_t      reg;
  28.189  } dom0_add_memtype_t;
  28.190 +DEFINE_GUEST_HANDLE(dom0_add_memtype_t);
  28.191  
  28.192  /*
  28.193   * Tear down an existing memory-range type. If @handle is remembered then it
  28.194 @@ -293,6 +315,7 @@ typedef struct dom0_del_memtype {
  28.195      uint32_t handle;
  28.196      uint32_t reg;
  28.197  } dom0_del_memtype_t;
  28.198 +DEFINE_GUEST_HANDLE(dom0_del_memtype_t);
  28.199  
  28.200  /* Read current type of an MTRR (x86-specific). */
  28.201  #define DOM0_READ_MEMTYPE        33
  28.202 @@ -304,6 +327,7 @@ typedef struct dom0_read_memtype {
  28.203      unsigned long nr_mfns;
  28.204      uint32_t type;
  28.205  } dom0_read_memtype_t;
  28.206 +DEFINE_GUEST_HANDLE(dom0_read_memtype_t);
  28.207  
  28.208  /* Interface for controlling Xen software performance counters. */
  28.209  #define DOM0_PERFCCONTROL        34
  28.210 @@ -315,20 +339,23 @@ typedef struct dom0_perfc_desc {
  28.211      uint32_t     nr_vals;              /* number of values for this counter */
  28.212      uint32_t     vals[64];             /* array of values */
  28.213  } dom0_perfc_desc_t;
  28.214 +DEFINE_GUEST_HANDLE(dom0_perfc_desc_t);
  28.215  typedef struct dom0_perfccontrol {
  28.216      /* IN variables. */
  28.217      uint32_t       op;                /*  DOM0_PERFCCONTROL_OP_??? */
  28.218      /* OUT variables. */
  28.219      uint32_t       nr_counters;       /*  number of counters */
  28.220 -    dom0_perfc_desc_t *desc;          /*  counter information (or NULL) */
  28.221 +    GUEST_HANDLE(dom0_perfc_desc_t) desc; /*  counter information (or NULL) */
  28.222  } dom0_perfccontrol_t;
  28.223 +DEFINE_GUEST_HANDLE(dom0_perfccontrol_t);
  28.224  
  28.225  #define DOM0_MICROCODE           35
  28.226  typedef struct dom0_microcode {
  28.227      /* IN variables. */
  28.228 -    void    *data;                    /* Pointer to microcode data */
  28.229 +    GUEST_HANDLE(void) data;          /* Pointer to microcode data */
  28.230      uint32_t length;                  /* Length of microcode data. */
  28.231  } dom0_microcode_t;
  28.232 +DEFINE_GUEST_HANDLE(dom0_microcode_t);
  28.233  
  28.234  #define DOM0_IOPORT_PERMISSION   36
  28.235  typedef struct dom0_ioport_permission {
  28.236 @@ -337,6 +364,7 @@ typedef struct dom0_ioport_permission {
  28.237      uint32_t nr_ports;                /* size of port range */
  28.238      uint8_t  allow_access;            /* allow or deny access to range? */
  28.239  } dom0_ioport_permission_t;
  28.240 +DEFINE_GUEST_HANDLE(dom0_ioport_permission_t);
  28.241  
  28.242  #define DOM0_GETVCPUCONTEXT      37
  28.243  typedef struct dom0_getvcpucontext {
  28.244 @@ -344,8 +372,9 @@ typedef struct dom0_getvcpucontext {
  28.245      domid_t  domain;                  /* domain to be affected */
  28.246      uint32_t vcpu;                    /* vcpu # */
  28.247      /* OUT variables. */
  28.248 -    vcpu_guest_context_t *ctxt;
  28.249 +    GUEST_HANDLE(vcpu_guest_context_t) ctxt;
  28.250  } dom0_getvcpucontext_t;
  28.251 +DEFINE_GUEST_HANDLE(dom0_getvcpucontext_t);
  28.252  
  28.253  #define DOM0_GETVCPUINFO         43
  28.254  typedef struct dom0_getvcpuinfo {
  28.255 @@ -360,16 +389,18 @@ typedef struct dom0_getvcpuinfo {
  28.256      uint32_t cpu;                     /* current mapping   */
  28.257      cpumap_t cpumap;                  /* allowable mapping */
  28.258  } dom0_getvcpuinfo_t;
  28.259 +DEFINE_GUEST_HANDLE(dom0_getvcpuinfo_t);
  28.260  
  28.261  #define DOM0_GETDOMAININFOLIST   38
  28.262  typedef struct dom0_getdomaininfolist {
  28.263      /* IN variables. */
  28.264      domid_t               first_domain;
  28.265      uint32_t              max_domains;
  28.266 -    dom0_getdomaininfo_t *buffer;
  28.267 +    GUEST_HANDLE(dom0_getdomaininfo_t) buffer;
  28.268      /* OUT variables. */
  28.269      uint32_t              num_domains;
  28.270  } dom0_getdomaininfolist_t;
  28.271 +DEFINE_GUEST_HANDLE(dom0_getdomaininfolist_t);
  28.272  
  28.273  #define DOM0_PLATFORM_QUIRK      39  
  28.274  #define QUIRK_NOIRQBALANCING  1
  28.275 @@ -377,37 +408,44 @@ typedef struct dom0_platform_quirk {
  28.276      /* IN variables. */
  28.277      uint32_t quirk_id;
  28.278  } dom0_platform_quirk_t;
  28.279 +DEFINE_GUEST_HANDLE(dom0_platform_quirk_t);
  28.280  
  28.281  #define DOM0_PHYSICAL_MEMORY_MAP 40
  28.282 +typedef struct dom0_memory_map_entry {
  28.283 +    uint64_t start, end;
  28.284 +    uint32_t flags; /* reserved */
  28.285 +    uint8_t  is_ram;
  28.286 +} dom0_memory_map_entry_t;
  28.287 +DEFINE_GUEST_HANDLE(dom0_memory_map_entry_t);
  28.288  typedef struct dom0_physical_memory_map {
  28.289      /* IN variables. */
  28.290      uint32_t max_map_entries;
  28.291      /* OUT variables. */
  28.292      uint32_t nr_map_entries;
  28.293 -    struct dom0_memory_map_entry {
  28.294 -        uint64_t start, end;
  28.295 -        uint32_t flags; /* reserved */
  28.296 -        uint8_t  is_ram;
  28.297 -    } *memory_map;
  28.298 +    GUEST_HANDLE(dom0_memory_map_entry_t) memory_map;
  28.299  } dom0_physical_memory_map_t;
  28.300 +DEFINE_GUEST_HANDLE(dom0_physical_memory_map_t);
  28.301  
  28.302  #define DOM0_MAX_VCPUS 41
  28.303  typedef struct dom0_max_vcpus {
  28.304      domid_t  domain;        /* domain to be affected */
  28.305      uint32_t max;           /* maximum number of vcpus */
  28.306  } dom0_max_vcpus_t;
  28.307 +DEFINE_GUEST_HANDLE(dom0_max_vcpus_t);
  28.308  
  28.309  #define DOM0_SETDOMAINHANDLE 44
  28.310  typedef struct dom0_setdomainhandle {
  28.311      domid_t domain;
  28.312      xen_domain_handle_t handle;
  28.313  } dom0_setdomainhandle_t;
  28.314 +DEFINE_GUEST_HANDLE(dom0_setdomainhandle_t);
  28.315  
  28.316  #define DOM0_SETDEBUGGING 45
  28.317  typedef struct dom0_setdebugging {
  28.318      domid_t domain;
  28.319      uint8_t enable;
  28.320  } dom0_setdebugging_t;
  28.321 +DEFINE_GUEST_HANDLE(dom0_setdebugging_t);
  28.322  
  28.323  #define DOM0_IRQ_PERMISSION 46
  28.324  typedef struct dom0_irq_permission {
  28.325 @@ -415,6 +453,7 @@ typedef struct dom0_irq_permission {
  28.326      uint8_t pirq;
  28.327      uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
  28.328  } dom0_irq_permission_t;
  28.329 +DEFINE_GUEST_HANDLE(dom0_irq_permission_t);
  28.330  
  28.331  #define DOM0_IOMEM_PERMISSION 47
  28.332  typedef struct dom0_iomem_permission {
  28.333 @@ -423,12 +462,14 @@ typedef struct dom0_iomem_permission {
  28.334      unsigned long nr_mfns;    /* number of pages in range (>0) */
  28.335      uint8_t allow_access;     /* allow (!0) or deny (0) access to range? */
  28.336  } dom0_iomem_permission_t;
  28.337 +DEFINE_GUEST_HANDLE(dom0_iomem_permission_t);
  28.338   
  28.339  #define DOM0_HYPERCALL_INIT   48
  28.340  typedef struct dom0_hypercall_init {
  28.341      domid_t  domain;          /* domain to be affected */
  28.342      unsigned long mfn;        /* machine frame to be initialised */
  28.343  } dom0_hypercall_init_t;
  28.344 +DEFINE_GUEST_HANDLE(dom0_hypercall_init_t);
  28.345   
  28.346  typedef struct dom0_op {
  28.347      uint32_t cmd;
  28.348 @@ -471,9 +512,10 @@ typedef struct dom0_op {
  28.349          struct dom0_irq_permission    irq_permission;
  28.350          struct dom0_iomem_permission  iomem_permission;
  28.351          struct dom0_hypercall_init    hypercall_init;
  28.352 -        uint8_t                  pad[128];
  28.353 +        uint8_t                       pad[128];
  28.354      } u;
  28.355  } dom0_op_t;
  28.356 +DEFINE_GUEST_HANDLE(dom0_op_t);
  28.357  
  28.358  #endif /* __XEN_PUBLIC_DOM0_OPS_H__ */
  28.359  
    29.1 --- a/xen/include/public/hvm/ioreq.h	Sat Mar 04 19:15:36 2006 +0100
    29.2 +++ b/xen/include/public/hvm/ioreq.h	Sat Mar 04 19:16:36 2006 +0100
    29.3 @@ -71,8 +71,8 @@ typedef struct {
    29.4  typedef struct {
    29.5      ioreq_t         vp_ioreq;
    29.6      /* Event channel port */
    29.7 -    unsigned long   vp_eport;   /* VMX vcpu uses this to notify DM */
    29.8 -    unsigned long   dm_eport;   /* DM uses this to notify VMX vcpu */
    29.9 +    unsigned int    vp_eport;   /* VMX vcpu uses this to notify DM */
   29.10 +    unsigned int    dm_eport;   /* DM uses this to notify VMX vcpu */
   29.11  } vcpu_iodata_t;
   29.12  
   29.13  typedef struct {
    30.1 --- a/xen/include/public/memory.h	Sat Mar 04 19:15:36 2006 +0100
    30.2 +++ b/xen/include/public/memory.h	Sat Mar 04 19:16:36 2006 +0100
    30.3 @@ -29,7 +29,7 @@ typedef struct xen_memory_reservation {
    30.4       *   OUT: GMFN bases of extents that were allocated
    30.5       *   (NB. This command also updates the mach_to_phys translation table)
    30.6       */
    30.7 -    guest_handle(ulong) extent_start;
    30.8 +    GUEST_HANDLE(ulong) extent_start;
    30.9  
   30.10      /* Number of extents, and size/alignment of each (2^extent_order pages). */
   30.11      unsigned long  nr_extents;
   30.12 @@ -50,7 +50,7 @@ typedef struct xen_memory_reservation {
   30.13      domid_t        domid;
   30.14  
   30.15  } xen_memory_reservation_t;
   30.16 -define_guest_handle(xen_memory_reservation_t);
   30.17 +DEFINE_GUEST_HANDLE(xen_memory_reservation_t);
   30.18  
   30.19  /*
   30.20   * Returns the maximum machine frame number of mapped RAM in this system.
   30.21 @@ -86,7 +86,7 @@ typedef struct xen_machphys_mfn_list {
   30.22       * any large discontiguities in the machine address space, 2MB gaps in
   30.23       * the machphys table will be represented by an MFN base of zero.
   30.24       */
   30.25 -    guest_handle(ulong) extent_start;
   30.26 +    GUEST_HANDLE(ulong) extent_start;
   30.27  
   30.28      /*
   30.29       * Number of extents written to the above array. This will be smaller
   30.30 @@ -94,7 +94,7 @@ typedef struct xen_machphys_mfn_list {
   30.31       */
   30.32      unsigned int nr_extents;
   30.33  } xen_machphys_mfn_list_t;
   30.34 -define_guest_handle(xen_machphys_mfn_list_t);
   30.35 +DEFINE_GUEST_HANDLE(xen_machphys_mfn_list_t);
   30.36  
   30.37  /*
   30.38   * Returns the base and size of the specified reserved 'RAM hole' in the
   30.39 @@ -115,7 +115,7 @@ typedef struct xen_reserved_phys_area {
   30.40      /* Base and size of the specified reserved area. */
   30.41      unsigned long first_gpfn, nr_gpfns;
   30.42  } xen_reserved_phys_area_t;
   30.43 -define_guest_handle(xen_reserved_phys_area_t);
   30.44 +DEFINE_GUEST_HANDLE(xen_reserved_phys_area_t);
   30.45  
   30.46  /*
   30.47   * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
   30.48 @@ -130,15 +130,15 @@ typedef struct xen_translate_gpfn_list {
   30.49      unsigned long nr_gpfns;
   30.50  
   30.51      /* List of GPFNs to translate. */
   30.52 -    guest_handle(ulong) gpfn_list;
   30.53 +    GUEST_HANDLE(ulong) gpfn_list;
   30.54  
   30.55      /*
   30.56       * Output list to contain MFN translations. May be the same as the input
   30.57       * list (in which case each input GPFN is overwritten with the output MFN).
   30.58       */
   30.59 -    guest_handle(ulong) mfn_list;
   30.60 +    GUEST_HANDLE(ulong) mfn_list;
   30.61  } xen_translate_gpfn_list_t;
   30.62 -define_guest_handle(xen_translate_gpfn_list_t);
   30.63 +DEFINE_GUEST_HANDLE(xen_translate_gpfn_list_t);
   30.64  
   30.65  #endif /* __XEN_PUBLIC_MEMORY_H__ */
   30.66  
    31.1 --- a/xen/include/public/xen.h	Sat Mar 04 19:15:36 2006 +0100
    31.2 +++ b/xen/include/public/xen.h	Sat Mar 04 19:16:36 2006 +0100
    31.3 @@ -9,28 +9,6 @@
    31.4  #ifndef __XEN_PUBLIC_XEN_H__
    31.5  #define __XEN_PUBLIC_XEN_H__
    31.6  
    31.7 -#ifdef __XEN__
    31.8 -#define __define_guest_handle(name, type) \
    31.9 -    typedef struct { type *p; } __guest_handle_ ## name
   31.10 -#else
   31.11 -#define __define_guest_handle(name, type) \
   31.12 -    typedef type * __guest_handle_ ## name
   31.13 -#endif
   31.14 -
   31.15 -#define define_guest_handle(name) __define_guest_handle(name, name)
   31.16 -#define guest_handle(name)        __guest_handle_ ## name
   31.17 -
   31.18 -#ifndef __ASSEMBLY__
   31.19 -/* Guest handles for primitive C types. */
   31.20 -__define_guest_handle(uchar, unsigned char);
   31.21 -__define_guest_handle(uint,  unsigned int);
   31.22 -__define_guest_handle(ulong, unsigned long);
   31.23 -define_guest_handle(char);
   31.24 -define_guest_handle(int);
   31.25 -define_guest_handle(long);
   31.26 -define_guest_handle(void);
   31.27 -#endif
   31.28 -
   31.29  #if defined(__i386__)
   31.30  #include "arch-x86_32.h"
   31.31  #elif defined(__x86_64__)
    32.1 --- a/xen/include/xen/console.h	Sat Mar 04 19:15:36 2006 +0100
    32.2 +++ b/xen/include/xen/console.h	Sat Mar 04 19:16:36 2006 +0100
    32.3 @@ -13,7 +13,7 @@ extern spinlock_t console_lock;
    32.4  
    32.5  void set_printk_prefix(const char *prefix);
    32.6  
    32.7 -long read_console_ring(char **, u32 *, int);
    32.8 +long read_console_ring(GUEST_HANDLE(char), u32 *, int);
    32.9  
   32.10  void init_console(void);
   32.11  void console_endboot(int disable_vga);
    33.1 --- a/xen/include/xen/guest_access.h	Sat Mar 04 19:15:36 2006 +0100
    33.2 +++ b/xen/include/xen/guest_access.h	Sat Mar 04 19:16:36 2006 +0100
    33.3 @@ -7,64 +7,17 @@
    33.4  #ifndef __XEN_GUEST_ACCESS_H__
    33.5  #define __XEN_GUEST_ACCESS_H__
    33.6  
    33.7 -#include <asm/uaccess.h>
    33.8 -
    33.9 -/* Is the guest handle a NULL reference? */
   33.10 -#define guest_handle_is_null(hnd)        ((hnd).p == NULL)
   33.11 -
   33.12 -/* Offset the given guest handle into the array it refers to. */
   33.13 -#define guest_handle_add_offset(hnd, nr) ((hnd).p += (nr))
   33.14 +#include <asm/guest_access.h>
   33.15  
   33.16 -/* Cast a guest handle to the specified type of handle. */
   33.17 -#define guest_handle_cast(hnd, type) ({         \
   33.18 -    type *_x = (hnd).p;                         \
   33.19 -    (guest_handle(type)) { _x };                \
   33.20 -})
   33.21 -
   33.22 -/*
   33.23 - * Copy an array of objects to guest context via a guest handle.
   33.24 - * Optionally specify an offset into the guest array.
   33.25 - */
   33.26 -#define copy_to_guest_offset(hnd, off, ptr, nr) ({      \
   33.27 -    const typeof(ptr) _x = (hnd).p;                     \
   33.28 -    const typeof(ptr) _y = (ptr);                       \
   33.29 -    copy_to_user(_x+(off), _y, sizeof(*_x)*(nr));       \
   33.30 -})
   33.31  #define copy_to_guest(hnd, ptr, nr)                     \
   33.32      copy_to_guest_offset(hnd, 0, ptr, nr)
   33.33  
   33.34 -/*
   33.35 - * Copy an array of objects from guest context via a guest handle.
   33.36 - * Optionally specify an offset into the guest array.
   33.37 - */
   33.38 -#define copy_from_guest_offset(ptr, hnd, off, nr) ({    \
   33.39 -    const typeof(ptr) _x = (hnd).p;                     \
   33.40 -    const typeof(ptr) _y = (ptr);                       \
   33.41 -    copy_from_user(_y, _x+(off), sizeof(*_x)*(nr));     \
   33.42 -})
   33.43  #define copy_from_guest(ptr, hnd, nr)                   \
   33.44      copy_from_guest_offset(ptr, hnd, 0, nr)
   33.45  
   33.46 -/*
   33.47 - * Pre-validate a guest handle.
   33.48 - * Allows use of faster __copy_* functions.
   33.49 - */
   33.50 -#define guest_handle_okay(hnd, nr)                      \
   33.51 -    array_access_ok((hnd).p, (nr), sizeof(*(hnd).p))
   33.52 -
   33.53 -#define __copy_to_guest_offset(hnd, off, ptr, nr) ({    \
   33.54 -    const typeof(ptr) _x = (hnd).p;                     \
   33.55 -    const typeof(ptr) _y = (ptr);                       \
   33.56 -    __copy_to_user(_x+(off), _y, sizeof(*_x)*(nr));     \
   33.57 -})
   33.58  #define __copy_to_guest(hnd, ptr, nr)                   \
   33.59      __copy_to_guest_offset(hnd, 0, ptr, nr)
   33.60  
   33.61 -#define __copy_from_guest_offset(ptr, hnd, off, nr) ({  \
   33.62 -    const typeof(ptr) _x = (hnd).p;                     \
   33.63 -    const typeof(ptr) _y = (ptr);                       \
   33.64 -    __copy_from_user(_y, _x+(off), sizeof(*_x)*(nr));   \
   33.65 -})
   33.66  #define __copy_from_guest(ptr, hnd, nr)                 \
   33.67      __copy_from_guest_offset(ptr, hnd, 0, nr)
   33.68  
    34.1 --- a/xen/include/xen/sched.h	Sat Mar 04 19:15:36 2006 +0100
    34.2 +++ b/xen/include/xen/sched.h	Sat Mar 04 19:16:36 2006 +0100
    34.3 @@ -311,7 +311,7 @@ void startup_cpu_idle_loop(void);
    34.4   *  'i' [unsigned] {char, int}
    34.5   *  'l' [unsigned] long
    34.6   *  'p' pointer (foo *)
    34.7 - *  'h' guest handle (guest_handle(foo))
    34.8 + *  'h' guest handle (GUEST_HANDLE(foo))
    34.9   */
   34.10  unsigned long hypercall_create_continuation(
   34.11      unsigned int op, const char *format, ...);