]> xenbits.xen.org Git - xenclient/kernel.git/commitdiff
Add a new ioctl to /proc/xen/privcmd which allows domctls to be performed restricted-privcmd-dev
authort_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:06:04 +0000 (12:06 +0000)
committert_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:06:04 +0000 (12:06 +0000)
without using the generic hypercall interface, so that they are available
on restricted fds.

This requires an unfortunate amount of fiddling with headers so that
XEN_GUEST_HANDLE_64 and uint64_aligned_t are available in kernel
space.

drivers/xen/privcmd/privcmd.c
include/asm-i386/mach-xen/asm/hypercall.h
include/asm-i386/mach-xen/asm/hypervisor.h
include/asm-x86_64/mach-xen/asm/hypercall.h
include/xen/interface/arch-x86/xen-x86_32.h
include/xen/interface/arch-x86/xen-x86_64.h
include/xen/interface/domctl.h
include/xen/interface/xen.h
include/xen/public/privcmd.h

index 5f65956714c972f301e035be73b724e0ecea0ff7..c190f1da6b12fc1ed9a37c91856e98404f7a258b 100644 (file)
@@ -25,8 +25,8 @@
 #include <asm/uaccess.h>
 #include <asm/tlb.h>
 #include <asm/hypervisor.h>
-#include <xen/public/privcmd.h>
 #include <xen/interface/xen.h>
+#include <xen/public/privcmd.h>
 #include <xen/xen_proc.h>
 #include <xen/features.h>
 
@@ -311,6 +311,22 @@ static long privcmd_ioctl(struct file *file,
         }
         break;
 
+        case IOCTL_PRIVCMD_DOMCTL: {
+                xen_domctl_t xd;
+
+                if (copy_from_user(&xd, udata, sizeof(xd)))
+                        return -EFAULT;
+                if (fdata->restrict_domid != UNRESTRICTED_DOMID &&
+                    xd.domain != fdata->restrict_domid)
+                        return -EACCES;
+                ret = HYPERVISOR_domctl(&xd);
+                if (ret >= 0) {
+                        if (copy_to_user(udata, &xd, sizeof(xd)))
+                                ret = -EFAULT;
+                }
+        }
+        break;
+
        default:
                ret = -EINVAL;
                break;
index db53073ab07558307d69269166fcd58006559a5b..800fa7c1d5ab118b3c62e928b9758b589721137b 100644 (file)
@@ -404,6 +404,13 @@ HYPERVISOR_xenoprof_op(
        return _hypercall2(int, xenoprof_op, op, arg);
 }
 
+static inline int __must_check
+HYPERVISOR_domctl(
+        xen_domctl_t *xd)
+{
+        return _hypercall1(int, domctl, xd);
+}
+
 static inline int __must_check
 HYPERVISOR_kexec_op(
        unsigned long op, void *args)
index 21a6624879cebac0c0c912844c63508083d7230a..202ad0a2b6393ca9feb35ea88f345bbaf779940b 100644 (file)
@@ -43,6 +43,7 @@
 #include <xen/interface/physdev.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/nmi.h>
+#include <xen/interface/domctl.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
 #if defined(__i386__)
index 651b449635c171ce781585051f02fb23556f9dfd..26ffab35bdcef3acfb382e13f891b8aa4db67ed6 100644 (file)
@@ -405,6 +405,13 @@ HYPERVISOR_xenoprof_op(
        return _hypercall2(int, xenoprof_op, op, arg);
 }
 
+static inline int __must_check
+HYPERVISOR_domctl(
+        xen_domctl_t *xd)
+{
+        return _hypercall1(int, domctl, xd);
+}
+
 static inline int __must_check
 HYPERVISOR_kexec_op(
        unsigned long op, void *args)
index 7cb6a0179f4dd3889c9b5aa2d80b35c84bfe7b75..64627ec53c58a8f69892b2aa22ac5d812f4397e9 100644 (file)
 #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
 #endif
 
-/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
-#if defined(__XEN__) || defined(__XEN_TOOLS__)
 #undef ___DEFINE_XEN_GUEST_HANDLE
-#define ___DEFINE_XEN_GUEST_HANDLE(name, type)                  \
+#define ___DEFINE_XEN_GUEST_HANDLE(name, type)                   \
     typedef struct { type *p; }                                 \
         __guest_handle_ ## name;                                \
     typedef struct { union { type *p; uint64_aligned_t q; }; }  \
 #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
 #define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
 #define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name)
-#endif
 
 #ifndef __ASSEMBLY__
 
index 1e54cf92a746118ea207fa03c60a692579b301af..12e09935c7a4f98f0f087652255b95ef333e85af 100644 (file)
 #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
 #endif
 
+#define uint64_aligned_t uint64_t
+#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
+
+
 /*
  * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
  *  @which == SEGBASE_*  ;  @base == 64-bit base address
index 6c800abd7e7666757120751994f70fc75c5606a1..676234acadbf79c0c5786592c377be8da3613d97 100644 (file)
 #ifndef __XEN_PUBLIC_DOMCTL_H__
 #define __XEN_PUBLIC_DOMCTL_H__
 
-#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
-#error "domctl operations are intended for use by node control tools only"
-#endif
-
 #include "xen.h"
 
 #define XEN_DOMCTL_INTERFACE_VERSION 0x00000005
index 4b444b4c71d51bfc97dce5c33a2133d15f43ae8b..3419fc4321c9199745fa6413b60b4d29012dd6cd 100644 (file)
@@ -616,16 +616,6 @@ __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t);
 
 #endif /* !__ASSEMBLY__ */
 
-/* Default definitions for macros used by domctl/sysctl. */
-#if defined(__XEN__) || defined(__XEN_TOOLS__)
-#ifndef uint64_aligned_t
-#define uint64_aligned_t uint64_t
-#endif
-#ifndef XEN_GUEST_HANDLE_64
-#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
-#endif
-#endif
-
 #endif /* __XEN_PUBLIC_XEN_H__ */
 
 /*
index 1d1965690eaa58f3a39eee78392624037a465620..30773e196fd95394f67ab2620b3eda1ab25fcf09 100644 (file)
@@ -81,5 +81,7 @@ typedef struct privcmd_restrict_domid {
        _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
 #define IOCTL_PRIVCMD_RESTRICT_DOMID                           \
        _IOC(_IOC_NONE, 'P', 4, sizeof(privcmd_restrict_domid_t))
+#define IOCTL_PRIVCMD_DOMCTL                           \
+       _IOC(_IOC_NONE, 'P', 5, sizeof(xen_domctl_t))
 
 #endif /* __LINUX_PUBLIC_PRIVCMD_H__ */