Message ID | 20221021052238.580986-4-bgray@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Use per-CPU temporary mappings for patching | expand |
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@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 */
On Mon, 2022-10-24 at 14:20 +1100, Russell Currey wrote: > On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > > 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. Yeah, for a different series though I assume. And I think it would be better suited in a suite dedicated to testing asm/inst.h functions.
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))); + return err; } #else /* !CONFIG_STRICT_KERNEL_RWX */
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@linux.ibm.com> --- arch/powerpc/lib/code-patching.c | 2 ++ 1 file changed, 2 insertions(+)