[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Merged.
# HG changeset patch # User emellor@xxxxxxxxxxxxxxxxxxxxxx # Node ID 439c25bd2235b50606d35e554060eca2b210f4ae # Parent 67fecef14e1a9ace1129d06dae3998b73f3882cb # Parent 530aede2d28c4e8aaf32a209d3facc66f4f1fd47 Merged. diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/Rules.mk --- a/buildconfigs/Rules.mk Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/Rules.mk Tue Apr 11 11:42:28 2006 @@ -124,14 +124,14 @@ rm -rf tmp-$@ cp -al $(<D) tmp-$@ ( cd linux-2.6-xen-sparse && ./mkbuildtree ../tmp-$@ ) - diff -Nurp $(<D) tmp-$@ > $@ || true + diff -Nurp $(patsubst ref%,pristine%,$(<D)) tmp-$@ > $@ || true rm -rf tmp-$@ %-xen.patch: ref-%/.valid-ref rm -rf tmp-$@ cp -al $(<D) tmp-$@ ( cd $*-xen-sparse && ./mkbuildtree ../tmp-$@ ) - diff -Nurp $(<D) tmp-$@ > $@ || true + diff -Nurp $(patsubst ref%,pristine%,$(<D)) tmp-$@ > $@ || true rm -rf tmp-$@ %-mrproper: %-mrproper-extra diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xen0_ia64 --- a/buildconfigs/linux-defconfig_xen0_ia64 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xen0_ia64 Tue Apr 11 11:42:28 2006 @@ -95,6 +95,7 @@ CONFIG_XEN_PRIVILEGED_GUEST=y CONFIG_XEN_BLKDEV_GRANT=y CONFIG_XEN_BLKDEV_FRONTEND=y +CONFIG_XEN_BACKEND=y CONFIG_XEN_BLKDEV_BACKEND=y CONFIG_XEN_SYSFS=y CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xen0_x86_32 --- a/buildconfigs/linux-defconfig_xen0_x86_32 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xen0_x86_32 Tue Apr 11 11:42:28 2006 @@ -1312,6 +1312,7 @@ # CONFIG_XEN_PRIVILEGED_GUEST=y # CONFIG_XEN_UNPRIVILEGED_GUEST is not set +CONFIG_XEN_BACKEND=y CONFIG_XEN_PCIDEV_BACKEND=y # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set CONFIG_XEN_PCIDEV_BACKEND_PASS=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xen0_x86_64 --- a/buildconfigs/linux-defconfig_xen0_x86_64 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xen0_x86_64 Tue Apr 11 11:42:28 2006 @@ -1238,6 +1238,7 @@ # CONFIG_XEN_PRIVILEGED_GUEST=y # CONFIG_XEN_UNPRIVILEGED_GUEST is not set +CONFIG_XEN_BACKEND=y CONFIG_XEN_PCIDEV_BACKEND=y # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set CONFIG_XEN_PCIDEV_BACKEND_PASS=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xenU_ia64 --- a/buildconfigs/linux-defconfig_xenU_ia64 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xenU_ia64 Tue Apr 11 11:42:28 2006 @@ -92,6 +92,7 @@ CONFIG_XEN_PRIVILEGED_GUEST=y CONFIG_XEN_BLKDEV_GRANT=y CONFIG_XEN_BLKDEV_FRONTEND=y +CONFIG_XEN_BACKEND=y CONFIG_XEN_BLKDEV_BACKEND=y CONFIG_XEN_SYSFS=y CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xenU_x86_32 --- a/buildconfigs/linux-defconfig_xenU_x86_32 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xenU_x86_32 Tue Apr 11 11:42:28 2006 @@ -858,13 +858,9 @@ # # CONFIG_XEN_PRIVILEGED_GUEST is not set CONFIG_XEN_UNPRIVILEGED_GUEST=y -# CONFIG_XEN_PCIDEV_BACKEND is not set -# CONFIG_XEN_BLKDEV_BACKEND is not set -# CONFIG_XEN_NETDEV_BACKEND is not set -# CONFIG_XEN_TPMDEV_BACKEND is not set +# CONFIG_XEN_BACKEND is not set CONFIG_XEN_BLKDEV_FRONTEND=y CONFIG_XEN_NETDEV_FRONTEND=y -# CONFIG_XEN_BLKDEV_TAP is not set # CONFIG_XEN_TPMDEV_FRONTEND is not set CONFIG_XEN_SCRUB_PAGES=y CONFIG_XEN_DISABLE_SERIAL=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xenU_x86_64 --- a/buildconfigs/linux-defconfig_xenU_x86_64 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xenU_x86_64 Tue Apr 11 11:42:28 2006 @@ -1135,13 +1135,9 @@ # # CONFIG_XEN_PRIVILEGED_GUEST is not set CONFIG_XEN_UNPRIVILEGED_GUEST=y -# CONFIG_XEN_PCIDEV_BACKEND is not set -# CONFIG_XEN_BLKDEV_BACKEND is not set -# CONFIG_XEN_NETDEV_BACKEND is not set -# CONFIG_XEN_TPMDEV_BACKEND is not set +# CONFIG_XEN_BACKEND is not set CONFIG_XEN_BLKDEV_FRONTEND=y CONFIG_XEN_NETDEV_FRONTEND=y -# CONFIG_XEN_BLKDEV_TAP is not set # CONFIG_XEN_TPMDEV_FRONTEND is not set CONFIG_XEN_SCRUB_PAGES=y CONFIG_XEN_DISABLE_SERIAL=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xen_ia64 --- a/buildconfigs/linux-defconfig_xen_ia64 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xen_ia64 Tue Apr 11 11:42:28 2006 @@ -95,6 +95,7 @@ CONFIG_XEN_PRIVILEGED_GUEST=y CONFIG_XEN_BLKDEV_GRANT=y CONFIG_XEN_BLKDEV_FRONTEND=y +CONFIG_XEN_BACKEND=y CONFIG_XEN_BLKDEV_BACKEND=y CONFIG_XEN_SYSFS=y CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xen_x86_32 --- a/buildconfigs/linux-defconfig_xen_x86_32 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xen_x86_32 Tue Apr 11 11:42:28 2006 @@ -2978,6 +2978,7 @@ # CONFIG_XEN_PRIVILEGED_GUEST=y # CONFIG_XEN_UNPRIVILEGED_GUEST is not set +CONFIG_XEN_BACKEND=y CONFIG_XEN_PCIDEV_BACKEND=y # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set CONFIG_XEN_PCIDEV_BACKEND_PASS=y diff -r 67fecef14e1a -r 439c25bd2235 buildconfigs/linux-defconfig_xen_x86_64 --- a/buildconfigs/linux-defconfig_xen_x86_64 Mon Apr 10 15:38:48 2006 +++ b/buildconfigs/linux-defconfig_xen_x86_64 Tue Apr 11 11:42:28 2006 @@ -2648,6 +2648,7 @@ # CONFIG_XEN_PRIVILEGED_GUEST=y # CONFIG_XEN_UNPRIVILEGED_GUEST is not set +CONFIG_XEN_BACKEND=y CONFIG_XEN_PCIDEV_BACKEND=y # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set CONFIG_XEN_PCIDEV_BACKEND_PASS=y diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/arch/ia64/Kconfig --- a/linux-2.6-xen-sparse/arch/ia64/Kconfig Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig Tue Apr 11 11:42:28 2006 @@ -79,8 +79,13 @@ bool default y +config XEN_BACKEND + depends on XEN + bool + default y + config XEN_BLKDEV_BACKEND - depends on XEN + depends on XEN && XEN_BACKEND bool default y diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/drivers/xen/Kconfig --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig Tue Apr 11 11:42:28 2006 @@ -28,9 +28,16 @@ bool default !XEN_PRIVILEGED_GUEST +config XEN_BACKEND + tristate "Backend driver support" + default y + help + Support for backend device drivers that provide I/O services + to other virtual machines. + config XEN_PCIDEV_BACKEND tristate "PCI device backend driver" - depends PCI + depends on PCI && XEN_BACKEND default XEN_PRIVILEGED_GUEST help The PCI device backend driver allows the kernel to export arbitrary @@ -70,6 +77,7 @@ config XEN_BLKDEV_BACKEND tristate "Block-device backend driver" + depends on XEN_BACKEND default y help The block-device backend driver allows the kernel to export its @@ -91,6 +99,7 @@ config XEN_NETDEV_BACKEND tristate "Network-device backend driver" + depends on XEN_BACKEND default y help The network-device backend driver allows the kernel to export its @@ -120,6 +129,7 @@ config XEN_TPMDEV_BACKEND tristate "TPM-device backend driver" + depends on XEN_BACKEND default n help The TPM-device backend driver @@ -155,6 +165,7 @@ config XEN_BLKDEV_TAP tristate "Block device tap driver" + depends on XEN_BACKEND default n help This driver allows a VM to interact on block device channels diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue Apr 11 11:42:28 2006 @@ -300,13 +300,6 @@ goto abort_transaction; } - err = xenbus_printf(xbt, dev->nodename, - "state", "%d", XenbusStateConnected); - if (err) { - message = "writing frontend XenbusStateConnected"; - goto abort_transaction; - } - err = xenbus_transaction_end(xbt, 0); if (err) { if (err == -EAGAIN) @@ -314,6 +307,8 @@ xenbus_dev_fatal(dev, err, "completing transaction"); goto destroy_ring; } + + xenbus_switch_state(dev, XenbusStateConnected); return 0; diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile Tue Apr 11 11:42:28 2006 @@ -1,4 +1,8 @@ obj-y += xenbus.o +obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o + +xenbus_be-objs = +xenbus_be-objs += xenbus_backend_client.o xenbus-objs = xenbus-objs += xenbus_client.o diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Tue Apr 11 11:42:28 2006 @@ -259,134 +259,6 @@ xenbus_dev_error(dev, err, "freeing event channel %d", port); return err; } - - -/* Based on Rusty Russell's skeleton driver's map_page */ -int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr) -{ - struct gnttab_map_grant_ref op = { - .flags = GNTMAP_host_map, - .ref = gnt_ref, - .dom = dev->otherend_id, - }; - struct vm_struct *area; - - *vaddr = NULL; - - area = alloc_vm_area(PAGE_SIZE); - if (!area) - return -ENOMEM; - - op.host_addr = (unsigned long)area->addr; - - lock_vm_area(area); - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1)); - unlock_vm_area(area); - - if (op.status != GNTST_okay) { - free_vm_area(area); - xenbus_dev_fatal(dev, op.status, - "mapping in shared page %d from domain %d", - gnt_ref, dev->otherend_id); - return op.status; - } - - /* Stuff the handle in an unused field */ - area->phys_addr = (unsigned long)op.handle; - - *vaddr = area->addr; - return 0; -} -EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc); - - -int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref, - grant_handle_t *handle, void *vaddr) -{ - struct gnttab_map_grant_ref op = { - .host_addr = (unsigned long)vaddr, - .flags = GNTMAP_host_map, - .ref = gnt_ref, - .dom = dev->otherend_id, - }; - - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1)); - - if (op.status != GNTST_okay) { - xenbus_dev_fatal(dev, op.status, - "mapping in shared page %d from domain %d", - gnt_ref, dev->otherend_id); - } else - *handle = op.handle; - - return op.status; -} -EXPORT_SYMBOL_GPL(xenbus_map_ring); - - -/* Based on Rusty Russell's skeleton driver's unmap_page */ -int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr) -{ - struct vm_struct *area; - struct gnttab_unmap_grant_ref op = { - .host_addr = (unsigned long)vaddr, - }; - - /* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr) - * method so that we don't have to muck with vmalloc internals here. - * We could force the user to hang on to their struct vm_struct from - * xenbus_map_ring_valloc, but these 6 lines considerably simplify - * this API. - */ - read_lock(&vmlist_lock); - for (area = vmlist; area != NULL; area = area->next) { - if (area->addr == vaddr) - break; - } - read_unlock(&vmlist_lock); - - if (!area) { - xenbus_dev_error(dev, -ENOENT, - "can't find mapped virtual address %p", vaddr); - return GNTST_bad_virt_addr; - } - - op.handle = (grant_handle_t)area->phys_addr; - - lock_vm_area(area); - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1)); - unlock_vm_area(area); - - if (op.status == GNTST_okay) - free_vm_area(area); - else - xenbus_dev_error(dev, op.status, - "unmapping page at handle %d error %d", - (int16_t)area->phys_addr, op.status); - - return op.status; -} -EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree); - - -int xenbus_unmap_ring(struct xenbus_device *dev, - grant_handle_t handle, void *vaddr) -{ - struct gnttab_unmap_grant_ref op = { - .host_addr = (unsigned long)vaddr, - .handle = handle, - }; - - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1)); - - if (op.status != GNTST_okay) - xenbus_dev_error(dev, op.status, - "unmapping page at handle %d error %d", - handle, op.status); - - return op.status; -} -EXPORT_SYMBOL_GPL(xenbus_unmap_ring); XenbusState xenbus_read_driver_state(const char *path) diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Apr 11 11:42:28 2006 @@ -3,7 +3,7 @@ * * Copyright (C) 2005 Rusty Russell, IBM Corporation * Copyright (C) 2005 Mike Wray, Hewlett-Packard - * Copyright (C) 2005 XenSource Ltd + * Copyright (C) 2005, 2006 XenSource Ltd * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -883,7 +883,7 @@ int *result = data; if (xendev->state != XenbusStateConnected) { - result = 0; + *result = 0; return 1; } @@ -902,8 +902,6 @@ void xenbus_probe(void *unused) { - int i; - BUG_ON((xenstored_ready <= 0)); /* Enumerate devices in xenstore. */ @@ -916,28 +914,6 @@ /* Notify others that xenstore is up */ notifier_call_chain(&xenstore_chain, 0, NULL); - - /* On a 10 second timeout, waiting for all devices currently - configured. We need to do this to guarantee that the filesystems - and / or network devices needed for boot are available, before we - can allow the boot to proceed. - - A possible improvement here would be to have the tools add a - per-device flag to the store entry, indicating whether it is needed - at boot time. This would allow people who knew what they were - doing to accelerate their boot slightly, but of course needs tools - or manual intervention to set up those flags correctly. - */ - for (i = 0; i < 10 * HZ; i++) { - if (all_devices_ready()) - return; - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } - - printk(KERN_WARNING - "XENBUS: Timeout connecting to devices!\n"); } @@ -1072,6 +1048,38 @@ postcore_initcall(xenbus_probe_init); + +/* + * On a 10 second timeout, wait for all devices currently configured. We need + * to do this to guarantee that the filesystems and / or network devices + * needed for boot are available, before we can allow the boot to proceed. + * + * This needs to be on a late_initcall, to happen after the frontend device + * drivers have been initialised, but before the root fs is mounted. + * + * A possible improvement here would be to have the tools add a per-device + * flag to the store entry, indicating whether it is needed at boot time. + * This would allow people who knew what they were doing to accelerate their + * boot slightly, but of course needs tools or manual intervention to set up + * those flags correctly. + */ +static int __init wait_for_devices(void) +{ + unsigned long timeout = jiffies + 10*HZ; + + while (time_before(jiffies, timeout)) { + if (all_devices_ready()) + return 0; + schedule_timeout_interruptible(HZ/10); + } + + printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n"); + return 0; +} + +late_initcall(wait_for_devices); + + /* * Local variables: * c-file-style: "linux" diff -r 67fecef14e1a -r 439c25bd2235 tools/ioemu/hw/vga.c --- a/tools/ioemu/hw/vga.c Mon Apr 10 15:38:48 2006 +++ b/tools/ioemu/hw/vga.c Tue Apr 11 11:42:28 2006 @@ -1369,10 +1369,16 @@ { unsigned int eax, edx; - __asm__("cpuid" +#ifdef __x86_64__ +#define __bx "rbx" +#else +#define __bx "ebx" +#endif + __asm__("push %%"__bx"; cpuid; pop %%"__bx : "=a" (eax), "=d" (edx) : "0" (op) - : "bx", "cx"); + : "cx"); +#undef __bx return edx; } diff -r 67fecef14e1a -r 439c25bd2235 tools/ioemu/vl.c --- a/tools/ioemu/vl.c Mon Apr 10 15:38:48 2006 +++ b/tools/ioemu/vl.c Tue Apr 11 11:42:28 2006 @@ -3243,8 +3243,17 @@ /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); if (has_cdrom) { - bs_table[2] = bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); + int fd; + if ( (fd = open(hd_filename[2], O_RDONLY | O_BINARY)) < 0) { + hd_filename[2]=NULL; + bs_table[2]=NULL; + fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]); + } + else { + close(fd); + bs_table[2] = bdrv_new("cdrom"); + bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); + } } /* open the virtual block devices */ diff -r 67fecef14e1a -r 439c25bd2235 xen/arch/x86/hvm/platform.c --- a/xen/arch/x86/hvm/platform.c Mon Apr 10 15:38:48 2006 +++ b/xen/arch/x86/hvm/platform.c Tue Apr 11 11:42:28 2006 @@ -401,6 +401,11 @@ GET_OP_SIZE_FOR_NONEBYTE(instr->op_size); return reg_mem(instr->op_size, opcode, instr, rex); + case 0x3B: /* cmp m32/16, r32/16 */ + instr->instr = INSTR_CMP; + GET_OP_SIZE_FOR_NONEBYTE(instr->op_size); + return mem_reg(instr->op_size, opcode, instr, rex); + case 0x80: case 0x81: { diff -r 67fecef14e1a -r 439c25bd2235 xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Mon Apr 10 15:38:48 2006 +++ b/xen/arch/x86/hvm/vmx/vmx.c Tue Apr 11 11:42:28 2006 @@ -1947,7 +1947,7 @@ && !(vector & INTR_INFO_VALID_MASK)) __hvm_bug(regs); - vector &= 0xff; + vector &= INTR_INFO_VECTOR_MASK; local_irq_disable(); TRACE_VMEXIT(1,vector); @@ -2077,10 +2077,8 @@ return; } - { - __vmread(GUEST_RIP, &eip); - TRACE_VMEXIT(0,exit_reason); - } + __vmread(GUEST_RIP, &eip); + TRACE_VMEXIT(0,exit_reason); switch (exit_reason) { case EXIT_REASON_EXCEPTION_NMI: @@ -2097,7 +2095,7 @@ if ((error = __vmread(VM_EXIT_INTR_INFO, &vector)) || !(vector & INTR_INFO_VALID_MASK)) __hvm_bug(®s); - vector &= 0xff; + vector &= INTR_INFO_VECTOR_MASK; TRACE_VMEXIT(1,vector); perfc_incra(cause_vector, vector); diff -r 67fecef14e1a -r 439c25bd2235 xen/include/asm-x86/hvm/io.h --- a/xen/include/asm-x86/hvm/io.h Mon Apr 10 15:38:48 2006 +++ b/xen/include/asm-x86/hvm/io.h Tue Apr 11 11:42:28 2006 @@ -77,7 +77,7 @@ __u32 flags; }; -#define MAX_INST_LEN 32 +#define MAX_INST_LEN 15 /* Maximum instruction length = 15 bytes */ struct mmio_op { int flags; diff -r 67fecef14e1a -r 439c25bd2235 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c --- /dev/null Mon Apr 10 15:38:48 2006 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c Tue Apr 11 11:42:28 2006 @@ -0,0 +1,173 @@ +/****************************************************************************** + * Backend-client-facing interface for the Xenbus driver. In other words, the + * interface between the Xenbus and the device-specific code in the backend + * driver. + * + * Copyright (C) 2005-2006 XenSource Ltd + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation; or, when distributed + * separately from the Linux kernel or incorporated into other + * software packages, subject to the following license: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this source file (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include <xen/gnttab.h> +#include <xen/xenbus.h> +#include <xen/driver_util.h> + +/* Based on Rusty Russell's skeleton driver's map_page */ +int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr) +{ + struct gnttab_map_grant_ref op = { + .flags = GNTMAP_host_map, + .ref = gnt_ref, + .dom = dev->otherend_id, + }; + struct vm_struct *area; + + *vaddr = NULL; + + area = alloc_vm_area(PAGE_SIZE); + if (!area) + return -ENOMEM; + + op.host_addr = (unsigned long)area->addr; + + lock_vm_area(area); + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1)); + unlock_vm_area(area); + + if (op.status != GNTST_okay) { + free_vm_area(area); + xenbus_dev_fatal(dev, op.status, + "mapping in shared page %d from domain %d", + gnt_ref, dev->otherend_id); + return op.status; + } + + /* Stuff the handle in an unused field */ + area->phys_addr = (unsigned long)op.handle; + + *vaddr = area->addr; + return 0; +} +EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc); + + +int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref, + grant_handle_t *handle, void *vaddr) +{ + struct gnttab_map_grant_ref op = { + .host_addr = (unsigned long)vaddr, + .flags = GNTMAP_host_map, + .ref = gnt_ref, + .dom = dev->otherend_id, + }; + + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1)); + + if (op.status != GNTST_okay) { + xenbus_dev_fatal(dev, op.status, + "mapping in shared page %d from domain %d", + gnt_ref, dev->otherend_id); + } else + *handle = op.handle; + + return op.status; +} +EXPORT_SYMBOL_GPL(xenbus_map_ring); + + +/* Based on Rusty Russell's skeleton driver's unmap_page */ +int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr) +{ + struct vm_struct *area; + struct gnttab_unmap_grant_ref op = { + .host_addr = (unsigned long)vaddr, + }; + + /* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr) + * method so that we don't have to muck with vmalloc internals here. + * We could force the user to hang on to their struct vm_struct from + * xenbus_map_ring_valloc, but these 6 lines considerably simplify + * this API. + */ + read_lock(&vmlist_lock); + for (area = vmlist; area != NULL; area = area->next) { + if (area->addr == vaddr) + break; + } + read_unlock(&vmlist_lock); + + if (!area) { + xenbus_dev_error(dev, -ENOENT, + "can't find mapped virtual address %p", vaddr); + return GNTST_bad_virt_addr; + } + + op.handle = (grant_handle_t)area->phys_addr; + + lock_vm_area(area); + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1)); + unlock_vm_area(area); + + if (op.status == GNTST_okay) + free_vm_area(area); + else + xenbus_dev_error(dev, op.status, + "unmapping page at handle %d error %d", + (int16_t)area->phys_addr, op.status); + + return op.status; +} +EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree); + + +int xenbus_unmap_ring(struct xenbus_device *dev, + grant_handle_t handle, void *vaddr) +{ + struct gnttab_unmap_grant_ref op = { + .host_addr = (unsigned long)vaddr, + .handle = handle, + }; + + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1)); + + if (op.status != GNTST_okay) + xenbus_dev_error(dev, op.status, + "unmapping page at handle %d error %d", + handle, op.status); + + return op.status; +} +EXPORT_SYMBOL_GPL(xenbus_unmap_ring); + + +/* + * Local variables: + * c-file-style: "linux" + * indent-tabs-mode: t + * c-indent-level: 8 + * c-basic-offset: 8 + * tab-width: 8 + * End: + */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |