Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1351050 > unrolled thread
| Started by | Andy Lutomirski <luto@kernel.org> |
|---|---|
| First post | 2016-03-06 07:00 +0100 |
| Last post | 2016-03-06 17:20 +0100 |
| Articles | 11 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Andy Lutomirski <luto@kernel.org> - 2016-03-06 07:00 +0100
[PATCH v2 06/10] x86/traps: Clear DR6 early in do_debug and improve the comment Andy Lutomirski <luto@kernel.org> - 2016-03-06 07:00 +0100
[PATCH v2 01/10] selftests/x86: In syscall_nt, test NT|TF as well Andy Lutomirski <luto@kernel.org> - 2016-03-06 07:00 +0100
[PATCH v2 05/10] x86/traps: Clear TIF_BLOCKSTEP on all debug exceptions Andy Lutomirski <luto@kernel.org> - 2016-03-06 07:00 +0100
[PATCH v2 03/10] x86/entry/32: Filter NT and speed up AC filtering in SYSENTER Andy Lutomirski <luto@kernel.org> - 2016-03-06 07:00 +0100
[PATCH v2 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Andy Lutomirski <luto@kernel.org> - 2016-03-06 07:00 +0100
Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Ingo Molnar <mingo@kernel.org> - 2016-03-06 09:30 +0100
Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Andy Lutomirski <luto@amacapital.net> - 2016-03-06 17:20 +0100
Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Ingo Molnar <mingo@kernel.org> - 2016-03-07 09:30 +0100
Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Ingo Molnar <mingo@kernel.org> - 2016-03-06 09:40 +0100
Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Andy Lutomirski <luto@amacapital.net> - 2016-03-06 17:20 +0100
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2016-03-06 07:00 +0100 |
| Subject | [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups |
| Message-ID | <r9zTr-Q8-3@gated-at.bofh.it> |
hpa asked me to get rid of the ASM_CLAC at the beginning of the SYSENTER
path. Little did he know...
This series makes the observed behavior of SYSENTER wrt flags the same
for all sane flags and kernel bitnesses. That is, SYSENTER preserves
flags now unless you do a syscall that explicitly changes flags, and
the HW flags that the syscall executes with are sanitized. This
includes NT, TF, AC and all arithmetic flags. Prior to this series,
32-bit kernels clobbered TF and the arithmetic flags and behaved
highly erratically if NT was set. (If IF is cleared by evil userspace
when SYSENTER starts, IF will be set again on return. There's nothing
the kernel can do about this -- SYSENTER inherently forgets the state
of IF.)
This series speeds up SYSENTER on all kernels by a surprisingly large
amount on Skylake because it eliminates an unconditional CLAC.
While SYSENTER used to handle TF correctly as far as I can tell on
64-bit kernels, the means by which it did so was heavily tangled up in
the ptrace single-step logic. It now works just like all the other
kernel entries except insofar as do_debug has a simple special case
for it. Relatedly, the bizarre and poorly explained old fixup in
do_debug is now hidden behind a WARN_ON_ONCE in preparation for
deleting it at some point.
The code that fixed up NMI and #DB early in SYSENTER in 32-bit kernels
used to be both terrifying and incorrect. (It doesn't appear to have
been exploitably bad, but the reason for that is subtle, and the code
was certainy more fragile than it deserved to me.) We still need a
special fixup, but it's much simpler now.
While I was doing all this, I also noticed that DR6 and BTF handling
in do_debug was a bit off. Two of the patches in here try to fix it
up.
Have fun!
tl;dr: Cleanups and sanity fixes here, but no security fixes, and I
don't think anything needs to be backported or put in x86/urgent.
This series applies to the result of merging tip:x86/asm and
tip:x86/urgent. I've been testing on a somewhat bastardized base,
because tip currently doesn't work on my laptop in 32-bit mode. (That
bug is fixed in Linus' tree.)
Changes from v1:
- s/Sysenter/SYSENTER in two places (Borislav)
- int main() -> int main(void) (Borislav)
Andy Lutomirski (10):
selftests/x86: In syscall_nt, test NT|TF as well
x86/entry/compat: In SYSENTER, sink AC clearing below the existing
FLAGS test
x86/entry/32: Filter NT and speed up AC filtering in SYSENTER
x86/entry/32: Restore FLAGS on SYSEXIT
x86/traps: Clear TIF_BLOCKSTEP on all debug exceptions
x86/traps: Clear DR6 early in do_debug and improve the comment
x86/entry: Vastly simplify SYSENTER TF handling
x86/entry: Only allocate space for SYSENTER_stack if needed
x86/entry/32: Simplify and fix up the SYSENTER stack #DB/NMI fixup
x86/entry/32: Add and check a stack canary for the SYSENTER stack
arch/x86/entry/entry_32.S | 182 ++++++++++++++++++-------------
arch/x86/entry/entry_64_compat.S | 15 ++-
arch/x86/include/asm/processor.h | 5 +-
arch/x86/include/asm/proto.h | 15 ++-
arch/x86/kernel/asm-offsets_32.c | 5 +
arch/x86/kernel/process.c | 3 +
arch/x86/kernel/traps.c | 87 ++++++++++++---
tools/testing/selftests/x86/syscall_nt.c | 57 ++++++++--
8 files changed, 263 insertions(+), 106 deletions(-)
--
2.5.0
[toc] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2016-03-06 07:00 +0100 |
| Subject | [PATCH v2 06/10] x86/traps: Clear DR6 early in do_debug and improve the comment |
| Message-ID | <r9zTt-Q8-17@gated-at.bofh.it> |
| In reply to | #1351050 |
Leaving any bits set in DR6 on return from a debug exception is asking for trouble. Prevent it by writing zero right away and clarify the comment. Signed-off-by: Andy Lutomirski <luto@kernel.org> --- arch/x86/kernel/traps.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 19e6cfa501e3..6dddc220e3ed 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -593,6 +593,18 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) ist_enter(regs); get_debugreg(dr6, 6); + /* + * The Intel SDM says: + * + * Certain debug exceptions may clear bits 0-3. The remaining + * contents of the DR6 register are never cleared by the + * processor. To avoid confusion in identifying debug + * exceptions, debug handlers should clear the register before + * returning to the interrupted task. + * + * Keep it simple: clear DR6 immediately. + */ + set_debugreg(0, 6); /* Filter out all the reserved bits which are preset to 1 */ dr6 &= ~DR6_RESERVED; @@ -616,9 +628,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) if ((dr6 & DR_STEP) && kmemcheck_trap(regs)) goto exit; - /* DR6 may or may not be cleared by the CPU */ - set_debugreg(0, 6); - /* Store the virtualized DR6 value */ tsk->thread.debugreg6 = dr6; -- 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2016-03-06 07:00 +0100 |
| Subject | [PATCH v2 01/10] selftests/x86: In syscall_nt, test NT|TF as well |
| Message-ID | <r9zTt-Q8-15@gated-at.bofh.it> |
| In reply to | #1351050 |
Setting TF prevents fastpath returns in most cases, which causes the
test to fail on 32-bit kernels because 32-bit kernels do not, in
fact, handle NT correctly on SYSENTER entries.
The next patch will fix 32-bit kernels.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
tools/testing/selftests/x86/syscall_nt.c | 57 +++++++++++++++++++++++++++-----
1 file changed, 49 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/x86/syscall_nt.c b/tools/testing/selftests/x86/syscall_nt.c
index 60c06af4646a..43fcab367fb0 100644
--- a/tools/testing/selftests/x86/syscall_nt.c
+++ b/tools/testing/selftests/x86/syscall_nt.c
@@ -17,6 +17,9 @@
#include <stdio.h>
#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <err.h>
#include <sys/syscall.h>
#include <asm/processor-flags.h>
@@ -26,6 +29,8 @@
# define WIDTH "l"
#endif
+static unsigned int nerrs;
+
static unsigned long get_eflags(void)
{
unsigned long eflags;
@@ -39,16 +44,52 @@ static void set_eflags(unsigned long eflags)
: : "rm" (eflags) : "flags");
}
-int main()
+static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),
+ int flags)
{
- printf("[RUN]\tSet NT and issue a syscall\n");
- set_eflags(get_eflags() | X86_EFLAGS_NT);
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = handler;
+ sa.sa_flags = SA_SIGINFO | flags;
+ sigemptyset(&sa.sa_mask);
+ if (sigaction(sig, &sa, 0))
+ err(1, "sigaction");
+}
+
+static void sigtrap(int sig, siginfo_t *si, void *ctx_void)
+{
+}
+
+static void do_it(unsigned long extraflags)
+{
+ unsigned long flags;
+
+ set_eflags(get_eflags() | extraflags);
syscall(SYS_getpid);
- if (get_eflags() & X86_EFLAGS_NT) {
- printf("[OK]\tThe syscall worked and NT is still set\n");
- return 0;
+ flags = get_eflags();
+ if ((flags & extraflags) == extraflags) {
+ printf("[OK]\tThe syscall worked and flags are still set\n");
} else {
- printf("[FAIL]\tThe syscall worked but NT was cleared\n");
- return 1;
+ printf("[FAIL]\tThe syscall worked but flags were cleared (flags = 0x%lx but expected 0x%lx set)\n",
+ flags, extraflags);
+ nerrs++;
}
}
+
+int main(void)
+{
+ printf("[RUN]\tSet NT and issue a syscall\n");
+ do_it(X86_EFLAGS_NT);
+
+ /*
+ * Now try it again with TF set -- TF forces returns via IRET in all
+ * cases except non-ptregs-using 64-bit full fast path syscalls.
+ */
+
+ sethandler(SIGTRAP, sigtrap, 0);
+
+ printf("[RUN]\tSet NT|TF and issue a syscall\n");
+ do_it(X86_EFLAGS_NT | X86_EFLAGS_TF);
+
+ return nerrs == 0 ? 0 : 1;
+}
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2016-03-06 07:00 +0100 |
| Subject | [PATCH v2 05/10] x86/traps: Clear TIF_BLOCKSTEP on all debug exceptions |
| Message-ID | <r9zTt-Q8-13@gated-at.bofh.it> |
| In reply to | #1351050 |
The SDM says that debug exceptions clear BTF, and we need to keep TIF_BLOCKSTEP in sync with BTF. Clear it unconditionally and improve the comment. I suspect that the fact that kmemcheck could cause TIF_BLOCKSTEP not to be cleared was just an oversight. Signed-off-by: Andy Lutomirski <luto@kernel.org> --- arch/x86/kernel/traps.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index dd2c2e66c2e1..19e6cfa501e3 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -598,6 +598,13 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) dr6 &= ~DR6_RESERVED; /* + * The SDM says "The processor clears the BTF flag when it + * generates a debug exception." Clear TIF_BLOCKSTEP to keep + * TIF_BLOCKSTEP in sync with the hardware BTF flag. + */ + clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP); + + /* * If dr6 has no reason to give us about the origin of this trap, * then it's very likely the result of an icebp/int01 trap. * User wants a sigtrap for that. @@ -612,11 +619,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) /* DR6 may or may not be cleared by the CPU */ set_debugreg(0, 6); - /* - * The processor cleared BTF, so don't mark that we need it set. - */ - clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP); - /* Store the virtualized DR6 value */ tsk->thread.debugreg6 = dr6; -- 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2016-03-06 07:00 +0100 |
| Subject | [PATCH v2 03/10] x86/entry/32: Filter NT and speed up AC filtering in SYSENTER |
| Message-ID | <r9zTt-Q8-19@gated-at.bofh.it> |
| In reply to | #1351050 |
This makes the 32-bit code work just like the 64-bit code. It should speed up syscalls on 32-bit kernels on Skylake by something like 20 cycles (by analogy to the 64-bit compat case). It also cleans up NT just like we do for the 64-bit case. Signed-off-by: Andy Lutomirski <luto@kernel.org> --- arch/x86/entry/entry_32.S | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index ab710eee4308..289a17bf0c71 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -294,7 +294,6 @@ sysenter_past_esp: pushl $__USER_DS /* pt_regs->ss */ pushl %ebp /* pt_regs->sp (stashed in bp) */ pushfl /* pt_regs->flags (except IF = 0) */ - ASM_CLAC /* Clear AC after saving FLAGS */ orl $X86_EFLAGS_IF, (%esp) /* Fix IF */ pushl $__USER_CS /* pt_regs->cs */ pushl $0 /* pt_regs->ip = 0 (placeholder) */ @@ -302,6 +301,23 @@ sysenter_past_esp: SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */ /* + * SYSENTER doesn't filter flags, so we need to clear NT and AC + * ourselves. To save a few cycles, we can check whether + * either was set instead of doing an unconditional popfq. + * This needs to happen before enabling interrupts so that + * we don't get preempted with NT set. + * + * NB.: .Lsysenter_fix_flags is a label with the code under it moved + * out-of-line as an optimization: NT is unlikely to be set in the + * majority of the cases and instead of polluting the I$ unnecessarily, + * we're keeping that code behind a branch which will predict as + * not-taken and therefore its instructions won't be fetched. + */ + testl $X86_EFLAGS_NT|X86_EFLAGS_AC, PT_EFLAGS(%esp) + jnz .Lsysenter_fix_flags +.Lsysenter_flags_fixed: + + /* * User mode is traced as though IRQs are on, and SYSENTER * turned them off. */ @@ -339,6 +355,11 @@ sysenter_past_esp: .popsection _ASM_EXTABLE(1b, 2b) PTGS_TO_GS_EX + +.Lsysenter_fix_flags: + pushl $X86_EFLAGS_FIXED + popfl + jmp .Lsysenter_flags_fixed ENDPROC(entry_SYSENTER_32) # system call handler stub -- 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2016-03-06 07:00 +0100 |
| Subject | [PATCH v2 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test |
| Message-ID | <r9zTt-Q8-21@gated-at.bofh.it> |
| In reply to | #1351050 |
CLAC is slow, and the SYSENTER code already has an unlikely path that runs if unusual flags are set. Drop the CLAC and instead rely on the unlikely path to clear AC. This seems to save ~24 cycles on my Skylake laptop. (Hey, Intel, make this faster please!) Signed-off-by: Andy Lutomirski <luto@kernel.org> --- arch/x86/entry/entry_64_compat.S | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index 89bcb4979e7a..8d3728131809 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -66,8 +66,6 @@ ENTRY(entry_SYSENTER_compat) */ pushfq /* pt_regs->flags (except IF = 0) */ orl $X86_EFLAGS_IF, (%rsp) /* Fix saved flags */ - ASM_CLAC /* Clear AC after saving FLAGS */ - pushq $__USER32_CS /* pt_regs->cs */ xorq %r8,%r8 pushq %r8 /* pt_regs->ip = 0 (placeholder) */ @@ -90,9 +88,9 @@ ENTRY(entry_SYSENTER_compat) cld /* - * Sysenter doesn't filter flags, so we need to clear NT + * SYSENTER doesn't filter flags, so we need to clear NT and AC * ourselves. To save a few cycles, we can check whether - * NT was set instead of doing an unconditional popfq. + * either was set instead of doing an unconditional popfq. * This needs to happen before enabling interrupts so that * we don't get preempted with NT set. * @@ -102,7 +100,7 @@ ENTRY(entry_SYSENTER_compat) * we're keeping that code behind a branch which will predict as * not-taken and therefore its instructions won't be fetched. */ - testl $X86_EFLAGS_NT, EFLAGS(%rsp) + testl $X86_EFLAGS_NT|X86_EFLAGS_AC, EFLAGS(%rsp) jnz .Lsysenter_fix_flags .Lsysenter_flags_fixed: -- 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2016-03-06 09:30 +0100 |
| Subject | Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups |
| Message-ID | <r9CeC-2uz-5@gated-at.bofh.it> |
| In reply to | #1351050 |
* Andy Lutomirski <luto@kernel.org> wrote: > This series applies to the result of merging tip:x86/asm and > tip:x86/urgent. I've been testing on a somewhat bastardized base, > because tip currently doesn't work on my laptop in 32-bit mode. (That > bug is fixed in Linus' tree.) Hm, which fix is that? Generally, tip:master closely tracks Linus's latest (so it should work as-is), but individual sub-trees are only updated when necessary - but a refresh can be done anytime if requested. Thanks, Ingo
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2016-03-06 17:20 +0100 |
| Message-ID | <r9Jzs-7lO-9@gated-at.bofh.it> |
| In reply to | #1351063 |
On Mar 6, 2016 12:22 AM, "Ingo Molnar" <mingo@kernel.org> wrote: > > > * Andy Lutomirski <luto@kernel.org> wrote: > > > This series applies to the result of merging tip:x86/asm and > > tip:x86/urgent. I've been testing on a somewhat bastardized base, > > because tip currently doesn't work on my laptop in 32-bit mode. (That > > bug is fixed in Linus' tree.) > > Hm, which fix is that? http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=de9e478b9d49f3a0214310d921450cf5bb4a21e6
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2016-03-07 09:30 +0100 |
| Subject | Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups |
| Message-ID | <r9YIa-oh-17@gated-at.bofh.it> |
| In reply to | #1351147 |
* Andy Lutomirski <luto@amacapital.net> wrote: > On Mar 6, 2016 12:22 AM, "Ingo Molnar" <mingo@kernel.org> wrote: > > > > > > * Andy Lutomirski <luto@kernel.org> wrote: > > > > > This series applies to the result of merging tip:x86/asm and > > > tip:x86/urgent. I've been testing on a somewhat bastardized base, > > > because tip currently doesn't work on my laptop in 32-bit mode. (That > > > bug is fixed in Linus' tree.) > > > > Hm, which fix is that? > > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=de9e478b9d49f3a0214310d921450cf5bb4a21e6 ah, indeed. I've merged v4.5-rc7 into tip:x86/asm, which includes this fix, to make the topic branch bisectable on SkyLake as well. Thanks, Ingo
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2016-03-06 09:40 +0100 |
| Subject | Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups |
| Message-ID | <r9Coh-2xJ-7@gated-at.bofh.it> |
| In reply to | #1351050 |
* Andy Lutomirski <luto@kernel.org> wrote: > hpa asked me to get rid of the ASM_CLAC at the beginning of the SYSENTER > path. Little did he know... Btw., before we further change this code, something else I think would be very useful. We have countless system call entry points on x86 CPUs, and they are now consistently named and are very easy to grep for: triton:~/tip> git grep 'ENTRY(entry_' arch/x86/entry/ arch/x86/entry/entry_32.S:ENTRY(entry_SYSENTER_32) arch/x86/entry/entry_32.S:ENTRY(entry_INT80_32) arch/x86/entry/entry_64.S:ENTRY(entry_SYSCALL_64) arch/x86/entry/entry_64_compat.S:ENTRY(entry_SYSENTER_compat) arch/x86/entry/entry_64_compat.S:ENTRY(entry_SYSCALL_compat) arch/x86/entry/entry_64_compat.S:ENTRY(entry_INT80_compat) Furthermore, each entry point has extensive comments, except one important detail: none of the comments really explains the circumstances under which the entry points are _used_ by user-space. I'd like to see something like: arch/x86/entry/entry_64.S:ENTRY(entry_SYSCALL_64) * * The 64-bit SYSCALL instruction is used by all modern 64-bit user-space * code to execute most system calls: this instruction is the fastest and * sanest implementation on modern Intel and AMD CPUs. * ... and we should add similar explanations for all of the 6 entry points, with caveats and limitations listed generously. Especially valuable would be to list eventual 'strange' usages of the various syscall instructions, used by rare packages, compatibility layers, emulators, embedded libraries, etc. (To the extent we know about them, obviously.) I.e. it would be very nice to do a full documentation of our current system call usage patterns, as utilized by user-space. Beyond the documentation value this will also help people prioritize optimizations between the various entry points - which should be optimized more, which entry point matters less, etc. Thanks, Ingo
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2016-03-06 17:20 +0100 |
| Message-ID | <r9Jzs-7lO-13@gated-at.bofh.it> |
| In reply to | #1351065 |
On Mar 6, 2016 12:31 AM, "Ingo Molnar" <mingo@kernel.org> wrote: > > > * Andy Lutomirski <luto@kernel.org> wrote: > > > hpa asked me to get rid of the ASM_CLAC at the beginning of the SYSENTER > > path. Little did he know... > > Btw., before we further change this code, something else I think would be very > useful. We have countless system call entry points on x86 CPUs, and they are now > consistently named and are very easy to grep for: > > triton:~/tip> git grep 'ENTRY(entry_' arch/x86/entry/ > arch/x86/entry/entry_32.S:ENTRY(entry_SYSENTER_32) > arch/x86/entry/entry_32.S:ENTRY(entry_INT80_32) > arch/x86/entry/entry_64.S:ENTRY(entry_SYSCALL_64) > arch/x86/entry/entry_64_compat.S:ENTRY(entry_SYSENTER_compat) > arch/x86/entry/entry_64_compat.S:ENTRY(entry_SYSCALL_compat) > arch/x86/entry/entry_64_compat.S:ENTRY(entry_INT80_compat) > > Furthermore, each entry point has extensive comments, except one important detail: > none of the comments really explains the circumstances under which the entry > points are _used_ by user-space. > > I'd like to see something like: > > arch/x86/entry/entry_64.S:ENTRY(entry_SYSCALL_64) > > * > * The 64-bit SYSCALL instruction is used by all modern 64-bit user-space > * code to execute most system calls: this instruction is the fastest and > * sanest implementation on modern Intel and AMD CPUs. > * > > ... and we should add similar explanations for all of the 6 entry points, with > caveats and limitations listed generously. > > Especially valuable would be to list eventual 'strange' usages of the various > syscall instructions, used by rare packages, compatibility layers, emulators, > embedded libraries, etc. (To the extent we know about them, obviously.) I'll send a follow-up patch. --Andy
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web