summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib/code-patching.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2021-10-18 13:51:43 +0100
committerMark Brown <broonie@kernel.org>2021-10-18 13:51:43 +0100
commited96f35cecb0a7d1d95bbba8b9f212e60d0f7480 (patch)
tree15fe5f3dc395c3b1e713ad52bcd529b1a343cfe2 /arch/powerpc/lib/code-patching.c
parent72bf80cf09c4693780ad93a31b48fa5a4e17a946 (diff)
parent519d81956ee277b4419c723adfb154603c2565ba (diff)
downloadlinux-stable-ed96f35cecb0a7d1d95bbba8b9f212e60d0f7480.tar.gz
linux-stable-ed96f35cecb0a7d1d95bbba8b9f212e60d0f7480.tar.bz2
linux-stable-ed96f35cecb0a7d1d95bbba8b9f212e60d0f7480.zip
Merge tag 'v5.15-rc6' into regulator-5.16
Linux 5.15-rc6
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
-rw-r--r--arch/powerpc/lib/code-patching.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index f9a3019e37b4..c5ed98823835 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -228,6 +228,11 @@ bool is_offset_in_branch_range(long offset)
return (offset >= -0x2000000 && offset <= 0x1fffffc && !(offset & 0x3));
}
+bool is_offset_in_cond_branch_range(long offset)
+{
+ return offset >= -0x8000 && offset <= 0x7fff && !(offset & 0x3);
+}
+
/*
* Helper to check if a given instruction is a conditional branch
* Derived from the conditional checks in analyse_instr()
@@ -280,7 +285,7 @@ int create_cond_branch(struct ppc_inst *instr, const u32 *addr,
offset = offset - (unsigned long)addr;
/* Check we can represent the target in the instruction format */
- if (offset < -0x8000 || offset > 0x7FFF || offset & 0x3)
+ if (!is_offset_in_cond_branch_range(offset))
return 1;
/* Mask out the flags and target, so they don't step on each other. */