linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] Out-of-line static calls for powerpc64 ELF V2
@ 2022-10-05  5:32 Benjamin Gray
  2022-10-05  5:32 ` [PATCH v3 1/6] powerpc/code-patching: Implement generic text patching function Benjamin Gray
                   ` (5 more replies)
  0 siblings, 6 replies; 25+ messages in thread
From: Benjamin Gray @ 2022-10-05  5:32 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: ajd, peterz, Benjamin Gray, npiggin, ardb, jbaron, rostedt, jpoimboe

Implementation of out-of-line static calls for PowerPC 64-bit ELF V2 ABI.
Static calls patch an indirect branch into a direct branch at runtime.
Out-of-line specifically has a caller directly call a trampoline, and
the trampoline gets patched to directly call the target.

Previous versions here:
V2: https://lore.kernel.org/all/20220926064316.765967-1-bgray@linux.ibm.com/
V1: https://lore.kernel.org/all/20220916062330.430468-1-bgray@linux.ibm.com/

Changed for V3:

[general]
* Rebased on top of
  https://lore.kernel.org/all/0df84a2eea551c1d000c34c36d0c1d23cbe26a97.1664289176.git.christophe.leroy@csgroup.eu/
  for removing the separate CONFIG_STRICT_KERNEL_RWX cases. Can rebase back onto next if necessary.
* Some some minor refactoring/style fixes throughout

[1/6]
* Code patching rewritten again
* This time it only adds support for what is needed:
        * int or long sized writes only
        * assumed within a cacheline (static call pointers are aligned
          for atomic updates, instructions are aligned anyway)
        * unconditional instruction syncing because non-instruction
          patching is not used in any performance sensitive paths
        * similarly, dword case is marked unlikely. ftrace activation is biggest
          performance concern, and it only uses non-prefixed instructions.
* Should be zero difference on 32-bit, minor differences on 64-bit
* Design doesn't need to be revisited unless specifically 1 or 2 byte
  patching is needed. Most such patches can be emulated by read-update-store
  of 4 bytes. Non-cacheline safe patches can be split similarly (they
  can't have atomicity requirements if they aren't aligned).

[3/6]
* Refactored to use patch_branch (thx Christophe)

[5/6]
* Required .localentry NAME, 1 directive guarded by toolchain version check
* Removed #ifdef's from static call implementation. Added sign_extend_long to
  support this.
* Fixed a bug in ppc_function_toc handling of lis case & made it more verbose
  to make such errors stand out more. New layout splits into calculating required
  values, and then applying them in two steps.

[6/6]
* Replaced SAVE_REGS/RESTORE_REGS macros with functions
* Reduced global register usage of tests
* Support running on 32-bit as well


Benjamin Gray (6):
  powerpc/code-patching: Implement generic text patching function
  powerpc/module: Handle caller-saved TOC in module linker
  powerpc/module: Optimise nearby branches in ELF V2 ABI stub
  static_call: Move static call selftest to static_call_selftest.c
  powerpc/64: Add support for out-of-line static calls
  powerpc: Add tests for out-of-line static calls

 arch/powerpc/Kconfig                     |  26 ++-
 arch/powerpc/include/asm/code-patching.h |  30 +++
 arch/powerpc/include/asm/static_call.h   |  80 ++++++-
 arch/powerpc/kernel/Makefile             |   4 +-
 arch/powerpc/kernel/module_64.c          |  26 ++-
 arch/powerpc/kernel/static_call.c        | 183 +++++++++++++++-
 arch/powerpc/kernel/static_call_test.c   | 263 +++++++++++++++++++++++
 arch/powerpc/kernel/static_call_test.h   |  56 +++++
 arch/powerpc/lib/code-patching.c         |  73 +++++--
 kernel/Makefile                          |   1 +
 kernel/static_call_inline.c              |  43 ----
 kernel/static_call_selftest.c            |  41 ++++
 12 files changed, 753 insertions(+), 73 deletions(-)
 create mode 100644 arch/powerpc/kernel/static_call_test.c
 create mode 100644 arch/powerpc/kernel/static_call_test.h
 create mode 100644 kernel/static_call_selftest.c


base-commit: 9a5e80596e50f1ab19fecb2d337e7ea3287ee083
--
2.37.3

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-10-06 21:55 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05  5:32 [PATCH v3 0/6] Out-of-line static calls for powerpc64 ELF V2 Benjamin Gray
2022-10-05  5:32 ` [PATCH v3 1/6] powerpc/code-patching: Implement generic text patching function Benjamin Gray
2022-10-05 17:55   ` Christophe Leroy
2022-10-06  3:36     ` Benjamin Gray
2022-10-06  9:19       ` Christophe Leroy
2022-10-06 21:53         ` Benjamin Gray
2022-10-05  5:32 ` [PATCH v3 2/6] powerpc/module: Handle caller-saved TOC in module linker Benjamin Gray
2022-10-05 19:18   ` Christophe Leroy
2022-10-06  3:51     ` Andrew Donnellan
2022-10-06  4:39     ` Benjamin Gray
2022-10-05  5:32 ` [PATCH v3 3/6] powerpc/module: Optimise nearby branches in ELF V2 ABI stub Benjamin Gray
2022-10-05 19:21   ` Christophe Leroy
2022-10-06  8:24   ` Andrew Donnellan
2022-10-05  5:32 ` [PATCH v3 4/6] static_call: Move static call selftest to static_call_selftest.c Benjamin Gray
2022-10-05 19:22   ` Christophe Leroy
2022-10-05  5:32 ` [PATCH v3 5/6] powerpc/64: Add support for out-of-line static calls Benjamin Gray
2022-10-05 19:38   ` Christophe Leroy
2022-10-06  0:39     ` Michael Ellerman
2022-10-06  5:01       ` Benjamin Gray
2022-10-06 18:22       ` Segher Boessenkool
2022-10-06 18:38         ` Christophe Leroy
2022-10-06 20:45           ` Segher Boessenkool
2022-10-06 20:50             ` Christophe Leroy
2022-10-06 21:04               ` Segher Boessenkool
2022-10-05  5:32 ` [PATCH v3 6/6] powerpc: Add tests " Benjamin Gray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).