Skip to content

x86: Remove anonymous out-of-line fixups

Peter Zijlstra lkml 2 versions – Applied

Status from this message: The following commit has been merged into the x86/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest23 patches 18 repliesApplied
  2. v122 patches 31 repliesSuperseded

Changes in v2 from the cover letter

- Dropped using __cold on labels, because clang. Also gcc doesn't actually generate different code with it. The intent was for the code to end up in .text.cold but that doesn't happen.
- Fixed the vmread constraints to disallow %0 == %1.
- Added a asm-goto-output variant to vmx's vmread implementation.
- Audited Xen and FPU code and converted them from -1 to -EFAULT, as a concequence EX_TYPE_NEG_REG no longer exists.
- Fixed the EX_DATA_*_MASK macros to include an explicit 'int' cast, such that FIELD_GET() will sign-extend the top field.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/23bitfield.h: Fix "type of reg too small for mask" testinclude/linux/bitfield.h+18 -10 replies
2/23x86,mmx_32: Remove .fixup usagearch/x86/lib/mmx_32.c+30 -560 replies
2/23x86/mmx_32: Remove X86_USE_3DNOWarch/x86/Kconfig arch/x86/Kconfig.cpu arch/x86/include/asm/mmx.h +8 more+1 -4691 reply
3/23x86,copy_user_64: Remove .fixup usagearch/x86/lib/copy_user_64.S+11 -211 reply
4/23x86,copy_mc_64: Remove .fixup usagearch/x86/lib/copy_mc_64.S+4 -81 reply
5/23x86,entry_64: Remove .fixup usagearch/x86/entry/entry_64.S+6 -72 replies
6/23x86,entry_32: Remove .fixup usagearch/x86/entry/entry_32.S arch/x86/include/asm/extable_fixup_types.h arch/x86/mm/extable.c+24 -200 replies
7/23x86,extable: Extend extable functionalityarch/x86/include/asm/asm.h arch/x86/include/asm/extable.h arch/x86/include/asm/extable_fixup_types.h +4 more+141 -320 replies
8/23x86,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/23x86,futex: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/futex.h+10 -200 replies
10/23x86,uaccess: Remove .fixup usagearch/x86/include/asm/uaccess.h+17 -220 replies
11/23x86,xen: Remove .fixup usagearch/x86/include/asm/xen/page.h+3 -116 replies
11/23x86,xen: Remove .fixup usagearch/x86/include/asm/xen/page.h+3 -110 replies
12/23x86,fpu: Remove .fixup usagearch/x86/kernel/fpu/legacy.h arch/x86/kernel/fpu/xstate.h+2 -100 replies
13/23x86,segment: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/include/asm/segment.h+2 -80 replies
14/23x86,kvm: Remove .fixup usagearch/x86/include/asm/extable_fixup_types.h arch/x86/kvm/emulate.c+5 -120 replies
15/23x86,vmx: Remove .fixup usagearch/x86/kvm/vmx/vmx_ops.h+7 -90 replies
16/23x86,vmx: Provide asm-goto-output vmreadarch/x86/kvm/vmx/vmx_ops.h+27 -04 replies
17/23x86,checksum_32: Remove .fixup usagearch/x86/lib/checksum_32.S+3 -160 replies
18/23x86,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
19/23x86,usercopy_32: Simplify __copy_user_intel_nocache()arch/x86/lib/usercopy_32.c+20 -200 replies
20/23x86,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 -282 replies
21/23x86,word-at-a-time: Remove .fixup usagearch/x86/include/asm/word-at-a-time.h+47 -190 replies
22/23x86: Remove .fixup sectionarch/x86/entry/vdso/vdso-layout.lds.S arch/x86/kernel/vmlinux.lds.S+0 -20 replies
23/23objtool: Remove .fixup handlingtools/objtool/check.c+2 -60 replies

Reviews trailers per patch

9 of 25 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPaolo BonziniJuergen GrossJosh PoimboeufBorislav PetkovLai Jiangshan
SeriesR-b
1/23
2/23A-b
2/23A-b
3/23R-b
4/23R-b
5/23R-b R-b
6/23
7/23
8/23
9/23
10/23
11/23R-b
11/23R-b
12/23
13/23
14/23
15/23R-b
16/23R-b
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. Scroll the table sideways for all 5 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/23] 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)."

Also available here:

git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/wip.extable

Changes since v1:

- Dropped using __cold on labels, because clang. Also gcc doesn't actually generate different code with it. The intent was for the code to end up in .text.cold but that doesn't happen.
- Fixed the vmread constraints to disallow %0 == %1.
- Added a asm-goto-output variant to vmx's vmread implementation.
- Audited Xen and FPU code and converted them from -1 to -EFAULT, as a concequence EX_TYPE_NEG_REG no longer exists.
- Fixed the EX_DATA_*_MASK macros to include an explicit 'int' cast, such that FIELD_GET() will sign-extend the top field.

---
 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                 |  33 ++++++++
 arch/x86/include/asm/extable.h             |   6 +-
 arch/x86/include/asm/extable_fixup_types.h |  50 ++++++++++--
 arch/x86/include/asm/futex.h               |  28 ++-----
 arch/x86/include/asm/insn-eval.h           |   2 +
 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             |  39 ++++-----
 arch/x86/include/asm/word-at-a-time.h      |  66 ++++++++++-----
 arch/x86/include/asm/xen/page.h            |  14 +---
 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/vmlinux.lds.S              |   1 -
 arch/x86/kvm/emulate.c                     |  16 +---
 arch/x86/kvm/vmx/vmx_ops.h                 |  43 +++++++---
 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/insn-eval.c                   |  66 +++++++++------
 arch/x86/lib/mmx_32.c                      |  86 +++++++-------------
 arch/x86/lib/usercopy_32.c                 |  66 ++++++---------
 arch/x86/lib/usercopy_64.c                 |   8 +-
 arch/x86/mm/extable.c                      | 124 ++++++++++++++++++++++-------
 arch/x86/net/bpf_jit_comp.c                |   2 +-
 include/linux/bitfield.h                   |  19 ++++-
 tools/objtool/check.c                      |   8 +-
 31 files changed, 477 insertions(+), 406 deletions(-)