Skip to content

x86/entry: Consolidation part II (syscalls)

Thomas Gleixner kvm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest23 patches 19 repliesIn review
  2. v213 patches 23 repliesApplied
  3. v18 patches 47 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23rcu: Dont acquire lock in NMI handler in rcu_nmi_enter_common()kernel/rcu/tree.c+1 -11 reply
2/23rcu: Add comments marking transitions between RCU watching and notkernel/rcu/tree.c+25 -41 reply
3/23vmlinux.lds.h: Create section for protection against instrumentationinclude/asm-generic/sections.h include/asm-generic/vmlinux.lds.h include/linux/compiler.h +2 more+36 -12 replies
4/23kprobes: Prevent probes in .noinstr.text sectionkernel/kprobes.c+11 -05 replies
5/23tracing: Provide lockdep less trace_hardirqs_on/off() variantsinclude/linux/irqflags.h kernel/trace/trace_preemptirq.c+27 -01 reply
6/23bug: Annotate WARN/BUG/stackfail as noinstr safearch/x86/include/asm/bug.h include/asm-generic/bug.h kernel/panic.c+13 -34 replies
7/23lockdep: Prepare for noinstr sectionsinclude/linux/irqflags.h include/linux/sched.h kernel/locking/lockdep.c +2 more+55 -180 replies
8/23x86/entry: Mark enter_from_user_mode() noinstrarch/x86/entry/common.c+1 -10 replies
9/23x86/entry/common: Protect against instrumentationarch/x86/entry/common.c+89 -440 replies
10/23x86/entry: Move irq tracing on syscall entry to C-codearch/x86/entry/common.c arch/x86/entry/entry_32.S arch/x86/entry/entry_64.S +1 more+19 -340 replies
11/23x86/entry: Move irq flags tracing to prepare_exit_to_usermode()arch/x86/entry/common.c arch/x86/entry/entry_32.S arch/x86/entry/entry_64.S +1 more+26 -210 replies
12/23context_tracking: Ensure that the critical path cannot be instrumentedinclude/linux/context_tracking.h include/linux/context_tracking_state.h kernel/context_tracking.c+14 -120 replies
13/23lib/smp_processor_id: Move it into noinstr sectionlib/smp_processor_id.c+5 -50 replies
14/23x86/speculation/mds: Mark mds_user_clear_cpu_buffers() __always_inlinearch/x86/include/asm/nospec-branch.h+2 -20 replies
15/23x86/entry/64: Check IF in __preempt_enable_notrace() thunkarch/x86/entry/thunk_64.S arch/x86/include/asm/irqflags.h arch/x86/include/asm/paravirt.h+25 -80 replies
16/23x86/entry/64: Mark ___preempt_schedule_notrace() thunk noinstrarch/x86/entry/thunk_64.S+18 -00 replies
17/23rcu/tree: Mark the idle relevant functions noinstrkernel/rcu/tree.c kernel/rcu/tree_plugin.h kernel/rcu/update.c+42 -353 replies
18/23x86/kvm: Move context tracking where it belongsarch/x86/kvm/svm.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+28 -20 replies
19/23x86/kvm/vmx: Add hardirq tracing to guest enter/exitarch/x86/kvm/vmx/vmx.c+23 -22 replies
20/23x86/kvm/svm: Handle hardirqs proper on guest enter/exitarch/x86/kvm/svm.c+28 -120 replies
21/23context_tracking: Make guest_enter/exit_irqoff() .noinstr readyinclude/linux/context_tracking.h+16 -50 replies
22/23x86/kvm/vmx: Move guest enter/exit into .noinstr.textarch/x86/include/asm/hardirq.h arch/x86/kvm/vmx/ops.h arch/x86/kvm/vmx/vmenter.S +2 more+68 -490 replies
23/23x86/kvm/svm: Move guest enter/exit into .noinstr.textarch/x86/kvm/svm.c+62 -520 replies

Reviews trailers per patch

2 of 23 patches have a Reviewed-by or Acked-by.

PatchJoel Fernandes (Google)Frederic Weisbecker
1/23R-b R-b
2/23R-b
3/23
4/23
5/23
6/23
7/23
8/23
9/23
10/23
11/23
12/23
13/23
14/23
15/23
16/23
17/23
18/23
19/23
20/23
21/23
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [patch V3 00/23] x86/entry: Consolidation part II (syscalls)

Hi!

This is the third version of the syscall entry code consolidation series. V2 can be found here:

https://lore.kernel.org/r/[email protected]

It applies on top of

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/entry

and is also available from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel entry-v3-part2

The changes vs. V2:

- A massive rework utilizing Peter Zijlstras objtool patches to analyze the new .noinstr.text section:

https://lore.kernel.org/r/[email protected]

Working with this was really helpful as it clearly pin pointed code which calls out of the protected section which is much more efficient and focussed than chasing everything manually.

- Picked up the two RCU patches from Paul for completeness. The bugfix is required anyway and the comments have been really helpful to see where the defense line has to be.

- As the tool flagged KVM as red zone, I looked at the context tracking usage there and it has similar if not worse issues. New set of patches dealing with that.

Please have a close look at the approach and the resulting protected areas.

Known issues:

- The kprobes '.noinstr.text' exclusion currently works only for built in code. Haven't figured out how to to fix that, but I'm sure that Masami knows :)

- The various SANitizers if enabled ruin the picture. Peter and I still have no brilliant idea what to do about that.

Thanks,

tglx

---
 arch/x86/entry/common.c                |  173 ++++++++++++++++++++++++---------
 arch/x86/entry/entry_32.S              |   24 ----
 arch/x86/entry/entry_64.S              |    6 -
 arch/x86/entry/entry_64_compat.S       |   32 ------
 arch/x86/entry/thunk_64.S              |   45 +++++++-
 arch/x86/include/asm/bug.h             |    3 
 arch/x86/include/asm/hardirq.h         |    4 
 arch/x86/include/asm/irqflags.h        |    3 
 arch/x86/include/asm/nospec-branch.h   |    4 
 arch/x86/include/asm/paravirt.h        |    3 
 arch/x86/kvm/svm.c                     |  152 ++++++++++++++++++----------
 arch/x86/kvm/vmx/ops.h                 |    4 
 arch/x86/kvm/vmx/vmenter.S             |    2 
 arch/x86/kvm/vmx/vmx.c                 |   78 +++++++++++---
 arch/x86/kvm/x86.c                     |    4 
 b/include/asm-generic/bug.h            |    9 +
 include/asm-generic/sections.h         |    3 
 include/asm-generic/vmlinux.lds.h      |    4 
 include/linux/compiler.h               |   24 ++++
 include/linux/compiler_types.h         |    4 
 include/linux/context_tracking.h       |   27 +++--
 include/linux/context_tracking_state.h |    6 -
 include/linux/irqflags.h               |    6 +
 include/linux/sched.h                  |    1 
 kernel/context_tracking.c              |   14 +-
 kernel/kprobes.c                       |   11 ++
 kernel/locking/lockdep.c               |   66 +++++++++---
 kernel/panic.c                         |    4 
 kernel/rcu/tree.c                      |   91 +++++++++++------
 kernel/rcu/tree_plugin.h               |    4 
 kernel/rcu/update.c                    |    7 -
 kernel/trace/trace_preemptirq.c        |   25 ++++
 lib/debug_locks.c                      |    2 
 lib/smp_processor_id.c                 |   10 -
 scripts/mod/modpost.c                  |    2 
 35 files changed, 590 insertions(+), 267 deletions(-)