Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1366744ybb; Sun, 29 Mar 2020 02:52:48 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsGxHhMK7dUAXY03c+wm1hfqarldQBoJLNgULpqEavokj5rK3sNMuy88kY8pwQVwqIWUdoN X-Received: by 2002:a9d:228:: with SMTP id 37mr5635845otb.52.1585475568340; Sun, 29 Mar 2020 02:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585475568; cv=none; d=google.com; s=arc-20160816; b=dhUtzlEvRuIoDuFypyYHDM8qdzntSM6cBfHGglCQqTorbb0D7ne3qtoKLpJZFHAwQc Jk2vOcb4h5CxCdhhAT9Druj7TFGO+/+rtXgW9C8NPqoNrW4NjMHOiePWnBLQTdyT2lKe vdu0hhx6SmSt7j8PwKpydleJJUjeO9z42h/Xb6ey4yf9Ya16Hg1TQ8juM1UKjGMIptyc 7o/iJg/1yvJQ5QErvE+5T2vM2AKktOlbPuJoy9/ARqXPifR5oLUVTXaOpkrOTWgJQpZ9 ovULgxXLG1LxLTxtSsASJxxHbAz8TsR3L+d+X1FbR6xZPz/3daIRWYGPNY9EOwXGRdbI jNzw== 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=QMHt+CzUvu9PdrsCMW23L7vVLi66IzMH33dqHOLEvp0=; b=W/HAlg5FGd/9ZF+NU8cXikO3UpvJQg3LSBemSnB9arMtdgfbw4y8ahzr3ptnQ4WcuX UQdSNquYB124gcnRVj3TUPpMHghXl/BEnLDDSxaxh48G/ZPEqqqitfb1LD5sLe8BxuHm qLxwPtJaSPhEpj9+OC/FQd7KkXYHNEM4Uy0Vdh7KrsJN5GdWr+WXAc2EDE25TY2+u6G4 sN5wgN39rEuE93WF16Tht3BDkMd6mfFeTtut9t76HjQNgf+AMWh6HjPfopJ6ZOENC+rB HnWmyApPjkY+du289veNi7iCAuWd7hPBP/7BW7/4TrR8rMyCSRT5vOBGLn+egl3litzx hj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=wkzIp4Sl; 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 k7si3056074otp.258.2020.03.29.02.52.35; Sun, 29 Mar 2020 02:52:48 -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=wkzIp4Sl; 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 S1727958AbgC2JsX (ORCPT + 99 others); Sun, 29 Mar 2020 05:48:23 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:57842 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbgC2JsX (ORCPT ); Sun, 29 Mar 2020 05:48:23 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48qrPZ20Z7z9tyY2; Sun, 29 Mar 2020 11:48:18 +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=wkzIp4Sl; 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 a-YX7TigDYri; Sun, 29 Mar 2020 11:48:18 +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 48qrPZ0n2nz9tyY1; Sun, 29 Mar 2020 11:48:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1585475298; bh=QMHt+CzUvu9PdrsCMW23L7vVLi66IzMH33dqHOLEvp0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=wkzIp4SlY62kuhQIBgmcI/5xGhSRfgP+eVn0BEV3FVpr3LBYI/IWCoXN1WHiahGVV FK5udao4bhdHPrDglhnRRFxvi0euUS1ekEn0hO9VtTOayLTVAocziCH8IayOWMU57Z B+FBgxFb7AaVgEXuDuCQgJTig8tv9dEZNs42ZFLw= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E7BAA8B770; Sun, 29 Mar 2020 11:48:19 +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 2Enbwj-751-v; Sun, 29 Mar 2020 11:48:19 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 460B28B752; Sun, 29 Mar 2020 11:48:16 +0200 (CEST) Subject: Re: [PATCH v2] powerpc/kprobes: Blacklist functions running with MMU disabled on PPC32 To: "Naveen N. Rao" , Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <3ada1af1b479c5a88bf9f3b8955bf5ba3f32f1ba.1582565849.git.christophe.leroy@c-s.fr> <1585299144.f9e0pmxsgv.naveen@linux.ibm.com> From: Christophe Leroy Message-ID: <9fd6134f-1807-bb49-cf6a-fa49175fdfe5@c-s.fr> Date: Sun, 29 Mar 2020 11:48:09 +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: <1585299144.f9e0pmxsgv.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 27/03/2020 à 10:07, Naveen N. Rao a écrit : > Christophe Leroy wrote: >> kprobe does not handle events happening in real mode, all >> functions running with MMU disabled have to be blacklisted. >> >> As already done for PPC64, do it for PPC32. >> >> Signed-off-by: Christophe Leroy >> --- >> v2: >> - Don't rename nonrecoverable as local, mark it noprobe instead. >> - Add missing linux/kprobes.h include in pq2.c >> --- >>  arch/powerpc/include/asm/ppc_asm.h           | 10 +++ >>  arch/powerpc/kernel/cpu_setup_6xx.S          |  4 +- >>  arch/powerpc/kernel/entry_32.S               | 65 ++++++++------------ >>  arch/powerpc/kernel/fpu.S                    |  1 + >>  arch/powerpc/kernel/idle_6xx.S               |  2 +- >>  arch/powerpc/kernel/idle_e500.S              |  2 +- >>  arch/powerpc/kernel/l2cr_6xx.S               |  2 +- >>  arch/powerpc/kernel/misc.S                   |  2 + >>  arch/powerpc/kernel/misc_32.S                |  4 +- >>  arch/powerpc/kernel/swsusp_32.S              |  6 +- >>  arch/powerpc/kernel/vector.S                 |  1 + >>  arch/powerpc/mm/book3s32/hash_low.S          | 38 ++++++------ >>  arch/powerpc/mm/mem.c                        |  2 + >>  arch/powerpc/platforms/52xx/lite5200_sleep.S |  2 + >>  arch/powerpc/platforms/82xx/pq2.c            |  3 + >>  arch/powerpc/platforms/83xx/suspend-asm.S    |  1 + >>  arch/powerpc/platforms/powermac/cache.S      |  2 + >>  arch/powerpc/platforms/powermac/sleep.S      | 13 ++-- >>  18 files changed, 86 insertions(+), 74 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/ppc_asm.h >> b/arch/powerpc/include/asm/ppc_asm.h >> index 6b03dff61a05..e8f34ba89497 100644 >> --- a/arch/powerpc/include/asm/ppc_asm.h >> +++ b/arch/powerpc/include/asm/ppc_asm.h >> @@ -267,8 +267,18 @@ GLUE(.,name): >>      .pushsection "_kprobe_blacklist","aw";        \ >>      PPC_LONG (entry) ;                \ >>      .popsection >> +#define _NOKPROBE_ENTRY(entry)                \ >> +    _ASM_NOKPROBE_SYMBOL(entry)                \ >> +    _ENTRY(entry) >> +#define _NOKPROBE_GLOBAL(entry)                \ >> +    _ASM_NOKPROBE_SYMBOL(entry)                \ >> +    _GLOBAL(entry) >>  #else >>  #define _ASM_NOKPROBE_SYMBOL(entry) >> +#define _NOKPROBE_ENTRY(entry)                \ >> +    _ENTRY(entry) >> +#define _NOKPROBE_GLOBAL(entry)                \ >> +    _GLOBAL(entry) >>  #endif > > Michael hasn't preferred including NOKPROBE variants of those macros > previously, since he would like to see some cleanups there: > https://patchwork.ozlabs.org/patch/696138/ Ok [...] >> @@ -194,8 +188,7 @@ transfer_to_handler: >>      bt-    31-TLF_NAPPING,4f >>      bt-    31-TLF_SLEEPING,7f >>  #endif /* CONFIG_PPC_BOOK3S_32 || CONFIG_E500 */ >> -    .globl transfer_to_handler_cont >> -transfer_to_handler_cont: >> +_NOKPROBE_ENTRY(transfer_to_handler_cont) >>  3: >>      mflr    r9 >>      tovirt_novmstack r2, r2     /* set r2 to current */ >> @@ -297,6 +290,7 @@ reenable_mmu: >>   * On kernel stack overflow, load up an initial stack pointer >>   * and call StackOverflow(regs), which should not return. >>   */ >> +_ASM_NOKPROBE_SYMBOL(stack_ovf) >>  stack_ovf: > > The current convention is to add the NOKPROBE annotation at the _end_ of > the associated function/symbol... Ok. For big functions that looks unpractical, but I'll do that. [...] >> @@ -1033,17 +1026,15 @@ exc_exit_restart_end: >>      li    r10, 0 >>      stw    r10, 8(r1) >>      REST_2GPRS(9, r1) >> -    .globl exc_exit_restart >> +_NOKPROBE_ENTRY(exc_exit_restart) >>  exc_exit_restart: >>      lwz    r11,_NIP(r1) >>      lwz    r12,_MSR(r1) >> -exc_exit_start: >>      mtspr    SPRN_SRR0,r11 >>      mtspr    SPRN_SRR1,r12 >>      REST_2GPRS(11, r1) >>      lwz    r1,GPR1(r1) >> -    .globl exc_exit_restart_end >> -exc_exit_restart_end: >> +.Lexc_exit_restart_end: > > I think it would be good to break this into smaller patches to handle > specific code paths, if possible. At the very least, it would be good to > move changes to symbol visibility to a separate patch since this also > changes the names printed in a backtrace. Ok. I removed most symbol visibility changes. I only kept the ones in book3s32/hash_low.S and did a separate patch for it. I split into patches per platform, then one bigger for everything in arch/powerpc/kernel/ except entries, then I did one for exception entry, one for syscall exit and one for exception exit. Christophe