ia64/linux-2.6.18-xen.hg

changeset 187:b5fdf02c38f4

[IA64] Linux xencomm consolidation

Use common xencomm.c and remove ia64 xencomm.c

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Aug 16 13:44:51 2007 -0600 (2007-08-16)
parents 60d8f0befd18
children ec6f71d1b335 7419a3be8273
files arch/ia64/Kconfig arch/ia64/kernel/setup.c arch/ia64/xen/Makefile arch/ia64/xen/hypervisor.c arch/ia64/xen/xcom_hcall.c arch/ia64/xen/xcom_mini.c arch/ia64/xen/xcom_privcmd.c arch/ia64/xen/xencomm.c include/asm-ia64/hypercall.h include/asm-ia64/sal.h include/asm-ia64/xen/xcom_hcall.h include/asm-ia64/xen/xencomm.h
line diff
     1.1 --- a/arch/ia64/Kconfig	Thu Aug 16 10:58:46 2007 -0600
     1.2 +++ b/arch/ia64/Kconfig	Thu Aug 16 13:44:51 2007 -0600
     1.3 @@ -61,6 +61,7 @@ config GENERIC_IOMAP
     1.4  config XEN
     1.5  	bool "Xen hypervisor support"
     1.6  	default y
     1.7 +	select XEN_XENCOMM
     1.8  	help
     1.9  	  Enable Xen hypervisor support.  Resulting kernel runs
    1.10  	  both as a guest OS on Xen and natively on hardware.
     2.1 --- a/arch/ia64/kernel/setup.c	Thu Aug 16 10:58:46 2007 -0600
     2.2 +++ b/arch/ia64/kernel/setup.c	Thu Aug 16 13:44:51 2007 -0600
     2.3 @@ -449,7 +449,7 @@ setup_arch (char **cmdline_p)
     2.4  		struct xen_ia64_opt_feature optf;
     2.5  
     2.6  		/* Must be done before any hypercall.  */
     2.7 -		xencomm_init();
     2.8 +		xencomm_initialize();
     2.9  
    2.10  		setup_xen_features();
    2.11  		/* Register a call for panic conditions. */
     3.1 --- a/arch/ia64/xen/Makefile	Thu Aug 16 10:58:46 2007 -0600
     3.2 +++ b/arch/ia64/xen/Makefile	Thu Aug 16 13:44:51 2007 -0600
     3.3 @@ -3,7 +3,7 @@
     3.4  #
     3.5  
     3.6  obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o \
     3.7 -	 hypervisor.o util.o xencomm.o xcom_hcall.o xcom_mini.o \
     3.8 +	 hypervisor.o util.o xencomm.o xcom_hcall.o \
     3.9  	 xcom_privcmd.o xen_dma.o
    3.10  
    3.11  obj-$(CONFIG_IA64_GENERIC) += machvec.o
     4.1 --- a/arch/ia64/xen/hypervisor.c	Thu Aug 16 10:58:46 2007 -0600
     4.2 +++ b/arch/ia64/xen/hypervisor.c	Thu Aug 16 13:44:51 2007 -0600
     4.3 @@ -447,7 +447,7 @@ HYPERVISOR_grant_table_op(unsigned int c
     4.4  				(struct gnttab_map_grant_ref*)uop + i);
     4.5  		}
     4.6  	}
     4.7 -	return xencomm_mini_hypercall_grant_table_op(cmd, uop, count);
     4.8 +	return xencomm_hypercall_grant_table_op(cmd, uop, count);
     4.9  }
    4.10  EXPORT_SYMBOL(HYPERVISOR_grant_table_op);
    4.11  
     5.1 --- a/arch/ia64/xen/xcom_hcall.c	Thu Aug 16 10:58:46 2007 -0600
     5.2 +++ b/arch/ia64/xen/xcom_hcall.c	Thu Aug 16 13:44:51 2007 -0600
     5.3 @@ -14,6 +14,11 @@
     5.4   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     5.5   *
     5.6   *          Tristan Gingold <tristan.gingold@bull.net>
     5.7 + *
     5.8 + *          Copyright (c) 2007
     5.9 + *          Isaku Yamahata <yamahata at valinux co jp>
    5.10 + *                          VA Linux Systems Japan K.K.
    5.11 + *          consolidate mini and inline version.
    5.12   */
    5.13  #include <linux/types.h>
    5.14  #include <linux/errno.h>
    5.15 @@ -42,8 +47,8 @@
    5.16  
    5.17  /* Xencomm notes:
    5.18   * This file defines hypercalls to be used by xencomm.  The hypercalls simply
    5.19 - * create inlines descriptors for pointers and then call the raw arch hypercall
    5.20 - * xencomm_arch_hypercall_XXX
    5.21 + * create inlines or mini descriptors for pointers and then call the raw arch
    5.22 + * hypercall xencomm_arch_hypercall_XXX
    5.23   *
    5.24   * If the arch wants to directly use these hypercalls, simply define macros
    5.25   * in asm/hypercall.h, eg:
    5.26 @@ -52,107 +57,206 @@
    5.27   * The arch may also define HYPERVISOR_xxx as a function and do more operations
    5.28   * before/after doing the hypercall.
    5.29   *
    5.30 - * Note: because only inline descriptors are created these functions must only
    5.31 - * be called with in kernel memory parameters.
    5.32 + * Note: because only inline or mini descriptors are created these functions
    5.33 + * must only be called with in kernel memory parameters.
    5.34   */
    5.35  
    5.36  int
    5.37  xencomm_hypercall_console_io(int cmd, int count, char *str)
    5.38  {
    5.39  	return xencomm_arch_hypercall_console_io
    5.40 -		(cmd, count, xencomm_create_inline(str));
    5.41 +		(cmd, count, xencomm_map_no_alloc(str, count));
    5.42  }
    5.43 +EXPORT_SYMBOL_GPL(xencomm_hypercall_console_io);
    5.44  
    5.45  int
    5.46  xencomm_hypercall_event_channel_op(int cmd, void *op)
    5.47  {
    5.48 -	return xencomm_arch_hypercall_event_channel_op
    5.49 -		(cmd, xencomm_create_inline(op));
    5.50 +	struct xencomm_handle *desc;
    5.51 +	desc = xencomm_map_no_alloc(op, sizeof(evtchn_op_t));
    5.52 +	if (desc == NULL)
    5.53 +		return -EINVAL;
    5.54 +
    5.55 +	return xencomm_arch_hypercall_event_channel_op(cmd, desc);
    5.56  }
    5.57 +EXPORT_SYMBOL_GPL(xencomm_hypercall_event_channel_op);
    5.58  
    5.59  int
    5.60  xencomm_hypercall_xen_version(int cmd, void *arg)
    5.61  {
    5.62 +	struct xencomm_handle *desc;
    5.63 +	unsigned int argsize;
    5.64 +
    5.65  	switch (cmd) {
    5.66  	case XENVER_version:
    5.67 +		/* do not actually pass an argument */
    5.68 +		return xencomm_arch_hypercall_xen_version(cmd, 0);
    5.69  	case XENVER_extraversion:
    5.70 +		argsize = sizeof(xen_extraversion_t);
    5.71 +		break;
    5.72  	case XENVER_compile_info:
    5.73 +		argsize = sizeof(xen_compile_info_t);
    5.74 +		break;
    5.75  	case XENVER_capabilities:
    5.76 +		argsize = sizeof(xen_capabilities_info_t);
    5.77 +		break;
    5.78  	case XENVER_changeset:
    5.79 +		argsize = sizeof(xen_changeset_info_t);
    5.80 +		break;
    5.81  	case XENVER_platform_parameters:
    5.82 +		argsize = sizeof(xen_platform_parameters_t);
    5.83 +		break;
    5.84  	case XENVER_pagesize:
    5.85 +		argsize = (arg == NULL) ? 0 : sizeof(void *);
    5.86 +		break;
    5.87  	case XENVER_get_features:
    5.88 +		argsize = (arg == NULL) ? 0 : sizeof(xen_feature_info_t);
    5.89  		break;
    5.90 +
    5.91  	default:
    5.92 -		printk("%s: unknown version cmd %d\n", __func__, cmd);
    5.93 +		printk("%s: unknown version op %d\n", __func__, cmd);
    5.94  		return -ENOSYS;
    5.95  	}
    5.96  
    5.97 -	return xencomm_arch_hypercall_xen_version
    5.98 -		(cmd, xencomm_create_inline(arg));
    5.99 +	desc = xencomm_map_no_alloc(arg, argsize);
   5.100 +	if (desc == NULL)
   5.101 +		return -EINVAL;
   5.102 +
   5.103 +	return xencomm_arch_hypercall_xen_version(cmd, desc);
   5.104  }
   5.105 +EXPORT_SYMBOL_GPL(xencomm_hypercall_xen_version);
   5.106  
   5.107  int
   5.108  xencomm_hypercall_physdev_op(int cmd, void *op)
   5.109  {
   5.110 +	unsigned int argsize;
   5.111 +	
   5.112 +	switch (cmd) {
   5.113 +	case PHYSDEVOP_apic_read:
   5.114 +	case PHYSDEVOP_apic_write:
   5.115 +		argsize = sizeof(physdev_apic_t);
   5.116 +		break;
   5.117 +	case PHYSDEVOP_alloc_irq_vector:
   5.118 +	case PHYSDEVOP_free_irq_vector:
   5.119 +		argsize = sizeof(physdev_irq_t);
   5.120 +		break;
   5.121 +	case PHYSDEVOP_irq_status_query:
   5.122 +		argsize = sizeof(physdev_irq_status_query_t);
   5.123 +		break;
   5.124 +
   5.125 +	default:
   5.126 +		printk("%s: unknown physdev op %d\n", __func__, cmd);
   5.127 +		return -ENOSYS;
   5.128 +	}
   5.129 +	
   5.130  	return xencomm_arch_hypercall_physdev_op
   5.131 -		(cmd, xencomm_create_inline(op));
   5.132 +		(cmd, xencomm_map_no_alloc(op, argsize));
   5.133  }
   5.134  
   5.135 -static void *
   5.136 -xencommize_grant_table_op(unsigned int cmd, void *op, unsigned int count)
   5.137 +static int
   5.138 +xencommize_grant_table_op(struct xencomm_mini **xc_area,
   5.139 +			  unsigned int cmd, void *op, unsigned int count,
   5.140 +			  struct xencomm_handle **desc)
   5.141  {
   5.142 +	struct xencomm_handle *desc1;
   5.143 +	unsigned int argsize;
   5.144 +
   5.145  	switch (cmd) {
   5.146  	case GNTTABOP_map_grant_ref:
   5.147 +		argsize = sizeof(struct gnttab_map_grant_ref);
   5.148 +		break;
   5.149  	case GNTTABOP_unmap_grant_ref:
   5.150 +		argsize = sizeof(struct gnttab_unmap_grant_ref);
   5.151 +		break;
   5.152  	case GNTTABOP_unmap_and_replace:
   5.153 +		argsize = sizeof(struct gnttab_unmap_and_replace);
   5.154  		break;
   5.155  	case GNTTABOP_setup_table:
   5.156  	{
   5.157  		struct gnttab_setup_table *setup = op;
   5.158 -		struct xencomm_handle *frame_list;
   5.159  
   5.160 -		frame_list = xencomm_create_inline
   5.161 -			(xen_guest_handle(setup->frame_list));
   5.162 +		argsize = sizeof(*setup);
   5.163  
   5.164 -		set_xen_guest_handle(setup->frame_list, (void *)frame_list);
   5.165 +		if (count != 1)
   5.166 +			return -EINVAL;
   5.167 +		desc1 = __xencomm_map_no_alloc
   5.168 +			(xen_guest_handle(setup->frame_list),
   5.169 +			 setup->nr_frames *
   5.170 +			 sizeof(*xen_guest_handle(setup->frame_list)),
   5.171 +			 *xc_area);
   5.172 +		if (desc1 == NULL)
   5.173 +			return -EINVAL;
   5.174 +		(*xc_area)++;
   5.175 +		set_xen_guest_handle(setup->frame_list, (void *)desc1);
   5.176  		break;
   5.177  	}
   5.178  	case GNTTABOP_dump_table:
   5.179 +		argsize = sizeof(struct gnttab_dump_table);
   5.180 +		break;
   5.181  	case GNTTABOP_transfer:
   5.182 +		argsize = sizeof(struct gnttab_transfer);
   5.183 +		break;
   5.184  	case GNTTABOP_copy:
   5.185 +		argsize = sizeof(struct gnttab_copy);
   5.186 +		break;
   5.187 +	case GNTTABOP_query_size:
   5.188 +		argsize = sizeof(struct gnttab_query_size);
   5.189  		break;
   5.190  	default:
   5.191 -		printk("%s: unknown grant table op %d\n", __func__, cmd);
   5.192 +		printk("%s: unknown hypercall grant table op %d\n",
   5.193 +		       __func__, cmd);
   5.194  		BUG();
   5.195  	}
   5.196  
   5.197 -	return  xencomm_create_inline(op);
   5.198 +	*desc = __xencomm_map_no_alloc(op, count * argsize, *xc_area);
   5.199 +	if (*desc == NULL)
   5.200 +		return -EINVAL;
   5.201 +	(*xc_area)++;
   5.202 +
   5.203 +	return 0;
   5.204  }
   5.205  
   5.206  int
   5.207 -xencomm_hypercall_grant_table_op(unsigned int cmd, void *op, unsigned int count)
   5.208 +xencomm_hypercall_grant_table_op(unsigned int cmd, void *op,
   5.209 +                                      unsigned int count)
   5.210  {
   5.211 -	void *desc = xencommize_grant_table_op (cmd, op, count);
   5.212 +	int rc;
   5.213 +	struct xencomm_handle *desc;
   5.214 +	XENCOMM_MINI_ALIGNED(xc_area, 2);
   5.215 +
   5.216 +	rc = xencommize_grant_table_op(&xc_area, cmd, op, count, &desc);
   5.217 +	if (rc)
   5.218 +		return rc;
   5.219  
   5.220  	return xencomm_arch_hypercall_grant_table_op(cmd, desc, count);
   5.221  }
   5.222 +EXPORT_SYMBOL_GPL(xencomm_hypercall_grant_table_op);
   5.223  
   5.224  int
   5.225  xencomm_hypercall_sched_op(int cmd, void *arg)
   5.226  {
   5.227 +	struct xencomm_handle *desc;
   5.228 +	unsigned int argsize;
   5.229 +
   5.230  	switch (cmd) {
   5.231  	case SCHEDOP_yield:
   5.232  	case SCHEDOP_block:
   5.233 +		argsize = 0;
   5.234 +		break;
   5.235  	case SCHEDOP_shutdown:
   5.236 +		argsize = sizeof(sched_shutdown_t);
   5.237 +		break;
   5.238  	case SCHEDOP_remote_shutdown:
   5.239 +		argsize = sizeof(sched_remote_shutdown_t);
   5.240  		break;
   5.241  	case SCHEDOP_poll:
   5.242  	{
   5.243  		sched_poll_t *poll = arg;
   5.244  		struct xencomm_handle *ports;
   5.245  
   5.246 -		ports = xencomm_create_inline(xen_guest_handle(poll->ports));
   5.247 +		argsize = sizeof(sched_poll_t);
   5.248 +		ports = xencomm_map_no_alloc(xen_guest_handle(poll->ports),
   5.249 +				     sizeof(*xen_guest_handle(poll->ports)));
   5.250  
   5.251  		set_xen_guest_handle(poll->ports, (void *)ports);
   5.252  		break;
   5.253 @@ -162,14 +266,22 @@ xencomm_hypercall_sched_op(int cmd, void
   5.254  		return -ENOSYS;
   5.255  	}
   5.256  	
   5.257 -	return xencomm_arch_hypercall_sched_op(cmd, xencomm_create_inline(arg));
   5.258 +	desc = xencomm_map_no_alloc(arg, argsize);
   5.259 +	if (desc == NULL)
   5.260 +		return -EINVAL;
   5.261 +
   5.262 +	return xencomm_arch_hypercall_sched_op(cmd, desc);
   5.263  }
   5.264 +EXPORT_SYMBOL_GPL(xencomm_hypercall_sched_op);
   5.265  
   5.266  int
   5.267  xencomm_hypercall_multicall(void *call_list, int nr_calls)
   5.268  {
   5.269 +	int rc;
   5.270  	int i;
   5.271  	multicall_entry_t *mce;
   5.272 +	struct xencomm_handle *desc;
   5.273 +	XENCOMM_MINI_ALIGNED(xc_area, nr_calls * 2);
   5.274  
   5.275  	for (i = 0; i < nr_calls; i++) {
   5.276  		mce = (multicall_entry_t *)call_list + i;
   5.277 @@ -180,9 +292,13 @@ xencomm_hypercall_multicall(void *call_l
   5.278  			/* No-op on ia64.  */
   5.279  			break;
   5.280  		case __HYPERVISOR_grant_table_op:
   5.281 -			mce->args[1] = (unsigned long)xencommize_grant_table_op
   5.282 -				(mce->args[0], (void *)mce->args[1],
   5.283 -				 mce->args[2]);
   5.284 +			rc = xencommize_grant_table_op
   5.285 +				(&xc_area,
   5.286 +				 mce->args[0], (void *)mce->args[1],
   5.287 +				 mce->args[2], &desc);
   5.288 +			if (rc)
   5.289 +				return rc;
   5.290 +			mce->args[1] = (unsigned long)desc;
   5.291  			break;
   5.292  		case __HYPERVISOR_memory_op:
   5.293  		default:
   5.294 @@ -192,17 +308,26 @@ xencomm_hypercall_multicall(void *call_l
   5.295  		}
   5.296  	}
   5.297  
   5.298 -	return xencomm_arch_hypercall_multicall
   5.299 -		(xencomm_create_inline(call_list), nr_calls);
   5.300 +	desc = xencomm_map_no_alloc(call_list,
   5.301 +				    nr_calls * sizeof(multicall_entry_t));
   5.302 +	if (desc == NULL)
   5.303 +		return -EINVAL;
   5.304 +
   5.305 +	return xencomm_arch_hypercall_multicall(desc, nr_calls);
   5.306  }
   5.307 +EXPORT_SYMBOL_GPL(xencomm_hypercall_multicall);
   5.308  
   5.309  int
   5.310  xencomm_hypercall_callback_op(int cmd, void *arg)
   5.311  {
   5.312 +	unsigned int argsize;
   5.313  	switch (cmd)
   5.314  	{
   5.315  	case CALLBACKOP_register:
   5.316 +		argsize = sizeof(struct callback_register);
   5.317 +		break;
   5.318  	case CALLBACKOP_unregister:
   5.319 +		argsize = sizeof(struct callback_unregister);
   5.320  		break;
   5.321  	default:
   5.322  		printk("%s: unknown callback op %d\n", __func__, cmd);
   5.323 @@ -210,16 +335,24 @@ xencomm_hypercall_callback_op(int cmd, v
   5.324  	}
   5.325  
   5.326  	return xencomm_arch_hypercall_callback_op
   5.327 -		(cmd, xencomm_create_inline(arg));
   5.328 +		(cmd, xencomm_map_no_alloc(arg, argsize));
   5.329  }
   5.330  
   5.331 -static void
   5.332 -xencommize_memory_reservation (xen_memory_reservation_t *mop)
   5.333 +static int
   5.334 +xencommize_memory_reservation(struct xencomm_mini *xc_area,
   5.335 +			      xen_memory_reservation_t *mop)
   5.336  {
   5.337  	struct xencomm_handle *desc;
   5.338  
   5.339 -	desc = xencomm_create_inline(xen_guest_handle(mop->extent_start));
   5.340 +	desc = __xencomm_map_no_alloc(xen_guest_handle(mop->extent_start),
   5.341 +			mop->nr_extents *
   5.342 +			sizeof(*xen_guest_handle(mop->extent_start)),
   5.343 +			xc_area);
   5.344 +	if (desc == NULL)
   5.345 +		return -EINVAL;
   5.346 +
   5.347  	set_xen_guest_handle(mop->extent_start, (void *)desc);
   5.348 +	return 0;
   5.349  }
   5.350  
   5.351  int
   5.352 @@ -230,39 +363,61 @@ xencomm_hypercall_memory_op(unsigned int
   5.353  	xen_memory_map_t *memmap = NULL;
   5.354  	XEN_GUEST_HANDLE(void) buffer;
   5.355  	int rc;
   5.356 +	struct xencomm_handle *desc;
   5.357 +	unsigned int argsize;
   5.358 +	XENCOMM_MINI_ALIGNED(xc_area, 2);
   5.359  
   5.360  	switch (cmd) {
   5.361  	case XENMEM_increase_reservation:
   5.362  	case XENMEM_decrease_reservation:
   5.363  	case XENMEM_populate_physmap:
   5.364  		xmr = (xen_memory_reservation_t *)arg;
   5.365 -		xen_guest_handle(extent_start_va[0]) =
   5.366 -			xen_guest_handle(xmr->extent_start);
   5.367 -		xencommize_memory_reservation((xen_memory_reservation_t *)arg);
   5.368 +		set_xen_guest_handle(extent_start_va[0],
   5.369 +				     xen_guest_handle(xmr->extent_start));
   5.370 +
   5.371 +		argsize = sizeof(*xmr);
   5.372 +		rc = xencommize_memory_reservation(xc_area, xmr);
   5.373 +		if (rc)
   5.374 +			return rc;
   5.375 +		xc_area++;
   5.376  		break;
   5.377  		
   5.378  	case XENMEM_maximum_ram_page:
   5.379 +		argsize = 0;
   5.380  		break;
   5.381  
   5.382  	case XENMEM_exchange:
   5.383  		xme_in  = &((xen_memory_exchange_t *)arg)->in;
   5.384  		xme_out = &((xen_memory_exchange_t *)arg)->out;
   5.385 -		xen_guest_handle(extent_start_va[0]) =
   5.386 -			xen_guest_handle(xme_in->extent_start);
   5.387 -		xen_guest_handle(extent_start_va[1]) =
   5.388 -			xen_guest_handle(xme_out->extent_start);
   5.389 -		xencommize_memory_reservation
   5.390 -			(&((xen_memory_exchange_t *)arg)->in);
   5.391 -		xencommize_memory_reservation
   5.392 -			(&((xen_memory_exchange_t *)arg)->out);
   5.393 +		set_xen_guest_handle(extent_start_va[0],
   5.394 +				     xen_guest_handle(xme_in->extent_start));
   5.395 +		set_xen_guest_handle(extent_start_va[1],
   5.396 +				     xen_guest_handle(xme_out->extent_start));
   5.397 +
   5.398 +		argsize = sizeof(xen_memory_exchange_t);
   5.399 +		rc = xencommize_memory_reservation(xc_area, xme_in);
   5.400 +		if (rc)
   5.401 +			return rc;
   5.402 +		xc_area++;
   5.403 +		rc = xencommize_memory_reservation(xc_area, xme_out);
   5.404 +		if (rc)
   5.405 +			return rc;
   5.406 +		xc_area++;
   5.407 +		break;
   5.408 +
   5.409 +	case XENMEM_add_to_physmap:
   5.410 +		argsize = sizeof(xen_add_to_physmap_t);
   5.411  		break;
   5.412  
   5.413  	case XENMEM_machine_memory_map:
   5.414 +		argsize = sizeof(*memmap);
   5.415  		memmap = (xen_memory_map_t *)arg;
   5.416 -		xen_guest_handle(buffer) = xen_guest_handle(memmap->buffer);
   5.417 -		set_xen_guest_handle(memmap->buffer,
   5.418 -			(void *)xencomm_create_inline(
   5.419 -				xen_guest_handle(memmap->buffer)));
   5.420 +		set_xen_guest_handle(buffer, xen_guest_handle(memmap->buffer));
   5.421 +		desc = xencomm_map_no_alloc(xen_guest_handle(memmap->buffer),
   5.422 +					      memmap->nr_entries);
   5.423 +		if (desc == NULL)
   5.424 +			return -EINVAL;
   5.425 +		set_xen_guest_handle(memmap->buffer, (void *)desc);
   5.426  		break;
   5.427  
   5.428  	default:
   5.429 @@ -270,45 +425,59 @@ xencomm_hypercall_memory_op(unsigned int
   5.430  		return -ENOSYS;
   5.431  	}
   5.432  
   5.433 -	rc =  xencomm_arch_hypercall_memory_op(cmd, xencomm_create_inline(arg));
   5.434 +	desc = xencomm_map_no_alloc(arg, argsize);
   5.435 +	if (desc == NULL)
   5.436 +		return -EINVAL;
   5.437 +
   5.438 +	rc = xencomm_arch_hypercall_memory_op(cmd, desc);
   5.439  
   5.440  	switch (cmd) {
   5.441  	case XENMEM_increase_reservation:
   5.442  	case XENMEM_decrease_reservation:
   5.443  	case XENMEM_populate_physmap:
   5.444 -		xen_guest_handle(xmr->extent_start) =
   5.445 -			xen_guest_handle(extent_start_va[0]);
   5.446 +		set_xen_guest_handle(xmr->extent_start,
   5.447 +				     xen_guest_handle(extent_start_va[0]));
   5.448  		break;
   5.449  
   5.450  	case XENMEM_exchange:
   5.451 -		xen_guest_handle(xme_in->extent_start) =
   5.452 -			xen_guest_handle(extent_start_va[0]);
   5.453 -		xen_guest_handle(xme_out->extent_start) =
   5.454 -			xen_guest_handle(extent_start_va[1]);
   5.455 +		set_xen_guest_handle(xme_in->extent_start,
   5.456 +				     xen_guest_handle(extent_start_va[0]));
   5.457 +		set_xen_guest_handle(xme_out->extent_start,
   5.458 +				     xen_guest_handle(extent_start_va[1]));
   5.459  		break;
   5.460  
   5.461  	case XENMEM_machine_memory_map:
   5.462 -		xen_guest_handle(memmap->buffer) = xen_guest_handle(buffer);
   5.463 +		set_xen_guest_handle(memmap->buffer, xen_guest_handle(buffer));
   5.464  		break;
   5.465  	}
   5.466  
   5.467  	return rc;
   5.468  }
   5.469 +EXPORT_SYMBOL_GPL(xencomm_hypercall_memory_op);
   5.470  
   5.471  unsigned long
   5.472  xencomm_hypercall_hvm_op(int cmd, void *arg)
   5.473  {
   5.474 +	struct xencomm_handle *desc;
   5.475 +	unsigned int argsize;
   5.476 +
   5.477  	switch (cmd) {
   5.478 +	case HVMOP_get_param:
   5.479  	case HVMOP_set_param:
   5.480 -	case HVMOP_get_param:
   5.481 +		argsize = sizeof(xen_hvm_param_t);
   5.482  		break;
   5.483  	default:
   5.484 -		printk("%s: unknown hvm op %d\n", __func__, cmd);
   5.485 -		return -ENOSYS;
   5.486 +		printk("%s: unknown HVMOP %d\n", __func__, cmd);
   5.487 +		return -EINVAL;
   5.488  	}
   5.489  
   5.490 -	return xencomm_arch_hypercall_hvm_op(cmd, xencomm_create_inline(arg));
   5.491 +	desc = xencomm_map_no_alloc(arg, argsize);
   5.492 +	if (desc == NULL)
   5.493 +		return -EINVAL;
   5.494 +
   5.495 +	return xencomm_arch_hypercall_hvm_op(cmd, desc);
   5.496  }
   5.497 +EXPORT_SYMBOL_GPL(xencomm_hypercall_hvm_op);
   5.498  
   5.499  int
   5.500  xencomm_hypercall_suspend(unsigned long srec)
   5.501 @@ -317,18 +486,31 @@ xencomm_hypercall_suspend(unsigned long 
   5.502  
   5.503  	arg.reason = SHUTDOWN_suspend;
   5.504  
   5.505 -	return xencomm_arch_hypercall_suspend(xencomm_create_inline(&arg));
   5.506 +	return xencomm_arch_hypercall_suspend(
   5.507 +		xencomm_map_no_alloc(&arg, sizeof(arg)));
   5.508  }
   5.509  
   5.510  int
   5.511  xencomm_hypercall_xenoprof_op(int op, void *arg)
   5.512  {
   5.513 +	unsigned int argsize;
   5.514 +	struct xencomm_handle *desc;
   5.515 +
   5.516  	switch (op) {
   5.517  	case XENOPROF_init:
   5.518 +		argsize = sizeof(xenoprof_init_t);
   5.519 +		break;
   5.520  	case XENOPROF_set_active:
   5.521 +		argsize = sizeof(domid_t);
   5.522 +		break;
   5.523  	case XENOPROF_set_passive:
   5.524 +		argsize = sizeof(xenoprof_passive_t);
   5.525 +		break;
   5.526  	case XENOPROF_counter:
   5.527 +		argsize = sizeof(xenoprof_counter_t);
   5.528 +		break;
   5.529  	case XENOPROF_get_buffer:
   5.530 +		argsize = sizeof(xenoprof_get_buffer_t);
   5.531  		break;
   5.532  
   5.533  	case XENOPROF_reset_active_list:
   5.534 @@ -342,25 +524,40 @@ xencomm_hypercall_xenoprof_op(int op, vo
   5.535  	case XENOPROF_release_counters:
   5.536  	case XENOPROF_shutdown:
   5.537  		return xencomm_arch_hypercall_xenoprof_op(op, arg);
   5.538 -		break;
   5.539  
   5.540  	default:
   5.541  		printk("%s: op %d isn't supported\n", __func__, op);
   5.542  		return -ENOSYS;
   5.543  	}
   5.544 -	return xencomm_arch_hypercall_xenoprof_op(op,
   5.545 -						  xencomm_create_inline(arg));
   5.546 +
   5.547 +	desc = xencomm_map_no_alloc(arg, argsize);
   5.548 +	if (desc == NULL)
   5.549 +		return -EINVAL;
   5.550 +
   5.551 +	return xencomm_arch_hypercall_xenoprof_op(op, desc);
   5.552  }
   5.553 +EXPORT_SYMBOL_GPL(xencomm_hypercall_xenoprof_op);
   5.554  
   5.555  int
   5.556 -xencomm_hypercall_perfmon_op(unsigned long cmd, void* arg, unsigned long count)
   5.557 +xencomm_hypercall_perfmon_op(unsigned long cmd, void* arg,
   5.558 +                                  unsigned long count)
   5.559  {
   5.560 +	unsigned int argsize;
   5.561 +	struct xencomm_handle *desc;
   5.562 +
   5.563  	switch (cmd) {
   5.564  	case PFM_GET_FEATURES:
   5.565 +		argsize = sizeof(pfarg_features_t);
   5.566 +		break;
   5.567  	case PFM_CREATE_CONTEXT:
   5.568 +		argsize = sizeof(pfarg_context_t);
   5.569 +		break;
   5.570 +	case PFM_LOAD_CONTEXT:
   5.571 +		argsize = sizeof(pfarg_load_t);
   5.572 +		break;
   5.573  	case PFM_WRITE_PMCS:
   5.574  	case PFM_WRITE_PMDS:
   5.575 -	case PFM_LOAD_CONTEXT:
   5.576 +		argsize = sizeof(pfarg_reg_t) * count;
   5.577  		break;
   5.578  
   5.579  	case PFM_DESTROY_CONTEXT:
   5.580 @@ -371,22 +568,32 @@ xencomm_hypercall_perfmon_op(unsigned lo
   5.581  
   5.582  	default:
   5.583  		printk("%s:%d cmd %ld isn't supported\n",
   5.584 -		       __func__,__LINE__, cmd);
   5.585 +		       __func__, __LINE__, cmd);
   5.586  		BUG();
   5.587  	}
   5.588  
   5.589 -	return xencomm_arch_hypercall_perfmon_op(cmd,
   5.590 -	                                         xencomm_create_inline(arg),
   5.591 -	                                         count);
   5.592 +	desc = xencomm_map_no_alloc(arg, argsize);
   5.593 +	if (desc == NULL)
   5.594 +		return -EINVAL;
   5.595 +
   5.596 +	return xencomm_arch_hypercall_perfmon_op(cmd, desc, count);
   5.597  }
   5.598 +EXPORT_SYMBOL_GPL(xencomm_hypercall_perfmon_op);
   5.599  
   5.600  long
   5.601  xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg)
   5.602  {
   5.603 +	unsigned int argsize;
   5.604  	switch (cmd) {
   5.605 -	case VCPUOP_register_runstate_memory_area:
   5.606 -		xencommize_memory_reservation((xen_memory_reservation_t *)arg);
   5.607 +	case VCPUOP_register_runstate_memory_area: {
   5.608 +		vcpu_register_runstate_memory_area_t *area =
   5.609 +			(vcpu_register_runstate_memory_area_t *)arg;
   5.610 +		argsize = sizeof(*arg);
   5.611 +		set_xen_guest_handle(area->addr.h,
   5.612 +		     (void *)xencomm_map_no_alloc(area->addr.v,
   5.613 +						  sizeof(area->addr.v)));
   5.614  		break;
   5.615 +	}
   5.616  
   5.617  	default:
   5.618  		printk("%s: unknown vcpu op %d\n", __func__, cmd);
   5.619 @@ -394,18 +601,26 @@ xencomm_hypercall_vcpu_op(int cmd, int c
   5.620  	}
   5.621  
   5.622  	return xencomm_arch_hypercall_vcpu_op(cmd, cpu,
   5.623 -					      xencomm_create_inline(arg));
   5.624 +					xencomm_map_no_alloc(arg, argsize));
   5.625  }
   5.626  
   5.627  long
   5.628  xencomm_hypercall_opt_feature(void *arg)
   5.629  {
   5.630 -	return xencomm_arch_hypercall_opt_feature(xencomm_create_inline(arg));
   5.631 +	return xencomm_arch_hypercall_opt_feature(
   5.632 +		xencomm_map_no_alloc(arg,
   5.633 +				     sizeof(struct xen_ia64_opt_feature)));
   5.634  }
   5.635  
   5.636  int
   5.637  xencomm_hypercall_fpswa_revision(unsigned int *revision)
   5.638  {
   5.639 -	return xencomm_arch_hypercall_fpswa_revision(
   5.640 -		xencomm_create_inline(revision));
   5.641 +	struct xencomm_handle *desc;
   5.642 +
   5.643 +	desc = xencomm_map_no_alloc(revision, sizeof(*revision));
   5.644 +	if (desc == NULL)
   5.645 +		return -EINVAL;
   5.646 +
   5.647 +	return xencomm_arch_hypercall_fpswa_revision(desc);
   5.648  }
   5.649 +EXPORT_SYMBOL_GPL(xencomm_hypercall_fpswa_revision);
     6.1 --- a/arch/ia64/xen/xcom_mini.c	Thu Aug 16 10:58:46 2007 -0600
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,488 +0,0 @@
     6.4 -/*
     6.5 - * This program is free software; you can redistribute it and/or modify
     6.6 - * it under the terms of the GNU General Public License as published by
     6.7 - * the Free Software Foundation; either version 2 of the License, or
     6.8 - * (at your option) any later version.
     6.9 - *
    6.10 - * This program is distributed in the hope that it will be useful,
    6.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.13 - * GNU General Public License for more details.
    6.14 - *
    6.15 - * You should have received a copy of the GNU General Public License
    6.16 - * along with this program; if not, write to the Free Software
    6.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    6.18 - *
    6.19 - *          Tristan Gingold <tristan.gingold@bull.net>
    6.20 - */
    6.21 -#include <linux/types.h>
    6.22 -#include <linux/errno.h>
    6.23 -#include <linux/kernel.h>
    6.24 -#include <linux/module.h>
    6.25 -#include <xen/interface/xen.h>
    6.26 -#include <xen/interface/platform.h>
    6.27 -#include <xen/interface/memory.h>
    6.28 -#include <xen/interface/xencomm.h>
    6.29 -#include <xen/interface/version.h>
    6.30 -#include <xen/interface/event_channel.h>
    6.31 -#include <xen/interface/physdev.h>
    6.32 -#include <xen/interface/grant_table.h>
    6.33 -#include <xen/interface/hvm/params.h>
    6.34 -#include <xen/interface/xenoprof.h>
    6.35 -#ifdef CONFIG_VMX_GUEST
    6.36 -#include <asm/hypervisor.h>
    6.37 -#else
    6.38 -#include <asm/hypercall.h>
    6.39 -#endif
    6.40 -#include <asm/xen/xencomm.h>
    6.41 -#include <asm/perfmon.h>
    6.42 -
    6.43 -int
    6.44 -xencomm_mini_hypercall_event_channel_op(int cmd, void *op)
    6.45 -{
    6.46 -	struct xencomm_mini xc_area[2];
    6.47 -	int nbr_area = 2;
    6.48 -	struct xencomm_handle *desc;
    6.49 -	int rc;
    6.50 -
    6.51 -	rc = xencomm_create_mini(xc_area, &nbr_area,
    6.52 -	                         op, sizeof(evtchn_op_t), &desc);
    6.53 -	if (rc)
    6.54 -		return rc;
    6.55 -
    6.56 -	return xencomm_arch_hypercall_event_channel_op(cmd, desc);
    6.57 -}
    6.58 -EXPORT_SYMBOL(xencomm_mini_hypercall_event_channel_op);
    6.59 -
    6.60 -static int
    6.61 -xencommize_mini_grant_table_op(struct xencomm_mini *xc_area, int *nbr_area,
    6.62 -                               unsigned int cmd, void *op, unsigned int count,
    6.63 -                               struct xencomm_handle **desc)
    6.64 -{
    6.65 -	struct xencomm_handle *desc1;
    6.66 -	unsigned int argsize;
    6.67 -	int rc;
    6.68 -
    6.69 -	switch (cmd) {
    6.70 -	case GNTTABOP_map_grant_ref:
    6.71 -		argsize = sizeof(struct gnttab_map_grant_ref);
    6.72 -		break;
    6.73 -	case GNTTABOP_unmap_grant_ref:
    6.74 -		argsize = sizeof(struct gnttab_unmap_grant_ref);
    6.75 -		break;
    6.76 -	case GNTTABOP_unmap_and_replace:
    6.77 -		argsize = sizeof(struct gnttab_unmap_and_replace);
    6.78 -		break;
    6.79 -	case GNTTABOP_setup_table:
    6.80 -	{
    6.81 -		struct gnttab_setup_table *setup = op;
    6.82 -
    6.83 -		argsize = sizeof(*setup);
    6.84 -
    6.85 -		if (count != 1)
    6.86 -			return -EINVAL;
    6.87 -		rc = xencomm_create_mini
    6.88 -			(xc_area, nbr_area,
    6.89 -			 xen_guest_handle(setup->frame_list),
    6.90 -			 setup->nr_frames 
    6.91 -			 * sizeof(*xen_guest_handle(setup->frame_list)),
    6.92 -			 &desc1);
    6.93 -		if (rc)
    6.94 -			return rc;
    6.95 -		set_xen_guest_handle(setup->frame_list, (void *)desc1);
    6.96 -		break;
    6.97 -	}
    6.98 -	case GNTTABOP_dump_table:
    6.99 -		argsize = sizeof(struct gnttab_dump_table);
   6.100 -		break;
   6.101 -	case GNTTABOP_transfer:
   6.102 -		argsize = sizeof(struct gnttab_transfer);
   6.103 -		break;
   6.104 -	case GNTTABOP_copy:
   6.105 -		argsize = sizeof(struct gnttab_copy);
   6.106 -		break;
   6.107 -	case GNTTABOP_query_size:
   6.108 -		argsize = sizeof(struct gnttab_query_size);
   6.109 -		break;
   6.110 -	default:
   6.111 -		printk("%s: unknown mini grant table op %d\n", __func__, cmd);
   6.112 -		BUG();
   6.113 -	}
   6.114 -
   6.115 -	rc = xencomm_create_mini(xc_area, nbr_area, op, count * argsize, desc);
   6.116 -	if (rc)
   6.117 -		return rc;
   6.118 -
   6.119 -	return 0;
   6.120 -}
   6.121 -
   6.122 -int
   6.123 -xencomm_mini_hypercall_grant_table_op(unsigned int cmd, void *op,
   6.124 -                                      unsigned int count)
   6.125 -{
   6.126 -	int rc;
   6.127 -	struct xencomm_handle *desc;
   6.128 -	int nbr_area = 2;
   6.129 -	struct xencomm_mini xc_area[2];
   6.130 -
   6.131 -	rc = xencommize_mini_grant_table_op(xc_area, &nbr_area,
   6.132 -	                                    cmd, op, count, &desc);
   6.133 -	if (rc)
   6.134 -		return rc;
   6.135 -
   6.136 -	return xencomm_arch_hypercall_grant_table_op(cmd, desc, count);
   6.137 -}
   6.138 -EXPORT_SYMBOL(xencomm_mini_hypercall_grant_table_op);
   6.139 -
   6.140 -int
   6.141 -xencomm_mini_hypercall_multicall(void *call_list, int nr_calls)
   6.142 -{
   6.143 -	int i;
   6.144 -	multicall_entry_t *mce;
   6.145 -	int nbr_area = 2 + nr_calls * 3;
   6.146 -	struct xencomm_mini xc_area[nbr_area];
   6.147 -	struct xencomm_handle *desc;
   6.148 -	int rc;
   6.149 -
   6.150 -	for (i = 0; i < nr_calls; i++) {
   6.151 -		mce = (multicall_entry_t *)call_list + i;
   6.152 -
   6.153 -		switch (mce->op) {
   6.154 -		case __HYPERVISOR_update_va_mapping:
   6.155 -		case __HYPERVISOR_mmu_update:
   6.156 -			/* No-op on ia64.  */
   6.157 -			break;
   6.158 -		case __HYPERVISOR_grant_table_op:
   6.159 -			rc = xencommize_mini_grant_table_op
   6.160 -				(xc_area, &nbr_area,
   6.161 -				 mce->args[0], (void *)mce->args[1],
   6.162 -				 mce->args[2], &desc);
   6.163 -			if (rc)
   6.164 -				return rc;
   6.165 -			mce->args[1] = (unsigned long)desc;
   6.166 -			break;
   6.167 -		case __HYPERVISOR_memory_op:
   6.168 -		default:
   6.169 -			printk("%s: unhandled multicall op entry op %lu\n",
   6.170 -			       __func__, mce->op);
   6.171 -			return -ENOSYS;
   6.172 -		}
   6.173 -	}
   6.174 -
   6.175 -	rc = xencomm_create_mini(xc_area, &nbr_area, call_list,
   6.176 -	                         nr_calls * sizeof(multicall_entry_t), &desc);
   6.177 -	if (rc)
   6.178 -		return rc;
   6.179 -
   6.180 -	return xencomm_arch_hypercall_multicall(desc, nr_calls);
   6.181 -}
   6.182 -EXPORT_SYMBOL(xencomm_mini_hypercall_multicall);
   6.183 -
   6.184 -static int
   6.185 -xencommize_mini_memory_reservation(struct xencomm_mini *area, int *nbr_area,
   6.186 -                                   xen_memory_reservation_t *mop)
   6.187 -{
   6.188 -	struct xencomm_handle *desc;
   6.189 -	int rc;
   6.190 -
   6.191 -	rc = xencomm_create_mini
   6.192 -		(area, nbr_area,
   6.193 -		 xen_guest_handle(mop->extent_start),
   6.194 -		 mop->nr_extents 
   6.195 -		 * sizeof(*xen_guest_handle(mop->extent_start)),
   6.196 -		 &desc);
   6.197 -	if (rc)
   6.198 -		return rc;
   6.199 -
   6.200 -	set_xen_guest_handle(mop->extent_start, (void *)desc);
   6.201 -
   6.202 -	return 0;
   6.203 -}
   6.204 -
   6.205 -int
   6.206 -xencomm_mini_hypercall_memory_op(unsigned int cmd, void *arg)
   6.207 -{
   6.208 -	int nbr_area = 4;
   6.209 -	struct xencomm_mini xc_area[4];
   6.210 -	struct xencomm_handle *desc;
   6.211 -	int rc;
   6.212 -	unsigned int argsize;
   6.213 -
   6.214 -	switch (cmd) {
   6.215 -	case XENMEM_increase_reservation:
   6.216 -	case XENMEM_decrease_reservation:
   6.217 -	case XENMEM_populate_physmap:
   6.218 -		argsize = sizeof(xen_memory_reservation_t);
   6.219 -		rc = xencommize_mini_memory_reservation
   6.220 -			(xc_area, &nbr_area, (xen_memory_reservation_t *)arg);
   6.221 -		if (rc)
   6.222 -			return rc;
   6.223 -		break;
   6.224 -		
   6.225 -	case XENMEM_maximum_ram_page:
   6.226 -		argsize = 0;
   6.227 -		break;
   6.228 -
   6.229 -	case XENMEM_exchange:
   6.230 -		argsize = sizeof(xen_memory_exchange_t);
   6.231 -		rc = xencommize_mini_memory_reservation
   6.232 -			(xc_area, &nbr_area,
   6.233 -			 &((xen_memory_exchange_t *)arg)->in);
   6.234 -		if (rc)
   6.235 -			return rc;
   6.236 -		rc = xencommize_mini_memory_reservation
   6.237 -			(xc_area, &nbr_area,
   6.238 -			 &((xen_memory_exchange_t *)arg)->out);
   6.239 -		if (rc)
   6.240 -			return rc;
   6.241 -		break;
   6.242 -
   6.243 -	case XENMEM_add_to_physmap:
   6.244 -		argsize = sizeof (xen_add_to_physmap_t);
   6.245 -		break;
   6.246 -
   6.247 -	case XENMEM_machine_memory_map:
   6.248 -	{
   6.249 -		xen_memory_map_t *memmap = (xen_memory_map_t *)arg;
   6.250 -		argsize = sizeof(*memmap);
   6.251 -		rc = xencomm_create_mini(xc_area, &nbr_area,
   6.252 -					 xen_guest_handle(memmap->buffer),
   6.253 -					 memmap->nr_entries, &desc);
   6.254 -		if (rc)
   6.255 -			return rc;
   6.256 -		set_xen_guest_handle(memmap->buffer, (void *)desc);
   6.257 -		break;
   6.258 -	}
   6.259 -
   6.260 -	default:
   6.261 -		printk("%s: unknown mini memory op %d\n", __func__, cmd);
   6.262 -		return -ENOSYS;
   6.263 -	}
   6.264 -
   6.265 -	rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
   6.266 -	if (rc)
   6.267 -		return rc;
   6.268 -
   6.269 -	return xencomm_arch_hypercall_memory_op(cmd, desc);
   6.270 -}
   6.271 -EXPORT_SYMBOL(xencomm_mini_hypercall_memory_op);
   6.272 -
   6.273 -unsigned long
   6.274 -xencomm_mini_hypercall_hvm_op(int cmd, void *arg)
   6.275 -{
   6.276 -	struct xencomm_handle *desc;
   6.277 -	int nbr_area = 2;
   6.278 -	struct xencomm_mini xc_area[2];
   6.279 -	unsigned int argsize;
   6.280 -	int rc;
   6.281 -
   6.282 -	switch (cmd) {
   6.283 -	case HVMOP_get_param:
   6.284 -	case HVMOP_set_param:
   6.285 -		argsize = sizeof(xen_hvm_param_t);
   6.286 -		break;
   6.287 -	default:
   6.288 -		printk("%s: unknown HVMOP %d\n", __func__, cmd);
   6.289 -		return -EINVAL;
   6.290 -	}
   6.291 -
   6.292 -	rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
   6.293 -	if (rc)
   6.294 -		return rc;
   6.295 -
   6.296 -	return xencomm_arch_hypercall_hvm_op(cmd, desc);
   6.297 -}
   6.298 -EXPORT_SYMBOL(xencomm_mini_hypercall_hvm_op);
   6.299 -
   6.300 -int
   6.301 -xencomm_mini_hypercall_xen_version(int cmd, void *arg)
   6.302 -{
   6.303 -	struct xencomm_handle *desc;
   6.304 -	int nbr_area = 2;
   6.305 -	struct xencomm_mini xc_area[2];
   6.306 -	unsigned int argsize;
   6.307 -	int rc;
   6.308 -
   6.309 -	switch (cmd) {
   6.310 -	case XENVER_version:
   6.311 -		/* do not actually pass an argument */
   6.312 -		return xencomm_arch_hypercall_xen_version(cmd, 0);
   6.313 -	case XENVER_extraversion:
   6.314 -		argsize = sizeof(xen_extraversion_t);
   6.315 -		break;
   6.316 -	case XENVER_compile_info:
   6.317 -		argsize = sizeof(xen_compile_info_t);
   6.318 -		break;
   6.319 -	case XENVER_capabilities:
   6.320 -		argsize = sizeof(xen_capabilities_info_t);
   6.321 -		break;
   6.322 -	case XENVER_changeset:
   6.323 -		argsize = sizeof(xen_changeset_info_t);
   6.324 -		break;
   6.325 -	case XENVER_platform_parameters:
   6.326 -		argsize = sizeof(xen_platform_parameters_t);
   6.327 -		break;
   6.328 -	case XENVER_pagesize:
   6.329 -		argsize = (arg == NULL) ? 0 : sizeof(void *);
   6.330 -		break;
   6.331 -	case XENVER_get_features:
   6.332 -		argsize = (arg == NULL) ? 0 : sizeof(xen_feature_info_t);
   6.333 -		break;
   6.334 -
   6.335 -	default:
   6.336 -		printk("%s: unknown version op %d\n", __func__, cmd);
   6.337 -		return -ENOSYS;
   6.338 -	}
   6.339 -
   6.340 -	rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
   6.341 -	if (rc)
   6.342 -		return rc;
   6.343 -
   6.344 -	return xencomm_arch_hypercall_xen_version(cmd, desc);
   6.345 -}
   6.346 -EXPORT_SYMBOL(xencomm_mini_hypercall_xen_version);
   6.347 -
   6.348 -int
   6.349 -xencomm_mini_hypercall_xenoprof_op(int op, void *arg)
   6.350 -{
   6.351 -	unsigned int argsize;
   6.352 -	struct xencomm_mini xc_area[2];
   6.353 -	int nbr_area = 2;
   6.354 -	struct xencomm_handle *desc;
   6.355 -	int rc;
   6.356 -
   6.357 -	switch (op) {
   6.358 -	case XENOPROF_init:
   6.359 -		argsize = sizeof(xenoprof_init_t);
   6.360 -		break;
   6.361 -	case XENOPROF_set_active:
   6.362 -		argsize = sizeof(domid_t);
   6.363 -		break;
   6.364 -	case XENOPROF_set_passive:
   6.365 -		argsize = sizeof(xenoprof_passive_t);
   6.366 -		break;
   6.367 -	case XENOPROF_counter:
   6.368 -		argsize = sizeof(xenoprof_counter_t);
   6.369 -		break;
   6.370 -	case XENOPROF_get_buffer:
   6.371 -		argsize = sizeof(xenoprof_get_buffer_t);
   6.372 -		break;
   6.373 -
   6.374 -	case XENOPROF_reset_active_list:
   6.375 -	case XENOPROF_reset_passive_list:
   6.376 -	case XENOPROF_reserve_counters:
   6.377 -	case XENOPROF_setup_events:
   6.378 -	case XENOPROF_enable_virq:
   6.379 -	case XENOPROF_start:
   6.380 -	case XENOPROF_stop:
   6.381 -	case XENOPROF_disable_virq:
   6.382 -	case XENOPROF_release_counters:
   6.383 -	case XENOPROF_shutdown:
   6.384 -		return xencomm_arch_hypercall_xenoprof_op(op, arg);
   6.385 -
   6.386 -	default:
   6.387 -		printk("%s: op %d isn't supported\n", __func__, op);
   6.388 -		return -ENOSYS;
   6.389 -	}
   6.390 -	rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
   6.391 -	if (rc)
   6.392 -		return rc;
   6.393 -	return xencomm_arch_hypercall_xenoprof_op(op, desc);
   6.394 -}
   6.395 -EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_xenoprof_op);
   6.396 -
   6.397 -int
   6.398 -xencomm_mini_hypercall_perfmon_op(unsigned long cmd, void* arg,
   6.399 -                                  unsigned long count)
   6.400 -{
   6.401 -	unsigned int argsize;
   6.402 -	struct xencomm_mini xc_area[2];
   6.403 -	int nbr_area = 2;
   6.404 -	struct xencomm_handle *desc;
   6.405 -	int rc;
   6.406 -
   6.407 -	switch (cmd) {
   6.408 -	case PFM_GET_FEATURES:
   6.409 -		argsize = sizeof(pfarg_features_t);
   6.410 -		break;
   6.411 -	case PFM_CREATE_CONTEXT:
   6.412 -		argsize = sizeof(pfarg_context_t);
   6.413 -		break;
   6.414 -	case PFM_LOAD_CONTEXT:
   6.415 -		argsize = sizeof(pfarg_load_t);
   6.416 -		break;
   6.417 -	case PFM_WRITE_PMCS:
   6.418 -	case PFM_WRITE_PMDS:
   6.419 -		argsize = sizeof(pfarg_reg_t) * count;
   6.420 -		break;
   6.421 -
   6.422 -	case PFM_DESTROY_CONTEXT:
   6.423 -	case PFM_UNLOAD_CONTEXT:
   6.424 -	case PFM_START:
   6.425 -	case PFM_STOP:
   6.426 -		return xencomm_arch_hypercall_perfmon_op(cmd, arg, count);
   6.427 -
   6.428 -	default:
   6.429 -		printk("%s:%d cmd %ld isn't supported\n",
   6.430 -		       __func__, __LINE__, cmd);
   6.431 -		BUG();
   6.432 -	}
   6.433 -
   6.434 -	rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
   6.435 -	if (rc)
   6.436 -		return rc;
   6.437 -	return xencomm_arch_hypercall_perfmon_op(cmd, desc, count);
   6.438 -}
   6.439 -EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_perfmon_op);
   6.440 -
   6.441 -int
   6.442 -xencomm_mini_hypercall_sched_op(int cmd, void *arg)
   6.443 -{
   6.444 -	int rc, nbr_area = 2;
   6.445 -	struct xencomm_mini xc_area[2];
   6.446 -	struct xencomm_handle *desc;
   6.447 -	unsigned int argsize;
   6.448 -
   6.449 -	switch (cmd) {
   6.450 -	case SCHEDOP_yield:
   6.451 -	case SCHEDOP_block:
   6.452 -		argsize = 0;
   6.453 -		break;
   6.454 -	case SCHEDOP_shutdown:
   6.455 -		argsize = sizeof(sched_shutdown_t);
   6.456 -		break;
   6.457 -	case SCHEDOP_poll:
   6.458 -		argsize = sizeof(sched_poll_t);
   6.459 -		break;
   6.460 -	case SCHEDOP_remote_shutdown:
   6.461 -		argsize = sizeof(sched_remote_shutdown_t);
   6.462 -		break;
   6.463 -
   6.464 -	default:
   6.465 -		printk("%s: unknown sched op %d\n", __func__, cmd);
   6.466 -		return -ENOSYS;
   6.467 -	}
   6.468 -
   6.469 -	rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
   6.470 -	if (rc)
   6.471 -		return rc;
   6.472 -
   6.473 -	return xencomm_arch_hypercall_sched_op(cmd, desc);
   6.474 -}
   6.475 -EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_sched_op);
   6.476 -
   6.477 -int
   6.478 -xencomm_mini_hypercall_fpswa_revision(unsigned int *revision)
   6.479 -{
   6.480 -	int nbr_area = 2;
   6.481 -	struct xencomm_mini xc_area[2];
   6.482 -	struct xencomm_handle *desc;
   6.483 -	int rc;
   6.484 -
   6.485 -	rc = xencomm_create_mini(xc_area, &nbr_area,
   6.486 -				 revision, sizeof(*revision), &desc);
   6.487 -	if (rc)
   6.488 -		return rc;
   6.489 -	return xencomm_arch_hypercall_fpswa_revision(desc);
   6.490 -}
   6.491 -EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_fpswa_revision);
     7.1 --- a/arch/ia64/xen/xcom_privcmd.c	Thu Aug 16 10:58:46 2007 -0600
     7.2 +++ b/arch/ia64/xen/xcom_privcmd.c	Thu Aug 16 13:44:51 2007 -0600
     7.3 @@ -54,7 +54,7 @@ xencomm_privcmd_platform_op(privcmd_hype
     7.4  	if (kern_op.interface_version != XENPF_INTERFACE_VERSION)
     7.5  		return -EACCES;
     7.6  
     7.7 -	op_desc = xencomm_create_inline(&kern_op);
     7.8 +	op_desc = xencomm_map_no_alloc(&kern_op, sizeof(kern_op));
     7.9  
    7.10  	switch (kern_op.cmd) {
    7.11  	default:
    7.12 @@ -73,8 +73,7 @@ xencomm_privcmd_platform_op(privcmd_hype
    7.13  	if (copy_to_user(user_op, &kern_op, sizeof(struct xen_platform_op)))
    7.14  		ret = -EFAULT;
    7.15  
    7.16 -	if (desc)
    7.17 -		xencomm_free(desc);
    7.18 +	xencomm_free(desc);
    7.19  	return ret;
    7.20  }
    7.21  
    7.22 @@ -96,14 +95,16 @@ xencomm_privcmd_sysctl(privcmd_hypercall
    7.23  	if (kern_op.interface_version != XEN_SYSCTL_INTERFACE_VERSION)
    7.24  		return -EACCES;
    7.25  
    7.26 -	op_desc = xencomm_create_inline(&kern_op);
    7.27 +	op_desc = xencomm_map_no_alloc(&kern_op, sizeof(kern_op));
    7.28  
    7.29  	switch (kern_op.cmd) {
    7.30  	case XEN_SYSCTL_readconsole:
    7.31 -		ret = xencomm_create(
    7.32 +		desc = xencomm_map(
    7.33  			xen_guest_handle(kern_op.u.readconsole.buffer),
    7.34 -			kern_op.u.readconsole.count,
    7.35 -			&desc, GFP_KERNEL);
    7.36 +			kern_op.u.readconsole.count);
    7.37 +		if (xen_guest_handle(kern_op.u.readconsole.buffer) != NULL &&
    7.38 +		    kern_op.u.readconsole.count > 0 && desc == NULL)
    7.39 +			return -ENOMEM;
    7.40  		set_xen_guest_handle(kern_op.u.readconsole.buffer,
    7.41  		                     (void *)desc);
    7.42  		break;
    7.43 @@ -130,55 +131,62 @@ xencomm_privcmd_sysctl(privcmd_hypercall
    7.44  		}
    7.45  
    7.46  		/* query the buffer size for xencomm */
    7.47 -		tmp_desc = xencomm_create_inline(&tmp_op);
    7.48 +		tmp_desc = xencomm_map_no_alloc(&tmp_op, sizeof(tmp_op));
    7.49  		ret = xencomm_arch_hypercall_sysctl(tmp_desc);
    7.50  		if (ret)
    7.51  			return ret;
    7.52  
    7.53 -		ret = xencomm_create(xen_guest_handle(kern_op.u.perfc_op.desc),
    7.54 -		                     tmp_op.u.perfc_op.nr_counters *
    7.55 -		                     sizeof(xen_sysctl_perfc_desc_t),
    7.56 -		                     &desc, GFP_KERNEL);
    7.57 -		if (ret)
    7.58 -			return ret;
    7.59 +		desc = xencomm_map(xen_guest_handle(kern_op.u.perfc_op.desc),
    7.60 +				   tmp_op.u.perfc_op.nr_counters *
    7.61 +				   sizeof(xen_sysctl_perfc_desc_t));
    7.62 +		if (xen_guest_handle(kern_op.u.perfc_op.desc) != NULL &&
    7.63 +		    tmp_op.u.perfc_op.nr_counters > 0 && desc == NULL)
    7.64 +			return -ENOMEM;
    7.65  
    7.66  		set_xen_guest_handle(kern_op.u.perfc_op.desc, (void *)desc);
    7.67  
    7.68 -		ret = xencomm_create(xen_guest_handle(kern_op.u.perfc_op.val),
    7.69 -		                     tmp_op.u.perfc_op.nr_vals *
    7.70 -		                     sizeof(xen_sysctl_perfc_val_t),
    7.71 -		                     &desc1, GFP_KERNEL);
    7.72 -		if (ret)
    7.73 +		desc1 = xencomm_map(xen_guest_handle(kern_op.u.perfc_op.val),
    7.74 +				    tmp_op.u.perfc_op.nr_vals *
    7.75 +				    sizeof(xen_sysctl_perfc_val_t));
    7.76 +		if (xen_guest_handle(kern_op.u.perfc_op.val) != NULL &&
    7.77 +		    tmp_op.u.perfc_op.nr_vals > 0 && desc1 == NULL) {
    7.78  			xencomm_free(desc);
    7.79 +			return -ENOMEM;
    7.80 +		}
    7.81  
    7.82  		set_xen_guest_handle(kern_op.u.perfc_op.val, (void *)desc1);
    7.83  		break;
    7.84  	}
    7.85  	case XEN_SYSCTL_getdomaininfolist:
    7.86 -		ret = xencomm_create(
    7.87 +		desc = xencomm_map(
    7.88  			xen_guest_handle(kern_op.u.getdomaininfolist.buffer),
    7.89  			kern_op.u.getdomaininfolist.max_domains *
    7.90 -			sizeof(xen_domctl_getdomaininfo_t),
    7.91 -			&desc, GFP_KERNEL);
    7.92 +			sizeof(xen_domctl_getdomaininfo_t));
    7.93 +		if (xen_guest_handle(kern_op.u.getdomaininfolist.buffer) !=
    7.94 +		    NULL && kern_op.u.getdomaininfolist.max_domains > 0 &&
    7.95 +		    desc == NULL)
    7.96 +			return -ENOMEM;
    7.97  		set_xen_guest_handle(kern_op.u.getdomaininfolist.buffer,
    7.98  				     (void *)desc);
    7.99  		break;
   7.100  	case XEN_SYSCTL_debug_keys:
   7.101 -		ret = xencomm_create(
   7.102 +		desc = xencomm_map(
   7.103  			xen_guest_handle(kern_op.u.debug_keys.keys),
   7.104 -			kern_op.u.debug_keys.nr_keys,
   7.105 -			&desc, GFP_KERNEL);
   7.106 +			kern_op.u.debug_keys.nr_keys);
   7.107 +		if (xen_guest_handle(kern_op.u.debug_keys.keys) != NULL &&
   7.108 +		    kern_op.u.debug_keys.nr_keys > 0 && desc == NULL)
   7.109 +			return -ENOMEM;
   7.110  		set_xen_guest_handle(kern_op.u.debug_keys.keys,
   7.111  				     (void *)desc);
   7.112  		break;
   7.113  
   7.114  	case XEN_SYSCTL_physinfo:
   7.115 -		ret = xencomm_create(
   7.116 +		desc = xencomm_map(
   7.117  			xen_guest_handle(kern_op.u.physinfo.cpu_to_node),
   7.118 -			kern_op.u.physinfo.max_cpu_id * sizeof(uint32_t),
   7.119 -			&desc, GFP_KERNEL);
   7.120 -		if (ret)
   7.121 -			return ret;
   7.122 +			kern_op.u.physinfo.max_cpu_id * sizeof(uint32_t));
   7.123 +		if (xen_guest_handle(kern_op.u.physinfo.cpu_to_node) != NULL &&
   7.124 +		    kern_op.u.physinfo.max_cpu_id > 0 && desc == NULL)
   7.125 +			return -ENOMEM;
   7.126  
   7.127  		set_xen_guest_handle(kern_op.u.physinfo.cpu_to_node,
   7.128  		                     (void *)desc);
   7.129 @@ -199,10 +207,8 @@ xencomm_privcmd_sysctl(privcmd_hypercall
   7.130  	if (copy_to_user(user_op, &kern_op, sizeof(xen_sysctl_t)))
   7.131  		ret = -EFAULT;
   7.132  
   7.133 -	if (desc)
   7.134 -		xencomm_free(desc);
   7.135 -	if (desc1)
   7.136 -		xencomm_free(desc1);
   7.137 +	xencomm_free(desc);
   7.138 +	xencomm_free(desc1);
   7.139  	return ret;
   7.140  }
   7.141  
   7.142 @@ -223,7 +229,7 @@ xencomm_privcmd_domctl(privcmd_hypercall
   7.143  	if (kern_op.interface_version != XEN_DOMCTL_INTERFACE_VERSION)
   7.144  		return -EACCES;
   7.145  
   7.146 -	op_desc = xencomm_create_inline(&kern_op);
   7.147 +	op_desc = xencomm_map_no_alloc(&kern_op, sizeof(kern_op));
   7.148  
   7.149  	switch (kern_op.cmd) {
   7.150  	case XEN_DOMCTL_createdomain:
   7.151 @@ -236,10 +242,12 @@ xencomm_privcmd_domctl(privcmd_hypercall
   7.152  	{
   7.153  		unsigned long nr_pages = kern_op.u.getmemlist.max_pfns;
   7.154  
   7.155 -		ret = xencomm_create(
   7.156 +		desc = xencomm_map(
   7.157  			xen_guest_handle(kern_op.u.getmemlist.buffer),
   7.158 -			nr_pages * sizeof(unsigned long),
   7.159 -			&desc, GFP_KERNEL);
   7.160 +			nr_pages * sizeof(unsigned long));
   7.161 +		if (xen_guest_handle(kern_op.u.getmemlist.buffer) != NULL &&
   7.162 +		    nr_pages > 0 && desc == NULL)
   7.163 +			return -ENOMEM;
   7.164  		set_xen_guest_handle(kern_op.u.getmemlist.buffer,
   7.165  		                     (void *)desc);
   7.166  		break;
   7.167 @@ -247,18 +255,23 @@ xencomm_privcmd_domctl(privcmd_hypercall
   7.168  	case XEN_DOMCTL_getpageframeinfo:
   7.169  		break;
   7.170  	case XEN_DOMCTL_getpageframeinfo2:
   7.171 -		ret = xencomm_create(
   7.172 +		desc = xencomm_map(
   7.173  			xen_guest_handle(kern_op.u.getpageframeinfo2.array),
   7.174 -			kern_op.u.getpageframeinfo2.num,
   7.175 -			&desc, GFP_KERNEL);
   7.176 +			kern_op.u.getpageframeinfo2.num);
   7.177 +		if (xen_guest_handle(kern_op.u.getpageframeinfo2.array) !=
   7.178 +		    NULL && kern_op.u.getpageframeinfo2.num > 0 &&
   7.179 +		    desc == NULL)
   7.180 +			return -ENOMEM;
   7.181  		set_xen_guest_handle(kern_op.u.getpageframeinfo2.array,
   7.182  		                     (void *)desc);
   7.183  		break;
   7.184  	case XEN_DOMCTL_shadow_op:
   7.185 -		ret = xencomm_create(
   7.186 +		desc = xencomm_map(
   7.187  			xen_guest_handle(kern_op.u.shadow_op.dirty_bitmap),
   7.188 -			ROUND_DIV(kern_op.u.shadow_op.pages, 8),
   7.189 -			&desc, GFP_KERNEL);
   7.190 +			ROUND_DIV(kern_op.u.shadow_op.pages, 8));
   7.191 +		if (xen_guest_handle(kern_op.u.shadow_op.dirty_bitmap) != NULL
   7.192 +		    && kern_op.u.shadow_op.pages > 0 && desc == NULL)
   7.193 +			return -ENOMEM;
   7.194  		set_xen_guest_handle(kern_op.u.shadow_op.dirty_bitmap,
   7.195  		                     (void *)desc);
   7.196  		break;
   7.197 @@ -266,20 +279,25 @@ xencomm_privcmd_domctl(privcmd_hypercall
   7.198  		break;
   7.199  	case XEN_DOMCTL_setvcpucontext:
   7.200  	case XEN_DOMCTL_getvcpucontext:
   7.201 -		ret = xencomm_create(
   7.202 +		desc = xencomm_map(
   7.203  			xen_guest_handle(kern_op.u.vcpucontext.ctxt),
   7.204 -			sizeof(vcpu_guest_context_t),
   7.205 -			&desc, GFP_KERNEL);
   7.206 +			sizeof(vcpu_guest_context_t));
   7.207 +		if (xen_guest_handle(kern_op.u.vcpucontext.ctxt) != NULL &&
   7.208 +		    desc == NULL)
   7.209 +			return -ENOMEM;
   7.210  		set_xen_guest_handle(kern_op.u.vcpucontext.ctxt, (void *)desc);
   7.211  		break;
   7.212  	case XEN_DOMCTL_getvcpuinfo:
   7.213  		break;
   7.214  	case XEN_DOMCTL_setvcpuaffinity:
   7.215  	case XEN_DOMCTL_getvcpuaffinity:
   7.216 -		ret = xencomm_create(
   7.217 +		desc = xencomm_map(
   7.218  			xen_guest_handle(kern_op.u.vcpuaffinity.cpumap.bitmap),
   7.219 -			ROUND_DIV(kern_op.u.vcpuaffinity.cpumap.nr_cpus, 8),
   7.220 -			&desc, GFP_KERNEL);
   7.221 +			ROUND_DIV(kern_op.u.vcpuaffinity.cpumap.nr_cpus, 8));
   7.222 +		if (xen_guest_handle(kern_op.u.vcpuaffinity.cpumap.bitmap) !=
   7.223 +		    NULL && kern_op.u.vcpuaffinity.cpumap.nr_cpus > 0 &&
   7.224 +		    desc == NULL)
   7.225 +			return -ENOMEM;
   7.226  		set_xen_guest_handle(kern_op.u.vcpuaffinity.cpumap.bitmap,
   7.227  		                     (void *)desc);
   7.228  		break;
   7.229 @@ -311,8 +329,7 @@ xencomm_privcmd_domctl(privcmd_hypercall
   7.230  	if (copy_to_user(user_op, &kern_op, sizeof(xen_domctl_t)))
   7.231  		ret = -EFAULT;
   7.232  
   7.233 -	if (desc)
   7.234 -		xencomm_free(desc);
   7.235 +	xencomm_free(desc);
   7.236  	return ret;
   7.237  }
   7.238  
   7.239 @@ -332,13 +349,14 @@ xencomm_privcmd_acm_op(privcmd_hypercall
   7.240  	
   7.241  	switch (kern_arg.cmd) {
   7.242  	case ACMOP_getssid: {
   7.243 -		op_desc = xencomm_create_inline(&kern_arg);
   7.244 +		op_desc = xencomm_map_no_alloc(&kern_arg, sizeof(kern_arg));
   7.245  
   7.246 -		ret = xencomm_create(
   7.247 +		desc = xencomm_map(
   7.248  			xen_guest_handle(kern_arg.u.getssid.ssidbuf),
   7.249 -			kern_arg.u.getssid.ssidbuf_size, &desc, GFP_KERNEL);
   7.250 -		if (ret)
   7.251 -			return ret;
   7.252 +			kern_arg.u.getssid.ssidbuf_size);
   7.253 +		if (xen_guest_handle(kern_arg.u.getssid.ssidbuf) != NULL &&
   7.254 +		    kern_arg.u.getssid.ssidbuf_size > 0 && desc == NULL)
   7.255 +			return -ENOMEM;
   7.256  
   7.257  		set_xen_guest_handle(kern_arg.u.getssid.ssidbuf, (void *)desc);
   7.258  
   7.259 @@ -378,28 +396,28 @@ xencomm_privcmd_memory_op(privcmd_hyperc
   7.260  		if (copy_from_user(&kern_op, user_op,
   7.261  		                   sizeof(xen_memory_reservation_t)))
   7.262  			return -EFAULT;
   7.263 -		desc_op = xencomm_create_inline(&kern_op);
   7.264 +		desc_op = xencomm_map_no_alloc(&kern_op, sizeof(kern_op));
   7.265  
   7.266  		if (xen_guest_handle(kern_op.extent_start)) {
   7.267  			void * addr;
   7.268  
   7.269  			addr = xen_guest_handle(kern_op.extent_start);
   7.270 -			ret = xencomm_create
   7.271 +			desc = xencomm_map
   7.272  				(addr,
   7.273  				 kern_op.nr_extents *
   7.274  				 sizeof(*xen_guest_handle
   7.275 -					(kern_op.extent_start)),
   7.276 -				 &desc, GFP_KERNEL);
   7.277 -			if (ret)
   7.278 -				return ret;
   7.279 +					(kern_op.extent_start)));
   7.280 +			if (addr != NULL && kern_op.nr_extents > 0 &&
   7.281 +			    desc == NULL)
   7.282 +				return -ENOMEM;
   7.283 +
   7.284  			set_xen_guest_handle(kern_op.extent_start,
   7.285  			                     (void *)desc);
   7.286  		}
   7.287  
   7.288  		ret = xencomm_arch_hypercall_memory_op(cmd, desc_op);
   7.289  
   7.290 -		if (desc)
   7.291 -			xencomm_free(desc);
   7.292 +		xencomm_free(desc);
   7.293  
   7.294  		if (ret != 0)
   7.295  			return ret;
   7.296 @@ -419,7 +437,7 @@ xencomm_privcmd_memory_op(privcmd_hyperc
   7.297  		user_domid = (domid_t __user *)hypercall->arg[1];
   7.298  		if (copy_from_user(&kern_domid, user_domid, sizeof(domid_t)))
   7.299  			return -EFAULT;
   7.300 -		desc = xencomm_create_inline(&kern_domid);
   7.301 +		desc = xencomm_map_no_alloc(&kern_domid, sizeof(kern_domid));
   7.302  
   7.303  		ret = xencomm_arch_hypercall_memory_op(cmd, desc);
   7.304  
   7.305 @@ -439,41 +457,41 @@ xencomm_privcmd_memory_op(privcmd_hyperc
   7.306  		if (copy_from_user(&kern_op, user_op,
   7.307  		                   sizeof(xen_translate_gpfn_list_t)))
   7.308  			return -EFAULT;
   7.309 -		desc_op = xencomm_create_inline(&kern_op);
   7.310 +		desc_op = xencomm_map_no_alloc(&kern_op, sizeof(kern_op));
   7.311  
   7.312  		if (kern_op.nr_gpfns) {
   7.313  			/* gpfn_list.  */
   7.314  			addr = xen_guest_handle(kern_op.gpfn_list);
   7.315  
   7.316 -			ret = xencomm_create(addr, kern_op.nr_gpfns *
   7.317 +			desc_gpfn = xencomm_map(addr, kern_op.nr_gpfns *
   7.318  			                     sizeof(*xen_guest_handle
   7.319 -			                            (kern_op.gpfn_list)),
   7.320 -			                     &desc_gpfn, GFP_KERNEL);
   7.321 -			if (ret)
   7.322 -				return ret;
   7.323 +			                            (kern_op.gpfn_list)));
   7.324 +			if (addr != NULL && kern_op.nr_gpfns > 0 &&
   7.325 +			    desc_gpfn == NULL)
   7.326 +				return -ENOMEM;
   7.327  			set_xen_guest_handle(kern_op.gpfn_list,
   7.328  			                     (void *)desc_gpfn);
   7.329  
   7.330  			/* mfn_list.  */
   7.331  			addr = xen_guest_handle(kern_op.mfn_list);
   7.332  
   7.333 -			ret = xencomm_create(addr, kern_op.nr_gpfns *
   7.334 +			desc_mfn = xencomm_map(addr, kern_op.nr_gpfns *
   7.335  			                     sizeof(*xen_guest_handle
   7.336 -			                            (kern_op.mfn_list)),
   7.337 -			                     &desc_mfn, GFP_KERNEL);
   7.338 -			if (ret)
   7.339 -				return ret;
   7.340 +			                            (kern_op.mfn_list)));
   7.341 +			if (addr != NULL && kern_op.nr_gpfns > 0 &&
   7.342 +			    desc_mfn == NULL) {
   7.343 +				xencomm_free(desc_gpfn);
   7.344 +				return -ENOMEM;
   7.345 +			}
   7.346 +
   7.347  			set_xen_guest_handle(kern_op.mfn_list,
   7.348  			                     (void *)desc_mfn);
   7.349  		}
   7.350  
   7.351  		ret = xencomm_arch_hypercall_memory_op(cmd, desc_op);
   7.352  
   7.353 -		if (desc_gpfn)
   7.354 -			xencomm_free(desc_gpfn);
   7.355 -
   7.356 -		if (desc_mfn)
   7.357 -			xencomm_free(desc_mfn);
   7.358 +		xencomm_free(desc_gpfn);
   7.359 +		xencomm_free(desc_mfn);
   7.360  
   7.361  		if (ret != 0)
   7.362  			return ret;
   7.363 @@ -527,9 +545,9 @@ xencomm_privcmd_xen_version(privcmd_hype
   7.364  		return -ENOSYS;
   7.365  	}
   7.366  
   7.367 -	rc = xencomm_create(arg, argsize, &desc, GFP_KERNEL);
   7.368 -	if (rc)
   7.369 -		return rc;
   7.370 +	desc = xencomm_map(arg, argsize);
   7.371 +	if (arg != NULL && argsize > 0 && desc == NULL)
   7.372 +		return -ENOMEM;
   7.373  
   7.374  	rc = xencomm_arch_hypercall_xen_version(cmd, desc);
   7.375  
   7.376 @@ -560,10 +578,9 @@ xencomm_privcmd_event_channel_op(privcmd
   7.377  		return -EINVAL;
   7.378  	}
   7.379  
   7.380 -	ret = xencomm_create((void *)hypercall->arg[1], argsize,
   7.381 -	                     &desc, GFP_KERNEL);
   7.382 -	if (ret)
   7.383 -		return ret;
   7.384 +	desc = xencomm_map((void *)hypercall->arg[1], argsize);
   7.385 +	if ((void *)hypercall->arg[1] != NULL && argsize > 0 && desc == NULL)
   7.386 +		return -ENOMEM;
   7.387  
   7.388  	ret = xencomm_arch_hypercall_event_channel_op(cmd, desc);
   7.389  
   7.390 @@ -599,10 +616,9 @@ xencomm_privcmd_hvm_op(privcmd_hypercall
   7.391  		return -EINVAL;
   7.392  	}
   7.393  
   7.394 -	ret = xencomm_create((void *)hypercall->arg[1], argsize,
   7.395 -	                     &desc, GFP_KERNEL);
   7.396 -	if (ret)
   7.397 -		return ret;
   7.398 +	desc = xencomm_map((void *)hypercall->arg[1], argsize);
   7.399 +	if ((void *)hypercall->arg[1] != NULL && argsize > 0 && desc == NULL)
   7.400 +		return -ENOMEM;
   7.401  
   7.402  	ret = xencomm_arch_hypercall_hvm_op(cmd, desc);
   7.403  
   7.404 @@ -627,10 +643,9 @@ xencomm_privcmd_sched_op(privcmd_hyperca
   7.405  		return -EINVAL;
   7.406  	}
   7.407  
   7.408 -	ret = xencomm_create((void *)hypercall->arg[1], argsize,
   7.409 -	                     &desc, GFP_KERNEL);
   7.410 -	if (ret)
   7.411 -		return ret;
   7.412 +	desc = xencomm_map((void *)hypercall->arg[1], argsize);
   7.413 +	if ((void *)hypercall->arg[1] != NULL && argsize > 0 && desc == NULL)
   7.414 +		return -ENOMEM;
   7.415  
   7.416  	ret = xencomm_arch_hypercall_sched_op(cmd, desc);
   7.417  
   7.418 @@ -650,10 +665,10 @@ xencomm_privcmd_ia64_dom0vp_op(privcmd_h
   7.419  		unsigned int __user *revision_user =
   7.420  			(unsigned int* __user)hypercall->arg[1];
   7.421  		struct xencomm_handle *desc;
   7.422 -		ret = xencomm_create(&revision, sizeof(revision),
   7.423 -				     &desc, GFP_KERNEL);
   7.424 -		if (ret)
   7.425 -			break;
   7.426 +		desc = xencomm_map(&revision, sizeof(revision));
   7.427 +		if (desc == NULL)
   7.428 +			return -ENOMEM;
   7.429 +
   7.430  		ret = xencomm_arch_hypercall_fpswa_revision(desc);
   7.431  		xencomm_free(desc);
   7.432  		if (ret)
     8.1 --- a/arch/ia64/xen/xencomm.c	Thu Aug 16 10:58:46 2007 -0600
     8.2 +++ b/arch/ia64/xen/xencomm.c	Thu Aug 16 13:44:51 2007 -0600
     8.3 @@ -27,19 +27,17 @@
     8.4  
     8.5  #include <asm/xen/xencomm.h>
     8.6  
     8.7 -static int xencomm_debug = 0;
     8.8 -
     8.9  static unsigned long kernel_start_pa;
    8.10  
    8.11  void
    8.12 -xencomm_init (void)
    8.13 +xencomm_initialize (void)
    8.14  {
    8.15  	kernel_start_pa = KERNEL_START - ia64_tpa(KERNEL_START);
    8.16  }
    8.17  
    8.18  /* Translate virtual address to physical address.  */
    8.19  unsigned long
    8.20 -xencomm_vaddr_to_paddr(unsigned long vaddr)
    8.21 +xencomm_vtop(unsigned long vaddr)
    8.22  {
    8.23  #ifndef CONFIG_VMX_GUEST
    8.24  	struct page *page;
    8.25 @@ -109,155 +107,3 @@ xencomm_vaddr_to_paddr(unsigned long vad
    8.26  	return (page_to_pfn(page) << PAGE_SHIFT) | (vaddr & ~PAGE_MASK);
    8.27  #endif
    8.28  }
    8.29 -
    8.30 -static int
    8.31 -xencomm_init_desc(struct xencomm_desc *desc, void *buffer, unsigned long bytes)
    8.32 -{
    8.33 -	unsigned long recorded = 0;
    8.34 -	int i = 0;
    8.35 -
    8.36 -	BUG_ON((buffer == NULL) && (bytes > 0));
    8.37 -
    8.38 -	/* record the physical pages used */
    8.39 -	if (buffer == NULL)
    8.40 -		desc->nr_addrs = 0;
    8.41 -
    8.42 -	while ((recorded < bytes) && (i < desc->nr_addrs)) {
    8.43 -		unsigned long vaddr = (unsigned long)buffer + recorded;
    8.44 -		unsigned long paddr;
    8.45 -		int offset;
    8.46 -		int chunksz;
    8.47 -
    8.48 -		offset = vaddr % PAGE_SIZE; /* handle partial pages */
    8.49 -		chunksz = min(PAGE_SIZE - offset, bytes - recorded);
    8.50 -
    8.51 -		paddr = xencomm_vaddr_to_paddr(vaddr);
    8.52 -		if (paddr == ~0UL) {
    8.53 -			printk("%s: couldn't translate vaddr %lx\n",
    8.54 -			       __func__, vaddr);
    8.55 -			return -EINVAL;
    8.56 -		}
    8.57 -
    8.58 -		desc->address[i++] = paddr;
    8.59 -		recorded += chunksz;
    8.60 -	}
    8.61 -
    8.62 -	if (recorded < bytes) {
    8.63 -		printk("%s: could only translate %ld of %ld bytes\n",
    8.64 -		       __func__, recorded, bytes);
    8.65 -		return -ENOSPC;
    8.66 -	}
    8.67 -
    8.68 -	/* mark remaining addresses invalid (just for safety) */
    8.69 -	while (i < desc->nr_addrs)
    8.70 -		desc->address[i++] = XENCOMM_INVALID;
    8.71 -
    8.72 -	desc->magic = XENCOMM_MAGIC;
    8.73 -
    8.74 -	return 0;
    8.75 -}
    8.76 -
    8.77 -static struct xencomm_desc *
    8.78 -xencomm_alloc(gfp_t gfp_mask)
    8.79 -{
    8.80 -	struct xencomm_desc *desc;
    8.81 -
    8.82 -	desc = (struct xencomm_desc *)__get_free_page(gfp_mask);
    8.83 -	if (desc == NULL)
    8.84 -		panic("%s: page allocation failed\n", __func__);
    8.85 -
    8.86 -	desc->nr_addrs = (PAGE_SIZE - sizeof(struct xencomm_desc)) /
    8.87 -	                 sizeof(*desc->address);
    8.88 -
    8.89 -	return desc;
    8.90 -}
    8.91 -
    8.92 -void
    8.93 -xencomm_free(struct xencomm_handle *desc)
    8.94 -{
    8.95 -	if (desc)
    8.96 -		free_page((unsigned long)__va(desc));
    8.97 -}
    8.98 -
    8.99 -int
   8.100 -xencomm_create(void *buffer, unsigned long bytes,
   8.101 -               struct xencomm_handle **ret, gfp_t gfp_mask)
   8.102 -{
   8.103 -	struct xencomm_desc *desc;
   8.104 -	struct xencomm_handle *handle;
   8.105 -	int rc;
   8.106 -
   8.107 -	if (xencomm_debug)
   8.108 -		printk("%s: %p[%ld]\n", __func__, buffer, bytes);
   8.109 -
   8.110 -	if (buffer == NULL || bytes == 0) {
   8.111 -		*ret = (struct xencomm_handle *)NULL;
   8.112 -		return 0;
   8.113 -	}
   8.114 -
   8.115 -	desc = xencomm_alloc(gfp_mask);
   8.116 -	if (!desc) {
   8.117 -		printk("%s failure\n", "xencomm_alloc");
   8.118 -		return -ENOMEM;
   8.119 -	}
   8.120 -	handle = (struct xencomm_handle *)__pa(desc);
   8.121 -
   8.122 -	rc = xencomm_init_desc(desc, buffer, bytes);
   8.123 -	if (rc) {
   8.124 -		printk("%s failure: %d\n", "xencomm_init_desc", rc);
   8.125 -		xencomm_free(handle);
   8.126 -		return rc;
   8.127 -	}
   8.128 -
   8.129 -	*ret = handle;
   8.130 -	return 0;
   8.131 -}
   8.132 -
   8.133 -/* "mini" routines, for stack-based communications: */
   8.134 -
   8.135 -static void *
   8.136 -xencomm_alloc_mini(struct xencomm_mini *area, int *nbr_area)
   8.137 -{
   8.138 -	unsigned long base;
   8.139 -	unsigned int pageoffset;
   8.140 -
   8.141 -	while (*nbr_area >= 0) {
   8.142 -		/* Allocate an area.  */
   8.143 -		(*nbr_area)--;
   8.144 -
   8.145 -		base = (unsigned long)(area + *nbr_area);
   8.146 -		pageoffset = base % PAGE_SIZE;
   8.147 -
   8.148 -		/* If the area does not cross a page, use it.  */
   8.149 -		if ((PAGE_SIZE - pageoffset) >= sizeof(struct xencomm_mini))
   8.150 -			return &area[*nbr_area];
   8.151 -	}
   8.152 -	/* No more area.  */
   8.153 -	return NULL;
   8.154 -}
   8.155 -
   8.156 -int
   8.157 -xencomm_create_mini(struct xencomm_mini *area, int *nbr_area,
   8.158 -                    void *buffer, unsigned long bytes,
   8.159 -                    struct xencomm_handle **ret)
   8.160 -{
   8.161 -	struct xencomm_desc *desc;
   8.162 -	int rc;
   8.163 -	unsigned long res;
   8.164 -
   8.165 -	desc = xencomm_alloc_mini(area, nbr_area);
   8.166 -	if (!desc)
   8.167 -		return -ENOMEM;
   8.168 -	desc->nr_addrs = XENCOMM_MINI_ADDRS;
   8.169 -
   8.170 -	rc = xencomm_init_desc(desc, buffer, bytes);
   8.171 -	if (rc)
   8.172 -		return rc;
   8.173 -
   8.174 -	res = xencomm_vaddr_to_paddr((unsigned long)desc);
   8.175 -	if (res == ~0UL)
   8.176 -		return -EINVAL;
   8.177 -
   8.178 -	*ret = (struct xencomm_handle*)res;
   8.179 -	return 0;
   8.180 -}
     9.1 --- a/include/asm-ia64/hypercall.h	Thu Aug 16 10:58:46 2007 -0600
     9.2 +++ b/include/asm-ia64/hypercall.h	Thu Aug 16 13:44:51 2007 -0600
     9.3 @@ -405,19 +405,6 @@ HYPERVISOR_add_io_space(unsigned long ph
     9.4  #define HYPERVISOR_update_va_mapping(va, new_val, flags) (0)
     9.5  
     9.6  /* Use xencomm to do hypercalls.  */
     9.7 -#ifdef MODULE
     9.8 -#define HYPERVISOR_sched_op xencomm_mini_hypercall_sched_op
     9.9 -#define HYPERVISOR_event_channel_op xencomm_mini_hypercall_event_channel_op
    9.10 -#define HYPERVISOR_callback_op xencomm_mini_hypercall_callback_op
    9.11 -#define HYPERVISOR_multicall xencomm_mini_hypercall_multicall
    9.12 -#define HYPERVISOR_xen_version xencomm_mini_hypercall_xen_version
    9.13 -#define HYPERVISOR_console_io xencomm_mini_hypercall_console_io
    9.14 -#define HYPERVISOR_hvm_op xencomm_mini_hypercall_hvm_op
    9.15 -#define HYPERVISOR_memory_op xencomm_mini_hypercall_memory_op
    9.16 -#define HYPERVISOR_xenoprof_op xencomm_mini_hypercall_xenoprof_op
    9.17 -#define HYPERVISOR_perfmon_op xencomm_mini_hypercall_perfmon_op
    9.18 -#define HYPERVISOR_fpswa_revision xencomm_mini_hypercall_fpswa_revision
    9.19 -#else
    9.20  #define HYPERVISOR_sched_op xencomm_hypercall_sched_op
    9.21  #define HYPERVISOR_event_channel_op xencomm_hypercall_event_channel_op
    9.22  #define HYPERVISOR_callback_op xencomm_hypercall_callback_op
    9.23 @@ -429,8 +416,6 @@ HYPERVISOR_add_io_space(unsigned long ph
    9.24  #define HYPERVISOR_xenoprof_op xencomm_hypercall_xenoprof_op
    9.25  #define HYPERVISOR_perfmon_op xencomm_hypercall_perfmon_op
    9.26  #define HYPERVISOR_fpswa_revision xencomm_hypercall_fpswa_revision
    9.27 -#endif
    9.28 -
    9.29  #define HYPERVISOR_suspend xencomm_hypercall_suspend
    9.30  #define HYPERVISOR_vcpu_op xencomm_hypercall_vcpu_op
    9.31  #define HYPERVISOR_opt_feature xencomm_hypercall_opt_feature
    10.1 --- a/include/asm-ia64/sal.h	Thu Aug 16 10:58:46 2007 -0600
    10.2 +++ b/include/asm-ia64/sal.h	Thu Aug 16 13:44:51 2007 -0600
    10.3 @@ -701,9 +701,9 @@ ia64_sal_get_state_info (u64 sal_info_ty
    10.4  	if (is_running_on_xen()) {
    10.5  		struct xencomm_handle *desc;
    10.6  
    10.7 -		if (xencomm_create(sal_info,
    10.8 -		                   ia64_sal_get_state_info_size(sal_info_type),
    10.9 -		                   &desc, GFP_KERNEL))
   10.10 +		desc = xencomm_map(sal_info,
   10.11 +				ia64_sal_get_state_info_size(sal_info_type));
   10.12 +		if (desc == NULL)
   10.13  			return 0;
   10.14  
   10.15  		SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0,
    11.1 --- a/include/asm-ia64/xen/xcom_hcall.h	Thu Aug 16 10:58:46 2007 -0600
    11.2 +++ b/include/asm-ia64/xen/xcom_hcall.h	Thu Aug 16 13:44:51 2007 -0600
    11.3 @@ -19,7 +19,7 @@
    11.4  #ifndef _LINUX_XENCOMM_HCALL_H_
    11.5  #define _LINUX_XENCOMM_HCALL_H_
    11.6  
    11.7 -/* These function creates inline descriptor for the parameters and
    11.8 +/* These function creates inline or mini descriptor for the parameters and
    11.9     calls the corresponding xencomm_arch_hypercall_X.
   11.10     Architectures should defines HYPERVISOR_xxx as xencomm_hypercall_xxx unless
   11.11     they want to use their own wrapper.  */
   11.12 @@ -55,33 +55,6 @@ extern long xencomm_hypercall_vcpu_op(in
   11.13  
   11.14  extern long xencomm_hypercall_opt_feature(void *arg);
   11.15  
   11.16 -/* Using mini xencomm.  */
   11.17 -extern int xencomm_mini_hypercall_console_io(int cmd, int count, char *str);
   11.18 -
   11.19 -extern int xencomm_mini_hypercall_event_channel_op(int cmd, void *op);
   11.20 -
   11.21 -extern int xencomm_mini_hypercall_xen_version(int cmd, void *arg);
   11.22 -
   11.23 -extern int xencomm_mini_hypercall_physdev_op(int cmd, void *op);
   11.24 -
   11.25 -extern int xencomm_mini_hypercall_grant_table_op(unsigned int cmd, void *op,
   11.26 -                                                 unsigned int count);
   11.27 -
   11.28 -extern int xencomm_mini_hypercall_sched_op(int cmd, void *arg);
   11.29 -
   11.30 -extern int xencomm_mini_hypercall_multicall(void *call_list, int nr_calls);
   11.31 -
   11.32 -extern int xencomm_mini_hypercall_callback_op(int cmd, void *arg);
   11.33 -
   11.34 -extern int xencomm_mini_hypercall_memory_op(unsigned int cmd, void *arg);
   11.35 -
   11.36 -extern unsigned long xencomm_mini_hypercall_hvm_op(int cmd, void *arg);
   11.37 -
   11.38 -extern int xencomm_mini_hypercall_xenoprof_op(int op, void *arg);
   11.39 -
   11.40 -extern int xencomm_mini_hypercall_perfmon_op(unsigned long cmd, void* arg,
   11.41 -                                             unsigned long count);
   11.42 -
   11.43  /* For privcmd.  Locally declare argument type to avoid include storm.
   11.44     Type coherency will be checked within privcmd.c  */
   11.45  struct privcmd_hypercall;
    12.1 --- a/include/asm-ia64/xen/xencomm.h	Thu Aug 16 10:58:46 2007 -0600
    12.2 +++ b/include/asm-ia64/xen/xencomm.h	Thu Aug 16 13:44:51 2007 -0600
    12.3 @@ -16,45 +16,18 @@
    12.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    12.5   */
    12.6  
    12.7 -#ifndef _LINUX_XENCOMM_H_
    12.8 -#define _LINUX_XENCOMM_H_
    12.9 -
   12.10 -#include <xen/interface/xencomm.h>
   12.11 +#ifndef _ASM_IA64_XENCOMM_H_
   12.12 +#define _ASM_IA64_XENCOMM_H_
   12.13  
   12.14 -#define XENCOMM_MINI_ADDRS 3
   12.15 -struct xencomm_mini {
   12.16 -	struct xencomm_desc _desc;
   12.17 -	uint64_t address[XENCOMM_MINI_ADDRS];
   12.18 -};
   12.19 +#define is_kernel_addr(x)					\
   12.20 +	((PAGE_OFFSET <= (x) &&					\
   12.21 +	  (x) < (PAGE_OFFSET + (1UL << IA64_MAX_PHYS_BITS))) ||	\
   12.22 +	 (KERNEL_START <= (x) &&				\
   12.23 +	  (x) < KERNEL_START + KERNEL_TR_PAGE_SIZE))
   12.24  
   12.25  /* Must be called before any hypercall.  */
   12.26 -extern void xencomm_init (void);
   12.27 -
   12.28 -/* To avoid additionnal virt to phys conversion, an opaque structure is
   12.29 -   presented.  */
   12.30 -struct xencomm_handle;
   12.31 -
   12.32 -extern int xencomm_create(void *buffer, unsigned long bytes,
   12.33 -                          struct xencomm_handle **desc, gfp_t type);
   12.34 -extern void xencomm_free(struct xencomm_handle *desc);
   12.35 -
   12.36 -extern int xencomm_create_mini(struct xencomm_mini *area, int *nbr_area,
   12.37 -                               void *buffer, unsigned long bytes,
   12.38 -                               struct xencomm_handle **ret);
   12.39 +extern void xencomm_initialize (void);
   12.40  
   12.41 -/* Translate virtual address to physical address.  */
   12.42 -extern unsigned long xencomm_vaddr_to_paddr(unsigned long vaddr);
   12.43 +#include <xen/xencomm.h>
   12.44  
   12.45 -/* Inline version.  To be used only on linear space (kernel space).  */
   12.46 -static inline struct xencomm_handle *
   12.47 -xencomm_create_inline(void *buffer)
   12.48 -{
   12.49 -	unsigned long paddr;
   12.50 -
   12.51 -	paddr = xencomm_vaddr_to_paddr((unsigned long)buffer);
   12.52 -	return (struct xencomm_handle *)(paddr | XENCOMM_INLINE_FLAG);
   12.53 -}
   12.54 -
   12.55 -#define xen_guest_handle(hnd)  ((hnd).p)
   12.56 -
   12.57 -#endif /* _LINUX_XENCOMM_H_ */
   12.58 +#endif /* _ASM_IA64_XENCOMM_H_ */