From: Brian Gerst <brgerst@gmail.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
Andy Lutomirski <luto@amacapital.net>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 1/5] x86/vm86: Move userspace accesses to do_sys_vm86()
Date: Sat, 11 Jul 2015 01:09:16 -0400 [thread overview]
Message-ID: <1436591360-16210-2-git-send-email-brgerst@gmail.com> (raw)
In-Reply-To: <1436591360-16210-1-git-send-email-brgerst@gmail.com>
Move the userspace accesses down into the common function in
preparation for the next set of patches.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
arch/x86/kernel/vm86_32.c | 61 +++++++++++++++++++++--------------------------
1 file changed, 27 insertions(+), 34 deletions(-)
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index fc9db6e..71a8b0a 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -200,7 +200,8 @@ out:
static int do_vm86_irq_handling(int subfunction, int irqnumber);
-static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk);
+static long do_sys_vm86(struct vm86plus_struct __user *v86, bool plus,
+ struct kernel_vm86_struct *info);
SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
{
@@ -209,21 +210,8 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
* This remains on the stack until we
* return to 32 bit user space.
*/
- struct task_struct *tsk = current;
- int tmp;
- if (tsk->thread.saved_sp0)
- return -EPERM;
- tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
- offsetof(struct kernel_vm86_struct, vm86plus) -
- sizeof(info.regs));
- if (tmp)
- return -EFAULT;
- memset(&info.vm86plus, 0, (int)&info.regs32 - (int)&info.vm86plus);
- info.regs32 = current_pt_regs();
- tsk->thread.vm86_info = v86;
- do_sys_vm86(&info, tsk);
- return 0; /* we never return here */
+ return do_sys_vm86((struct vm86plus_struct __user *) v86, false, &info);
}
@@ -234,11 +222,7 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
* This remains on the stack until we
* return to 32 bit user space.
*/
- struct task_struct *tsk;
- int tmp;
- struct vm86plus_struct __user *v86;
- tsk = current;
switch (cmd) {
case VM86_REQUEST_IRQ:
case VM86_FREE_IRQ:
@@ -256,25 +240,34 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
}
/* we come here only for functions VM86_ENTER, VM86_ENTER_NO_BYPASS */
- if (tsk->thread.saved_sp0)
- return -EPERM;
- v86 = (struct vm86plus_struct __user *)arg;
- tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
- offsetof(struct kernel_vm86_struct, regs32) -
- sizeof(info.regs));
- if (tmp)
- return -EFAULT;
- info.regs32 = current_pt_regs();
- info.vm86plus.is_vm86pus = 1;
- tsk->thread.vm86_info = (struct vm86_struct __user *)v86;
- do_sys_vm86(&info, tsk);
- return 0; /* we never return here */
+ return do_sys_vm86((struct vm86plus_struct __user *) arg, true, &info);
}
-static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk)
+static long do_sys_vm86(struct vm86plus_struct __user *v86, bool plus,
+ struct kernel_vm86_struct *info)
{
struct tss_struct *tss;
+ struct task_struct *tsk = current;
+
+ if (tsk->thread.saved_sp0)
+ return -EPERM;
+ if (plus) {
+ if (copy_vm86_regs_from_user(&info->regs, &v86->regs,
+ offsetof(struct kernel_vm86_struct, regs32) -
+ sizeof(info->regs)))
+ return -EFAULT;
+ info->vm86plus.is_vm86pus = 1;
+ } else {
+ if (copy_vm86_regs_from_user(&info->regs, &v86->regs,
+ offsetof(struct kernel_vm86_struct, vm86plus) -
+ sizeof(info->regs)))
+ return -EFAULT;
+ memset(&info->vm86plus, 0, sizeof(struct vm86plus_info_struct));
+ }
+ info->regs32 = current_pt_regs();
+ tsk->thread.vm86_info = (struct vm86_struct __user *) v86;
+
/*
* make sure the vm86() system call doesn't try to do anything silly
*/
@@ -344,7 +337,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
"jmp resume_userspace"
: /* no outputs */
:"r" (&info->regs), "r" (task_thread_info(tsk)), "r" (0));
- /* we never return here */
+ return 0; /* we never return here */
}
static inline void return_to_32bit(struct kernel_vm86_regs *regs16, int retval)
--
2.4.3
next prev parent reply other threads:[~2015-07-11 6:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-11 5:09 [PATCH 0/5] x86/vm86: First round of vm86 cleanups Brian Gerst
2015-07-11 5:09 ` Brian Gerst [this message]
2015-07-11 16:37 ` [PATCH 1/5] x86/vm86: Move userspace accesses to do_sys_vm86() Andy Lutomirski
2015-07-13 16:45 ` Brian Gerst
2015-07-13 18:36 ` Andy Lutomirski
2015-07-13 19:46 ` Brian Gerst
2015-07-11 5:09 ` [PATCH 2/5] x86/vm86: Move vm86 fields out of thread_struct Brian Gerst
2015-07-11 5:09 ` [PATCH 3/5] x86/vm86: Move fields from kernel_vm86_struct Brian Gerst
2015-07-11 5:09 ` [PATCH 4/5] x86/vm86: Eliminate kernel_vm86_struct Brian Gerst
2015-07-11 5:09 ` [PATCH 5/5] x86/vm86: Use the normal pt_regs area for vm86 Brian Gerst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436591360-16210-2-git-send-email-brgerst@gmail.com \
--to=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome