All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@XenSource.com>
To: Ky Srinivasan <ksrinivasan@novell.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: PV drivers for HVM guests
Date: Thu, 05 Oct 2006 16:21:27 +0100	[thread overview]
Message-ID: <1160061687.3755.101.camel@localhost.localdomain> (raw)
In-Reply-To: <45229025.E57C.0030.0@novell.com>

[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]

On Tue, 2006-10-03 at 16:31 -0400, Ky Srinivasan wrote:
> 2)  Introduce  a compatibility component that bridges the gap between
> the current PV code and a given Linux target and leave much of the PV
> driver  code untouched.
> 
> I have implemented both these schemes for the sles9 kernel 

FWIW I have a half complete implementation (compile tested only) of such
a scheme which I've attached, perhaps you can crib something useful from
it ;-).

Basically it adds a compat-include directory to the end of the include
search path which contains compatibility versions of headers which may
not present in older kernels and adds compat.h which defines other
missing bits where necessary.

It covers most of the issues compiling against a RHEL4 (2.6.9) or SLES9
(2.6.5) kernel, although compatibility shims for
schedule_timeout_interruptible() and nonseekable_open() are still
missing and the versions used for triggering compatibility code are
certainly totally wrong (just right for RHEL4 and SLES9 though ;-)).

I'm fairly unhappy about the number of ifdef's in xenbus_probe.c. I
reckon some function reordering could coalesce a lot of them. Perhaps
they are candidates for splitting into a separate file.

This work will also be useful for the fully PV vendor kernel ports which
is why I'm interested.

Ian.

[-- Attachment #2: pvdriver-compat.diff --]
[-- Type: text/x-patch, Size: 23890 bytes --]

diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 05 11:45:07 2006 +0100
@@ -48,6 +48,10 @@
 #include <asm/hypervisor.h>
 #include <asm/maddr.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
 #define BLKIF_STATE_SUSPENDED    2
@@ -468,6 +472,27 @@ int blkif_ioctl(struct inode *inode, str
 		      command, (long)argument, inode->i_rdev);
 
 	switch (command) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+	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++)
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Wed Oct 04 15:59:00 2006 +0100
@@ -36,6 +36,10 @@
 #include <linux/blkdev.h>
 #include <linux/list.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_MAJOR(dev) ((dev)>>8)
 #define BLKIF_MINOR(dev) ((dev) & 0xff)
 
@@ -91,7 +95,9 @@ static struct block_device_operations xl
 	.open = blkif_open,
 	.release = blkif_release,
 	.ioctl  = blkif_ioctl,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) /* TODO: check version */
 	.getgeo = blkif_getgeo
+#endif
 };
 
 DEFINE_SPINLOCK(blkif_io_lock);
@@ -186,7 +192,11 @@ xlvbd_init_blk_queue(struct gendisk *gd,
 	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 -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/core/features.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/features.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c	Wed Oct 04 15:17:34 2006 +0100
@@ -10,6 +10,10 @@
 #include <linux/module.h>
 #include <asm/hypervisor.h>
 #include <xen/features.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Oct 04 15:20:24 2006 +0100
@@ -44,6 +44,10 @@
 #include <asm/io.h>
 #include <xen/interface/memory.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /* External tools reserve first few grant table entries. */
 #define NR_RESERVED_ENTRIES 8
 
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 05 14:17:04 2006 +0100
@@ -64,6 +64,10 @@
 #include <xen/interface/grant_table.h>
 #include <xen/gnttab.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /*
  * Mutually-exclusive module options to select receive data path:
  *  rx_copy : Packets are copied by network backend into local memory
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Oct 04 15:20:36 2006 +0100
@@ -34,6 +34,10 @@
 #include <xen/gnttab.h>
 #include <xen/xenbus.h>
 #include <xen/driver_util.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Oct 04 15:26:30 2006 +0100
@@ -39,6 +39,10 @@
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 static int xenbus_irq;
 
 extern void xenbus_probe(void *);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 05 16:09:05 2006 +0100
@@ -56,6 +56,10 @@
 
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 int xen_store_evtchn;
 struct xenstore_domain_interface *xen_store_interface;
 static unsigned long xen_store_mfn;
@@ -67,13 +71,17 @@ static void wait_for_devices(struct xenb
 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);
+#endif
 
 static int xenbus_dev_probe(struct device *_dev);
 static int xenbus_dev_remove(struct device *_dev);
+#ifdef CONFIG_XEN_BACKEND
 static void xenbus_dev_shutdown(struct device *_dev);
+#endif
 
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
@@ -176,10 +184,12 @@ static int read_backend_details(struct x
 }
 
 
+#ifdef CONFIG_XEN_BACKEND
 static int read_frontend_details(struct xenbus_device *xendev)
 {
 	return read_otherend_details(xendev, "frontend-id", "frontend");
 }
+#endif
 
 
 /* Bus type for frontend drivers. */
@@ -191,15 +201,18 @@ static struct xen_bus_type xenbus_fronte
 	.bus = {
 		.name     = "xen",
 		.match    = xenbus_match,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 		.probe    = xenbus_dev_probe,
 		.remove   = xenbus_dev_remove,
 		.shutdown = xenbus_dev_shutdown,
+#endif
 	},
 	.dev = {
 		.bus_id = "xen",
 	},
 };
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
@@ -299,6 +312,7 @@ static int xenbus_uevent_backend(struct 
 
 	return 0;
 }
+#endif
 
 static void otherend_changed(struct xenbus_watch *watch,
 			     const char **vec, unsigned int len)
@@ -423,6 +437,7 @@ static int xenbus_dev_remove(struct devi
 	return 0;
 }
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 static void xenbus_dev_shutdown(struct device *_dev)
 {
 	struct xenbus_device *dev = to_xenbus_device(_dev);
@@ -443,6 +458,7 @@ static void xenbus_dev_shutdown(struct d
  out:
 	put_device(&dev->dev);
 }
+#endif
 
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
 					 struct xen_bus_type *bus)
@@ -451,7 +467,13 @@ static int xenbus_register_driver_common
 
 	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 	drv->driver.owner = drv->owner;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+	drv->driver.probe = xenbus_dev_probe;
+	drv->driver.remove = xenbus_dev_remove;
+#endif
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -476,6 +498,7 @@ int xenbus_register_frontend(struct xenb
 }
 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;
@@ -483,6 +506,7 @@ int xenbus_register_backend(struct xenbu
 	return xenbus_register_driver_common(drv, &xenbus_backend);
 }
 EXPORT_SYMBOL_GPL(xenbus_register_backend);
+#endif
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
@@ -581,14 +605,20 @@ char *kasprintf(const char *fmt, ...)
 }
 
 static ssize_t xendev_show_nodename(struct device *dev,
-				    struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+				    struct device_attribute *attr,
+#endif
+				    char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
 }
 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 
 static ssize_t xendev_show_devtype(struct device *dev,
-				   struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+				   struct device_attribute *attr,
+#endif
+				   char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
 }
@@ -667,6 +697,7 @@ static int xenbus_probe_frontend(const c
 	return err;
 }
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<typename>/<frontend-uuid>/<name> */
 static int xenbus_probe_backend_unit(const char *dir,
 				     const char *type,
@@ -715,6 +746,7 @@ static int xenbus_probe_backend(const ch
 	kfree(nodename);
 	return err;
 }
+#endif
 
 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
 {
@@ -823,6 +855,7 @@ static void frontend_changed(struct xenb
 	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)
 {
@@ -830,6 +863,7 @@ static void backend_changed(struct xenbu
 
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
 }
+#endif
 
 /* We watch for devices appearing and vanishing. */
 static struct xenbus_watch fe_watch = {
@@ -837,10 +871,12 @@ static struct xenbus_watch fe_watch = {
 	.callback = frontend_changed,
 };
 
+#ifdef CONFIG_XEN_BACKEND
 static struct xenbus_watch be_watch = {
 	.node = "backend",
 	.callback = backend_changed,
 };
+#endif
 
 static int suspend_dev(struct device *dev, void *data)
 {
@@ -912,7 +948,9 @@ void xenbus_suspend(void)
 	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);
@@ -922,7 +960,9 @@ void xenbus_resume(void)
 	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);
 
@@ -957,11 +997,15 @@ void xenbus_probe(void *unused)
 
 	/* 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);
@@ -973,6 +1017,7 @@ static struct proc_dir_entry *xsd_kva_in
 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;
@@ -986,6 +1031,9 @@ static int xsd_kva_mmap(struct file *fil
 
 	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)
@@ -1020,7 +1068,9 @@ static int __init xenbus_probe_init(void
 
 	/* 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.
@@ -1091,7 +1141,9 @@ static int __init xenbus_probe_init(void
 
 	/* 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);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Thu Oct 05 16:01:30 2006 +0100
@@ -42,8 +42,13 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
+#include <linux/module.h>
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r 8959876abbe3 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Wed Oct 04 15:13:48 2006 +0100
@@ -8,6 +8,10 @@
  */
 
 #include <linux/config.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 #define ADDR (*(volatile long *) addr)
 
diff -r 8959876abbe3 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Oct 04 15:16:43 2006 +0100
@@ -38,10 +38,15 @@
 #include <linux/notifier.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
+#include <linux/init.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* Register callback to watch this node. */
 struct xenbus_watch
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/overrides.mk
--- a/unmodified_drivers/linux-2.6/overrides.mk	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/overrides.mk	Wed Oct 04 15:21:20 2006 +0100
@@ -9,4 +9,4 @@ EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRAN
 EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
 EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
 EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
-EXTRA_CFLAGS += -I$(M)/include
+EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_COMPAT_H
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/evtchn.c
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Wed Oct 04 15:26:54 2006 +0100
@@ -35,6 +35,10 @@
 #include <xen/interface/hvm/ioreq.h>
 #include <xen/features.h>
 #include "platform-pci.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 void *shared_info_area;
 
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Oct 05 10:52:37 2006 +0100
@@ -38,6 +38,10 @@
 
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define DRV_NAME    "xen-platform-pci"
 #define DRV_VERSION "0.10"
 #define DRV_RELDATE "03/03/2005"
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Wed Oct 04 15:26:59 2006 +0100
@@ -26,6 +26,10 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
 	BUG();
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/xenbus/Kbuild
--- a/unmodified_drivers/linux-2.6/xenbus/Kbuild	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/xenbus/Kbuild	Wed Oct 04 15:30:27 2006 +0100
@@ -8,3 +8,4 @@ xenbus-objs += xenbus_dev.o
 xenbus-objs += xenbus_dev.o 
 xenbus-objs += xenbus_client.o 
 xenbus-objs += xen_proc.o
+xenbus-objs += compat.o
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/blkfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/blkfront/Makefile	Wed Oct 04 15:25:10 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h	Wed Oct 04 14:32:22 2006 +0100
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#error "This version of Linux should not need compat pgtable-nopmd.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPMD_H */
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Wed Oct 04 14:30:35 2006 +0100
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPUD_H
+#define _PGTABLE_NOPUD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#error "This version of Linux should not need compat pgtable-nopud.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPUD_H */
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/compat.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/compat.h	Thu Oct 05 16:16:03 2006 +0100
@@ -0,0 +1,49 @@
+#ifndef COMPAT_INCLUDE_COMPAT_H
+#define COMPAT_INCLUDE_COMPAT_H
+
+#include <linux/version.h>
+
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) /* TODO: confirm version */
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+static inline void *kzalloc(size_t size, int flags)
+{
+        void *ret = kmalloc(size, flags);
+        if (ret)
+                memset(ret, 0, size);
+        return ret;
+}
+#endif
+
+#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
+#define __always_inline inline
+#endif
+
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+#if defined(_LINUX_INIT_H) && !defined(__init)
+#define __init
+#endif
+
+#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
+#define __read_mostly
+#endif
+
+#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#define end_that_request_last(req, uptodate) end_that_request_last(req)
+#endif
+
+#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+struct page *vmalloc_to_page(void *addr);
+unsigned long vmalloc_to_pfn(void *addr);
+#endif
+
+#endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/linux/io.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/io.h	Wed Oct 04 15:27:26 2006 +0100
@@ -0,0 +1,10 @@
+#ifndef _LINUX_IO_H
+#define _LINUX_IO_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) /* TODO: check version */
+#error "This version of Linux should not need compat linux/io.h"
+#endif
+
+#include <asm/io.h>
+
+#endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h	Wed Oct 04 14:44:32 2006 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#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_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so        *
+ * it is negated to the down_trylock() return values! Be careful  */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/netfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/netfront/Makefile	Wed Oct 04 15:25:01 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Makefile	Wed Oct 04 11:59:14 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/xenbus/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/Makefile	Wed Oct 04 15:31:51 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/xenbus/compat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/compat.c	Thu Oct 05 10:52:33 2006 +0100
@@ -0,0 +1,54 @@
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/highmem.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+/*
+ * Map a vmalloc()-space virtual address to the physical page.
+ */
+struct page * vmalloc_to_page(void * vmalloc_addr)
+{
+        unsigned long addr = (unsigned long) vmalloc_addr;
+        struct page *page = NULL;
+        pgd_t *pgd = pgd_offset_k(addr);
+        pud_t *pud;
+        pmd_t *pmd;
+        pte_t *ptep, pte;
+
+        if (!pgd_none(*pgd)) {
+                pud = pud_offset(pgd, addr);
+                if (!pud_none(*pud)) {
+                        pmd = pmd_offset(pud, addr);
+                        if (!pmd_none(*pmd)) {
+                                ptep = pte_offset_map(pmd, addr);
+                                pte = *ptep;
+                                if (pte_present(pte))
+                                        page = pte_page(pte);
+                                pte_unmap(ptep);
+                        }
+                }
+        }
+        return page;
+}
+
+EXPORT_SYMBOL(vmalloc_to_page);
+
+/*
+ * 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

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  parent reply	other threads:[~2006-10-05 15:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-03 20:31 PV drivers for HVM guests Ky Srinivasan
2006-10-03 22:19 ` Andrew D. Ball
2006-10-03 22:31 ` Steve Ofsthun
2006-10-04  7:56 ` Keir Fraser
2006-10-04  8:15   ` Muli Ben-Yehuda
2006-10-04  8:17     ` Keir Fraser
2006-10-04 11:02     ` Gerd Hoffmann
2006-10-04 15:54       ` Andi Kleen
2006-10-04 10:24 ` Steven Smith
2006-10-05 15:21 ` Ian Campbell [this message]
2006-10-05 16:47   ` Ky Srinivasan
2006-10-10  8:00   ` DOI Tsunehisa
2006-10-11 10:46     ` DOI Tsunehisa
2006-10-13  2:00       ` DOI Tsunehisa
2006-10-13  6:55         ` Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2006-10-04 18:40 Ky Srinivasan
2006-10-04 18:42 Ky Srinivasan
2006-10-05 14:59 ` Andrew D. Ball
2006-10-05 15:13   ` Ky Srinivasan
2006-10-04 18:45 Ky Srinivasan
2006-10-04 18:47 Ky Srinivasan
2006-10-04 18:50 Ky Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1160061687.3755.101.camel@localhost.localdomain \
    --to=ian.campbell@xensource.com \
    --cc=ksrinivasan@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.