Skip to content

RFC x86: Remove anonymous out-of-line fixups

Peter Zijlstra lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest22 patches 36 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22bitfield.h: Fix "type of reg too small for mask" testinclude/linux/bitfield.h+18 -10 replies
2/22x86,mmx_32: Remove .fixup usagearch/x86/lib/mmx_32.c+27 -564 replies
3/22x86,copy_user_64: Remove .fixup usagearch/x86/lib/copy_user_64.S+11 -210 replies
4/22x86,copy_mc_64: Remove .fixup usagearch/x86/lib/copy_mc_64.S+4 -80 replies
5/22x86,entry_64: Remove .fixup usagearch/x86/entry/entry_64.S+6 -70 replies
6/22x86,entry_32: Remove .fixup usagearch/x86/entry/entry_32.S arch/x86/include/asm/extable_fixup_types.h arch/x86/mm/extable.c+19 -202 replies
7/22x86,extable: Extend extable functionalityarch/x86/include/asm/asm.h arch/x86/include/asm/extable_fixup_types.h arch/x86/mm/extable.c+96 -411 replies
8/22x86,msr: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/msr.h arch/x86/mm/extable.c+47 -530 replies
9/22x86,futex: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/futex.h+10 -200 replies
10/22x86,uaccess: Remove .fixup usagearch/x86/include/asm/uaccess.h+15 -201 reply
11/22x86,xen: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/xen/page.h+3 -102 replies
12/22x86,fpu: Remove .fixup usagearch/x86/kernel/fpu/legacy.h arch/x86/kernel/fpu/xstate.h+2 -100 replies
13/22x86,segment: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/segment.h+2 -80 replies
14/22x86,ftrace: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/kernel/ftrace.c+3 -72 replies
15/22x86,vmx: Remove .fixup usagearch/x86/kvm/vmx/vmx_ops.h+6 -89 replies
16/22x86,checksum_32: Remove .fixup usagearch/x86/lib/checksum_32.S+3 -160 replies
17/22x86,sgx: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/sgx.h arch/x86/kernel/cpu/sgx/encls.h +1 more+35 -310 replies
18/22x86,kvm: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/kvm/emulate.c arch/x86/mm/extable.c+15 -112 replies
19/22x86,usercopy_32: Simplify..arch/x86/lib/usercopy_32.c+20 -200 replies
20/22x86,usercopy: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/lib/usercopy_32.c arch/x86/lib/usercopy_64.c +1 more+22 -280 replies
21/22x86,word-at-a-time: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/word-at-a-time.h arch/x86/mm/extable.c+26 -202 replies
22/22x86: Remove .fixup sectionarch/x86/entry/vdso/vdso-layout.lds.S arch/x86/kernel/vmlinux.lds.S+0 -21 reply

Reviews trailers per patch

1 of 22 patches has a Reviewed-by or Acked-by.

PatchPaolo Bonzini
1/22
2/22
3/22
4/22
5/22
6/22
7/22
8/22
9/22
10/22
11/22
12/22
13/22
14/22
15/22R-b
16/22
17/22
18/22
19/22
20/22
21/22
22/22

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

Read the v1 thread

Cover letter [RFC][PATCH 00/22] x86: Remove anonymous out-of-line fixups

Hi,

Direct counterpart to the arm64 series from Mark:

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

Since he already put it rather well:

"We recently realised that out-of-line extable fixups cause a number of problems for backtracing (mattering both for developers and for RELIABLE_STACKTRACE and LIVEPATCH). Dmitry spotted a confusing backtrace, which we identified was due to problems with unwinding fixups, as summarized in:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

The gist is that while backtracing through a fixup, the fixup gets symbolized as an offset from the nearest prior symbol (which happens to be __entry_tramp_text_end), and we the backtrace misses the function that was being fixed up (because the fixup handling adjusts the PC, then the fixup does a direct branch back to the original function). We can't reliably map from an arbitrary PC in the fixup text back to the original function.

The way we create fixups is a bit unfortunate: most fixups are generated from common templates, and only differ in register to be poked and the address to branch back to, leading to redundant copies of the same logic that must pollute Since the fixups are all written in assembly, and duplicated for each fixup site, we can only perform very simple fixups, and can't handle any complex triage that we might need for some exceptions (e.g. MTE faults)."

So far these patches have only been compile tested on x86_64 (defconfig,allyesconfig) and boot tested in kvm (defconfig) -- realy early days.

Enjoy..

---
 arch/x86/entry/entry_32.S                  |  28 ++---
 arch/x86/entry/entry_64.S                  |  13 ++-
 arch/x86/entry/vdso/vdso-layout.lds.S      |   1 -
 arch/x86/include/asm/asm.h                 |  27 +++++
 arch/x86/include/asm/extable_fixup_types.h |  44 ++++++--
 arch/x86/include/asm/futex.h               |  28 ++---
 arch/x86/include/asm/msr.h                 |  26 ++---
 arch/x86/include/asm/segment.h             |   9 +-
 arch/x86/include/asm/sgx.h                 |  18 ++++
 arch/x86/include/asm/uaccess.h             |  35 +++---
 arch/x86/include/asm/word-at-a-time.h      |  29 ++---
 arch/x86/include/asm/xen/page.h            |  12 +--
 arch/x86/kernel/cpu/sgx/encls.h            |  36 +------
 arch/x86/kernel/fpu/legacy.h               |   6 +-
 arch/x86/kernel/fpu/xstate.h               |   6 +-
 arch/x86/kernel/ftrace.c                   |   9 +-
 arch/x86/kernel/vmlinux.lds.S              |   1 -
 arch/x86/kvm/emulate.c                     |  14 +--
 arch/x86/kvm/vmx/vmx_ops.h                 |  14 ++-
 arch/x86/lib/checksum_32.S                 |  19 +---
 arch/x86/lib/copy_mc_64.S                  |  12 +--
 arch/x86/lib/copy_user_64.S                |  32 ++----
 arch/x86/lib/mmx_32.c                      |  83 +++++----------
 arch/x86/lib/usercopy_32.c                 |  66 +++++-------
 arch/x86/lib/usercopy_64.c                 |   8 +-
 arch/x86/mm/extable.c                      | 166 ++++++++++++++++++++++++-----
 include/linux/bitfield.h                   |  19 +++-
 27 files changed, 385 insertions(+), 376 deletions(-)