Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3186807ybb; Mon, 30 Mar 2020 23:28:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuvrXWuiWJng6MJ6elhH95Cit7SI6EvLMKVtRZqZDzTxPSvKvW6In5gO9suES6zCIAM71Xi X-Received: by 2002:aca:aa55:: with SMTP id t82mr1078068oie.147.1585636119583; Mon, 30 Mar 2020 23:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585636119; cv=none; d=google.com; s=arc-20160816; b=e5p8CSXmo8LkIaibK4oJP6tsN5jHRGEZHcEoBLU8zya5R/bTIuYPKjW2pMPO/BFeSb tIRaGtgMLVJGFwacrf6VGtCBQC5EXoXYTbpifcB/OyDif17yujTZ1zlKMDWgF8OG5t44 NQfaWoLvy2RitCtvr9t5Un/EaqwC6TNUK8t8xjXPb3jljDRCWET+FhyUI7DSDi7JfcO1 uCyURuiq3JdqxcoopaSVZfxWbDtBC6exwY8AZLmBgs3VDFrTJfJeCs1YuB+xeRqgcvjy 5NCZU9yDSCqpzbIkMOvkO7AeY82Xb5ur0Rg3MeT48/29VFMOh/w3GJNWHlBq2kB/SNwB ki0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=QHEbKBEkArQVVuyJdKh0gGs4/CIEJ9/kI47jhRFbnMU=; b=mJGjczw3Z44Rq5SzHq/Z5S90OkBsRjNRjD/oOE9H9p/mis8545YcqsYP+3WOgIsLr+ WhCBIkDa4Uopwn932ocqgW+Q8YZQ7QAuQs/S0AlgGcGfPLED/VLZeuMhFEqWi6dtJ1UH tSTjJdAcXQt+4K8xl0U7ks8u+YHj4HPMBu9jmzDFtd1mkWj8jLpiyq6G8/mtnFtvDD1l +K/cERgPhCmfnJ+T8C6NtL6H5ls7w7WWGRZqG+b40fKIs9isIAhLqux0NpI4cK8NAGdw wUT9G/JYcxR26XM+8rPYbWQPnwxcFNGanvBlUnDeDgOgUxn5FGs2FWOiHuuU2SU6pbPZ XPwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=kI5mOwjm; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w129si6166339oia.232.2020.03.30.23.28.26; Mon, 30 Mar 2020 23:28:39 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=kI5mOwjm; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbgCaG2I (ORCPT + 99 others); Tue, 31 Mar 2020 02:28:08 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:12639 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgCaG2I (ORCPT ); Tue, 31 Mar 2020 02:28:08 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48rzsd3MLMz9tw25; Tue, 31 Mar 2020 08:28:05 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=kI5mOwjm; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Y72CvPfE2aJI; Tue, 31 Mar 2020 08:28:05 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48rzsd2GPWz9v0KF; Tue, 31 Mar 2020 08:28:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1585636085; bh=QHEbKBEkArQVVuyJdKh0gGs4/CIEJ9/kI47jhRFbnMU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=kI5mOwjmMfai0Zz39DOOAus2hYlZKmozithcxAVsFm7RCYbaCXdjcqhzrUgXC8azV 6mgB96i8R3iIc3YAmZGjhTjrNroLQuA9p8kR0CF09eyjcFf4YATGnI7RDNODZlF3Vf pzvCUASD2lnHe/iR+i0tQWA4DVeybWiNzlsSNFO0= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 04FCE8B784; Tue, 31 Mar 2020 08:28:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id x4NtmrzTKc-4; Tue, 31 Mar 2020 08:28:05 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 337088B774; Tue, 31 Mar 2020 08:28:04 +0200 (CEST) Subject: Re: [PATCH 10/12] powerpc/entry32: Blacklist exception entry points for kprobe. To: "Naveen N. Rao" , Benjamin Herrenschmidt , 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> From: Christophe Leroy Message-ID: Date: Tue, 31 Mar 2020 08:28:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <1585635379.0xixuk2jdc.naveen@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Christophe