]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/ioport.c
USB: add USB test and measurement class driver
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / ioport.c
index e723ff3b1d53d7a85f79ed506f6678d0a26ed54e..19191430274496e8d04f4bd4e165f852e6753560 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/thread_info.h>
 #include <linux/syscalls.h>
+#include <asm/syscalls.h>
 
 /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
 static void set_bitmap(unsigned long *bitmap, unsigned int base,
@@ -113,11 +114,8 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
  * on system-call entry - see also fork() and the signal handling
  * code.
  */
-#ifdef CONFIG_X86_32
-asmlinkage long sys_iopl(unsigned long regsp)
+static int do_iopl(unsigned int level, struct pt_regs *regs)
 {
-       volatile struct pt_regs *regs = (struct pt_regs *)&regsp;
-       unsigned int level = regs->bx;
        unsigned int old = (regs->flags >> 12) & 3;
 
        if (level > 3)
@@ -131,20 +129,27 @@ asmlinkage long sys_iopl(unsigned long regsp)
 
        return 0;
 }
-#else
-asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs)
+
+#ifdef CONFIG_X86_32
+asmlinkage long sys_iopl(unsigned long regsp)
 {
-       unsigned int old = (regs->flags >> 12) & 3;
+       struct pt_regs *regs = (struct pt_regs *)&regsp;
+       unsigned int level = regs->bx;
+       struct thread_struct *t = &current->thread;
+       int rc;
 
-       if (level > 3)
-               return -EINVAL;
-       /* Trying to gain more privileges? */
-       if (level > old) {
-               if (!capable(CAP_SYS_RAWIO))
-                       return -EPERM;
-       }
-       regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
+       rc = do_iopl(level, regs);
+       if (rc < 0)
+               goto out;
 
-       return 0;
+       t->iopl = level << 12;
+       set_iopl_mask(t->iopl);
+out:
+       return rc;
+}
+#else
+asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs)
+{
+       return do_iopl(level, regs);
 }
 #endif