Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4204340pxt; Tue, 10 Aug 2021 23:50:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJiu5KEPI3e9v6pG3RsZSQUE3VZR88u2b5mhiXDEgN9sUKpT+gePVHEg4vOz27CcNPmyNU X-Received: by 2002:a05:6e02:1c08:: with SMTP id l8mr4972ilh.134.1628664615440; Tue, 10 Aug 2021 23:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628664615; cv=none; d=google.com; s=arc-20160816; b=yzYZXgZk7NJbjGlo+cEdObbbpcC+sRrne3vImyvoplrfmr6s+BHibmJBXyzu3MPVcf 8AS4pfdolwNegjJg/WqU6MZqjCdj/QmVmVevff2pPnmVTlV6IatWGHS767ePUtDoblGp f1LnIFDbCMwQ52vMgpS+PReo7sliMO7OwRPI8cfN2i8GqIRxIpugSfoRFUE5ocwQpysb xgqE2Ccr/o/Esd6IePSG3aj+mjsKp3tkLk+ZhLCnsrIWUfvMjMs4tvGPcLHja6bT1svg u7Ka2Hv43uWI2hXYn6Gil5RjI9Fp0ONImQwG8ogOFjNtc0MLT159jVmgphpeWDj5D9tp iNaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=5unGUTVOVyYBU6F+EknR4GGAGdXZ6evnMWdYSUACB1c=; b=q+WQ3a61J2TPiNtXIbvVvB4TkOq580H8UZd2hFkTf0X97W0BTSaei9XfwGtMe4TYtF TBOkwcXEvUHPGpOfkdIVF9E/kra1OVp5ZT1GIwZ8B9MhDFZrE3xuBdPt23sitzyDJNYO 9XItUNRSCP/aYQdsGhOEN9Gh4UuWJwPWsDp8RQgSJRKNQ+ZEXSzw9tMWBYuncF2VfklE rzGht7ERaEKACN5FhZIB4yEEEDjaJo9hKCgjSj+lPCAbBdPrF4EkNQFAJf57aw3igWIY rEVJStIGLjas/Zs4c7t/U2Q0PLFJNWkPY2eE/e8RN56cGmx8VfSCn8miFOmxmbNO81Bc 0ckQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si2655576ilq.142.2021.08.10.23.50.02; Tue, 10 Aug 2021 23:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235391AbhHKGs5 (ORCPT + 99 others); Wed, 11 Aug 2021 02:48:57 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:8397 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235337AbhHKGss (ORCPT ); Wed, 11 Aug 2021 02:48:48 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Gl0fd4DyVz86Hg; Wed, 11 Aug 2021 14:44:25 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 11 Aug 2021 14:48:22 +0800 Received: from [10.67.109.184] (10.67.109.184) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 11 Aug 2021 14:48:22 +0800 Subject: Re: [PATCH v2] powerpc/kprobes: Fix kprobe Oops happens in booke To: Christophe Leroy CC: , , , , , , , , , , References: <20210809023658.218915-1-pulehui@huawei.com> <9c6cdb3f-37ac-9a8c-2c75-3a939ed76ab4@csgroup.eu> From: Pu Lehui Message-ID: Date: Wed, 11 Aug 2021 14:48:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <9c6cdb3f-37ac-9a8c-2c75-3a939ed76ab4@csgroup.eu> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.109.184] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/11 13:31, Christophe Leroy wrote: > > > Le 11/08/2021 à 04:53, Pu Lehui a écrit : >> Ping, serious problem here. All booke ppc will trigger Oops when >> perform kprobes related operations. > > As far as I can see it is in the fixes branch: > https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/log/?h=fixes > > Thanks. >> >> On 2021/8/9 10:36, Pu Lehui wrote: >>> When using kprobe on powerpc booke series processor, Oops happens >>> as show bellow: >>> >>> / # echo "p:myprobe do_nanosleep" > >>> /sys/kernel/debug/tracing/kprobe_events >>> / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable >>> / # sleep 1 >>> [   50.076730] Oops: Exception in kernel mode, sig: 5 [#1] >>> [   50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 >>> [   50.077221] Modules linked in: >>> [   50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted >>> 5.14.0-rc4-00022-g251a1524293d #21 >>> [   50.077887] NIP:  c0b9c4e0 LR: c00ebecc CTR: 00000000 >>> [   50.078067] REGS: c3883de0 TRAP: 0700   Not tainted >>> (5.14.0-rc4-00022-g251a1524293d) >>> [   50.078349] MSR:  00029000   CR: 24000228  XER: 20000000 >>> [   50.078675] >>> [   50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 00000001 >>> 00000000 c3883ecc 00000001 >>> [   50.078675] GPR08: c100598c c00ea250 00000004 00000000 24000222 >>> 102490c2 bff4180c 101e60d4 >>> [   50.078675] GPR16: 00000000 102454ac 00000040 10240000 10241100 >>> 102410f8 10240000 00500000 >>> [   50.078675] GPR24: 00000002 00000000 c3883ea0 00000001 00000000 >>> 0000c350 3b9b8d50 00000000 >>> [   50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190 >>> [   50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0 >>> [   50.080638] Call Trace: >>> [   50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 >>> (unreliable) >>> [   50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110 >>> [   50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28 >>> [   50.081541] --- interrupt: c00 at 0x100a4d08 >>> [   50.081749] NIP:  100a4d08 LR: 101b5234 CTR: 00000003 >>> [   50.081931] REGS: c3883f50 TRAP: 0c00   Not tainted >>> (5.14.0-rc4-00022-g251a1524293d) >>> [   50.082183] MSR:  0002f902   CR: 24000222  XER: >>> 00000000 >>> [   50.082457] >>> [   50.082457] GPR00: 000000a2 bf980040 1024b4d0 bf980084 bf980084 >>> 64000000 00555345 fefefeff >>> [   50.082457] GPR08: 7f7f7f7f 101e0000 00000069 00000003 28000422 >>> 102490c2 bff4180c 101e60d4 >>> [   50.082457] GPR16: 00000000 102454ac 00000040 10240000 10241100 >>> 102410f8 10240000 00500000 >>> [   50.082457] GPR24: 00000002 bf9803f4 10240000 00000000 00000000 >>> 100039e0 00000000 102444e8 >>> [   50.083789] NIP [100a4d08] 0x100a4d08 >>> [   50.083917] LR [101b5234] 0x101b5234 >>> [   50.084042] --- interrupt: c00 >>> [   50.084238] Instruction dump: >>> [   50.084483] 4bfffc40 60000000 60000000 60000000 9421fff0 39400402 >>> 914200c0 38210010 >>> [   50.084841] 4bfffc20 00000000 00000000 00000000 <7fe00008> >>> 7c0802a6 7c892378 93c10048 >>> [   50.085487] ---[ end trace f6fffe98e2fa8f3e ]--- >>> [   50.085678] >>> Trace/breakpoint trap >>> >>> There is no real mode for booke arch and the MMU translation is >>> always on. The corresponding MSR_IS/MSR_DS bit in booke is used >>> to switch the address space, but not for real mode judgment. >>> >>> Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in >>> real mode") >>> Signed-off-by: Pu Lehui >>> --- >>> v1->v2: >>> - use IS_ENABLED(CONFIG_BOOKE) as suggested by Michael Ellerman and >>>    Christophe Leroy >>> - update Oops log to make problem clear >>> >>>   arch/powerpc/kernel/kprobes.c | 3 ++- >>>   1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/arch/powerpc/kernel/kprobes.c >>> b/arch/powerpc/kernel/kprobes.c >>> index cbc28d1a2e1b..7a7cd6bda53e 100644 >>> --- a/arch/powerpc/kernel/kprobes.c >>> +++ b/arch/powerpc/kernel/kprobes.c >>> @@ -292,7 +292,8 @@ int kprobe_handler(struct pt_regs *regs) >>>       if (user_mode(regs)) >>>           return 0; >>> -    if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR)) >>> +    if (!IS_ENABLED(CONFIG_BOOKE) && >>> +        (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR))) >>>           return 0; >>>       /* >>> > .