5 files changed, 113 insertions(+), 2 deletions(-)
drivers/xen/Makefile | 2
drivers/xen/privcmd/Makefile | 3 -
drivers/xen/privcmd/compat_privcmd.c | 72 ++++++++++++++++++++++++++++++++++
fs/compat_ioctl.c | 16 +++++++
include/xen/public/privcmd.h | 22 ++++++++++
# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1183669279 18000
# Node ID 7cae4be9db6be7b7d0c91dbb785ae14261c7116d
# Parent 3ece3641ec01362c4333c74688a7f04ae4706ba4
[XEN][LINUX] Add 32-bit privcmd ioctl conversion for 64-bit kernels.
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
diff -r 3ece3641ec01 -r 7cae4be9db6b drivers/xen/Makefile
--- a/drivers/xen/Makefile Thu Jul 05 16:01:19 2007 -0500
+++ b/drivers/xen/Makefile Thu Jul 05 16:01:19 2007 -0500
@@ -1,7 +1,6 @@ obj-y += core/
obj-y += core/
obj-y += console/
obj-y += evtchn/
-obj-y += privcmd/
obj-y += xenbus/
obj-y += gntdev/
obj-y += char/
@@ -18,3 +17,4 @@ obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pci
obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/
obj-$(CONFIG_XEN_FRAMEBUFFER) += fbfront/
obj-$(CONFIG_XEN_KEYBOARD) += fbfront/
+obj-$(CONFIG_XEN_PRIVCMD) += privcmd/
diff -r 3ece3641ec01 -r 7cae4be9db6b drivers/xen/privcmd/Makefile
--- a/drivers/xen/privcmd/Makefile Thu Jul 05 16:01:19 2007 -0500
+++ b/drivers/xen/privcmd/Makefile Thu Jul 05 16:01:19 2007 -0500
@@ -1,2 +1,3 @@
-obj-$(CONFIG_XEN_PRIVCMD) := privcmd.o
+obj-y += privcmd.o
+obj-$(CONFIG_COMPAT) += compat_privcmd.o
diff -r 3ece3641ec01 -r 7cae4be9db6b drivers/xen/privcmd/compat_privcmd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/privcmd/compat_privcmd.c Thu Jul 05 16:01:19 2007 -0500
@@ -0,0 +1,72 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) IBM Corp. 2006
+ *
+ * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
+ */
+
+#include <linux/config.h>
+#include <linux/compat.h>
+#include <linux/ioctl.h>
+#include <linux/syscalls.h>
+#include <asm/hypervisor.h>
+#include <asm/uaccess.h>
+#include <xen/public/privcmd.h>
+
+int privcmd_ioctl_32(int fd, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ switch (cmd) {
+ case IOCTL_PRIVCMD_MMAP_32: {
+ struct privcmd_mmap *p;
+ struct privcmd_mmap_32 *p32;
+ struct privcmd_mmap_32 n32;
+
+ p32 = compat_ptr(arg);
+ p = compat_alloc_user_space(sizeof(*p));
+ if (copy_from_user(&n32, p32, sizeof(n32)) ||
+ put_user(n32.num, &p->num) ||
+ put_user(n32.dom, &p->dom) ||
+ put_user(compat_ptr(n32.entry), &p->entry))
+ return -EFAULT;
+
+ ret = sys_ioctl(fd, IOCTL_PRIVCMD_MMAP, (unsigned long)p);
+ }
+ break;
+ case IOCTL_PRIVCMD_MMAPBATCH_32: {
+ struct privcmd_mmapbatch *p;
+ struct privcmd_mmapbatch_32 *p32;
+ struct privcmd_mmapbatch_32 n32;
+
+ p32 = compat_ptr(arg);
+ p = compat_alloc_user_space(sizeof(*p));
+ if (copy_from_user(&n32, p32, sizeof(n32)) ||
+ put_user(n32.num, &p->num) ||
+ put_user(n32.dom, &p->dom) ||
+ put_user(n32.addr, &p->addr) ||
+ put_user(compat_ptr(n32.arr), &p->arr))
+ return -EFAULT;
+
+ ret = sys_ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, (unsigned long)p);
+ }
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
diff -r 3ece3641ec01 -r 7cae4be9db6b fs/compat_ioctl.c
--- a/fs/compat_ioctl.c Thu Jul 05 16:01:19 2007 -0500
+++ b/fs/compat_ioctl.c Thu Jul 05 16:01:19 2007 -0500
@@ -123,6 +123,10 @@
#include <linux/dvb/frontend.h>
#include <linux/dvb/video.h>
#include <linux/lp.h>
+
+#include <xen/interface/xen.h>
+#include <xen/public/evtchn.h>
+#include <xen/public/privcmd.h>
/* Aiee. Someone does not find a difference between int and long */
#define EXT2_IOC32_GETFLAGS _IOR('f', 1, int)
@@ -2948,6 +2952,18 @@ COMPATIBLE_IOCTL(LPRESET)
/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
COMPATIBLE_IOCTL(LPGETFLAGS)
HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
+
+#ifdef CONFIG_XEN
+HANDLE_IOCTL(IOCTL_PRIVCMD_MMAP_32, privcmd_ioctl_32)
+HANDLE_IOCTL(IOCTL_PRIVCMD_MMAPBATCH_32, privcmd_ioctl_32)
+COMPATIBLE_IOCTL(IOCTL_PRIVCMD_HYPERCALL)
+COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_VIRQ)
+COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_INTERDOMAIN)
+COMPATIBLE_IOCTL(IOCTL_EVTCHN_BIND_UNBOUND_PORT)
+COMPATIBLE_IOCTL(IOCTL_EVTCHN_UNBIND)
+COMPATIBLE_IOCTL(IOCTL_EVTCHN_NOTIFY)
+COMPATIBLE_IOCTL(IOCTL_EVTCHN_RESET)
+#endif
};
int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff -r 3ece3641ec01 -r 7cae4be9db6b include/xen/public/privcmd.h
--- a/include/xen/public/privcmd.h Thu Jul 05 16:01:19 2007 -0500
+++ b/include/xen/public/privcmd.h Thu Jul 05 16:01:19 2007 -0500
@@ -34,6 +34,7 @@
#define __LINUX_PUBLIC_PRIVCMD_H__
#include <linux/types.h>
+#include <linux/compat.h>
#ifndef __user
#define __user
@@ -64,6 +65,27 @@ typedef struct privcmd_mmapbatch {
xen_pfn_t __user *arr; /* array of mfns - top nibble set on err */
} privcmd_mmapbatch_t;
+#ifdef CONFIG_COMPAT
+extern int privcmd_ioctl_32(int fd, unsigned int cmd, unsigned long arg);
+struct privcmd_mmap_32 {
+ int num;
+ domid_t dom;
+ compat_uptr_t entry;
+};
+
+struct privcmd_mmapbatch_32 {
+ int num; /* number of pages to populate */
+ domid_t dom; /* target domain */
+ __u64 addr; /* virtual address */
+ compat_uptr_t arr; /* array of mfns - top nibble set on err */
+};
+#define IOCTL_PRIVCMD_MMAP_32 \
+ _IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap_32))
+#define IOCTL_PRIVCMD_MMAPBATCH_32 \
+ _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch_32))
+
+#endif
+
/*
* @cmd: IOCTL_PRIVCMD_HYPERCALL
* @arg: &privcmd_hypercall_t
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|