[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [LINUX][X86/64] Support IO-port permissions bitmaps (ioperm() syscall).



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 28128dafbe03758434bc947002758edf60a2747e
# Parent  ec903b8e6612eba5c90451fcb1bbb25d34cd88e4
[LINUX][X86/64] Support IO-port permissions bitmaps (ioperm() syscall).
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 linux-2.6-xen-sparse/arch/x86_64/kernel/ioport-xen.c |   58 ++++++++++++++++---
 1 files changed, 50 insertions(+), 8 deletions(-)

diff -r ec903b8e6612 -r 28128dafbe03 
linux-2.6-xen-sparse/arch/x86_64/kernel/ioport-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/ioport-xen.c      Wed Jun 07 
11:24:44 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/ioport-xen.c      Wed Jun 07 
13:38:08 2006 +0100
@@ -18,6 +18,56 @@
 #include <linux/slab.h>
 #include <linux/thread_info.h>
 #include <xen/interface/physdev.h>
+
+/* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
+static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int 
extent, int new_value)
+{
+       int i;
+
+       if (new_value)
+               for (i = base; i < base + extent; i++)
+                       __set_bit(i, bitmap);
+       else
+               for (i = base; i < base + extent; i++)
+                       clear_bit(i, bitmap);
+}
+
+/*
+ * this changes the io permissions bitmap in the current task.
+ */
+asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
+{
+       struct thread_struct * t = &current->thread;
+       unsigned long *bitmap;
+       struct physdev_set_iobitmap set_iobitmap;
+
+       if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
+               return -EINVAL;
+       if (turn_on && !capable(CAP_SYS_RAWIO))
+               return -EPERM;
+
+       /*
+        * If it's the first ioperm() call in this thread's lifetime, set the
+        * IO bitmap up. ioperm() is much less timing critical than clone(),
+        * this is why we delay this operation until now:
+        */
+       if (!t->io_bitmap_ptr) {
+               bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
+               if (!bitmap)
+                       return -ENOMEM;
+
+               memset(bitmap, 0xff, IO_BITMAP_BYTES);
+               t->io_bitmap_ptr = bitmap;
+
+               set_iobitmap.bitmap   = (char *)bitmap;
+               set_iobitmap.nr_ports = IO_BITMAP_BITS;
+               HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap);
+       }
+
+       set_bitmap(t->io_bitmap_ptr, from, num, !turn_on);
+
+       return 0;
+}
 
 /*
  * sys_iopl has to be used when you want to access the IO ports
@@ -47,11 +97,3 @@ asmlinkage long sys_iopl(unsigned int ne
 
        return 0;
 }
-
-/*
- * this changes the io permissions bitmap in the current task.
- */
-asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
-{
-  return turn_on ? sys_iopl(3, NULL) : 0;
-}

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.