Skip to content
  1. Jul 22, 2015
  2. Jul 21, 2015
  3. Jul 17, 2015
  4. Jul 09, 2015
  5. Jul 07, 2015
    • Andy Lutomirski's avatar
      x86/irq, context_tracking: Document how IRQ context tracking works and add an RCU assertion · 0333a209
      Andy Lutomirski authored
      
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/e8bdc4ed0193fb2fd130f3d6b7b8023e2ec1ab62.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0333a209
    • Andy Lutomirski's avatar
      x86/entry: Remove SCHEDULE_USER and asm/context-tracking.h · 06a7b36c
      Andy Lutomirski authored
      
      
      SCHEDULE_USER is no longer used, and asm/context-tracking.h
      contained nothing else.  Remove the header entirely.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/854e9b45f69af20e26c47099eb236321563ebcee.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      06a7b36c
    • Andy Lutomirski's avatar
      x86/entry: Remove exception_enter() from most trap handlers · 8c84014f
      Andy Lutomirski authored
      
      
      On 64-bit kernels, we don't need it any more: we handle context
      tracking directly on entry from user mode and exit to user mode.
      
      On 32-bit kernels, we don't support context tracking at all, so
      these callbacks had no effect.
      
      Note: this doesn't change do_page_fault().  Before we do that,
      we need to make sure that there is no code that can page fault
      from kernel mode with CONTEXT_USER.  The 32-bit fast system call
      stack argument code is the only offender I'm aware of right now.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/ae22f4dfebd799c916574089964592be218151f9.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      8c84014f
    • Andy Lutomirski's avatar
      x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code · 02bc7768
      Andy Lutomirski authored
      
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/60e90901eee611e59e958bfdbbe39969b4f88fe5.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      02bc7768
    • Andy Lutomirski's avatar
      x86/asm/entry/64: Simplify IRQ stack pt_regs handling · a586f98e
      Andy Lutomirski authored
      
      
      There's no need for both RSI and RDI to point to the original stack.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/3a0481f809dd340c7d3f54ce3fd6d66ef2a578cd.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      a586f98e
    • Andy Lutomirski's avatar
      x86/asm/entry/64: Save all regs on interrupt entry · ff467594
      Andy Lutomirski authored
      
      
      To prepare for the big rewrite of the error and interrupt exit
      paths, we will need pt_regs completely filled in.
      
      It's already completely filled in when error_exit runs, so rearrange
      interrupt handling to match it.  This will slow down interrupt
      handling very slightly (eight instructions), but the
      simplification it enables will be more than worth it.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/d8a766a7f558b30e6e01352854628a2d9943460c.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ff467594
    • Andy Lutomirski's avatar
      x86/entry/64: Migrate 64-bit and compat syscalls to the new exit handlers and... · 29ea1b25
      Andy Lutomirski authored
      
      x86/entry/64: Migrate 64-bit and compat syscalls to the new exit handlers and remove old assembly code
      
      These need to be migrated together, as the compat case used to
      jump into the middle of the 64-bit exit code.
      
      Remove the old assembly code.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/d4d1d70de08ac3640badf50048a9e8f18fe2497f.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      29ea1b25
    • Andy Lutomirski's avatar
      x86/entry/64: Really create an error-entry-from-usermode code path · cb6f64ed
      Andy Lutomirski authored
      In 539f5113
      
       ("x86/asm/entry/64: Disentangle error_entry/exit
      gsbase/ebx/usermode code"), I arranged the code slightly wrong
      -- IRET faults would skip the code path that was intended to
      execute on all error entries from user mode.  Fix it up.
      
      While we're at it, make all the labels in error_entry local.
      
      This does not fix a bug, but we'll need it, and it slightly
      shrinks the code.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/91e17891e49fa3d61357eadc451529ad48143ee1.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      cb6f64ed
    • Andy Lutomirski's avatar
      x86/entry: Add new, comprehensible entry and exit handlers written in C · c5c46f59
      Andy Lutomirski authored
      
      
      The current x86 entry and exit code, written in a mixture of assembly and
      C code, is incomprehensible due to being open-coded in a lot of places
      without coherent documentation.
      
      It appears to work primary by luck and duct tape: i.e. obvious runtime
      failures were fixed on-demand, without re-thinking the design.
      
      Due to those reasons our confidence level in that code is low, and it is
      very difficult to incrementally improve.
      
      Add new code written in C, in preparation for simply deleting the old
      entry code.
      
      prepare_exit_to_usermode() is a new function that will handle all
      slow path exits to user mode.  It is called with IRQs disabled
      and it leaves us in a state in which it is safe to immediately
      return to user mode.  IRQs must not be re-enabled at any point
      after prepare_exit_to_usermode() returns and user mode is actually
      entered. (We can, of course, fail to enter user mode and treat
      that failure as a fresh entry to kernel mode.)
      
      All callers of do_notify_resume() will be migrated to call
      prepare_exit_to_usermode() instead; prepare_exit_to_usermode() needs
      to do everything that do_notify_resume() does today, but it also
      takes care of scheduling and context tracking.  Unlike
      do_notify_resume(), it does not need to be called in a loop.
      
      syscall_return_slowpath() is exactly what it sounds like: it will
      be called on any syscall exit slow path. It will replace
      syscall_trace_leave() and it calls prepare_exit_to_usermode() on the
      way out.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/c57c8b87661a4152801d7d3786eac2d1a2f209dd.1435952415.git.luto@kernel.org
      
      
      [ Improved the changelog a bit. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      c5c46f59
    • Andy Lutomirski's avatar
      x86/entry: Add enter_from_user_mode() and use it in syscalls · feed36cd
      Andy Lutomirski authored
      
      
      Changing the x86 context tracking hooks is dangerous because
      there are no good checks that we track our context correctly.
      Add a helper to check that we're actually in CONTEXT_USER when
      we enter from user mode and wire it up for syscall entries.
      
      Subsequent patches will wire this up for all non-NMI entries as
      well.  NMIs are their own special beast and cannot currently
      switch overall context tracking state.  Instead, they have their
      own special RCU hooks.
      
      This is a tiny speedup if !CONFIG_CONTEXT_TRACKING (removes a
      branch) and a tiny slowdown if CONFIG_CONTEXT_TRACING (adds a
      layer of indirection).  Eventually, we should fix up the core
      context tracking code to supply a function that does what we
      want (and can be much simpler than user_exit), which will enable
      us to get rid of the extra call.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/853b42420066ec3fb856779cdc223a6dcb5d355b.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      feed36cd
    • Andy Lutomirski's avatar
      x86/traps, context_tracking: Assert that we're in CONTEXT_KERNEL in exception entries · 02fdcd5e
      Andy Lutomirski authored
      
      
      Other than the super-atomic exception entries, all exception
      entries are supposed to switch our context tracking state to
      CONTEXT_KERNEL. Assert that they do.  These assertions appear
      trivial at this point, as exception_enter() is the function
      responsible for switching context, but I'm planning on reworking
      x86's exception context tracking, and these assertions will help
      make sure that all of this code keeps working.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/20fa1ee2d943233a184aaf96ff75394d3b34dfba.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      02fdcd5e
    • Andy Lutomirski's avatar
      x86/entry: Move C entry and exit code to arch/x86/entry/common.c · 1f484aa6
      Andy Lutomirski authored
      
      
      The entry and exit C helpers were confusingly scattered between
      ptrace.c and signal.c, even though they aren't specific to
      ptrace or signal handling.  Move them together in a new file.
      
      This change just moves code around.  It doesn't change anything.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/324d686821266544d8572423cc281f961da445f4.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      1f484aa6
    • Andy Lutomirski's avatar
      x86/entry/64/compat: Fix bad fast syscall arg failure path · 5e99cb7c
      Andy Lutomirski authored
      
      
      If user code does SYSCALL32 or SYSENTER without a valid stack,
      then our attempt to determine the syscall args will result in a
      failed uaccess fault.  Previously, we would try to recover by
      jumping to the syscall exit code, but we'd run the syscall exit
      work even though we never made it to the syscall entry work.
      
      Clean it up by treating the failure path as a non-syscall entry
      and exit pair.
      
      This fixes strace's output when running the syscall_arg_fault
      test. Without this fix, strace would get out of sync and would
      fail to associate syscall entries with syscall exits.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/903010762c07a3d67df914fea2da84b52b0f8f1d.1435952415.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      5e99cb7c
  6. Jul 06, 2015