Commit 10d8f7ec authored by Linus Torvalds's avatar Linus Torvalds

Fix broken x86_64 ioport code

parent affd2b3a
...@@ -58,15 +58,13 @@ static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_ ...@@ -58,15 +58,13 @@ static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_
asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
{ {
struct thread_struct * t = &current->thread; struct thread_struct * t = &current->thread;
int cpu = get_cpu(); struct tss_struct *tss;
if ((from + num <= from) || (from + num > IO_BITMAP_SIZE*32)) if ((from + num <= from) || (from + num > IO_BITMAP_SIZE*32))
return -EINVAL; return -EINVAL;
if (turn_on && !capable(CAP_SYS_RAWIO)) if (turn_on && !capable(CAP_SYS_RAWIO))
return -EPERM; return -EPERM;
struct tss_struct * tss = init_tss + cpu;
/* /*
* If it's the first ioperm() call in this thread's lifetime, set the * 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(), * IO bitmap up. ioperm() is much less timing critical than clone(),
...@@ -74,10 +72,8 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) ...@@ -74,10 +72,8 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
*/ */
if (!t->io_bitmap_ptr) { if (!t->io_bitmap_ptr) {
t->io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL); t->io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
if (!t->io_bitmap_ptr) { if (!t->io_bitmap_ptr)
put_cpu();
return -ENOMEM; return -ENOMEM;
}
memset(t->io_bitmap_ptr,0xff,IO_BITMAP_BYTES); memset(t->io_bitmap_ptr,0xff,IO_BITMAP_BYTES);
} }
...@@ -86,13 +82,13 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) ...@@ -86,13 +82,13 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
* do it in the per-thread copy and in the TSS ... * do it in the per-thread copy and in the TSS ...
*/ */
set_bitmap((unsigned long *) t->io_bitmap_ptr, from, num, !turn_on); set_bitmap((unsigned long *) t->io_bitmap_ptr, from, num, !turn_on);
tss = init_tss + get_cpu();
if (tss->io_map_base != IO_BITMAP_OFFSET) { if (tss->io_map_base != IO_BITMAP_OFFSET) {
memcpy(tss->io_bitmap, t->io_bitmap_ptr, sizeof(tss->io_bitmap)); memcpy(tss->io_bitmap, t->io_bitmap_ptr, sizeof(tss->io_bitmap));
tss->io_map_base = IO_BITMAP_OFFSET; tss->io_map_base = IO_BITMAP_OFFSET;
} else { } else {
set_bitmap((unsigned long *) tss->io_bitmap, from, num, !turn_on); set_bitmap((unsigned long *) tss->io_bitmap, from, num, !turn_on);
} }
put_cpu(); put_cpu();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment