Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp375864rwb; Wed, 7 Dec 2022 19:50:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KpeEUgY2YjV8SrDzG3pElYxkQ5oECCYfTyhqDv7cLWoPktLIhndWEYPwclGF6Eo4A6Q9r X-Received: by 2002:a17:906:578a:b0:7c0:ff72:d10f with SMTP id k10-20020a170906578a00b007c0ff72d10fmr11012046ejq.175.1670471400233; Wed, 07 Dec 2022 19:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670471400; cv=none; d=google.com; s=arc-20160816; b=FQ3kVIHHLaRqVJM86au9IL08qbS+QeABbaOfCHqmpKcXSFz8jfruCuMbwsRy8pSoR/ ZSe6IrEfiiUO1aniQP7lrFxExz/OqXC02nOEiRrcwvVVso7UzcrqRptBV6mrAt0o0nV3 uqhXDOj8alS8+qQZ6O6tWTGI8RneqWYDZciJL+RYmvZKkXNEP71FFjbgSA87Uf/ul9xN 5IDth7T7v3mdPSjTxXcrx5IHXwUqumRhRqqGmNED2rm/k6l/6YG3hbYxmto+9eN0PcbA ZQ5M3XYm4oz9yES7NJ8BrXqwjLxmb+6Az1Hmo6xuRI6dK1QTB4gCvi9SpJHTlfKzgLqV KNdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BXjtcctV5foA9+gjbEVKdT7rXJSOktoTRwxB2J4qPj0=; b=vHPCLimC1tTEXjx3ep0Jl2ln+JgH1cxK5RJlocnTfojHiMGrSgqjqGPX365+UYi/FQ WnnsFXmDUANpoOL4W+hwaEeLPFtQzg678n2tykNIPn+OfdbvtjjxwTYyTgtShvpm7bRn i+jQqiMyGZfTBnkvnM9+rzrlID5kWtaZtXa/o0BFHTM5YaOeajKmEhkjILOlHvQ+02oj KDSLbYFIt9FTquY+61hz2q+iSBk/PqWRCJ79ja8baQjv5EL0sG7lbUntb8WzILyQo+oy oOzUXkWWA9sjzJshBvuVQeahwQrpdg8fFO/NmAtVnyL8kbiQWhCAjOrFSgp8LFreUmWL oauw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EoW8SwG1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw9-20020a170907a0c900b0078de83a052csi19275822ejc.483.2022.12.07.19.49.42; Wed, 07 Dec 2022 19:50:00 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EoW8SwG1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbiLHC7W (ORCPT + 74 others); Wed, 7 Dec 2022 21:59:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiLHC7H (ORCPT ); Wed, 7 Dec 2022 21:59:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792E198540; Wed, 7 Dec 2022 18:59:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3BBDFB82204; Thu, 8 Dec 2022 02:59:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F01EAC433D7; Thu, 8 Dec 2022 02:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670468341; bh=m/A9xb4bgo9ywaAF/nOHCziALkNLqcaygAT8lXBG3nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EoW8SwG1rkXRJVaqfn9vIAHVFzW/VN/sg+lfYntRbwgdwNMiwpN4A45rEVDdH138L KgnHa+/5zjU1KPqo2uePcEzwzG9dKUaB0AOt03bQVy9HtenJMpzMEcQ1nFyxFWfoJe Ry53+fco7WDlENfHHSNDIRvZFEHoUKGEKmqvxhx6iXZKrFtdWHgpVMC+RJ5dC8aWDx n5hbSpXfkENd+Tnk7KkArEPqMcVEE50hqXK7aHzLTsg7XMPdqWCPX4sHXQjh+BaIM7 PtRJJEXBaqu3evGp6xuK1F0YCaW4jRLRieWe1MZ8SfHaXvdohupDos62deuOfziFi8 /Da5nk+dEQNNg== From: guoren@kernel.org To: arnd@arndb.de, guoren@kernel.org, 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, palmer@dabbelt.com, paul.walmsley@sifive.com, mark.rutland@arm.com, zouyipeng@huawei.com, bigeasy@linutronix.de, David.Laight@aculab.com, chenzhongjin@huawei.com, greentime.hu@sifive.com, andy.chiu@sifive.com, ben@decadent.org.uk, bjorn@kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Subject: [PATCH -next V10 03/10] riscv: entry: Add noinstr to prevent instrumentation inserted Date: Wed, 7 Dec 2022 21:58:09 -0500 Message-Id: <20221208025816.138712-4-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221208025816.138712-1-guoren@kernel.org> References: <20221208025816.138712-1-guoren@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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) Link: https://lore.kernel.org/linux-riscv/YxcQ6NoPf3AH0EXe@hirez.programming.kicks-ass.net/ 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 f3e96d60a2ff..f7fa973558bc 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) { struct task_struct *tsk; struct vm_area_struct *vma; -- 2.36.1