ia64/xen-unstable

changeset 9667:6df0bdcf8c9d

Add a new config option for all backend drivers. This has two benefits:
1. All backend drivers can be disabled or modularised via
one config option.
2. Backend helper routines that are not specific to any particular driver
can be disabled or modularised based on this config option. In
particular this may allow backend drivers plus the service module
to be upgraded separate from the kernel core as and when the backend
interfaces change (and they will).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Apr 10 18:30:07 2006 +0100 (2006-04-10)
parents ec68212e72c1
children b32bc0c5648d
files buildconfigs/linux-defconfig_xen0_ia64 buildconfigs/linux-defconfig_xen0_x86_32 buildconfigs/linux-defconfig_xen0_x86_64 buildconfigs/linux-defconfig_xenU_ia64 buildconfigs/linux-defconfig_xenU_x86_32 buildconfigs/linux-defconfig_xenU_x86_64 buildconfigs/linux-defconfig_xen_ia64 buildconfigs/linux-defconfig_xen_x86_32 buildconfigs/linux-defconfig_xen_x86_64 linux-2.6-xen-sparse/arch/ia64/Kconfig linux-2.6-xen-sparse/drivers/xen/Kconfig linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
line diff
     1.1 --- a/buildconfigs/linux-defconfig_xen0_ia64	Mon Apr 10 18:18:03 2006 +0100
     1.2 +++ b/buildconfigs/linux-defconfig_xen0_ia64	Mon Apr 10 18:30:07 2006 +0100
     1.3 @@ -95,6 +95,7 @@ CONFIG_ARCH_XEN=y
     1.4  CONFIG_XEN_PRIVILEGED_GUEST=y
     1.5  CONFIG_XEN_BLKDEV_GRANT=y
     1.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     1.7 +CONFIG_XEN_BACKEND=y
     1.8  CONFIG_XEN_BLKDEV_BACKEND=y
     1.9  CONFIG_XEN_SYSFS=y
    1.10  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
     2.1 --- a/buildconfigs/linux-defconfig_xen0_x86_32	Mon Apr 10 18:18:03 2006 +0100
     2.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_32	Mon Apr 10 18:30:07 2006 +0100
     2.3 @@ -1316,6 +1316,7 @@ CONFIG_XEN_INTERFACE_VERSION=0x00030101
     2.4  #
     2.5  CONFIG_XEN_PRIVILEGED_GUEST=y
     2.6  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
     2.7 +CONFIG_XEN_BACKEND=y
     2.8  CONFIG_XEN_PCIDEV_BACKEND=y
     2.9  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
    2.10  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     3.1 --- a/buildconfigs/linux-defconfig_xen0_x86_64	Mon Apr 10 18:18:03 2006 +0100
     3.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_64	Mon Apr 10 18:30:07 2006 +0100
     3.3 @@ -1246,6 +1246,7 @@ CONFIG_NO_IDLE_HZ=y
     3.4  #
     3.5  CONFIG_XEN_PRIVILEGED_GUEST=y
     3.6  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
     3.7 +CONFIG_XEN_BACKEND=y
     3.8  CONFIG_XEN_PCIDEV_BACKEND=y
     3.9  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
    3.10  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     4.1 --- a/buildconfigs/linux-defconfig_xenU_ia64	Mon Apr 10 18:18:03 2006 +0100
     4.2 +++ b/buildconfigs/linux-defconfig_xenU_ia64	Mon Apr 10 18:30:07 2006 +0100
     4.3 @@ -92,6 +92,7 @@ CONFIG_ARCH_XEN=y
     4.4  CONFIG_XEN_PRIVILEGED_GUEST=y
     4.5  CONFIG_XEN_BLKDEV_GRANT=y
     4.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     4.7 +CONFIG_XEN_BACKEND=y
     4.8  CONFIG_XEN_BLKDEV_BACKEND=y
     4.9  CONFIG_XEN_SYSFS=y
    4.10  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
     5.1 --- a/buildconfigs/linux-defconfig_xenU_x86_32	Mon Apr 10 18:18:03 2006 +0100
     5.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_32	Mon Apr 10 18:30:07 2006 +0100
     5.3 @@ -859,13 +859,9 @@ CONFIG_NO_IDLE_HZ=y
     5.4  #
     5.5  # CONFIG_XEN_PRIVILEGED_GUEST is not set
     5.6  CONFIG_XEN_UNPRIVILEGED_GUEST=y
     5.7 -# CONFIG_XEN_PCIDEV_BACKEND is not set
     5.8 -# CONFIG_XEN_BLKDEV_BACKEND is not set
     5.9 -# CONFIG_XEN_NETDEV_BACKEND is not set
    5.10 -# CONFIG_XEN_TPMDEV_BACKEND is not set
    5.11 +# CONFIG_XEN_BACKEND is not set
    5.12  CONFIG_XEN_BLKDEV_FRONTEND=y
    5.13  CONFIG_XEN_NETDEV_FRONTEND=y
    5.14 -# CONFIG_XEN_BLKDEV_TAP is not set
    5.15  # CONFIG_XEN_TPMDEV_FRONTEND is not set
    5.16  CONFIG_XEN_SCRUB_PAGES=y
    5.17  CONFIG_XEN_DISABLE_SERIAL=y
     6.1 --- a/buildconfigs/linux-defconfig_xenU_x86_64	Mon Apr 10 18:18:03 2006 +0100
     6.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_64	Mon Apr 10 18:30:07 2006 +0100
     6.3 @@ -1135,13 +1135,9 @@ CONFIG_NO_IDLE_HZ=y
     6.4  #
     6.5  # CONFIG_XEN_PRIVILEGED_GUEST is not set
     6.6  CONFIG_XEN_UNPRIVILEGED_GUEST=y
     6.7 -# CONFIG_XEN_PCIDEV_BACKEND is not set
     6.8 -# CONFIG_XEN_BLKDEV_BACKEND is not set
     6.9 -# CONFIG_XEN_NETDEV_BACKEND is not set
    6.10 -# CONFIG_XEN_TPMDEV_BACKEND is not set
    6.11 +# CONFIG_XEN_BACKEND is not set
    6.12  CONFIG_XEN_BLKDEV_FRONTEND=y
    6.13  CONFIG_XEN_NETDEV_FRONTEND=y
    6.14 -# CONFIG_XEN_BLKDEV_TAP is not set
    6.15  # CONFIG_XEN_TPMDEV_FRONTEND is not set
    6.16  CONFIG_XEN_SCRUB_PAGES=y
    6.17  CONFIG_XEN_DISABLE_SERIAL=y
     7.1 --- a/buildconfigs/linux-defconfig_xen_ia64	Mon Apr 10 18:18:03 2006 +0100
     7.2 +++ b/buildconfigs/linux-defconfig_xen_ia64	Mon Apr 10 18:30:07 2006 +0100
     7.3 @@ -95,6 +95,7 @@ CONFIG_ARCH_XEN=y
     7.4  CONFIG_XEN_PRIVILEGED_GUEST=y
     7.5  CONFIG_XEN_BLKDEV_GRANT=y
     7.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     7.7 +CONFIG_XEN_BACKEND=y
     7.8  CONFIG_XEN_BLKDEV_BACKEND=y
     7.9  CONFIG_XEN_SYSFS=y
    7.10  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
     8.1 --- a/buildconfigs/linux-defconfig_xen_x86_32	Mon Apr 10 18:18:03 2006 +0100
     8.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32	Mon Apr 10 18:30:07 2006 +0100
     8.3 @@ -2979,6 +2979,7 @@ CONFIG_NO_IDLE_HZ=y
     8.4  #
     8.5  CONFIG_XEN_PRIVILEGED_GUEST=y
     8.6  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
     8.7 +CONFIG_XEN_BACKEND=y
     8.8  CONFIG_XEN_PCIDEV_BACKEND=y
     8.9  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
    8.10  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     9.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Mon Apr 10 18:18:03 2006 +0100
     9.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Mon Apr 10 18:30:07 2006 +0100
     9.3 @@ -2656,6 +2656,7 @@ CONFIG_NO_IDLE_HZ=y
     9.4  #
     9.5  CONFIG_XEN_PRIVILEGED_GUEST=y
     9.6  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
     9.7 +CONFIG_XEN_BACKEND=y
     9.8  CONFIG_XEN_PCIDEV_BACKEND=y
     9.9  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
    9.10  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
    10.1 --- a/linux-2.6-xen-sparse/arch/ia64/Kconfig	Mon Apr 10 18:18:03 2006 +0100
    10.2 +++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig	Mon Apr 10 18:30:07 2006 +0100
    10.3 @@ -79,8 +79,13 @@ config XEN_BLKDEV_FRONTEND
    10.4  	bool
    10.5  	default y
    10.6  
    10.7 +config XEN_BACKEND
    10.8 +	depends on XEN
    10.9 +	bool
   10.10 +	default y
   10.11 +
   10.12  config XEN_BLKDEV_BACKEND
   10.13 -	depends on XEN
   10.14 +	depends on XEN && XEN_BACKEND
   10.15  	bool
   10.16  	default y
   10.17  
    11.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Mon Apr 10 18:18:03 2006 +0100
    11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Mon Apr 10 18:30:07 2006 +0100
    11.3 @@ -28,9 +28,16 @@ config XEN_UNPRIVILEGED_GUEST
    11.4  	bool
    11.5  	default !XEN_PRIVILEGED_GUEST
    11.6  
    11.7 +config XEN_BACKEND
    11.8 +        tristate "Backend driver support"
    11.9 +        default y
   11.10 +        help
   11.11 +          Support for backend device drivers that provide I/O services
   11.12 +          to other virtual machines.
   11.13 +
   11.14  config XEN_PCIDEV_BACKEND
   11.15  	tristate "PCI device backend driver"
   11.16 -	depends PCI
   11.17 +	depends on PCI && XEN_BACKEND
   11.18  	default XEN_PRIVILEGED_GUEST
   11.19  	help
   11.20  	  The PCI device backend driver allows the kernel to export arbitrary
   11.21 @@ -70,6 +77,7 @@ config XEN_PCIDEV_BE_DEBUG
   11.22  
   11.23  config XEN_BLKDEV_BACKEND
   11.24  	tristate "Block-device backend driver"
   11.25 +        depends on XEN_BACKEND
   11.26  	default y
   11.27  	help
   11.28  	  The block-device backend driver allows the kernel to export its
   11.29 @@ -91,6 +99,7 @@ config XEN_BLKDEV_TAP_BE
   11.30  
   11.31  config XEN_NETDEV_BACKEND
   11.32  	tristate "Network-device backend driver"
   11.33 +        depends on XEN_BACKEND
   11.34  	default y
   11.35  	help
   11.36  	  The network-device backend driver allows the kernel to export its
   11.37 @@ -120,6 +129,7 @@ config XEN_NETDEV_LOOPBACK
   11.38  
   11.39  config XEN_TPMDEV_BACKEND
   11.40  	tristate "TPM-device backend driver"
   11.41 +        depends on XEN_BACKEND
   11.42  	default n
   11.43  	help
   11.44  	  The TPM-device backend driver
   11.45 @@ -155,6 +165,7 @@ config XEN_NETDEV_FRONTEND
   11.46  
   11.47  config XEN_BLKDEV_TAP
   11.48  	tristate "Block device tap driver"
   11.49 +        depends on XEN_BACKEND
   11.50  	default n
   11.51  	help
   11.52  	  This driver allows a VM to interact on block device channels
    12.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile	Mon Apr 10 18:18:03 2006 +0100
    12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile	Mon Apr 10 18:30:07 2006 +0100
    12.3 @@ -1,4 +1,8 @@
    12.4  obj-y	+= xenbus.o
    12.5 +obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o
    12.6 +
    12.7 +xenbus_be-objs =
    12.8 +xenbus_be-objs += xenbus_backend_client.o
    12.9  
   12.10  xenbus-objs =
   12.11  xenbus-objs += xenbus_client.o
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Mon Apr 10 18:30:07 2006 +0100
    13.3 @@ -0,0 +1,173 @@
    13.4 +/******************************************************************************
    13.5 + * Backend-client-facing interface for the Xenbus driver.  In other words, the
    13.6 + * interface between the Xenbus and the device-specific code in the backend
    13.7 + * driver.
    13.8 + *
    13.9 + * Copyright (C) 2005-2006 XenSource Ltd
   13.10 + * 
   13.11 + * This program is free software; you can redistribute it and/or
   13.12 + * modify it under the terms of the GNU General Public License version 2
   13.13 + * as published by the Free Software Foundation; or, when distributed
   13.14 + * separately from the Linux kernel or incorporated into other
   13.15 + * software packages, subject to the following license:
   13.16 + * 
   13.17 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   13.18 + * of this source file (the "Software"), to deal in the Software without
   13.19 + * restriction, including without limitation the rights to use, copy, modify,
   13.20 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   13.21 + * and to permit persons to whom the Software is furnished to do so, subject to
   13.22 + * the following conditions:
   13.23 + * 
   13.24 + * The above copyright notice and this permission notice shall be included in
   13.25 + * all copies or substantial portions of the Software.
   13.26 + * 
   13.27 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   13.28 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   13.29 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   13.30 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   13.31 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   13.32 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   13.33 + * IN THE SOFTWARE.
   13.34 + */
   13.35 +
   13.36 +#include <xen/gnttab.h>
   13.37 +#include <xen/xenbus.h>
   13.38 +#include <xen/driver_util.h>
   13.39 +
   13.40 +/* Based on Rusty Russell's skeleton driver's map_page */
   13.41 +int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
   13.42 +{
   13.43 +	struct gnttab_map_grant_ref op = {
   13.44 +		.flags = GNTMAP_host_map,
   13.45 +		.ref   = gnt_ref,
   13.46 +		.dom   = dev->otherend_id,
   13.47 +	};
   13.48 +	struct vm_struct *area;
   13.49 +
   13.50 +	*vaddr = NULL;
   13.51 +
   13.52 +	area = alloc_vm_area(PAGE_SIZE);
   13.53 +	if (!area)
   13.54 +		return -ENOMEM;
   13.55 +
   13.56 +	op.host_addr = (unsigned long)area->addr;
   13.57 +
   13.58 +	lock_vm_area(area);
   13.59 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   13.60 +	unlock_vm_area(area);
   13.61 +
   13.62 +	if (op.status != GNTST_okay) {
   13.63 +		free_vm_area(area);
   13.64 +		xenbus_dev_fatal(dev, op.status,
   13.65 +				 "mapping in shared page %d from domain %d",
   13.66 +				 gnt_ref, dev->otherend_id);
   13.67 +		return op.status;
   13.68 +	}
   13.69 +
   13.70 +	/* Stuff the handle in an unused field */
   13.71 +	area->phys_addr = (unsigned long)op.handle;
   13.72 +
   13.73 +	*vaddr = area->addr;
   13.74 +	return 0;
   13.75 +}
   13.76 +EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
   13.77 +
   13.78 +
   13.79 +int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
   13.80 +		   grant_handle_t *handle, void *vaddr)
   13.81 +{
   13.82 +	struct gnttab_map_grant_ref op = {
   13.83 +		.host_addr = (unsigned long)vaddr,
   13.84 +		.flags     = GNTMAP_host_map,
   13.85 +		.ref       = gnt_ref,
   13.86 +		.dom       = dev->otherend_id,
   13.87 +	};
   13.88 +
   13.89 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   13.90 +
   13.91 +	if (op.status != GNTST_okay) {
   13.92 +		xenbus_dev_fatal(dev, op.status,
   13.93 +				 "mapping in shared page %d from domain %d",
   13.94 +				 gnt_ref, dev->otherend_id);
   13.95 +	} else
   13.96 +		*handle = op.handle;
   13.97 +
   13.98 +	return op.status;
   13.99 +}
  13.100 +EXPORT_SYMBOL_GPL(xenbus_map_ring);
  13.101 +
  13.102 +
  13.103 +/* Based on Rusty Russell's skeleton driver's unmap_page */
  13.104 +int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
  13.105 +{
  13.106 +	struct vm_struct *area;
  13.107 +	struct gnttab_unmap_grant_ref op = {
  13.108 +		.host_addr = (unsigned long)vaddr,
  13.109 +	};
  13.110 +
  13.111 +	/* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
  13.112 +	 * method so that we don't have to muck with vmalloc internals here.
  13.113 +	 * We could force the user to hang on to their struct vm_struct from
  13.114 +	 * xenbus_map_ring_valloc, but these 6 lines considerably simplify
  13.115 +	 * this API.
  13.116 +	 */
  13.117 +	read_lock(&vmlist_lock);
  13.118 +	for (area = vmlist; area != NULL; area = area->next) {
  13.119 +		if (area->addr == vaddr)
  13.120 +			break;
  13.121 +	}
  13.122 +	read_unlock(&vmlist_lock);
  13.123 +
  13.124 +	if (!area) {
  13.125 +		xenbus_dev_error(dev, -ENOENT,
  13.126 +				 "can't find mapped virtual address %p", vaddr);
  13.127 +		return GNTST_bad_virt_addr;
  13.128 +	}
  13.129 +
  13.130 +	op.handle = (grant_handle_t)area->phys_addr;
  13.131 +
  13.132 +	lock_vm_area(area);
  13.133 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  13.134 +	unlock_vm_area(area);
  13.135 +
  13.136 +	if (op.status == GNTST_okay)
  13.137 +		free_vm_area(area);
  13.138 +	else
  13.139 +		xenbus_dev_error(dev, op.status,
  13.140 +				 "unmapping page at handle %d error %d",
  13.141 +				 (int16_t)area->phys_addr, op.status);
  13.142 +
  13.143 +	return op.status;
  13.144 +}
  13.145 +EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
  13.146 +
  13.147 +
  13.148 +int xenbus_unmap_ring(struct xenbus_device *dev,
  13.149 +		     grant_handle_t handle, void *vaddr)
  13.150 +{
  13.151 +	struct gnttab_unmap_grant_ref op = {
  13.152 +		.host_addr = (unsigned long)vaddr,
  13.153 +		.handle    = handle,
  13.154 +	};
  13.155 +
  13.156 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  13.157 +
  13.158 +	if (op.status != GNTST_okay)
  13.159 +		xenbus_dev_error(dev, op.status,
  13.160 +				 "unmapping page at handle %d error %d",
  13.161 +				 handle, op.status);
  13.162 +
  13.163 +	return op.status;
  13.164 +}
  13.165 +EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
  13.166 +
  13.167 +
  13.168 +/*
  13.169 + * Local variables:
  13.170 + *  c-file-style: "linux"
  13.171 + *  indent-tabs-mode: t
  13.172 + *  c-indent-level: 8
  13.173 + *  c-basic-offset: 8
  13.174 + *  tab-width: 8
  13.175 + * End:
  13.176 + */
    14.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Mon Apr 10 18:18:03 2006 +0100
    14.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Mon Apr 10 18:30:07 2006 +0100
    14.3 @@ -261,134 +261,6 @@ int xenbus_free_evtchn(struct xenbus_dev
    14.4  }
    14.5  
    14.6  
    14.7 -/* Based on Rusty Russell's skeleton driver's map_page */
    14.8 -int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
    14.9 -{
   14.10 -	struct gnttab_map_grant_ref op = {
   14.11 -		.flags = GNTMAP_host_map,
   14.12 -		.ref   = gnt_ref,
   14.13 -		.dom   = dev->otherend_id,
   14.14 -	};
   14.15 -	struct vm_struct *area;
   14.16 -
   14.17 -	*vaddr = NULL;
   14.18 -
   14.19 -	area = alloc_vm_area(PAGE_SIZE);
   14.20 -	if (!area)
   14.21 -		return -ENOMEM;
   14.22 -
   14.23 -	op.host_addr = (unsigned long)area->addr;
   14.24 -
   14.25 -	lock_vm_area(area);
   14.26 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   14.27 -	unlock_vm_area(area);
   14.28 -
   14.29 -	if (op.status != GNTST_okay) {
   14.30 -		free_vm_area(area);
   14.31 -		xenbus_dev_fatal(dev, op.status,
   14.32 -				 "mapping in shared page %d from domain %d",
   14.33 -				 gnt_ref, dev->otherend_id);
   14.34 -		return op.status;
   14.35 -	}
   14.36 -
   14.37 -	/* Stuff the handle in an unused field */
   14.38 -	area->phys_addr = (unsigned long)op.handle;
   14.39 -
   14.40 -	*vaddr = area->addr;
   14.41 -	return 0;
   14.42 -}
   14.43 -EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
   14.44 -
   14.45 -
   14.46 -int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
   14.47 -		   grant_handle_t *handle, void *vaddr)
   14.48 -{
   14.49 -	struct gnttab_map_grant_ref op = {
   14.50 -		.host_addr = (unsigned long)vaddr,
   14.51 -		.flags     = GNTMAP_host_map,
   14.52 -		.ref       = gnt_ref,
   14.53 -		.dom       = dev->otherend_id,
   14.54 -	};
   14.55 -
   14.56 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   14.57 -
   14.58 -	if (op.status != GNTST_okay) {
   14.59 -		xenbus_dev_fatal(dev, op.status,
   14.60 -				 "mapping in shared page %d from domain %d",
   14.61 -				 gnt_ref, dev->otherend_id);
   14.62 -	} else
   14.63 -		*handle = op.handle;
   14.64 -
   14.65 -	return op.status;
   14.66 -}
   14.67 -EXPORT_SYMBOL_GPL(xenbus_map_ring);
   14.68 -
   14.69 -
   14.70 -/* Based on Rusty Russell's skeleton driver's unmap_page */
   14.71 -int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
   14.72 -{
   14.73 -	struct vm_struct *area;
   14.74 -	struct gnttab_unmap_grant_ref op = {
   14.75 -		.host_addr = (unsigned long)vaddr,
   14.76 -	};
   14.77 -
   14.78 -	/* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
   14.79 -	 * method so that we don't have to muck with vmalloc internals here.
   14.80 -	 * We could force the user to hang on to their struct vm_struct from
   14.81 -	 * xenbus_map_ring_valloc, but these 6 lines considerably simplify
   14.82 -	 * this API.
   14.83 -	 */
   14.84 -	read_lock(&vmlist_lock);
   14.85 -	for (area = vmlist; area != NULL; area = area->next) {
   14.86 -		if (area->addr == vaddr)
   14.87 -			break;
   14.88 -	}
   14.89 -	read_unlock(&vmlist_lock);
   14.90 -
   14.91 -	if (!area) {
   14.92 -		xenbus_dev_error(dev, -ENOENT,
   14.93 -				 "can't find mapped virtual address %p", vaddr);
   14.94 -		return GNTST_bad_virt_addr;
   14.95 -	}
   14.96 -
   14.97 -	op.handle = (grant_handle_t)area->phys_addr;
   14.98 -
   14.99 -	lock_vm_area(area);
  14.100 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  14.101 -	unlock_vm_area(area);
  14.102 -
  14.103 -	if (op.status == GNTST_okay)
  14.104 -		free_vm_area(area);
  14.105 -	else
  14.106 -		xenbus_dev_error(dev, op.status,
  14.107 -				 "unmapping page at handle %d error %d",
  14.108 -				 (int16_t)area->phys_addr, op.status);
  14.109 -
  14.110 -	return op.status;
  14.111 -}
  14.112 -EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
  14.113 -
  14.114 -
  14.115 -int xenbus_unmap_ring(struct xenbus_device *dev,
  14.116 -		     grant_handle_t handle, void *vaddr)
  14.117 -{
  14.118 -	struct gnttab_unmap_grant_ref op = {
  14.119 -		.host_addr = (unsigned long)vaddr,
  14.120 -		.handle    = handle,
  14.121 -	};
  14.122 -
  14.123 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  14.124 -
  14.125 -	if (op.status != GNTST_okay)
  14.126 -		xenbus_dev_error(dev, op.status,
  14.127 -				 "unmapping page at handle %d error %d",
  14.128 -				 handle, op.status);
  14.129 -
  14.130 -	return op.status;
  14.131 -}
  14.132 -EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
  14.133 -
  14.134 -
  14.135  XenbusState xenbus_read_driver_state(const char *path)
  14.136  {
  14.137  	XenbusState result;