[PATCH 3/7] riscv: kprobes: Use patch_text_nosync() for insn slots

Samuel Holland posted 7 patches 1 year, 12 months ago
There is a newer version of this series
[PATCH 3/7] riscv: kprobes: Use patch_text_nosync() for insn slots
Posted by Samuel Holland 1 year, 12 months ago
These instructions are not yet visible to the rest of the system,
so there is no need to do the whole stop_machine() dance.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 arch/riscv/kernel/probes/kprobes.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
index 2f08c14a933d..cbf8197072bf 100644
--- a/arch/riscv/kernel/probes/kprobes.c
+++ b/arch/riscv/kernel/probes/kprobes.c
@@ -28,9 +28,9 @@ static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
 
 	p->ainsn.api.restore = (unsigned long)p->addr + offset;
 
-	patch_text(p->ainsn.api.insn, &p->opcode, 1);
-	patch_text((void *)((unsigned long)(p->ainsn.api.insn) + offset),
-		   &insn, 1);
+	patch_text_nosync(p->ainsn.api.insn, &p->opcode, 1);
+	patch_text_nosync(p->ainsn.api.insn + offset,
+			  &insn, 1);
 }
 
 static void __kprobes arch_prepare_simulate(struct kprobe *p)
-- 
2.43.0
Re: [PATCH 3/7] riscv: kprobes: Use patch_text_nosync() for insn slots
Posted by Björn Töpel 1 year, 11 months ago
Samuel Holland <samuel.holland@sifive.com> writes:

> These instructions are not yet visible to the rest of the system,
> so there is no need to do the whole stop_machine() dance.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
>  arch/riscv/kernel/probes/kprobes.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
> index 2f08c14a933d..cbf8197072bf 100644
> --- a/arch/riscv/kernel/probes/kprobes.c
> +++ b/arch/riscv/kernel/probes/kprobes.c
> @@ -28,9 +28,9 @@ static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
>  
>  	p->ainsn.api.restore = (unsigned long)p->addr + offset;
>  
> -	patch_text(p->ainsn.api.insn, &p->opcode, 1);
> -	patch_text((void *)((unsigned long)(p->ainsn.api.insn) + offset),
> -		   &insn, 1);
> +	patch_text_nosync(p->ainsn.api.insn, &p->opcode, 1);
> +	patch_text_nosync(p->ainsn.api.insn + offset,
> +			  &insn, 1);

Nit: 100 chars lines!

Nice find!

Reviewed-by: Björn Töpel <bjorn@rivosinc.com>