Skip to content
Snippets Groups Projects
  1. Jun 05, 2023
  2. Jan 13, 2023
  3. Jul 05, 2022
  4. Jun 30, 2022
  5. Jun 21, 2022
  6. Jun 20, 2022
  7. Jun 11, 2020
    • Thomas Gleixner's avatar
      context_tracking: Ensure that the critical path cannot be instrumented · 0372007f
      Thomas Gleixner authored
      
      context tracking lacks a few protection mechanisms against instrumentation:
      
       - While the core functions are marked NOKPROBE they lack protection
         against function tracing which is required as the function entry/exit
         points can be utilized by BPF.
      
       - static functions invoked from the protected functions need to be marked
         as well as they can be instrumented otherwise.
      
       - using plain inline allows the compiler to emit traceable and probable
         functions.
      
      Fix this by marking the functions noinstr and converting the plain inlines
      to __always_inline.
      
      The NOKPROBE_SYMBOL() annotations are removed as the .noinstr.text section
      is already excluded from being probed.
      
      Cures the following objtool warnings:
      
       vmlinux.o: warning: objtool: enter_from_user_mode()+0x34: call to __context_tracking_exit() leaves .noinstr.text section
       vmlinux.o: warning: objtool: prepare_exit_to_usermode()+0x29: call to __context_tracking_enter() leaves .noinstr.text section
       vmlinux.o: warning: objtool: syscall_return_slowpath()+0x29: call to __context_tracking_enter() leaves .noinstr.text section
       vmlinux.o: warning: objtool: do_syscall_64()+0x7f: call to __context_tracking_enter() leaves .noinstr.text section
       vmlinux.o: warning: objtool: do_int80_syscall_32()+0x3d: call to __context_tracking_enter() leaves .noinstr.text section
       vmlinux.o: warning: objtool: do_fast_syscall_32()+0x9c: call to __context_tracking_enter() leaves .noinstr.text section
      
      and generates new ones...
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarAlexandre Chartre <alexandre.chartre@oracle.com>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200505134340.811520478@linutronix.de
      
      
      0372007f
  8. Feb 14, 2020
    • Frederic Weisbecker's avatar
      context-tracking: Introduce CONFIG_HAVE_TIF_NOHZ · 490f561b
      Frederic Weisbecker authored
      
      A few archs (x86, arm, arm64) don't rely anymore on TIF_NOHZ to call
      into context tracking on user entry/exit but instead use static keys
      (or not) to optimize those calls. Ideally every arch should migrate to
      that behaviour in the long run.
      
      Settle a config option to let those archs remove their TIF_NOHZ
      definitions.
      
      Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: David S. Miller <davem@davemloft.net>
      490f561b
  9. Oct 29, 2019
  10. May 21, 2019
  11. Nov 24, 2015
  12. Nov 10, 2015
  13. May 07, 2015
  14. Mar 09, 2015
    • Rik van Riel's avatar
      context_tracking: Export context_tracking_user_enter/exit · efc1e2c9
      Rik van Riel authored
      
      Export context_tracking_user_enter/exit so it can be used by KVM.
      
      Reviewed-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Will deacon <will.deacon@arm.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      efc1e2c9
    • Rik van Riel's avatar
      context_tracking: Run vtime_user_enter/exit only when state == CONTEXT_USER · 19fdd98b
      Rik van Riel authored
      
      Only run vtime_user_enter, vtime_user_exit, and the user enter & exit
      trace points when we are entering or exiting user state, respectively.
      
      The KVM code in guest_enter and guest_exit already take care of calling
      vtime_guest_enter and vtime_guest_exit, respectively.
      
      The RCU code only distinguishes between "idle" and "not idle or kernel".
      There should be no need to add an additional (unused) state there.
      
      Reviewed-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Will deacon <will.deacon@arm.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      19fdd98b
    • Rik van Riel's avatar
      context_tracking: Generalize context tracking APIs to support user and guest · 3aab4f50
      Rik van Riel authored
      
      Generalize the context tracking APIs to support various nature of
      contexts. This is performed by splitting out the mechanism from
      context_tracking_user_enter and context_tracking_user_exit into
      context_tracking_enter and context_tracking_exit.
      
      The nature of the context we track is now detailed in a ctx_state
      parameter pushed to these APIs, allowing the same functions to not just
      track kernel <> user space switching, but also kernel <> guest transitions.
      
      But leave the old functions in order to avoid breaking ARM, which calls
      these functions from assembler code, and cannot easily use C enum
      parameters.
      
      Reviewed-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Will deacon <will.deacon@arm.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      3aab4f50
    • Frederic Weisbecker's avatar
      context_tracking: Rename context symbols to prepare for transition state · c467ea76
      Frederic Weisbecker authored
      
      Current context tracking symbols are designed to express living state.
      As such they are prefixed with "IN_": IN_USER, IN_KERNEL.
      
      Now we are going to use these symbols to also express state transitions
      such as context_tracking_enter(IN_USER) or context_tracking_exit(IN_USER).
      But while the "IN_" prefix works well to express entering a context, it's
      confusing to depict a context exit: context_tracking_exit(IN_USER)
      could mean two things:
      	1) We are exiting the current context to enter user context.
      	2) We are exiting the user context
      We want 2) but the reviewer may be confused and understand 1)
      
      So lets disambiguate these symbols and rename them to CONTEXT_USER and
      CONTEXT_KERNEL.
      
      Acked-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Will deacon <will.deacon@arm.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      c467ea76
  15. Oct 28, 2014
    • Oleg Nesterov's avatar
      sched: stop the unbound recursion in preempt_schedule_context() · 009f60e2
      Oleg Nesterov authored and Ingo Molnar's avatar Ingo Molnar committed
      
      preempt_schedule_context() does preempt_enable_notrace() at the end
      and this can call the same function again; exception_exit() is heavy
      and it is quite possible that need-resched is true again.
      
      1. Change this code to dec preempt_count() and check need_resched()
         by hand.
      
      2. As Linus suggested, we can use the PREEMPT_ACTIVE bit and avoid
         the enable/disable dance around __schedule(). But in this case
         we need to move into sched/core.c.
      
      3. Cosmetic, but x86 forgets to declare this function. This doesn't
         really matter because it is only called by asm helpers, still it
         make sense to add the declaration into asm/preempt.h to match
         preempt_schedule().
      
      Reported-by: default avatarSasha Levin <sasha.levin@oracle.com>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Peter Anvin <hpa@zytor.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Chuck Ebbert <cebbert.lkml@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Link: http://lkml.kernel.org/r/20141005202322.GB27962@redhat.com
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      009f60e2
  16. Jun 14, 2014
  17. May 05, 2014
  18. Dec 02, 2013
  19. Sep 27, 2013
  20. Sep 25, 2013
  21. Aug 14, 2013
    • Frederic Weisbecker's avatar
      context_tracking: User/kernel broundary cross trace events · 1b6a259a
      Frederic Weisbecker authored
      
      This can be useful to track all kernel/user round trips.
      And it's also helpful to debug the context tracking subsystem.
      
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Li Zhong <zhong@linux.vnet.ibm.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Kevin Hilman <khilman@linaro.org>
      1b6a259a
Loading