ia64/xen-unstable

changeset 9874:ec61a8c25429

Wrap all GUEST_HANDLEs in structures, and define SET/GET macros to access them
in Linux and libxc.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 27 13:58:50 2006 +0100 (2006-04-27)
parents 4e1b8be54311
children 4e0f2272fbcd
files linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/core/gnttab.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h tools/libxc/xc_domain.c tools/libxc/xc_hvm_build.c tools/libxc/xc_linux_build.c tools/libxc/xc_linux_restore.c tools/libxc/xc_linux_save.c tools/libxc/xc_misc.c tools/libxc/xc_private.c tools/xenstat/libxenstat/src/xen-interface.c xen/include/public/arch-ia64.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Thu Apr 27 13:38:21 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Thu Apr 27 13:58:50 2006 +0100
     1.3 @@ -70,7 +70,7 @@ static int do_microcode_update (void)
     1.4  		return err;
     1.5  
     1.6  	op.cmd = DOM0_MICROCODE;
     1.7 -	op.u.microcode.data = user_buffer;
     1.8 +	SET_XEN_GUEST_HANDLE(op.u.microcode.data, user_buffer);
     1.9  	op.u.microcode.length = user_buffer_size;
    1.10  	err = HYPERVISOR_dom0_op(&op);
    1.11  
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Thu Apr 27 13:38:21 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Thu Apr 27 13:58:50 2006 +0100
     2.3 @@ -1368,7 +1368,7 @@ legacy_init_iomem_resources(struct resou
     2.4  #ifdef CONFIG_XEN
     2.5  	map = alloc_bootmem_low_pages(PAGE_SIZE);
     2.6  	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
     2.7 -	op.u.physical_memory_map.memory_map = map;
     2.8 +	SET_XEN_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
     2.9  	op.u.physical_memory_map.max_map_entries =
    2.10  		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
    2.11  	BUG_ON(HYPERVISOR_dom0_op(&op));
     3.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Thu Apr 27 13:38:21 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Thu Apr 27 13:58:50 2006 +0100
     3.3 @@ -271,11 +271,11 @@ int xen_create_contiguous_region(
     3.4  	pte_t         *pte;
     3.5  	unsigned long  frame, i, flags;
     3.6  	struct xen_memory_reservation reservation = {
     3.7 -		.extent_start = &frame,
     3.8  		.nr_extents   = 1,
     3.9  		.extent_order = 0,
    3.10  		.domid        = DOMID_SELF
    3.11  	};
    3.12 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, &frame);
    3.13  
    3.14  	/*
    3.15  	 * Currently an auto-translated guest will not perform I/O, nor will
    3.16 @@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
    3.17  	pte_t         *pte;
    3.18  	unsigned long  frame, i, flags;
    3.19  	struct xen_memory_reservation reservation = {
    3.20 -		.extent_start = &frame,
    3.21  		.nr_extents   = 1,
    3.22  		.extent_order = 0,
    3.23  		.domid        = DOMID_SELF
    3.24  	};
    3.25 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, &frame);
    3.26  
    3.27  	if (xen_feature(XENFEAT_auto_translated_physmap))
    3.28  		return;
     4.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Thu Apr 27 13:38:21 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Thu Apr 27 13:58:50 2006 +0100
     4.3 @@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
     4.4  
     4.5  	map = alloc_bootmem_low_pages(PAGE_SIZE);
     4.6  	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
     4.7 -	op.u.physical_memory_map.memory_map = map;
     4.8 +	SET_XEN_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
     4.9  	op.u.physical_memory_map.max_map_entries =
    4.10  		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
    4.11  	BUG_ON(HYPERVISOR_dom0_op(&op));
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Apr 27 13:38:21 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Apr 27 13:58:50 2006 +0100
     5.3 @@ -195,14 +195,14 @@ static int increase_reservation(unsigned
     5.4  		page = balloon_next_page(page);
     5.5  	}
     5.6  
     5.7 -	reservation.extent_start = frame_list;
     5.8 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
     5.9  	reservation.nr_extents   = nr_pages;
    5.10  	rc = HYPERVISOR_memory_op(
    5.11  		XENMEM_populate_physmap, &reservation);
    5.12  	if (rc < nr_pages) {
    5.13  		int ret;
    5.14  		/* We hit the Xen hard limit: reprobe. */
    5.15 -		reservation.extent_start = frame_list;
    5.16 +		SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
    5.17  		reservation.nr_extents   = rc;
    5.18  		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
    5.19  				&reservation);
    5.20 @@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
    5.21  		balloon_append(pfn_to_page(pfn));
    5.22  	}
    5.23  
    5.24 -	reservation.extent_start = frame_list;
    5.25 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
    5.26  	reservation.nr_extents   = nr_pages;
    5.27  	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
    5.28  	BUG_ON(ret != nr_pages);
    5.29 @@ -522,11 +522,11 @@ static int dealloc_pte_fn(
    5.30  	unsigned long mfn = pte_mfn(*pte);
    5.31  	int ret;
    5.32  	struct xen_memory_reservation reservation = {
    5.33 -		.extent_start = &mfn,
    5.34  		.nr_extents   = 1,
    5.35  		.extent_order = 0,
    5.36  		.domid        = DOMID_SELF
    5.37  	};
    5.38 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, &mfn);
    5.39  	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
    5.40  	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
    5.41  	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Apr 27 13:38:21 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Apr 27 13:58:50 2006 +0100
     6.3 @@ -399,7 +399,7 @@ gnttab_resume(void)
     6.4  
     6.5  	setup.dom        = DOMID_SELF;
     6.6  	setup.nr_frames  = NR_GRANT_FRAMES;
     6.7 -	setup.frame_list = frames;
     6.8 +	SET_XEN_GUEST_HANDLE(setup.frame_list, frames);
     6.9  
    6.10  	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
    6.11  	if (rc == -ENOSYS)
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Apr 27 13:38:21 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Apr 27 13:58:50 2006 +0100
     7.3 @@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
     7.4  {
     7.5  	unsigned long mfn = 0, flags;
     7.6  	struct xen_memory_reservation reservation = {
     7.7 -		.extent_start = mfn_list,
     7.8  		.nr_extents   = MAX_MFN_ALLOC,
     7.9  		.extent_order = 0,
    7.10  		.domid        = DOMID_SELF
    7.11  	};
    7.12 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, mfn_list);
    7.13  	spin_lock_irqsave(&mfn_lock, flags);
    7.14  	if ( unlikely(alloc_index == 0) )
    7.15  		alloc_index = HYPERVISOR_memory_op(
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Apr 27 13:38:21 2006 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Apr 27 13:58:50 2006 +0100
     8.3 @@ -607,7 +607,7 @@ static void network_alloc_rx_buffers(str
     8.4  	/* Tell the ballon driver what is going on. */
     8.5  	balloon_update_driver_allowance(i);
     8.6  
     8.7 -	reservation.extent_start = np->rx_pfn_array;
     8.8 +	SET_XEN_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
     8.9  	reservation.nr_extents   = i;
    8.10  	reservation.extent_order = 0;
    8.11  	reservation.address_bits = 0;
     9.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Thu Apr 27 13:38:21 2006 +0100
     9.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Thu Apr 27 13:58:50 2006 +0100
     9.3 @@ -163,13 +163,14 @@ HYPERVISOR_poll(
     9.4  	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
     9.5  {
     9.6  	struct sched_poll sched_poll = {
     9.7 -		.ports = ports,
     9.8  		.nr_ports = nr_ports,
     9.9  		.timeout = jiffies_to_st(timeout)
    9.10  	};
    9.11 +	int rc;
    9.12  
    9.13 -	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
    9.14 +	SET_XEN_GUEST_HANDLE(sched_poll.ports, ports);
    9.15  
    9.16 +	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
    9.17  	if (rc == -ENOSYS)
    9.18  		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
    9.19  
    10.1 --- a/tools/libxc/xc_domain.c	Thu Apr 27 13:38:21 2006 +0100
    10.2 +++ b/tools/libxc/xc_domain.c	Thu Apr 27 13:58:50 2006 +0100
    10.3 @@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
    10.4      op.cmd = DOM0_GETDOMAININFOLIST;
    10.5      op.u.getdomaininfolist.first_domain = first_domain;
    10.6      op.u.getdomaininfolist.max_domains  = max_domains;
    10.7 -    op.u.getdomaininfolist.buffer       = info;
    10.8 +    SET_XEN_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
    10.9  
   10.10      if ( xc_dom0_op(xc_handle, &op) < 0 )
   10.11          ret = -1;
   10.12 @@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
   10.13      op.cmd = DOM0_GETVCPUCONTEXT;
   10.14      op.u.getvcpucontext.domain = (domid_t)domid;
   10.15      op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
   10.16 -    op.u.getvcpucontext.ctxt   = ctxt;
   10.17 +    SET_XEN_GUEST_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
   10.18  
   10.19      if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
   10.20          return rc;
   10.21 @@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
   10.22      op.cmd = DOM0_SHADOW_CONTROL;
   10.23      op.u.shadow_control.domain = (domid_t)domid;
   10.24      op.u.shadow_control.op     = sop;
   10.25 -    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
   10.26 +    SET_XEN_GUEST_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
   10.27      op.u.shadow_control.pages  = pages;
   10.28  
   10.29      rc = do_dom0_op(xc_handle, &op);
   10.30 @@ -295,13 +295,15 @@ int xc_domain_memory_increase_reservatio
   10.31  {
   10.32      int err;
   10.33      struct xen_memory_reservation reservation = {
   10.34 -        .extent_start = extent_start, /* may be NULL */
   10.35          .nr_extents   = nr_extents,
   10.36          .extent_order = extent_order,
   10.37          .address_bits = address_bits,
   10.38          .domid        = domid
   10.39      };
   10.40  
   10.41 +    /* may be NULL */
   10.42 +    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
   10.43 +
   10.44      err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
   10.45      if ( err == nr_extents )
   10.46          return 0;
   10.47 @@ -326,13 +328,14 @@ int xc_domain_memory_decrease_reservatio
   10.48  {
   10.49      int err;
   10.50      struct xen_memory_reservation reservation = {
   10.51 -        .extent_start = extent_start,
   10.52          .nr_extents   = nr_extents,
   10.53          .extent_order = extent_order,
   10.54          .address_bits = 0,
   10.55          .domid        = domid
   10.56      };
   10.57  
   10.58 +    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
   10.59 +
   10.60      if ( extent_start == NULL )
   10.61      {
   10.62          fprintf(stderr,"decrease_reservation extent_start is NULL!\n");
   10.63 @@ -364,12 +367,12 @@ int xc_domain_memory_populate_physmap(in
   10.64  {
   10.65      int err;
   10.66      struct xen_memory_reservation reservation = {
   10.67 -        .extent_start = extent_start,
   10.68          .nr_extents   = nr_extents,
   10.69          .extent_order = extent_order,
   10.70          .address_bits = address_bits,
   10.71          .domid        = domid
   10.72      };
   10.73 +    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
   10.74  
   10.75      err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
   10.76      if ( err == nr_extents )
   10.77 @@ -395,9 +398,9 @@ int xc_domain_translate_gpfn_list(int xc
   10.78      struct xen_translate_gpfn_list op = {
   10.79          .domid        = domid,
   10.80          .nr_gpfns     = nr_gpfns,
   10.81 -        .gpfn_list    = gpfn_list,
   10.82 -        .mfn_list     = mfn_list
   10.83      };
   10.84 +    SET_XEN_GUEST_HANDLE(op.gpfn_list, gpfn_list);
   10.85 +    SET_XEN_GUEST_HANDLE(op.mfn_list, mfn_list);
   10.86  
   10.87      return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
   10.88  }
   10.89 @@ -467,7 +470,7 @@ int xc_vcpu_setcontext(int xc_handle,
   10.90      op.cmd = DOM0_SETVCPUCONTEXT;
   10.91      op.u.setvcpucontext.domain = domid;
   10.92      op.u.setvcpucontext.vcpu = vcpu;
   10.93 -    op.u.setvcpucontext.ctxt = ctxt;
   10.94 +    SET_XEN_GUEST_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
   10.95  
   10.96      if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
   10.97          return rc;
    11.1 --- a/tools/libxc/xc_hvm_build.c	Thu Apr 27 13:38:21 2006 +0100
    11.2 +++ b/tools/libxc/xc_hvm_build.c	Thu Apr 27 13:58:50 2006 +0100
    11.3 @@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
    11.4  
    11.5      launch_op.u.setvcpucontext.domain = (domid_t)domid;
    11.6      launch_op.u.setvcpucontext.vcpu   = 0;
    11.7 -    launch_op.u.setvcpucontext.ctxt   = ctxt;
    11.8 +    SET_XEN_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
    11.9  
   11.10      launch_op.cmd = DOM0_SETVCPUCONTEXT;
   11.11      rc = xc_dom0_op(xc_handle, &launch_op);
    12.1 --- a/tools/libxc/xc_linux_build.c	Thu Apr 27 13:38:21 2006 +0100
    12.2 +++ b/tools/libxc/xc_linux_build.c	Thu Apr 27 13:58:50 2006 +0100
    12.3 @@ -1180,7 +1180,7 @@ static int xc_linux_build_internal(int x
    12.4  
    12.5      launch_op.u.setvcpucontext.domain = (domid_t)domid;
    12.6      launch_op.u.setvcpucontext.vcpu   = 0;
    12.7 -    launch_op.u.setvcpucontext.ctxt   = ctxt;
    12.8 +    SET_XEN_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
    12.9  
   12.10      launch_op.cmd = DOM0_SETVCPUCONTEXT;
   12.11      rc = xc_dom0_op(xc_handle, &launch_op);
    13.1 --- a/tools/libxc/xc_linux_restore.c	Thu Apr 27 13:38:21 2006 +0100
    13.2 +++ b/tools/libxc/xc_linux_restore.c	Thu Apr 27 13:58:50 2006 +0100
    13.3 @@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
    13.4          if (count > 0) {
    13.5  
    13.6              struct xen_memory_reservation reservation = {
    13.7 -                .extent_start = pfntab,
    13.8                  .nr_extents   = count,
    13.9                  .extent_order = 0,
   13.10                  .domid        = dom
   13.11              };
   13.12 +            SET_XEN_GUEST_HANDLE(reservation.extent_start, pfntab);
   13.13  
   13.14              if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
   13.15                                     &reservation)) != count) {
   13.16 @@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
   13.17      op.cmd = DOM0_SETVCPUCONTEXT;
   13.18      op.u.setvcpucontext.domain = (domid_t)dom;
   13.19      op.u.setvcpucontext.vcpu   = 0;
   13.20 -    op.u.setvcpucontext.ctxt   = &ctxt;
   13.21 +    SET_XEN_GUEST_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
   13.22      rc = xc_dom0_op(xc_handle, &op);
   13.23  
   13.24      if (rc != 0) {
    14.1 --- a/tools/libxc/xc_linux_save.c	Thu Apr 27 13:38:21 2006 +0100
    14.2 +++ b/tools/libxc/xc_linux_save.c	Thu Apr 27 13:58:50 2006 +0100
    14.3 @@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
    14.4      privcmd_mmap_entry_t *entries;
    14.5      unsigned long m2p_chunks, m2p_size;
    14.6      unsigned long *m2p;
    14.7 +    unsigned long *extent_start;
    14.8      int i, rc;
    14.9  
   14.10      m2p_size   = M2P_SIZE(max_mfn);
   14.11      m2p_chunks = M2P_CHUNKS(max_mfn);
   14.12  
   14.13      xmml.max_extents = m2p_chunks;
   14.14 -    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
   14.15 +    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
   14.16          ERR("failed to allocate space for m2p mfns");
   14.17          return NULL;
   14.18      }
   14.19 +    SET_XEN_GUEST_HANDLE(xmml.extent_start, extent_start);
   14.20  
   14.21      if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
   14.22          (xmml.nr_extents != m2p_chunks)) {
   14.23 @@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
   14.24  
   14.25      for (i=0; i < m2p_chunks; i++) {
   14.26          entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE));
   14.27 -        entries[i].mfn = xmml.extent_start[i];
   14.28 +        entries[i].mfn = extent_start[i];
   14.29          entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
   14.30      }
   14.31  
   14.32 @@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
   14.33          return NULL;
   14.34      }
   14.35  
   14.36 -    free(xmml.extent_start);
   14.37 +    free(extent_start);
   14.38      free(entries);
   14.39  
   14.40      return m2p;
    15.1 --- a/tools/libxc/xc_misc.c	Thu Apr 27 13:38:21 2006 +0100
    15.2 +++ b/tools/libxc/xc_misc.c	Thu Apr 27 13:58:50 2006 +0100
    15.3 @@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
    15.4      unsigned int nr_chars = *pnr_chars;
    15.5  
    15.6      op.cmd = DOM0_READCONSOLE;
    15.7 -    op.u.readconsole.buffer = buffer;
    15.8 +    SET_XEN_GUEST_HANDLE(op.u.readconsole.buffer, buffer);
    15.9      op.u.readconsole.count  = nr_chars;
   15.10      op.u.readconsole.clear  = clear;
   15.11  
   15.12 @@ -38,10 +38,7 @@ int xc_readconsolering(int xc_handle,
   15.13          return ret;
   15.14  
   15.15      if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
   15.16 -    {
   15.17 -        *pbuffer   = op.u.readconsole.buffer;
   15.18          *pnr_chars = op.u.readconsole.count;
   15.19 -    }
   15.20  
   15.21      safe_munlock(buffer, nr_chars);
   15.22  
   15.23 @@ -91,7 +88,7 @@ int xc_perfc_control(int xc_handle,
   15.24  
   15.25      op.cmd = DOM0_PERFCCONTROL;
   15.26      op.u.perfccontrol.op   = opcode;
   15.27 -    op.u.perfccontrol.desc = desc;
   15.28 +    SET_XEN_GUEST_HANDLE(op.u.perfccontrol.desc, desc);
   15.29  
   15.30      rc = do_dom0_op(xc_handle, &op);
   15.31  
    16.1 --- a/tools/libxc/xc_private.c	Thu Apr 27 13:38:21 2006 +0100
    16.2 +++ b/tools/libxc/xc_private.c	Thu Apr 27 13:58:50 2006 +0100
    16.3 @@ -71,7 +71,7 @@ int xc_get_pfn_type_batch(int xc_handle,
    16.4      op.cmd = DOM0_GETPAGEFRAMEINFO2;
    16.5      op.u.getpageframeinfo2.domain = (domid_t)dom;
    16.6      op.u.getpageframeinfo2.num    = num;
    16.7 -    op.u.getpageframeinfo2.array  = arr;
    16.8 +    SET_XEN_GUEST_HANDLE(op.u.getpageframeinfo2.array, arr);
    16.9      return do_dom0_op(xc_handle, &op);
   16.10  }
   16.11  
   16.12 @@ -191,6 +191,9 @@ int xc_memory_op(int xc_handle,
   16.13      struct xen_memory_reservation *reservation = arg;
   16.14      struct xen_machphys_mfn_list *xmml = arg;
   16.15      struct xen_translate_gpfn_list *trans = arg;
   16.16 +    unsigned long *extent_start;
   16.17 +    unsigned long *gpfn_list;
   16.18 +    unsigned long *mfn_list;
   16.19      long ret = -EINVAL;
   16.20  
   16.21      hypercall.op     = __HYPERVISOR_memory_op;
   16.22 @@ -207,8 +210,9 @@ int xc_memory_op(int xc_handle,
   16.23              PERROR("Could not mlock");
   16.24              goto out1;
   16.25          }
   16.26 -        if ( (reservation->extent_start != NULL) &&
   16.27 -             (mlock(reservation->extent_start,
   16.28 +        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
   16.29 +        if ( (extent_start != NULL) &&
   16.30 +             (mlock(extent_start,
   16.31                      reservation->nr_extents * sizeof(unsigned long)) != 0) )
   16.32          {
   16.33              PERROR("Could not mlock");
   16.34 @@ -222,7 +226,8 @@ int xc_memory_op(int xc_handle,
   16.35              PERROR("Could not mlock");
   16.36              goto out1;
   16.37          }
   16.38 -        if ( mlock(xmml->extent_start,
   16.39 +        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
   16.40 +        if ( mlock(extent_start,
   16.41                     xmml->max_extents * sizeof(unsigned long)) != 0 )
   16.42          {
   16.43              PERROR("Could not mlock");
   16.44 @@ -243,16 +248,18 @@ int xc_memory_op(int xc_handle,
   16.45              PERROR("Could not mlock");
   16.46              goto out1;
   16.47          }
   16.48 -        if ( mlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
   16.49 +        GET_XEN_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
   16.50 +        if ( mlock(gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
   16.51          {
   16.52              PERROR("Could not mlock");
   16.53              safe_munlock(trans, sizeof(*trans));
   16.54              goto out1;
   16.55          }
   16.56 -        if ( mlock(trans->mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
   16.57 +        GET_XEN_GUEST_HANDLE(mfn_list, trans->mfn_list);
   16.58 +        if ( mlock(mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
   16.59          {
   16.60              PERROR("Could not mlock");
   16.61 -            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
   16.62 +            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
   16.63              safe_munlock(trans, sizeof(*trans));
   16.64              goto out1;
   16.65          }
   16.66 @@ -267,21 +274,25 @@ int xc_memory_op(int xc_handle,
   16.67      case XENMEM_decrease_reservation:
   16.68      case XENMEM_populate_physmap:
   16.69          safe_munlock(reservation, sizeof(*reservation));
   16.70 -        if ( reservation->extent_start != NULL )
   16.71 -            safe_munlock(reservation->extent_start,
   16.72 +        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
   16.73 +        if ( extent_start != NULL )
   16.74 +            safe_munlock(extent_start,
   16.75                           reservation->nr_extents * sizeof(unsigned long));
   16.76          break;
   16.77      case XENMEM_machphys_mfn_list:
   16.78          safe_munlock(xmml, sizeof(*xmml));
   16.79 -        safe_munlock(xmml->extent_start,
   16.80 +        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
   16.81 +        safe_munlock(extent_start,
   16.82                       xmml->max_extents * sizeof(unsigned long));
   16.83          break;
   16.84      case XENMEM_add_to_physmap:
   16.85          safe_munlock(arg, sizeof(struct xen_add_to_physmap));
   16.86          break;
   16.87      case XENMEM_translate_gpfn_list:
   16.88 -            safe_munlock(trans->mfn_list, trans->nr_gpfns * sizeof(long));
   16.89 -            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
   16.90 +            GET_XEN_GUEST_HANDLE(mfn_list, trans->mfn_list);
   16.91 +            safe_munlock(mfn_list, trans->nr_gpfns * sizeof(long));
   16.92 +            GET_XEN_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
   16.93 +            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
   16.94              safe_munlock(trans, sizeof(*trans));
   16.95          break;
   16.96      }
   16.97 @@ -317,7 +328,7 @@ int xc_get_pfn_list(int xc_handle,
   16.98      op.cmd = DOM0_GETMEMLIST;
   16.99      op.u.getmemlist.domain   = (domid_t)domid;
  16.100      op.u.getmemlist.max_pfns = max_pfns;
  16.101 -    op.u.getmemlist.buffer   = pfn_buf;
  16.102 +    SET_XEN_GUEST_HANDLE(op.u.getmemlist.buffer, pfn_buf);
  16.103  
  16.104  #ifdef VALGRIND
  16.105      memset(pfn_buf, 0, max_pfns * sizeof(unsigned long));
    17.1 --- a/tools/xenstat/libxenstat/src/xen-interface.c	Thu Apr 27 13:38:21 2006 +0100
    17.2 +++ b/tools/xenstat/libxenstat/src/xen-interface.c	Thu Apr 27 13:58:50 2006 +0100
    17.3 @@ -155,7 +155,7 @@ int xi_get_domaininfolist(xi_handle *han
    17.4  	dom0_op_t op;
    17.5  	op.u.getdomaininfolist.first_domain = first_domain;
    17.6  	op.u.getdomaininfolist.max_domains = max_domains;
    17.7 -	op.u.getdomaininfolist.buffer = info;
    17.8 +	SET_XEN_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
    17.9  
   17.10  	if (mlock( info, max_domains * sizeof(dom0_getdomaininfo_t)) < 0) {
   17.11  		perror("Failed to mlock domaininfo array");
    18.1 --- a/xen/include/public/arch-ia64.h	Thu Apr 27 13:38:21 2006 +0100
    18.2 +++ b/xen/include/public/arch-ia64.h	Thu Apr 27 13:58:50 2006 +0100
    18.3 @@ -7,16 +7,13 @@
    18.4  #ifndef __HYPERVISOR_IF_IA64_H__
    18.5  #define __HYPERVISOR_IF_IA64_H__
    18.6  
    18.7 -#ifdef __XEN__
    18.8  #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    18.9      typedef struct { type *p; } __guest_handle_ ## name
   18.10 -#else
   18.11 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   18.12 -    typedef type * __guest_handle_ ## name
   18.13 -#endif
   18.14  
   18.15 -#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
   18.16 -#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
   18.17 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
   18.18 +#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
   18.19 +#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
   18.20 +#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
   18.21  
   18.22  #ifndef __ASSEMBLY__
   18.23  /* Guest handles for primitive C types. */
    19.1 --- a/xen/include/public/arch-x86_32.h	Thu Apr 27 13:38:21 2006 +0100
    19.2 +++ b/xen/include/public/arch-x86_32.h	Thu Apr 27 13:58:50 2006 +0100
    19.3 @@ -9,16 +9,13 @@
    19.4  #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
    19.5  #define __XEN_PUBLIC_ARCH_X86_32_H__
    19.6  
    19.7 -#ifdef __XEN__
    19.8  #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    19.9      typedef struct { type *p; } __guest_handle_ ## name
   19.10 -#else
   19.11 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   19.12 -    typedef type * __guest_handle_ ## name
   19.13 -#endif
   19.14  
   19.15 -#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
   19.16 -#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
   19.17 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
   19.18 +#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
   19.19 +#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
   19.20 +#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
   19.21  
   19.22  #ifndef __ASSEMBLY__
   19.23  /* Guest handles for primitive C types. */
    20.1 --- a/xen/include/public/arch-x86_64.h	Thu Apr 27 13:38:21 2006 +0100
    20.2 +++ b/xen/include/public/arch-x86_64.h	Thu Apr 27 13:58:50 2006 +0100
    20.3 @@ -9,16 +9,13 @@
    20.4  #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
    20.5  #define __XEN_PUBLIC_ARCH_X86_64_H__
    20.6  
    20.7 -#ifdef __XEN__
    20.8  #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    20.9      typedef struct { type *p; } __guest_handle_ ## name
   20.10 -#else
   20.11 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
   20.12 -    typedef type * __guest_handle_ ## name
   20.13 -#endif
   20.14  
   20.15 -#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
   20.16 -#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
   20.17 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
   20.18 +#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
   20.19 +#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
   20.20 +#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
   20.21  
   20.22  #ifndef __ASSEMBLY__
   20.23  /* Guest handles for primitive C types. */