Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1240087
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 22/36] x86/entry: Add C code for fast system call entries |
| Date | 2015-10-06 03:00 +0200 |
| Message-ID | <qgoLO-7cw-49@gated-at.bofh.it> (permalink) |
| References | <qgoC6-715-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This handles both SYSENTER and SYSCALL. The asm glue will take care
of the differences.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/common.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 41d17508cf46..1b2606edc621 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -24,6 +24,8 @@
#include <asm/desc.h>
#include <asm/traps.h>
+#include <asm/vdso.h>
+#include <asm/uaccess.h>
#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>
@@ -360,4 +362,45 @@ __visible void do_int80_syscall_32(struct pt_regs *regs)
syscall_return_slowpath(regs);
}
+
+__visible void do_fast_syscall_32(struct pt_regs *regs)
+{
+ /*
+ * Called using the internal vDSO SYSENTER/SYSCALL32 calling
+ * convention. Adjust regs so it looks like we entered using int80.
+ */
+
+ unsigned long landing_pad = (unsigned long)current->mm->context.vdso +
+ vdso_image_32.sym_int80_landing_pad;
+
+ /*
+ * SYSENTER loses EIP, and even SYSCALL32 needs us to skip forward
+ * so that 'regs->ip -= 2' lands back on an int $0x80 instruction.
+ * Fix it up.
+ */
+ regs->ip = landing_pad;
+
+ /*
+ * Fetch ECX from where the vDSO stashed it.
+ *
+ * WARNING: We are in CONTEXT_USER and RCU isn't paying attention!
+ */
+ local_irq_enable();
+ if (get_user(*(u32 *)®s->cx,
+ (u32 __user __force *)(unsigned long)(u32)regs->sp)) {
+ /* User code screwed up. */
+ local_irq_disable();
+ regs->ax = -EFAULT;
+#ifdef CONFIG_CONTEXT_TRACKING
+ enter_from_user_mode();
+#endif
+ prepare_exit_to_usermode(regs);
+ return;
+ }
+ local_irq_disable();
+
+ /* Now this is just like a normal syscall. */
+ do_int80_syscall_32(regs);
+ return;
+}
#endif
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[PATCH v2 04/36] selftests/x86: Add a test for syscall restart and arg modification Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] selftests/x86: Add a test for ptrace syscall restart and arg modification tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-07 18:20 +0200
[PATCH v2 20/36] x86/entry: Add do_syscall_32, a C function to do 32-bit syscalls Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/entry: Add do_syscall_32(), a C function to do 32-bit syscalls tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:20 +0200
[PATCH v2 13/36] x86/vdso/32: Save extra registers in the INT80 vsyscall path Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/vdso/32: Save extra registers in the INT80 vsyscall path tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:10 +0200
[PATCH v2 11/36] x86/vdso: Replace hex int80 CFI annotations with gas directives Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/vdso: Replace hex int80 CFI annotations with GAS directives tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:10 +0200
[PATCH v2 02/36] x86/uaccess: __chk_range_not_ok is unlikely to return true Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
Re: [PATCH v2 02/36] x86/uaccess: __chk_range_not_ok is unlikely to return true Borislav Petkov <bp@alien8.de> - 2015-10-07 13:00 +0200
Re: [PATCH v2 02/36] x86/uaccess: __chk_range_not_ok is unlikely to return true Ingo Molnar <mingo@kernel.org> - 2015-10-07 18:30 +0200
[tip:x86/asm] x86/uaccess: Add unlikely() to __chk_range_not_ok() failure paths tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-07 18:20 +0200
[PATCH v2 06/36] x86/entry: Move lockdep_sys_exit to prepare_exit_to_usermode Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/entry, locking/lockdep: Move lockdep_sys_exit() to prepare_exit_to_usermode() tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-07 18:20 +0200
Re: [tip:x86/asm] x86/entry, locking/lockdep: Move lockdep_sys_exit() to prepare_exit_to_usermode() Peter Zijlstra <peterz@infradead.org> - 2015-10-08 11:00 +0200
Re: [tip:x86/asm] x86/entry, locking/lockdep: Move lockdep_sys_exit() to prepare_exit_to_usermode() Andy Lutomirski <luto@amacapital.net> - 2015-10-09 21:40 +0200
[PATCH v2 16/36] x86/entry/64/compat: Remove most of the fast system call machinery Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/entry/64/compat: Remove most of the fast system call machinery tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:20 +0200
[PATCH v2 22/36] x86/entry: Add C code for fast system call entries Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
Re: [PATCH v2 22/36] x86/entry: Add C code for fast system call entries Linus Torvalds <torvalds@linux-foundation.org> - 2015-10-06 10:30 +0200
Re: [PATCH v2 22/36] x86/entry: Add C code for fast system call entries Andy Lutomirski <luto@amacapital.net> - 2015-10-06 20:30 +0200
Re: [PATCH v2 22/36] x86/entry: Add C code for fast system call entries Linus Torvalds <torvalds@linux-foundation.org> - 2015-10-06 10:30 +0200
[tip:x86/asm] x86/entry: Add C code for fast system call entries tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:20 +0200
[PATCH v2 30/36] x86/entry: Make irqs_disabled checks in exit code depend on lockdep Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/entry: Make irqs_disabled checks in exit code depend on lockdep tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:20 +0200
[PATCH v2 15/36] x86/entry/64/compat: Remove audit optimizations Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
[tip:x86/asm] x86/entry/64/compat: Remove audit optimizations tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:20 +0200
[PATCH v2 32/36] x86/entry: Micro-optimize compat fast syscall arg fetch Andy Lutomirski <luto@kernel.org> - 2015-10-06 03:00 +0200
Re: [PATCH v2 32/36] x86/entry: Micro-optimize compat fast syscall arg fetch Ingo Molnar <mingo@kernel.org> - 2015-10-09 09:40 +0200
Re: [PATCH v2 32/36] x86/entry: Micro-optimize compat fast syscall arg fetch Andy Lutomirski <luto@amacapital.net> - 2015-10-09 21:30 +0200
Re: [PATCH v2 32/36] x86/entry: Micro-optimize compat fast syscall arg fetch Ingo Molnar <mingo@kernel.org> - 2015-10-10 11:10 +0200
[tip:x86/asm] x86/entry: Micro-optimize compat fast syscall arg fetch tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-10-09 15:20 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Linus Torvalds <torvalds@linux-foundation.org> - 2015-10-06 10:40 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Ingo Molnar <mingo@kernel.org> - 2015-10-06 11:00 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Andy Lutomirski <luto@amacapital.net> - 2015-10-06 20:30 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Ingo Molnar <mingo@kernel.org> - 2015-10-09 15:10 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Richard Weinberger <richard.weinberger@gmail.com> - 2015-10-12 20:40 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Andy Lutomirski <luto@amacapital.net> - 2015-10-12 20:50 +0200
Re: [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Richard Weinberger <richard@nod.at> - 2015-10-12 23:10 +0200
csiph-web