WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [rfc][patch][linux] ioctl32() compat plumbing for xen calls

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [rfc][patch][linux] ioctl32() compat plumbing for xen calls
From: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
Date: Thu, 13 Jul 2006 12:01:58 -0400
Cc: virtualization@xxxxxxxxxxxxxx
Delivery-date: Thu, 13 Jul 2006 09:00:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
changeset:   30726:2a6fda4e7dde1a0a5d29a62303e85bcea868eb47
tag:         tip
user:        Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
date:        Thu Jul 13 11:51:38 2006 -0400
files:       drivers/xen/privcmd/Makefile drivers/xen/privcmd/compat_privcmd.c 
fs/compat_ioctl.c include/xen/public/privcmd.h
description:
[ppc] ioctl32() compat plumbing for xen calls

The following patch deals with xen ioctl32() data structures that
contain pointer that are consumed _by_ Linux and not Xen.

Snuck in a few struct/typedef fixes that were missed before.

Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>


diff -r dd6f9da2ed0bcf52deb9f48e24ae56b470e1afc6 -r 
2a6fda4e7dde1a0a5d29a62303e85bcea868eb47 drivers/xen/privcmd/Makefile
--- a/drivers/xen/privcmd/Makefile      Thu Jul 13 11:40:56 2006 -0400
+++ b/drivers/xen/privcmd/Makefile      Thu Jul 13 11:51:38 2006 -0400
@@ -1,2 +1,2 @@
-
-obj-$(CONFIG_XEN_PRIVCMD)      := privcmd.o
+compat_obj-y   := compat_privcmd.o
+obj-$(CONFIG_XEN_PRIVCMD)      := privcmd.o $(compat_obj-$(CONFIG_COMPAT))
diff -r dd6f9da2ed0bcf52deb9f48e24ae56b470e1afc6 -r 
2a6fda4e7dde1a0a5d29a62303e85bcea868eb47 fs/compat_ioctl.c
--- a/fs/compat_ioctl.c Thu Jul 13 11:40:56 2006 -0400
+++ b/fs/compat_ioctl.c Thu Jul 13 11:51:38 2006 -0400
@@ -2986,6 +2986,8 @@ COMPATIBLE_IOCTL(LPGETFLAGS)
 COMPATIBLE_IOCTL(LPGETFLAGS)
 HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
 
+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)
diff -r dd6f9da2ed0bcf52deb9f48e24ae56b470e1afc6 -r 
2a6fda4e7dde1a0a5d29a62303e85bcea868eb47 include/xen/public/privcmd.h
--- a/include/xen/public/privcmd.h      Thu Jul 13 11:40:56 2006 -0400
+++ b/include/xen/public/privcmd.h      Thu Jul 13 11:51:38 2006 -0400
@@ -34,35 +34,61 @@
 #define __LINUX_PUBLIC_PRIVCMD_H__
 
 #include <linux/types.h>
+#include <linux/compat.h>
 
 #ifndef __user
 #define __user
 #endif
 
-typedef struct privcmd_hypercall
+struct privcmd_hypercall
 {
        __u64 op;
        __u64 arg[5];
-} privcmd_hypercall_t;
+};
+typedef struct privcmd_hypercall privcmd_hypercall_t;
 
-typedef struct privcmd_mmap_entry {
+struct privcmd_mmap_entry {
        __u64 va;
        __u64 mfn;
        __u64 npages;
-} privcmd_mmap_entry_t; 
+};
+typedef struct privcmd_mmap_entry privcmd_mmap_entry_t; 
 
-typedef struct privcmd_mmap {
+struct privcmd_mmap {
        int num;
        domid_t dom; /* target domain */
        privcmd_mmap_entry_t __user *entry;
-} privcmd_mmap_t; 
+};
+typedef struct privcmd_mmap privcmd_mmap_t; 
 
-typedef struct privcmd_mmapbatch {
+struct privcmd_mmapbatch {
        int num;     /* number of pages to populate */
        domid_t dom; /* target domain */
        __u64 addr;  /* virtual address */
        xen_pfn_t __user *arr; /* array of mfns - top nibble set on err */
-} privcmd_mmapbatch_t; 
+};
+typedef struct privcmd_mmapbatch 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
diff -r dd6f9da2ed0bcf52deb9f48e24ae56b470e1afc6 -r 
2a6fda4e7dde1a0a5d29a62303e85bcea868eb47 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 13 11:51:38 2006 -0400
@@ -0,0 +1,52 @@
+#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;
+}



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

<Prev in Thread] Current Thread [Next in Thread>