Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2048563rdb; Mon, 9 Oct 2023 10:43:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRHxogql4LOnnsfODiH7tE4tm7Ph6Jh8zi08kXEd0MqwZNbq04GXWJ4vYwjmmgGMIlK0nA X-Received: by 2002:a05:6a00:c89:b0:690:f877:aa22 with SMTP id a9-20020a056a000c8900b00690f877aa22mr15638036pfv.3.1696873410550; Mon, 09 Oct 2023 10:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696873410; cv=none; d=google.com; s=arc-20160816; b=WYptTsGiF4kOl7eXdqjWIDYqLciefmvE+t6QUyF3uDMhzptiV72YOYm9/ctcCAXYc5 sCxivepGKtwHtYQr7Aw+pK4YE2a2cGCNbOR4VAOBHiOK3kSzO9cvDPIqy1usOMlj62Cu QrQEVkE3M5v70F3Z87khk/bPK6O2mZJ680swAB13ziGSV0UrQo9/adKWr/mpSNuK4WPu XhwA3YH4/HYgkhDFE2LMVo7UWC+qfnsUycilev5x0UHt7ejDokIJLLk3M9kB1bQmvk0G DDAbWoOnMBqq0Z7voltoqU/UXle1dH9BUHq61ftSuf+CdRamX09o+Ye4rKrgAZ111TDe UQUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NnMTttrcelYaYIrt+NLGLTTRb9JsbmWtmliQHucd1xA=; fh=Nfg4DnC7Uk7kebj4a0q3UiV9BF8oLa+ynUuEpe3fOSY=; b=yBvYnLCifT0QPcc/L5gEyI4Vwp6TpJpl/itO6AEGGEjk0tOhZBitql04jA0k9fHoIR ggOXvrEz7ACRK5yeq+LEhBW09EYrYzNKuKI2Z4fdcFmSQeedQlaPe6TLQ3PlLkmDS16t PpwMPteqmzbb8MEgr6WPAODRGA+4/m0TXAx+MTIW1+zkJgtYsGfkN5V386INQFsHLavr 1AFej1jig8KKEnD3135u3Wte55YRpBRfaIxTyKW4RrRoV97n2StAeLaxIkGY5PRaP0H0 56yEEGh+fFJ8YvWzL57oREX25yVZAOPT4unxL+h4gOdo97VdEdMyAKojsQJi5qCvjwYN 81vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="Bq8dgu/m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j2-20020a655582000000b00584ca25959csi10064320pgs.540.2023.10.09.10.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 10:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="Bq8dgu/m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B942D801C1AC; Mon, 9 Oct 2023 10:43:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377488AbjJIRnS (ORCPT + 99 others); Mon, 9 Oct 2023 13:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbjJIRnR (ORCPT ); Mon, 9 Oct 2023 13:43:17 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA5894 for ; Mon, 9 Oct 2023 10:43:15 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b0dcbf3672so140098b6e.1 for ; Mon, 09 Oct 2023 10:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696873394; x=1697478194; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=NnMTttrcelYaYIrt+NLGLTTRb9JsbmWtmliQHucd1xA=; b=Bq8dgu/mRQQpF90U9EabozVQXjuova8Ay+TB+m/wvtWjiT7lbLcNYJ5Vu918t2KgNx YZJXOA52Bj+9BsZXQRnUmzzgp78GefIrbJ6PTAaIHvLuWuhYmHfcmjcTNQFRILVr54yN ZrKpq1ETKKuMEnFggOk+TiXeWoRNXgH3cM0DFAndshpbo+ZpJtOlsZjlkevkQh5j8rDH Edkr6Deh0jA3lsONDFwmGROgKW7XX8+kYfFQaAjWpC6nJD351VGhJgPf+8UcO5FBemaj eiFtHsZEI0iD/eKs8ZpSDW0ANVePxpsrtsF2gAOV2c2R9DexBcW1gkYPhrw/+0t87s5a ibaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696873394; x=1697478194; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NnMTttrcelYaYIrt+NLGLTTRb9JsbmWtmliQHucd1xA=; b=a+/+q9ROwulbAsXUarPRws/DoPWS9pFkbb5ZeU5C7bdsjRyyEQWpMcdHQi4MoI5jKA QOr8LKFWlH5lRCfKFNARJ9RQhrKo6iHzwmm1YBMBnOivmWH54073Zd7CcIQVYcbrYnxu SOAvuIJY4IZoJRVK577E3EzG/1IqPA78V5IkNJwFDITr1CJ5pkguJFb5aa7qZ8FNtayw 23CqTNN5Vaq+wIlcQgDQ/V5h1JLeiO7AUkIEYQCYBsoYkENJDN+WKiAC/+yioAyw1WHP z4Cc7Vy6Ge5wqlcDiui4q1+vPxcRgcwcVFTBW2LrJNeq8cK4ZxS8jvXJWF00eomvY5oJ WYYQ== X-Gm-Message-State: AOJu0YyszYDTfI01xGCUp1J5ZtaVkiTv507K0ciVTlFVuUqpvhGeh76T iUNVgoJ4crCT2oA3uPVrso9W0g== X-Received: by 2002:a05:6808:18a1:b0:3ae:156f:d325 with SMTP id bi33-20020a05680818a100b003ae156fd325mr19459911oib.58.1696873394538; Mon, 09 Oct 2023 10:43:14 -0700 (PDT) Received: from ghost (cpe-70-95-50-247.san.res.rr.com. [70.95.50.247]) by smtp.gmail.com with ESMTPSA id c20-20020a056808105400b003a40b3fce01sm1676687oih.10.2023.10.09.10.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 10:43:14 -0700 (PDT) Date: Mon, 9 Oct 2023 10:43:10 -0700 From: Charlie Jenkins To: =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: blacklist assembly symbols for kprobe Message-ID: References: <20231004131009.409193-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231004131009.409193-1-cleger@rivosinc.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 10:43:29 -0700 (PDT) On Wed, Oct 04, 2023 at 03:10:09PM +0200, Cl?ment L?ger wrote: > Adding kprobes on some assembly functions (mainly exception handling) > will result in crashes (either recursive trap or panic). To avoid such > errors, add ASM_NOKPROBE() macro which allow adding specific symbols > into the __kprobe_blacklist section and use to blacklist the following > symbols that showed to be problematic: > - handle_exception() > - ret_from_exception() > - handle_kernel_stack_overflow() > > Signed-off-by: Cl?ment L?ger > --- > arch/riscv/include/asm/asm.h | 10 ++++++++++ > arch/riscv/kernel/entry.S | 3 +++ > 2 files changed, 13 insertions(+) > > diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h > index 114bbadaef41..9194e334de15 100644 > --- a/arch/riscv/include/asm/asm.h > +++ b/arch/riscv/include/asm/asm.h > @@ -142,6 +142,16 @@ > REG_L x31, PT_T6(sp) > .endm > > +/* Annotate a function as being unsuitable for kprobes. */ > +#ifdef CONFIG_KPROBES > +#define ASM_NOKPROBE(name) \ > + .pushsection "_kprobe_blacklist", "aw"; \ > + RISCV_PTR name; \ > + .popsection > +#else > +#define ASM_NOKPROBE(name) > +#endif > + > #endif /* __ASSEMBLY__ */ > > #endif /* _ASM_RISCV_ASM_H */ > diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S > index 143a2bb3e697..f24bc4eeedde 100644 > --- a/arch/riscv/kernel/entry.S > +++ b/arch/riscv/kernel/entry.S > @@ -101,6 +101,7 @@ _save_context: > 1: > tail do_trap_unknown > SYM_CODE_END(handle_exception) > +ASM_NOKPROBE(handle_exception) > > /* > * The ret_from_exception must be called with interrupt disabled. Here is the > @@ -167,6 +168,7 @@ SYM_CODE_START_NOALIGN(ret_from_exception) > sret > #endif > SYM_CODE_END(ret_from_exception) > +ASM_NOKPROBE(ret_from_exception) > > #ifdef CONFIG_VMAP_STACK > SYM_CODE_START_LOCAL(handle_kernel_stack_overflow) > @@ -254,6 +256,7 @@ restore_caller_reg: > move a0, sp > tail handle_bad_stack > SYM_CODE_END(handle_kernel_stack_overflow) > +ASM_NOKPROBE(handle_kernel_stack_overflow) > #endif > > SYM_CODE_START(ret_from_fork) > -- > 2.42.0 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv Reviewed-by: Charlie Jenkins