linux-stable/arch/powerpc
Josh Poimboeuf 37251c7114 powerpc/module_64: Fix "expected nop" error on module re-patching
When a module with a livepatched function is unloaded and then reloaded,
klp attempts to dynamically re-patch it.  On ppc64, that fails with the
following error:

  module_64: livepatch_nfsd: Expected nop after call, got e8410018 at e_show+0x60/0x548 [livepatch_nfsd]
  livepatch: failed to initialize patch 'livepatch_nfsd' for module 'nfsd' (-8)
  livepatch: patch 'livepatch_nfsd' failed for module 'nfsd', refusing to load module 'nfsd'

The error happens because the restore r2 instruction had already
previously been written into the klp module's replacement function when
the original function was patched the first time.  So the instruction
wasn't a nop as expected.

When the restore r2 instruction has already been patched in, detect that
and skip the warning and the instruction write.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2f6329ffd9674df6ff57e03edeb2ca54414770ab.1674617130.git.jpoimboe@kernel.org
2023-01-26 21:08:04 +11:00
..
boot powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
configs USB/Thunderbolt driver changes for 6.2-rc1 2022-12-16 03:22:53 -08:00
crypto treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
include powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
kernel powerpc/module_64: Fix "expected nop" error on module re-patching 2023-01-26 21:08:04 +11:00
kexec powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
kvm powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
lib powerpc/code-patching: Fix oops with DEBUG_VM enabled 2022-12-16 23:59:43 +11:00
math-emu powerpc/math-emu: Inhibit W=1 warnings 2022-09-08 11:11:18 +10:00
mm powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
net powerpc/bpf/32: Fix Oops on tail call tests 2022-11-24 23:05:10 +11:00
perf powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
platforms powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
purgatory powerpc/purgatory: Omit use of bin2c 2022-07-27 21:36:03 +10:00
sysdev powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
tools powerpc/64: Add UADDR64 relocation support 2022-03-09 21:47:53 +11:00
xmon powerpc: Rename STACK_FRAME_MARKER and derive it from frame offset 2022-12-02 17:54:08 +11:00
Kbuild
Kconfig Merge branch 'topic/objtool' into next 2022-12-08 23:57:47 +11:00
Kconfig.debug powerpc: Add support for early debugging via Serial 16550 console 2022-09-28 19:22:09 +10:00
Makefile Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00
Makefile.postlink