提交 a1bf250a 编写于 作者: C Chris Wright 提交者: Ingo Molnar

x86: refactor ioport unification

Refactor ioport unification to pull out common code.

Cc: mboton@gmail.com
Cc: Kevin Winchester <kjwinchester@gmail.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: NChris Wright <chrisw@sous-sol.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 9718769d
...@@ -113,13 +113,9 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) ...@@ -113,13 +113,9 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
* on system-call entry - see also fork() and the signal handling * on system-call entry - see also fork() and the signal handling
* code. * code.
*/ */
#ifdef CONFIG_X86_32 static int do_iopl(unsigned int level, struct pt_regs *regs)
asmlinkage long sys_iopl(unsigned long regsp)
{ {
struct pt_regs *regs = (struct pt_regs *)&regsp;
unsigned int level = regs->bx;
unsigned int old = (regs->flags >> 12) & 3; unsigned int old = (regs->flags >> 12) & 3;
struct thread_struct *t = &current->thread;
if (level > 3) if (level > 3)
return -EINVAL; return -EINVAL;
...@@ -128,25 +124,31 @@ asmlinkage long sys_iopl(unsigned long regsp) ...@@ -128,25 +124,31 @@ asmlinkage long sys_iopl(unsigned long regsp)
if (!capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_RAWIO))
return -EPERM; return -EPERM;
} }
t->iopl = level << 12;
regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12); regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
set_iopl_mask(t->iopl);
return 0; 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) rc = do_iopl(level, regs);
return -EINVAL; if (rc < 0)
/* Trying to gain more privileges? */ goto out;
if (level > old) {
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
}
regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
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 #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册