[PATCH v8 3/6] powerpc/code-patching: Verify instruction patch succeeded
Russell Currey
ruscur at russell.cc
Mon Oct 24 14:20:11 AEDT 2022
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote:
> Verifies that if the instruction patching did not return an error
> then
> the value stored at the given address to patch is now equal to the
> instruction we patched it to.
>
> Signed-off-by: Benjamin Gray <bgray at linux.ibm.com>
> ---
> arch/powerpc/lib/code-patching.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/lib/code-patching.c
> b/arch/powerpc/lib/code-patching.c
> index 34fc7ac34d91..9b9eba574d7e 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -186,6 +186,8 @@ static int do_patch_instruction(u32 *addr,
> ppc_inst_t instr)
> err = __do_patch_instruction(addr, instr);
> local_irq_restore(flags);
>
> + WARN_ON(!err && !ppc_inst_equal(instr, ppc_inst_read(addr)));
> +
As a side note, I had a look at test-code-patching.c and it doesn't
look like we don't have a test for ppc_inst_equal() with prefixed
instructions. We should fix that.
> return err;
> }
> #else /* !CONFIG_STRICT_KERNEL_RWX */
More information about the Linuxppc-dev
mailing list