Skip to content

RFC arm64: Allocate .text and .init.text together

Ard Biesheuvel linux-arm-kernel linux-mm linux-modules linux-trace-kernel linuxppc-dev lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9mm: execmem: Add API to split an existing execmem cache allocationinclude/linux/execmem.h mm/execmem.c+53 -00 replies
2/9mm: execmem: Allow huge vmappings to be avoided for execmem cachesinclude/linux/execmem.h mm/execmem.c+4 -10 replies
3/9module: Place MOD_TEXT before MOD_INIT_TEXT in enumerationinclude/linux/module.h+2 -20 replies
4/9module: Allocate MOD_INIT_TEXT from the MOD_TEXT ROX allocationkernel/module/main.c+18 -41 reply
5/9arm64: mm: Permit permissions changes on huge vmappingsarch/arm64/mm/pageattr.c+10 -31 reply
6/9arm64: Enable the execmem ROX cache for module textarch/arm64/Kconfig arch/arm64/mm/init.c+19 -11 reply
7/9arm64: ftrace: Revert "fix unreachable PLT for ftrace_caller ..."arch/arm64/include/asm/module.h arch/arm64/include/asm/module.lds.h arch/arm64/kernel/ftrace.c +2 more+4 -340 replies
8/9arm64: module: Combine init and core PLT entries againarch/arm64/include/asm/module.h arch/arm64/include/asm/module.lds.h arch/arm64/kernel/module-plts.c+9 -280 replies
9/9arm64: ftrace: Simplify PLT handlingarch/arm64/include/asm/module.lds.h arch/arm64/kernel/module-plts.c arch/arm64/kernel/module.c+6 -220 replies

Reviews trailers per patch

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

PatchBradley Morgan
1/9
2/9
3/9
4/9R-b
5/9
6/9
7/9
8/9
9/9

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 0/9] arm64: Allocate .text and .init.text together

From: Ard Biesheuvel <[email protected]>

The arm64 module loader has to deal with a couple of corner cases that may occur when .init.text is placed out of direct branch range of .text:

- ordinary direct branches from .init.text into .text may require the use of a PLT entry (i.e., a trampoline aka veneer), which means not only that additional PLT entries need to be allocated for cross-section calls, but also that .init.text needs its own PLT reservation, as the one in .text will be out of range as well;

- dynamic patching of the ftrace handler into .init.text code needs its own dedicated trampoline as the one in .text may be too far away.

- recent compilers may omit BTI veneers for static functions that never have their address taken, and so additional veneers will need to be added to .text in case cross-section direct branches from .init.text require a PLT entry (and therefore a landing pad at the target end).

This is unfortunate, because it is actually somewhat unusual for .text and .init.text to be so far away from each other: only when allocating either of them (but not both) exhausts the 'near' (PLT-less) module region, the other will be allocated from the spillover region, which is not in direct branching range, and therefore requires PLT entries for cross-section calls.

This series addresses this wart by allocating both of them as a single chunk, and freeing the .init.text part along with the other init sections at the appropriate time. This ensures that the two regions will never require veneers for cross-section calls, allowing the arm64 module loader to be simplified.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Petr Pavlu <[email protected]>
Cc Daniel Gomez <[email protected]>
Cc Sami Tolvanen <[email protected]>
Cc Aaron Tomlin <[email protected]>
Cc "Adrian Barnaś" <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Kevin Brodsky <[email protected]>

Ard Biesheuvel (9):
mm: execmem: Add API to split an existing execmem cache allocation
mm: execmem: Allow huge vmappings to be avoided for execmem caches
module: Place MOD_TEXT before MOD_INIT_TEXT in enumeration
module: Allocate MOD_INIT_TEXT from the MOD_TEXT ROX allocation
arm64: mm: Permit permissions changes on huge vmappings
arm64: Enable the execmem ROX cache for module text
arm64: ftrace: Revert "fix unreachable PLT for ftrace_caller ..."
arm64: module: Combine init and core PLT entries again
arm64: ftrace: Simplify PLT handling

 arch/arm64/Kconfig                  |  1 +
 arch/arm64/include/asm/module.h     |  2 -
 arch/arm64/include/asm/module.lds.h |  3 -
 arch/arm64/kernel/ftrace.c          | 13 +---
 arch/arm64/kernel/module-plts.c     | 63 +++++---------------
 arch/arm64/kernel/module.c          | 20 +------
 arch/arm64/mm/init.c                | 19 +++++-
 arch/arm64/mm/pageattr.c            | 13 +++-
 include/linux/execmem.h             | 11 ++++
 include/linux/module.h              |  4 +-
 kernel/module/main.c                | 22 +++++--
 mm/execmem.c                        | 47 ++++++++++++++-
 12 files changed, 124 insertions(+), 94 deletions(-)
Signature · 1 line
2.55.0.860.g4b6b3295ed-goog