aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib/code-patching.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2018-10-08 10:40:34 +0200
committerIngo Molnar <mingo@kernel.org>2018-10-08 10:40:34 +0200
commitedfbeecd92b0c4a648ed96a7e255bfc9a1bc4642 (patch)
treeefdfc57e2520886842a27f2c9978c83d968ba709 /arch/powerpc/lib/code-patching.c
parentx86/asm: Use CC_SET()/CC_OUT() in __cmpxchg_double() (diff)
parentMerge tag 'char-misc-4.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/g... (diff)
downloadlinux-edfbeecd92b0c4a648ed96a7e255bfc9a1bc4642.tar.gz
linux-edfbeecd92b0c4a648ed96a7e255bfc9a1bc4642.zip
Merge branch 'linus' into x86/asm, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
-rw-r--r--arch/powerpc/lib/code-patching.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 850f3b8f4da5..5ffee298745f 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -142,7 +142,7 @@ static inline int unmap_patch_area(unsigned long addr)
return 0;
}
-int patch_instruction(unsigned int *addr, unsigned int instr)
+static int do_patch_instruction(unsigned int *addr, unsigned int instr)
{
int err;
unsigned int *patch_addr = NULL;
@@ -182,12 +182,22 @@ out:
}
#else /* !CONFIG_STRICT_KERNEL_RWX */
-int patch_instruction(unsigned int *addr, unsigned int instr)
+static int do_patch_instruction(unsigned int *addr, unsigned int instr)
{
return raw_patch_instruction(addr, instr);
}
#endif /* CONFIG_STRICT_KERNEL_RWX */
+
+int patch_instruction(unsigned int *addr, unsigned int instr)
+{
+ /* Make sure we aren't patching a freed init section */
+ if (init_mem_is_free && init_section_contains(addr, 4)) {
+ pr_debug("Skipping init section patching addr: 0x%px\n", addr);
+ return 0;
+ }
+ return do_patch_instruction(addr, instr);
+}
NOKPROBE_SYMBOL(patch_instruction);
int patch_branch(unsigned int *addr, unsigned long target, int flags)