mirror of
https://github.com/torvalds/linux.git
synced 2026-12-03 20:06:35 +00:00
Several architectures support text patching, but they name the header files that declare patching functions differently. Make all such headers consistently named text-patching.h and add an empty header in asm-generic for architectures that do not support text patching. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> # m68k Acked-by: Arnd Bergmann <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]> Tested-by: kdevops <[email protected]> Cc: Andreas Larsson <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Borislav Petkov (AMD) <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dinh Nguyen <[email protected]> Cc: Guo Ren <[email protected]> Cc: Helge Deller <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Johannes Berg <[email protected]> Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu (Google) <[email protected]> Cc: Matt Turner <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Russell King <[email protected]> Cc: Song Liu <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Steven Rostedt (Google) <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Uladzislau Rezki (Sony) <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
38 lines
933 B
C
38 lines
933 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/memory.h>
|
|
#include <linux/static_call.h>
|
|
|
|
#include <asm/text-patching.h>
|
|
|
|
void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
|
|
{
|
|
int err;
|
|
bool is_ret0 = (func == __static_call_return0);
|
|
unsigned long target = (unsigned long)(is_ret0 ? tramp + PPC_SCT_RET0 : func);
|
|
bool is_short = is_offset_in_branch_range((long)target - (long)tramp);
|
|
|
|
if (!tramp)
|
|
return;
|
|
|
|
mutex_lock(&text_mutex);
|
|
|
|
if (func && !is_short) {
|
|
err = patch_ulong(tramp + PPC_SCT_DATA, target);
|
|
if (err)
|
|
goto out;
|
|
}
|
|
|
|
if (!func)
|
|
err = patch_instruction(tramp, ppc_inst(PPC_RAW_BLR()));
|
|
else if (is_short)
|
|
err = patch_branch(tramp, target, 0);
|
|
else
|
|
err = patch_instruction(tramp, ppc_inst(PPC_RAW_NOP()));
|
|
out:
|
|
mutex_unlock(&text_mutex);
|
|
|
|
if (err)
|
|
panic("%s: patching failed %pS at %pS\n", __func__, func, tramp);
|
|
}
|
|
EXPORT_SYMBOL_GPL(arch_static_call_transform);
|