* [PATCH] MIPS: uprobes: Restore thread.trap_nr
@ 2023-04-23 1:38 Tiezhu Yang
2023-04-23 3:08 ` Bagas Sanjaya
2023-04-24 11:32 ` Thomas Bogendoerfer
0 siblings, 2 replies; 5+ messages in thread
From: Tiezhu Yang @ 2023-04-23 1:38 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel, loongson-kernel
thread.trap_nr is saved in arch_uprobe_pre_xol(), it should be restored
in arch_uprobe_{post,abort}_xol() accordingly, actually it was only done
in the post function, just do it in the abort function too, this change
is similar with x86 and powerpc.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/mips/kernel/uprobes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/kernel/uprobes.c b/arch/mips/kernel/uprobes.c
index 6b630ed..401b148 100644
--- a/arch/mips/kernel/uprobes.c
+++ b/arch/mips/kernel/uprobes.c
@@ -191,6 +191,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *aup,
{
struct uprobe_task *utask = current->utask;
+ current->thread.trap_nr = utask->autask.saved_trap_nr;
instruction_pointer_set(regs, utask->vaddr);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] MIPS: uprobes: Restore thread.trap_nr 2023-04-23 1:38 [PATCH] MIPS: uprobes: Restore thread.trap_nr Tiezhu Yang @ 2023-04-23 3:08 ` Bagas Sanjaya 2023-04-23 10:39 ` Tiezhu Yang 2023-04-24 11:32 ` Thomas Bogendoerfer 1 sibling, 1 reply; 5+ messages in thread From: Bagas Sanjaya @ 2023-04-23 3:08 UTC (permalink / raw) To: Tiezhu Yang, Thomas Bogendoerfer Cc: linux-mips, linux-kernel, loongson-kernel [-- Attachment #1: Type: text/plain, Size: 582 bytes --] On Sun, Apr 23, 2023 at 09:38:03AM +0800, Tiezhu Yang wrote: > thread.trap_nr is saved in arch_uprobe_pre_xol(), it should be restored > in arch_uprobe_{post,abort}_xol() accordingly, actually it was only done > in the post function, just do it in the abort function too, this change > is similar with x86 and powerpc. I'm confused (please fix up grammar, spelling, and punctuation). Can you explain why thread.trap_nr should be restored somewhere else? Also, what x86/powerpc changes as reference? Thanks. -- An old man doll... just what I always wanted! - Clara [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: uprobes: Restore thread.trap_nr 2023-04-23 3:08 ` Bagas Sanjaya @ 2023-04-23 10:39 ` Tiezhu Yang 2023-04-24 11:07 ` Oleg Nesterov 0 siblings, 1 reply; 5+ messages in thread From: Tiezhu Yang @ 2023-04-23 10:39 UTC (permalink / raw) To: Bagas Sanjaya, Thomas Bogendoerfer Cc: linux-mips, linux-kernel, loongson-kernel, Oleg Nesterov, Srikar Dronamraju Cc: Oleg Nesterov <oleg@redhat.com> Srikar Dronamraju <srikar@linux.vnet.ibm.com> On 04/23/2023 11:08 AM, Bagas Sanjaya wrote: > On Sun, Apr 23, 2023 at 09:38:03AM +0800, Tiezhu Yang wrote: >> thread.trap_nr is saved in arch_uprobe_pre_xol(), it should be restored >> in arch_uprobe_{post,abort}_xol() accordingly, actually it was only done >> in the post function, just do it in the abort function too, this change >> is similar with x86 and powerpc. > > I'm confused (please fix up grammar, spelling, and punctuation). Can you > explain why thread.trap_nr should be restored somewhere else? Also, what > x86/powerpc changes as reference? > Here is the related first commit for x86 in 2012: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0326f5a94dde When xol insn itself triggers the signal, restart the original insn, in this case, UTASK_SSTEP_TRAPPED is set [1], it does *abort_xol() instead of *post_xol() [2], then should do the restore operations. Maybe Oleg and Srikar could give more detailed backgrounds, thank you. https://lore.kernel.org/lkml/1682213883-3654-1-git-send-email-yangtiezhu@loongson.cn/ [1] https://elixir.bootlin.com/linux/latest/source/kernel/events/uprobes.c#L1980 [2] https://elixir.bootlin.com/linux/latest/source/kernel/events/uprobes.c#L2268 Thanks, Tiezhu ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: uprobes: Restore thread.trap_nr 2023-04-23 10:39 ` Tiezhu Yang @ 2023-04-24 11:07 ` Oleg Nesterov 0 siblings, 0 replies; 5+ messages in thread From: Oleg Nesterov @ 2023-04-24 11:07 UTC (permalink / raw) To: Tiezhu Yang Cc: Bagas Sanjaya, Thomas Bogendoerfer, linux-mips, linux-kernel, loongson-kernel, Srikar Dronamraju On 04/23, Tiezhu Yang wrote: > > Cc: > Oleg Nesterov <oleg@redhat.com> > Srikar Dronamraju <srikar@linux.vnet.ibm.com> > > On 04/23/2023 11:08 AM, Bagas Sanjaya wrote: > >On Sun, Apr 23, 2023 at 09:38:03AM +0800, Tiezhu Yang wrote: > >>thread.trap_nr is saved in arch_uprobe_pre_xol(), it should be restored > >>in arch_uprobe_{post,abort}_xol() accordingly, actually it was only done > >>in the post function, just do it in the abort function too, this change > >>is similar with x86 and powerpc. > > > >I'm confused (please fix up grammar, spelling, and punctuation). Can you > >explain why thread.trap_nr should be restored somewhere else? Also, what > >x86/powerpc changes as reference? > > > > Here is the related first commit for x86 in 2012: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0326f5a94dde > > When xol insn itself triggers the signal, restart the original insn, > in this case, UTASK_SSTEP_TRAPPED is set [1], it does *abort_xol() > instead of *post_xol() [2], then should do the restore operations. Yes... for example, if the uprobed task was killed abort() should restore the state and (in particular) change ->trap_nr from UPROBE_TRAP_NR back to ->saved_trap_nr. So the patch looks fine to me. Oleg. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: uprobes: Restore thread.trap_nr 2023-04-23 1:38 [PATCH] MIPS: uprobes: Restore thread.trap_nr Tiezhu Yang 2023-04-23 3:08 ` Bagas Sanjaya @ 2023-04-24 11:32 ` Thomas Bogendoerfer 1 sibling, 0 replies; 5+ messages in thread From: Thomas Bogendoerfer @ 2023-04-24 11:32 UTC (permalink / raw) To: Tiezhu Yang; +Cc: linux-mips, linux-kernel, loongson-kernel On Sun, Apr 23, 2023 at 09:38:03AM +0800, Tiezhu Yang wrote: > thread.trap_nr is saved in arch_uprobe_pre_xol(), it should be restored > in arch_uprobe_{post,abort}_xol() accordingly, actually it was only done > in the post function, just do it in the abort function too, this change > is similar with x86 and powerpc. > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > arch/mips/kernel/uprobes.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/mips/kernel/uprobes.c b/arch/mips/kernel/uprobes.c > index 6b630ed..401b148 100644 > --- a/arch/mips/kernel/uprobes.c > +++ b/arch/mips/kernel/uprobes.c > @@ -191,6 +191,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *aup, > { > struct uprobe_task *utask = current->utask; > > + current->thread.trap_nr = utask->autask.saved_trap_nr; > instruction_pointer_set(regs, utask->vaddr); > } > > -- > 2.1.0 applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-24 11:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-04-23 1:38 [PATCH] MIPS: uprobes: Restore thread.trap_nr Tiezhu Yang 2023-04-23 3:08 ` Bagas Sanjaya 2023-04-23 10:39 ` Tiezhu Yang 2023-04-24 11:07 ` Oleg Nesterov 2023-04-24 11:32 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox