diff options
| author | Benjamin Gray <[email protected]> | 2024-05-15 02:44:42 +0000 |
|---|---|---|
| committer | Michael Ellerman <[email protected]> | 2024-08-21 10:15:12 +0000 |
| commit | dbf828aab466c6534711d1f1454c409ea68d18d0 (patch) | |
| tree | 71be154aa3e1c4464431f9b8b06687900d49b109 /arch/powerpc/lib/code-patching.c | |
| parent | powerpc/code-patching: Add generic memory patching (diff) | |
| download | kernel-dbf828aab466c6534711d1f1454c409ea68d18d0.tar.gz kernel-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 <[email protected]>
Reviewed-by: Hari Bathini <[email protected]>
Acked-by: Naveen N Rao <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
| -rw-r--r-- | arch/powerpc/lib/code-patching.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 7f423fa3c51b..acdab294b340 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -386,12 +386,18 @@ NOKPROBE_SYMBOL(patch_instruction); int patch_uint(void *addr, unsigned int val) { + if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned int))) + return -EINVAL; + return patch_mem(addr, val, false); } NOKPROBE_SYMBOL(patch_uint); int patch_ulong(void *addr, unsigned long val) { + if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned long))) + return -EINVAL; + return patch_mem(addr, val, true); } NOKPROBE_SYMBOL(patch_ulong); |
