Message ID | 1682213883-3654-1-git-send-email-yangtiezhu@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1984198vqo; Sat, 22 Apr 2023 19:16:35 -0700 (PDT) X-Google-Smtp-Source: AKy350bjtqpO6HeRXEiNBvbZx0lsJvxKUKsd5ncryEBRk42BVF0i/CRGln5+NmpDDZnxE5E0NBPg X-Received: by 2002:a05:6a20:a111:b0:f3:ae06:c4e6 with SMTP id q17-20020a056a20a11100b000f3ae06c4e6mr1115264pzk.6.1682216194974; Sat, 22 Apr 2023 19:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682216194; cv=none; d=google.com; s=arc-20160816; b=nGjlDCQ113jpmOvgfS4ZV/0qUeuFIljFZSSwsLv4eOWTI8nEzFa/uuhOcX4CLwu5wN Vijx0KMeDpcHFenzMDuENNry3DWZq+5F9HktCEcBrwwEiblgw2hxWFMqniSc6aU/Gcum R2L9GE3jxJOrFXIQY2Lk4t48nx/ejTDEIvgKsXIPij7njPRVU0pDNvCwFr6nJYKEjzAG RQVLw8jLjQPmKopkxHuPymH1M7riX9TAgnykGTtwGZBOq2DGAZk5hhNqlVnoDrNveaI9 UWlw5L4h1psWZMJrmCX81inKsunvF9MPCACBPu5IJgNQxdnIEADdKH/8LMYRI14hGF75 Ikxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=w1R2BSDv5osg7Y/Ur/OR2/TikdQA/lrBYRFvWzbKw98=; b=rvs2akRCjSLh4mEOGJ+ttchIACaUVt9opJZ9y3p8lsw6AA6zj+NVsZ6fcK52K0nrSs oQc2RuFLN+DR9FyCtSxEmcR0FYv9zkxiqHJ2LvcKX5ZuNaRW+RyAKOZTww5Pz8cIZzqc 3NP7h04DAxipXQwFNOj5E5hyTPAP8xqbFc8A7fwr0JG2RTDLehlnckWduPO5nqYmrD/o xoQLjsy2lR37uGKo33j57+CLGNCyEAZMWs1TJ/cQ3SFxfeJo7ywI7LX49iwd1TR8etZC XUwtVLEriGKjT3crVvydPDsD4L/MoEd0yicsjHWlvKwiGBjcuEns0J9sa9cRg9Vc45RI /L1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r80-20020a632b53000000b00524cf947602si6022045pgr.686.2023.04.22.19.16.21; Sat, 22 Apr 2023 19:16:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbjDWBiM (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Sat, 22 Apr 2023 21:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbjDWBiL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 22 Apr 2023 21:38:11 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B665A10FD; Sat, 22 Apr 2023 18:38:08 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxYU_8i0RkotEgAA--.51512S3; Sun, 23 Apr 2023 09:38:05 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxsrT8i0RkiPk1AA--.7506S2; Sun, 23 Apr 2023 09:38:04 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH] MIPS: uprobes: Restore thread.trap_nr Date: Sun, 23 Apr 2023 09:38:03 +0800 Message-Id: <1682213883-3654-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8DxsrT8i0RkiPk1AA--.7506S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvdXoWrZw13uw1rWw1UtFW3tFy8AFb_yoW3trcEkw 17Za4vkr15Jr4UZ34Uu3y3WFZxX34rGFn3A3W29FWUKw4Yyr1UCFs8GF98AF4DG3yqyrZ0 yrn8Xrn8ua129jkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY U7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3w AFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK 6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j6F4UM28EF7 xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r4UJwAS0I0E 0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzV Aqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S 6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026x CaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_ JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r 1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_ Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8Jb IYCTnIWIevJa73UjIFyTuYvjxUwmhFDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763931528655563102?= X-GMAIL-MSGID: =?utf-8?q?1763931528655563102?= |
Series |
MIPS: uprobes: Restore thread.trap_nr
|
|
Commit Message
Tiezhu Yang
April 23, 2023, 1:38 a.m. UTC
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(+)
Comments
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.
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
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.
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.
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); }