Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3196112ybb; Mon, 30 Mar 2020 23:45:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt62RFHARwhNoOkCmtetPaj4xekv6v21rumSP+tqpPkd/afBc91OhYFSFTfjPx9pPLOxZsB X-Received: by 2002:a9d:12d:: with SMTP id 42mr2067615otu.2.1585637131015; Mon, 30 Mar 2020 23:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585637131; cv=none; d=google.com; s=arc-20160816; b=O9wXMYUnJvoe3GyoWoc6DTcioURT6jkCSvbwvJM8yeut4ETSFg7ukc+P6HBf+KSt5w 82sJIqlwPNVgX18btDZdw9RtfKl6BulT/HX+/9gyIuCx1nonMZcvTSGqWqpwc+8C7Qy5 K/BZmMhnmJRp7mdB1aiwoiqgSMvypjSinBod6W29SMaaE1yb00kjNunrprLFIIzHeOXK R3duL/5nb4XW4Et0d4shHo+TqXAvtGDosiEx1WtoD8wGMM97luUPc4riOrmJblkkseug 93J/cO9PW0y/22T0Hf3/ltRP8rmNDzhtVpZ/WKrkyJ4q/z+14jfGO2tEscMbqYPmNQuK zY+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date; bh=tvo77HN8+z2LkD6IpErDqYBB3CKnaxMGQuIDEtzTr+w=; b=x1/Ulf5xEyU7K3G/SzreqaT+PJ9NfHr+mq9Ars53OPNV/pcWh7W+xV8bJHhW3W/sWI oiO2HZq7luWxt94lH8QNPAwgCNyOGZHQZHotWcAmjcEj/nR9tyY/yJLJSg3vecVt13u0 CbYD33YgE2O64Kkhq7zaQleN44857Z0hqRcLG/B6CJV6CVo2/+GshotchqYoB8A5efQ5 nanPwQbfzc5Sc8Ieojx+5nN6/nb8TEaoVfsDD8218Kht71qjauqiMUMannO0i5Qxlctc KQlcMpl27CcnxNXVmL/5qPrwRFxp56qk4wpTjWiOkUPujMuh5c0cJ056BeiADRJ1EaFi 2wJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si7560969otf.299.2020.03.30.23.45.18; Mon, 30 Mar 2020 23:45:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727018AbgCaGoi convert rfc822-to-8bit (ORCPT + 99 others); Tue, 31 Mar 2020 02:44:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39698 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgCaGoi (ORCPT ); Tue, 31 Mar 2020 02:44:38 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02V6YOFW023300 for ; Tue, 31 Mar 2020 02:44:37 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 301yffd0j4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 31 Mar 2020 02:44:37 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 31 Mar 2020 07:44:33 +0100 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 31 Mar 2020 07:44:29 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02V6hQID50856256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Mar 2020 06:43:26 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B552A405F; Tue, 31 Mar 2020 06:44:30 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E18DA4060; Tue, 31 Mar 2020 06:44:29 +0000 (GMT) Received: from localhost (unknown [9.85.74.140]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 31 Mar 2020 06:44:29 +0000 (GMT) Date: Tue, 31 Mar 2020 12:14:27 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH 10/12] powerpc/entry32: Blacklist exception entry points for kprobe. To: Benjamin Herrenschmidt , Christophe Leroy , Michael Ellerman , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <1585588031.jvow7mwq4x.naveen@linux.ibm.com> <7f367f35-1bb8-bbb6-f399-8e911f76e043@c-s.fr> <83053ddf-9ba6-d551-6711-890c3f3810b5@c-s.fr> <1585635379.0xixuk2jdc.naveen@linux.ibm.com> In-Reply-To: MIME-Version: 1.0 User-Agent: astroid/v0.15-13-gb675b421 (https://github.com/astroidmail/astroid) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 20033106-0028-0000-0000-000003EF2CA4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20033106-0029-0000-0000-000024B4AE22 Message-Id: <1585637023.fay3842pux.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-03-31_02:2020-03-30,2020-03-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 mlxscore=0 phishscore=0 clxscore=1015 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003310048 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy wrote: > > > Le 31/03/2020 à 08:17, Naveen N. Rao a écrit : >> Christophe Leroy wrote: >>> >>> >>> Le 30/03/2020 à 20:33, Christophe Leroy a écrit : >>>> >>>> >>>> Le 30/03/2020 à 19:08, Naveen N. Rao a écrit : >>>>> Christophe Leroy wrote: >>>>>> kprobe does not handle events happening in real mode. >>>>>> >>>>>> As exception entry points are running with MMU disabled, >>>>>> blacklist them. >>>>>> >>>>>> Signed-off-by: Christophe Leroy >>>>>> --- >>>>>>  arch/powerpc/kernel/entry_32.S | 7 +++++++ >>>>>>  1 file changed, 7 insertions(+) >>>>>> >>>>>> diff --git a/arch/powerpc/kernel/entry_32.S >>>>>> b/arch/powerpc/kernel/entry_32.S >>>>>> index 94f78c03cb79..9a1a45d6038a 100644 >>>>>> --- a/arch/powerpc/kernel/entry_32.S >>>>>> +++ b/arch/powerpc/kernel/entry_32.S >>>>>> @@ -51,6 +51,7 @@ mcheck_transfer_to_handler: >>>>>>      mfspr    r0,SPRN_DSRR1 >>>>>>      stw    r0,_DSRR1(r11) >>>>>>      /* fall through */ >>>>>> +_ASM_NOKPROBE_SYMBOL(mcheck_transfer_to_handler) >>>>>> >>>>>>      .globl    debug_transfer_to_handler >>>>>>  debug_transfer_to_handler: >>>>>> @@ -59,6 +60,7 @@ debug_transfer_to_handler: >>>>>>      mfspr    r0,SPRN_CSRR1 >>>>>>      stw    r0,_CSRR1(r11) >>>>>>      /* fall through */ >>>>>> +_ASM_NOKPROBE_SYMBOL(debug_transfer_to_handler) >>>>>> >>>>>>      .globl    crit_transfer_to_handler >>>>>>  crit_transfer_to_handler: >>>>>> @@ -94,6 +96,7 @@ crit_transfer_to_handler: >>>>>>      rlwinm    r0,r1,0,0,(31 - THREAD_SHIFT) >>>>>>      stw    r0,KSP_LIMIT(r8) >>>>>>      /* fall through */ >>>>>> +_ASM_NOKPROBE_SYMBOL(crit_transfer_to_handler) >>>>>>  #endif >>>>>> >>>>>>  #ifdef CONFIG_40x >>>>>> @@ -115,6 +118,7 @@ crit_transfer_to_handler: >>>>>>      rlwinm    r0,r1,0,0,(31 - THREAD_SHIFT) >>>>>>      stw    r0,KSP_LIMIT(r8) >>>>>>      /* fall through */ >>>>>> +_ASM_NOKPROBE_SYMBOL(crit_transfer_to_handler) >>>>>>  #endif >>>>>> >>>>>>  /* >>>>>> @@ -127,6 +131,7 @@ crit_transfer_to_handler: >>>>>>      .globl    transfer_to_handler_full >>>>>>  transfer_to_handler_full: >>>>>>      SAVE_NVGPRS(r11) >>>>>> +_ASM_NOKPROBE_SYMBOL(transfer_to_handler_full) >>>>>>      /* fall through */ >>>>>> >>>>>>      .globl    transfer_to_handler >>>>>> @@ -286,6 +291,8 @@ reenable_mmu: >>>>>>      lwz    r2, GPR2(r11) >>>>>>      b    fast_exception_return >>>>>>  #endif >>>>>> +_ASM_NOKPROBE_SYMBOL(transfer_to_handler) >>>>>> +_ASM_NOKPROBE_SYMBOL(transfer_to_handler_cont) >>>>> >>>>> These are added after 'reenable_mmu', which is itself not >>>>> blacklisted. Is that intentional? >>>> >>>> Yes I put it as the complete end of the entry part, ie just before >>>> stack_ovf which is a function by itself. >>>> >>>> Note that reenable_mmu is inside an #ifdef CONFIG_TRACE_IRQFLAGS. >>>> >>>> I'm not completely sure where to put the _ASM_NOKPROBE_SYMBOL()s, >>>> that's the reason why I put it close to the symbol itself in my first >>>> series. >>>> >>>> Could you have a look at the code and tell me what looks the most >>>> appropriate as a location to you ? >>>> >>>> https://elixir.bootlin.com/linux/v5.6/source/arch/powerpc/kernel/entry_32.S#L230 >>> >>> >>> Ok, thinking about it once more, I guess we have a problem as >>> everything after that reenable_mmu will be visible. >> >> I see that we reach reenable_mmu through a 'rfi' with MSR_KERNEL, which >> seems safe to me. So, I figured it can be probed without issues? > > Yes it can. And that's the reason why I didn't blacklist it. However the > 4: and 7: which are after reenable_mmu are called from earlier, at a > time we are still in real mode. So I need to do something about that I > guess. Ah yes, good catch. Makes sense to move 'reenable_mmu' after all. Thanks, Naveen