diff mbox series

riscv: uprobes: Restore thread.bad_cause

Message ID 1682214146-3756-1-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Accepted
Commit 58b1294dd1d65bb62f08dddbf418f954210c2057
Delegated to: Palmer Dabbelt
Headers show
Series riscv: uprobes: Restore thread.bad_cause | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next at HEAD 310c33dc7a12
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 1 and now 1
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 18 this patch: 18
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 18 this patch: 18
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 3 this patch: 3
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
conchuod/source_inline success Was 0 now: 0
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Tiezhu Yang April 23, 2023, 1:42 a.m. UTC
thread.bad_cause is saved in arch_uprobe_pre_xol(), it should be restored
in arch_uprobe_{post,abort}_xol() accordingly, otherwise the save operation
is meaningless, this change is similar with x86 and powerpc.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/riscv/kernel/probes/uprobes.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Tiezhu Yang April 24, 2023, 11:49 a.m. UTC | #1
Cc:
Oleg Nesterov <oleg@redhat.com>
Srikar Dronamraju <srikar@linux.vnet.ibm.com>

On 04/23/2023 09:42 AM, Tiezhu Yang wrote:
> thread.bad_cause is saved in arch_uprobe_pre_xol(), it should be restored
> in arch_uprobe_{post,abort}_xol() accordingly, otherwise the save operation
> is meaningless, this change is similar with x86 and powerpc.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/riscv/kernel/probes/uprobes.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
> index c976a21..194f166 100644
> --- a/arch/riscv/kernel/probes/uprobes.c
> +++ b/arch/riscv/kernel/probes/uprobes.c
> @@ -67,6 +67,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
>  	struct uprobe_task *utask = current->utask;
>
>  	WARN_ON_ONCE(current->thread.bad_cause != UPROBE_TRAP_NR);
> +	current->thread.bad_cause = utask->autask.saved_cause;
>
>  	instruction_pointer_set(regs, utask->vaddr + auprobe->insn_size);
>
> @@ -102,6 +103,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
>  {
>  	struct uprobe_task *utask = current->utask;
>
> +	current->thread.bad_cause = utask->autask.saved_cause;
>  	/*
>  	 * Task has received a fatal signal, so reset back to probbed
>  	 * address.
>

Hi Oleg and Srikar,

Could you please review this patch, thank you.

Thanks,
Tiezhu
Oleg Nesterov April 24, 2023, 3:28 p.m. UTC | #2
On 04/24, Tiezhu Yang wrote:
>
> >diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
> >index c976a21..194f166 100644
> >--- a/arch/riscv/kernel/probes/uprobes.c
> >+++ b/arch/riscv/kernel/probes/uprobes.c
> >@@ -67,6 +67,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
> > 	struct uprobe_task *utask = current->utask;
> >
> > 	WARN_ON_ONCE(current->thread.bad_cause != UPROBE_TRAP_NR);
> >+	current->thread.bad_cause = utask->autask.saved_cause;
> >
> > 	instruction_pointer_set(regs, utask->vaddr + auprobe->insn_size);
> >
> >@@ -102,6 +103,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
> > {
> > 	struct uprobe_task *utask = current->utask;
> >
> >+	current->thread.bad_cause = utask->autask.saved_cause;
> > 	/*
> > 	 * Task has received a fatal signal, so reset back to probbed
> > 	 * address.
> >

Acked-by: Oleg Nesterov <oleg@redhat.com>
Guo Ren May 5, 2023, 10:01 a.m. UTC | #3
Thx for fixup.

Reviewed-by: Guo Ren <guoren@kernel.org>

On Sun, Apr 23, 2023 at 9:42 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> thread.bad_cause is saved in arch_uprobe_pre_xol(), it should be restored
> in arch_uprobe_{post,abort}_xol() accordingly, otherwise the save operation
> is meaningless, this change is similar with x86 and powerpc.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/riscv/kernel/probes/uprobes.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
> index c976a21..194f166 100644
> --- a/arch/riscv/kernel/probes/uprobes.c
> +++ b/arch/riscv/kernel/probes/uprobes.c
> @@ -67,6 +67,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
>         struct uprobe_task *utask = current->utask;
>
>         WARN_ON_ONCE(current->thread.bad_cause != UPROBE_TRAP_NR);
> +       current->thread.bad_cause = utask->autask.saved_cause;
>
>         instruction_pointer_set(regs, utask->vaddr + auprobe->insn_size);
>
> @@ -102,6 +103,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
>  {
>         struct uprobe_task *utask = current->utask;
>
> +       current->thread.bad_cause = utask->autask.saved_cause;
>         /*
>          * Task has received a fatal signal, so reset back to probbed
>          * address.
> --
> 2.1.0
>
Tiezhu Yang June 15, 2023, 3:30 p.m. UTC | #4
ping, what is the status of this patch which has been received Acked-by
and Reviewed-by:

https://lore.kernel.org/linux-riscv/1682214146-3756-1-git-send-email-yangtiezhu@loongson.cn/

Thanks,
Tiezhu
Palmer Dabbelt June 20, 2023, 7:27 p.m. UTC | #5
On Sun, 23 Apr 2023 09:42:26 +0800, Tiezhu Yang wrote:
> thread.bad_cause is saved in arch_uprobe_pre_xol(), it should be restored
> in arch_uprobe_{post,abort}_xol() accordingly, otherwise the save operation
> is meaningless, this change is similar with x86 and powerpc.
> 
> 

Applied, thanks!

[1/1] riscv: uprobes: Restore thread.bad_cause
      https://git.kernel.org/palmer/c/58b1294dd1d6

Best regards,
patchwork-bot+linux-riscv@kernel.org June 20, 2023, 7:40 p.m. UTC | #6
Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Sun, 23 Apr 2023 09:42:26 +0800 you wrote:
> thread.bad_cause is saved in arch_uprobe_pre_xol(), it should be restored
> in arch_uprobe_{post,abort}_xol() accordingly, otherwise the save operation
> is meaningless, this change is similar with x86 and powerpc.
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/riscv/kernel/probes/uprobes.c | 2 ++
>  1 file changed, 2 insertions(+)

Here is the summary with links:
  - riscv: uprobes: Restore thread.bad_cause
    https://git.kernel.org/riscv/c/58b1294dd1d6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
index c976a21..194f166 100644
--- a/arch/riscv/kernel/probes/uprobes.c
+++ b/arch/riscv/kernel/probes/uprobes.c
@@ -67,6 +67,7 @@  int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
 	struct uprobe_task *utask = current->utask;
 
 	WARN_ON_ONCE(current->thread.bad_cause != UPROBE_TRAP_NR);
+	current->thread.bad_cause = utask->autask.saved_cause;
 
 	instruction_pointer_set(regs, utask->vaddr + auprobe->insn_size);
 
@@ -102,6 +103,7 @@  void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
 {
 	struct uprobe_task *utask = current->utask;
 
+	current->thread.bad_cause = utask->autask.saved_cause;
 	/*
 	 * Task has received a fatal signal, so reset back to probbed
 	 * address.