diff -Nur unmodified_drivers/linux-2.6/blkfront/blkfront.c unmodified_drivers_new/linux-2.6/blkfront/blkfront.c --- unmodified_drivers/linux-2.6/blkfront/blkfront.c 2006-10-04 00:38:41.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/blkfront/blkfront.c 2006-10-13 11:11:43.000000000 -0400 @@ -47,6 +47,7 @@ #include #include #include +#include #define BLKIF_STATE_DISCONNECTED 0 #define BLKIF_STATE_CONNECTED 1 @@ -466,6 +467,27 @@ command, (long)argument, inode->i_rdev); switch (command) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) + case HDIO_GETGEO: { + struct block_device *bd = inode->i_bdev; + struct hd_geometry geo; + int ret; + + if (!argument) + return -EINVAL; + + geo.start = get_start_sect(bd); + ret = blkif_getgeo(bd, &geo); + if (ret) + return ret; + + if (copy_to_user((struct hd_geometry __user *)argument, &geo, + sizeof(geo))) + return -EFAULT; + + return 0; + } +#endif case CDROMMULTISESSION: DPRINTK("FIXME: support multisession CDs later\n"); for (i = 0; i < sizeof(struct cdrom_multisession); i++) @@ -678,8 +700,12 @@ req, (bret->status == BLKIF_RSP_OKAY), req->hard_nr_sectors); BUG_ON(ret); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) + end_that_request_last(req); +#else end_that_request_last( req, (bret->status == BLKIF_RSP_OKAY)); +#endif break; default: BUG(); diff -Nur unmodified_drivers/linux-2.6/blkfront/Makefile unmodified_drivers_new/linux-2.6/blkfront/Makefile --- unmodified_drivers/linux-2.6/blkfront/Makefile 2006-10-04 00:38:41.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/blkfront/Makefile 2006-10-13 11:11:43.000000000 -0400 @@ -1,5 +1,5 @@ +include $(M)/overrides.mk -obj-$(CONFIG_XEN_BLKDEV_FRONTEND) := xenblk.o - -xenblk-objs := blkfront.o vbd.o +obj-m += xen-vbd.o +xen-vbd-objs := blkfront.o vbd.o diff -Nur unmodified_drivers/linux-2.6/blkfront/vbd.c unmodified_drivers_new/linux-2.6/blkfront/vbd.c --- unmodified_drivers/linux-2.6/blkfront/vbd.c 2006-10-04 00:38:41.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/blkfront/vbd.c 2006-10-13 11:11:43.000000000 -0400 @@ -35,6 +35,7 @@ #include "block.h" #include #include +#include #define BLKIF_MAJOR(dev) ((dev)>>8) #define BLKIF_MINOR(dev) ((dev) & 0xff) @@ -91,7 +92,9 @@ .open = blkif_open, .release = blkif_release, .ioctl = blkif_ioctl, +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) .getgeo = blkif_getgeo +#endif }; DEFINE_SPINLOCK(blkif_io_lock); @@ -186,7 +189,11 @@ if (rq == NULL) return -1; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) elevator_init(rq, "noop"); +#else + elevator_init(rq, &elevator_noop); +#endif /* Hard sector size and max sectors impersonate the equiv. hardware. */ blk_queue_hardsect_size(rq, sector_size); diff -Nur unmodified_drivers/linux-2.6/include/asm/hypervisor.h unmodified_drivers_new/linux-2.6/include/asm/hypervisor.h --- unmodified_drivers/linux-2.6/include/asm/hypervisor.h 2006-10-04 00:38:45.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/include/asm/hypervisor.h 2006-10-13 11:11:43.000000000 -0400 @@ -47,10 +47,14 @@ #include #include #if defined(__i386__) -# ifdef CONFIG_X86_PAE -# include +# if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10) +# ifdef CONFIG_X86_PAE +# include +# else +# include +# endif # else -# include +typedef struct { pgd_t pgd; } pud_t; # endif #endif diff -Nur unmodified_drivers/linux-2.6/include/asm/synch_bitops.h unmodified_drivers_new/linux-2.6/include/asm/synch_bitops.h --- unmodified_drivers/linux-2.6/include/asm/synch_bitops.h 2006-10-04 00:38:45.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/include/asm/synch_bitops.h 2006-10-13 11:11:43.000000000 -0400 @@ -8,6 +8,7 @@ */ #include +#include #define ADDR (*(volatile long *) addr) diff -Nur unmodified_drivers/linux-2.6/include/xen/platform_compat.h unmodified_drivers_new/linux-2.6/include/xen/platform_compat.h --- unmodified_drivers/linux-2.6/include/xen/platform_compat.h 1969-12-31 19:00:00.000000000 -0500 +++ unmodified_drivers_new/linux-2.6/include/xen/platform_compat.h 2006-10-13 11:11:43.000000000 -0400 @@ -0,0 +1,55 @@ +/***************************************************************************** + * platform_compat.h + * Bridge the gap between legacy linux versions of interest and the current + * Linux kernel to support PV front-end drivers in the unmodified legacy + * kernels. + */ + +#ifndef __PLATFORM_COMPAT_H +#define __PLATFORM_COMPAT_H +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) + + +#if defined(__LINUX_COMPILER_H) && !defined(__always_inline) +#define __always_inline inline +#endif + +#if defined(__LINUX_CACHE_H) && !defined(__read_mostly) +#define __read_mostly +#endif + + +#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK) +#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED +#endif + + +/* + * Mutex support + */ +#define mutex semaphore +#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo) +#define mutex_init(foo) init_MUTEX(foo) +#define mutex_lock(foo) down(foo) +#define mutex_unlock(foo) up(foo) + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) +#define nonseekable_open(a,b) +extern int system_state; +size_t strcspn(const char *s, const char *reject); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) +unsigned long vmalloc_to_pfn(void *addr); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) +signed long schedule_timeout_interruptible(signed long timeout); +void *kzalloc(size_t size, int flags); +#endif + +#endif +#endif diff -Nur unmodified_drivers/linux-2.6/include/xen/xenbus.h unmodified_drivers_new/linux-2.6/include/xen/xenbus.h --- unmodified_drivers/linux-2.6/include/xen/xenbus.h 2006-10-04 00:38:49.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/include/xen/xenbus.h 2006-10-13 11:11:43.000000000 -0400 @@ -35,13 +35,18 @@ #define _XEN_XENBUS_H #include +#include #include +#include +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) #include +#endif #include #include #include #include #include +#include /* Register callback to watch this node. */ struct xenbus_watch diff -Nur unmodified_drivers/linux-2.6/netfront/Makefile unmodified_drivers_new/linux-2.6/netfront/Makefile --- unmodified_drivers/linux-2.6/netfront/Makefile 2006-10-04 00:38:42.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/netfront/Makefile 2006-10-13 11:11:43.000000000 -0400 @@ -1,4 +1,4 @@ +include $(M)/overrides.mk -obj-$(CONFIG_XEN_NETDEV_FRONTEND) := xennet.o - -xennet-objs := netfront.o +obj-m = xen-vnif.o +xen-vnif-objs := netfront.o diff -Nur unmodified_drivers/linux-2.6/netfront/netfront.c unmodified_drivers_new/linux-2.6/netfront/netfront.c --- unmodified_drivers/linux-2.6/netfront/netfront.c 2006-10-04 00:38:42.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/netfront/netfront.c 2006-10-13 11:11:43.000000000 -0400 @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff -Nur unmodified_drivers/linux-2.6/platform-pci/features.c unmodified_drivers_new/linux-2.6/platform-pci/features.c --- unmodified_drivers/linux-2.6/platform-pci/features.c 2006-10-04 00:38:41.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/platform-pci/features.c 2006-10-13 11:11:43.000000000 -0400 @@ -10,6 +10,7 @@ #include #include #include +#include u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly; /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */ diff -Nur unmodified_drivers/linux-2.6/platform-pci/Kbuild unmodified_drivers_new/linux-2.6/platform-pci/Kbuild --- unmodified_drivers/linux-2.6/platform-pci/Kbuild 2006-10-04 00:39:42.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/platform-pci/Kbuild 2006-10-13 11:11:43.000000000 -0400 @@ -4,4 +4,4 @@ EXTRA_CFLAGS += -I$(M)/platform-pci -xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o +xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o platform_compat.o diff -Nur unmodified_drivers/linux-2.6/platform-pci/Makefile unmodified_drivers_new/linux-2.6/platform-pci/Makefile --- unmodified_drivers/linux-2.6/platform-pci/Makefile 1969-12-31 19:00:00.000000000 -0500 +++ unmodified_drivers_new/linux-2.6/platform-pci/Makefile 2006-10-13 11:11:43.000000000 -0400 @@ -0,0 +1,7 @@ +include $(M)/overrides.mk + +obj-m := xen-platform-pci.o + +EXTRA_CFLAGS += -I$(M)/platform-pci + +xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o platform_compat.o diff -Nur unmodified_drivers/linux-2.6/platform-pci/platform_compat.c unmodified_drivers_new/linux-2.6/platform-pci/platform_compat.c --- unmodified_drivers/linux-2.6/platform-pci/platform_compat.c 1969-12-31 19:00:00.000000000 -0500 +++ unmodified_drivers_new/linux-2.6/platform-pci/platform_compat.c 2006-10-13 11:11:43.000000000 -0400 @@ -0,0 +1,93 @@ +/* + * Compatibility shim for hosting Xen PV drivers in unmodified + * 2.6.5 and 2.6.9 based kernels. + */ +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) +#include +#include +#include +#include +#include +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) +int system_state=1; +EXPORT_SYMBOL(system_state); + +/** + * strcspn - Calculate the length of the initial substring of @s which does + * not contain letters in @reject + * @s: The string to be searched + * @reject: The string to avoid + */ +size_t strcspn(const char *s, const char *reject) +{ + const char *p; + const char *r; + size_t count = 0; + + for (p = s; *p != '\0'; ++p) { + for (r = reject; *r != '\0'; ++r) { + if (*p == *r) + return count; + } + ++count; + } + + return count; +} + +EXPORT_SYMBOL(strcspn); + +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) +/* + * Map a vmalloc()-space virtual address to the physical page frame number. + */ +unsigned long vmalloc_to_pfn(void * vmalloc_addr) +{ + return page_to_pfn(vmalloc_to_page(vmalloc_addr)); +} + +EXPORT_SYMBOL(vmalloc_to_pfn); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) +/** + * kzalloc - allocate memory. The memory is set to zero. + * @size: how many bytes of memory are required. + * @flags: the type of memory to allocate. + */ +void *kzalloc(size_t size, int flags) +{ + void *ret = kmalloc(size, flags); + if (ret) + memset(ret, 0, size); + return ret; +} +EXPORT_SYMBOL(kzalloc); + +signed long schedule_timeout_interruptible(signed long timeout) +{ + __set_current_state(TASK_INTERRUPTIBLE); + return schedule_timeout(timeout); +} +EXPORT_SYMBOL(schedule_timeout_interruptible); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) +asmlinkage NORET_TYPE void do_exit(long code) +#else +fastcall NORET_TYPE void do_exit(long code) +#endif +{ + complete_and_exit(NULL, code); +} +EXPORT_SYMBOL(do_exit); +#endif + + +#endif diff -Nur unmodified_drivers/linux-2.6/platform-pci/platform-pci.c unmodified_drivers_new/linux-2.6/platform-pci/platform-pci.c --- unmodified_drivers/linux-2.6/platform-pci/platform-pci.c 2006-10-04 00:39:42.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/platform-pci/platform-pci.c 2006-10-13 11:11:43.000000000 -0400 @@ -35,6 +35,7 @@ #include #include #include +#include #include "platform-pci.h" diff -Nur unmodified_drivers/linux-2.6/xenbus/Makefile unmodified_drivers_new/linux-2.6/xenbus/Makefile --- unmodified_drivers/linux-2.6/xenbus/Makefile 2006-10-04 00:38:44.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/xenbus/Makefile 2006-10-13 11:11:43.000000000 -0400 @@ -1,12 +1,10 @@ -obj-y += xenbus.o -obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o - -xenbus_be-objs = -xenbus_be-objs += xenbus_backend_client.o +include $(M)/overrides.mk +obj-m += xenbus.o xenbus-objs = -xenbus-objs += xenbus_client.o xenbus-objs += xenbus_comms.o xenbus-objs += xenbus_xs.o -xenbus-objs += xenbus_probe.o -obj-$(CONFIG_XEN_XENBUS_DEV) += xenbus_dev.o +xenbus-objs += xenbus_probe.o +xenbus-objs += xenbus_dev.o +xenbus-objs += xenbus_client.o +xenbus-objs += xen_proc.o diff -Nur unmodified_drivers/linux-2.6/xenbus/xenbus_probe.c unmodified_drivers_new/linux-2.6/xenbus/xenbus_probe.c --- unmodified_drivers/linux-2.6/xenbus/xenbus_probe.c 2006-10-04 00:38:45.000000000 -0400 +++ unmodified_drivers_new/linux-2.6/xenbus/xenbus_probe.c 2006-10-13 19:00:04.000000000 -0400 @@ -67,13 +67,15 @@ static void wait_for_devices(struct xenbus_driver *xendrv); static int xenbus_probe_frontend(const char *type, const char *name); +#ifdef CONFIG_XEN_BACKEND static int xenbus_uevent_backend(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); static int xenbus_probe_backend(const char *type, const char *domid); +static void xenbus_dev_shutdown(struct device *_dev); +#endif static int xenbus_dev_probe(struct device *_dev); static int xenbus_dev_remove(struct device *_dev); -static void xenbus_dev_shutdown(struct device *_dev); /* If something in array of ids matches this device, return it. */ static const struct xenbus_device_id * @@ -176,11 +178,6 @@ } -static int read_frontend_details(struct xenbus_device *xendev) -{ - return read_otherend_details(xendev, "frontend-id", "frontend"); -} - /* Bus type for frontend drivers. */ static struct xen_bus_type xenbus_frontend = { @@ -191,15 +188,24 @@ .bus = { .name = "xen", .match = xenbus_match, +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) .probe = xenbus_dev_probe, .remove = xenbus_dev_remove, +#ifdef CONFIG_XEN_BACKEND .shutdown = xenbus_dev_shutdown, +#endif +#endif }, .dev = { .bus_id = "xen", }, }; +#ifdef CONFIG_XEN_BACKEND +static int read_frontend_details(struct xenbus_device *xendev) +{ + return read_otherend_details(xendev, "frontend-id", "frontend"); +} /* backend/// => -- */ static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename) { @@ -300,6 +306,8 @@ return 0; } +#endif + static void otherend_changed(struct xenbus_watch *watch, const char **vec, unsigned int len) { @@ -409,6 +417,7 @@ return 0; } +#ifdef CONFIG_XEN_BACKEND static void xenbus_dev_shutdown(struct device *_dev) { struct xenbus_device *dev = to_xenbus_device(_dev); @@ -429,6 +438,7 @@ out: put_device(&dev->dev); } +#endif static int xenbus_register_driver_common(struct xenbus_driver *drv, struct xen_bus_type *bus) @@ -437,7 +447,11 @@ drv->driver.name = drv->name; drv->driver.bus = &bus->bus; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) drv->driver.owner = drv->owner; +#endif + drv->driver.probe = xenbus_dev_probe; + drv->driver.remove = xenbus_dev_remove; mutex_lock(&xenwatch_mutex); ret = driver_register(&drv->driver); @@ -462,6 +476,7 @@ } EXPORT_SYMBOL_GPL(xenbus_register_frontend); +#ifdef CONFIG_XEN_BACKEND int xenbus_register_backend(struct xenbus_driver *drv) { drv->read_otherend_details = read_frontend_details; @@ -469,6 +484,7 @@ return xenbus_register_driver_common(drv, &xenbus_backend); } EXPORT_SYMBOL_GPL(xenbus_register_backend); +#endif void xenbus_unregister_driver(struct xenbus_driver *drv) { @@ -566,15 +582,26 @@ return p; } +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) static ssize_t xendev_show_nodename(struct device *dev, struct device_attribute *attr, char *buf) +#else +static ssize_t xendev_show_nodename(struct device *dev, + char *buf) +#endif { return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename); } DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) static ssize_t xendev_show_devtype(struct device *dev, struct device_attribute *attr, char *buf) +#else +static ssize_t xendev_show_devtype(struct device *dev, + char *buf) +#endif + { return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype); } @@ -653,6 +680,7 @@ return err; } +#ifdef CONFIG_XEN_BACKEND /* backend/// */ static int xenbus_probe_backend_unit(const char *dir, const char *type, @@ -702,6 +730,7 @@ return err; } +#endif static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type) { int err = 0; @@ -809,6 +838,7 @@ dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend); } +#ifdef CONFIG_XEN_BACKEND static void backend_changed(struct xenbus_watch *watch, const char **vec, unsigned int len) { @@ -817,17 +847,18 @@ dev_changed(vec[XS_WATCH_PATH], &xenbus_backend); } +static struct xenbus_watch be_watch = { + .node = "backend", + .callback = backend_changed, +}; +#endif + /* We watch for devices appearing and vanishing. */ static struct xenbus_watch fe_watch = { .node = "device", .callback = frontend_changed, }; -static struct xenbus_watch be_watch = { - .node = "backend", - .callback = backend_changed, -}; - static int suspend_dev(struct device *dev, void *data) { int err = 0; @@ -898,7 +929,9 @@ DPRINTK(""); bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev); +#ifdef CONFIG_XEN_BACKEND bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev); +#endif xs_suspend(); } EXPORT_SYMBOL_GPL(xenbus_suspend); @@ -908,7 +941,9 @@ xb_init_comms(); xs_resume(); bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev); +#ifdef CONFIG_XEN_BACKEND bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev); +#endif } EXPORT_SYMBOL_GPL(xenbus_resume); @@ -943,11 +978,15 @@ /* Enumerate devices in xenstore. */ xenbus_probe_devices(&xenbus_frontend); +#ifdef CONFIG_XEN_BACKEND xenbus_probe_devices(&xenbus_backend); +#endif /* Watch for changes. */ register_xenbus_watch(&fe_watch); +#ifdef CONFIG_XEN_BACKEND register_xenbus_watch(&be_watch); +#endif /* Notify others that xenstore is up */ notifier_call_chain(&xenstore_chain, 0, NULL); @@ -959,6 +998,7 @@ static struct proc_dir_entry *xsd_kva_intf; static struct proc_dir_entry *xsd_port_intf; +#ifdef CONFIG_XEN_PRIVILEGED_GUEST static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma) { size_t size = vma->vm_end - vma->vm_start; @@ -972,6 +1012,9 @@ return 0; } +#else +#define xsd_kva_mmap NULL +#endif static int xsd_kva_read(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -1006,7 +1049,9 @@ /* Register ourselves with the kernel bus subsystem */ bus_register(&xenbus_frontend.bus); +#ifdef CONFIG_XEN_BACKEND bus_register(&xenbus_backend.bus); +#endif /* * Domain0 doesn't have a store_evtchn or store_mfn yet. @@ -1077,7 +1122,9 @@ /* Register ourselves with the kernel device subsystem */ device_register(&xenbus_frontend.dev); +#ifdef CONFIG_XEN_BACKEND device_register(&xenbus_backend.dev); +#endif if (!is_initial_xendomain()) xenbus_probe(NULL);