Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13119802rwl; Wed, 4 Jan 2023 03:58:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvzE7q13OEIAedAaXYW+hwpJd4B/Plv2VhV3YmejWl1tUtsSfUZijC/GpsmwS4D0Kyu8k8U X-Received: by 2002:a17:907:d410:b0:7c1:fbea:c5ce with SMTP id vi16-20020a170907d41000b007c1fbeac5cemr40436596ejc.7.1672833514540; Wed, 04 Jan 2023 03:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672833514; cv=none; d=google.com; s=arc-20160816; b=d+JMcEehDdM1hgRYzM1Dwsbpvc8JlWqDVT9cqK/Fo1KA8E9MJEoDlqTjDXV7BNZqYD LBc3iMRwhDNkKtolGOgffzZDU7MscrEbj92YozBGkbBU9gMrNKwlrgM8nRvFsyQOsrfF U4FnsdDOEyWTWAkcgg5JTMbQCcGLTT63cixIVdFssdCTTeRpv0TRVUE4YGrkweCa/6bs lHYZspOZxMwazLsVGPcctPX18x3gUboTWYDQnyrjQ7qZUPWx3rEfJ+sTEAVr1noQX9m3 1lLOKqdmCnkjnGJg/m1glk3H93kGG4Rk2EL9RoxslbRmvPvERHkJCwQg5eX/SzwHl4Ue RwpA== 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; bh=8ZDIFuM/4ZAC/FJdm/SJSaUBkcv3xBx8ZRBEM98sSWI=; b=RT+kqhVg+v+T9HB+C/OkzPgsaWWcDFpXsA7nOUiQAXgvXLuR8o2oSIEwcA2ueSGjKG q3AyAnU3WFZxS7Bs73nHBACxEaqnKvRDTb8zjG5QaqPC2YAW0KNHAw2iVRQB5lTtEon4 6CfYcZ+LWQA8/OdCNWzoHZoZL3ksDsS3bTqW26ewoh5ZP9uxENOT4I0E+nVdtFUc/U8u fexV5ILfxyAFSPHrnIgSlZayeiffQ9ABY1T6TXoQRCcloWB8/B/scu+jhRysyyFFDSxF JSoTSha8mddZH+ONy7gRgNE+wH2jxrhhaUc+BZFLdca1C9mUh2xlcbBwQeXZ3+H0lzUq FotA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb10-20020a1709071c8a00b007c773e7d8dfsi30577531ejc.203.2023.01.04.03.58.21; Wed, 04 Jan 2023 03:58:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239164AbjADL4A (ORCPT + 57 others); Wed, 4 Jan 2023 06:56:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239144AbjADLzs (ORCPT ); Wed, 4 Jan 2023 06:55:48 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3EE041E7; Wed, 4 Jan 2023 03:55:47 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7EBD51042; Wed, 4 Jan 2023 03:56:28 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.37.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C49E53F587; Wed, 4 Jan 2023 03:55:43 -0800 (PST) Date: Wed, 4 Jan 2023 11:55:35 +0000 From: Mark Rutland To: guoren@kernel.org Cc: arnd@arndb.de, palmer@rivosinc.com, tglx@linutronix.de, peterz@infradead.org, luto@kernel.org, conor.dooley@microchip.com, heiko@sntech.de, jszhang@kernel.org, lazyparser@gmail.com, falcon@tinylab.org, chenhuacai@kernel.org, apatel@ventanamicro.com, atishp@atishpatra.org, ben@decadent.org.uk, bjorn@kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= Subject: Re: [PATCH -next V12 3/7] riscv: entry: Add noinstr to prevent instrumentation inserted Message-ID: References: <20230103033531.2011112-1-guoren@kernel.org> <20230103033531.2011112-4-guoren@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230103033531.2011112-4-guoren@kernel.org> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 On Mon, Jan 02, 2023 at 10:35:27PM -0500, guoren@kernel.org wrote: > From: Guo Ren > > Without noinstr the compiler is free to insert instrumentation (think > all the k*SAN, KCov, GCov, ftrace etc..) which can call code we're not > yet ready to run this early in the entry path, for instance it could > rely on RCU which isn't on yet, or expect lockdep state. (by peterz) That's generally true, and makes sense to me, but .... > Link: https://lore.kernel.org/linux-riscv/YxcQ6NoPf3AH0EXe@hirez.programming.kicks-ass.net/ > Reviewed-by: Björn Töpel > Suggested-by: Peter Zijlstra > Tested-by: Jisheng Zhang > Signed-off-by: Guo Ren > Signed-off-by: Guo Ren > --- > arch/riscv/kernel/traps.c | 4 ++-- > arch/riscv/mm/fault.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c > index 549bde5c970a..96ec76c54ff2 100644 > --- a/arch/riscv/kernel/traps.c > +++ b/arch/riscv/kernel/traps.c > @@ -95,9 +95,9 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, > } > > #if defined(CONFIG_XIP_KERNEL) && defined(CONFIG_RISCV_ALTERNATIVE) > -#define __trap_section __section(".xip.traps") > +#define __trap_section __noinstr_section(".xip.traps") > #else > -#define __trap_section > +#define __trap_section noinstr > #endif > #define DO_ERROR_INFO(name, signo, code, str) \ > asmlinkage __visible __trap_section void name(struct pt_regs *regs) \ > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c > index d86f7cebd4a7..b26f68eac61c 100644 > --- a/arch/riscv/mm/fault.c > +++ b/arch/riscv/mm/fault.c > @@ -204,7 +204,7 @@ static inline bool access_error(unsigned long cause, struct vm_area_struct *vma) > * This routine handles page faults. It determines the address and the > * problem, and then passes it off to one of the appropriate routines. > */ > -asmlinkage void do_page_fault(struct pt_regs *regs) > +asmlinkage void noinstr do_page_fault(struct pt_regs *regs) ... why do you need that for do_page_fault? That doesn't (currently) do any entry/exit logic, so this seems unnecessary per the commit description. Thanks, Mark. > { > struct task_struct *tsk; > struct vm_area_struct *vma; > -- > 2.36.1 >