aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/include/asm/code-patching.h
diff options
context:
space:
mode:
authorBenjamin Gray <bgray@linux.ibm.com>2024-05-15 12:44:42 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2024-08-21 20:15:12 +1000
commitdbf828aab466c6534711d1f1454c409ea68d18d0 (patch)
tree71be154aa3e1c4464431f9b8b06687900d49b109 /arch/powerpc/include/asm/code-patching.h
parente6b8940e7e80cdfe98ba8493214922998920dd9c (diff)
downloadlinux-dbf828aab466c6534711d1f1454c409ea68d18d0.tar.gz
linux-dbf828aab466c6534711d1f1454c409ea68d18d0.tar.bz2
linux-dbf828aab466c6534711d1f1454c409ea68d18d0.zip
powerpc/code-patching: Add data patch alignment check
The new data patching still needs to be aligned within a cacheline too for the flushes to work correctly. To simplify this requirement, we just say data patches must be aligned. Detect when data patching is not aligned, returning an invalid argument error. Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Reviewed-by: Hari Bathini <hbathini@linux.ibm.com> Acked-by: Naveen N Rao <naveen@kernel.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240515024445.236364-3-bgray@linux.ibm.com
Diffstat (limited to 'arch/powerpc/include/asm/code-patching.h')
-rw-r--r--arch/powerpc/include/asm/code-patching.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
index 21a36e2c4e26..e7f14720f630 100644
--- a/arch/powerpc/include/asm/code-patching.h
+++ b/arch/powerpc/include/asm/code-patching.h
@@ -95,11 +95,17 @@ int patch_ulong(void *addr, unsigned long val);
static inline int patch_uint(void *addr, unsigned int val)
{
+ if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned int)))
+ return -EINVAL;
+
return patch_instruction(addr, ppc_inst(val));
}
static inline int patch_ulong(void *addr, unsigned long val)
{
+ if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned long)))
+ return -EINVAL;
+
return patch_instruction(addr, ppc_inst(val));
}