Re: [PATCH v4 07/16] powerpc: Introduce functions for instruction nullity and equality
From: Jordan Niethe <hidden>
Date: 2020-03-23 09:37:40
On Mon, Mar 23, 2020 at 5:46 PM Nicholas Piggin [off-list ref] wrote:
Jordan Niethe's on March 20, 2020 3:18 pm:quoted
In preparation for an instruction data type that can not be directly used with the '==' operator use functions for checking equality and nullity. Signed-off-by: Jordan Niethe <redacted> --- arch/powerpc/kernel/optprobes.c | 2 +- arch/powerpc/kernel/trace/ftrace.c | 33 +++++++++++++++------------- arch/powerpc/lib/code-patching.c | 16 +++++++------- arch/powerpc/lib/feature-fixups.c | 2 +- arch/powerpc/lib/test_emulate_step.c | 4 ++-- arch/powerpc/xmon/xmon.c | 4 ++-- 6 files changed, 32 insertions(+), 29 deletions(-)diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c index 1025a7a3b3a8..6027425a85f2 100644 --- a/arch/powerpc/kernel/optprobes.c +++ b/arch/powerpc/kernel/optprobes.c@@ -259,7 +259,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p) (unsigned long)emulate_step_addr, BRANCH_SET_LINK); - if (!branch_op_callback || !branch_emulate_step) + if (ppc_inst_null(branch_op_callback) || ppc_inst_null(branch_emulate_step))Is an instruction null, or zeroes?
ppc_inst_zero() would probably be clearer.
Oh, most of this comes from create_branch and things. Hmm, would rather see those functions modified to take a &insn and return an int err.
Good idea.
quoted
@@ -437,7 +438,7 @@ int ftrace_make_nop(struct module *mod, * then we had to use a trampoline to make the call. * Otherwise just update the call site. */ - if (test_24bit_addr(ip, addr)) { + if (!ppc_inst_null(test_24bit_addr(ip, addr))) { /* within range */ old = ftrace_call_replace(ip, addr, 1); new = PPC_INST(PPC_INST_NOP);test_24bit_addr shouldn't be passing a ppc_inst back, but a bool.
True.
Thanks, Nick