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
This commit is contained in:
parent
e6b8940e7e
commit
dbf828aab4
@ -95,11 +95,17 @@ int patch_ulong(void *addr, unsigned long val);
|
|||||||
|
|
||||||
static inline int patch_uint(void *addr, unsigned int 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));
|
return patch_instruction(addr, ppc_inst(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int patch_ulong(void *addr, unsigned long 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));
|
return patch_instruction(addr, ppc_inst(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,12 +386,18 @@ NOKPROBE_SYMBOL(patch_instruction);
|
|||||||
|
|
||||||
int patch_uint(void *addr, unsigned int val)
|
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);
|
return patch_mem(addr, val, false);
|
||||||
}
|
}
|
||||||
NOKPROBE_SYMBOL(patch_uint);
|
NOKPROBE_SYMBOL(patch_uint);
|
||||||
|
|
||||||
int patch_ulong(void *addr, unsigned long val)
|
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);
|
return patch_mem(addr, val, true);
|
||||||
}
|
}
|
||||||
NOKPROBE_SYMBOL(patch_ulong);
|
NOKPROBE_SYMBOL(patch_ulong);
|
||||||
|
Loading…
Reference in New Issue
Block a user