From patchwork Wed Feb 22 03:30:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13148687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02100C636D6 for ; Wed, 22 Feb 2023 03:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jKm+r5B1pVCXQh8QGjoNc73pEWOVvXsSbDZLHUtzE4g=; b=PgoqHKUuDwdziR 48rCRVKNTolD0LLuJjb6H9EVUwwrBSfcBhvp97oUKjek3wasy/eamZGT33I5t7P46mzQsjwM7gKY+ oxVKgjsjwH45T/Sr6M6bY9b5DWQCZQnDYkYkkKH/NC51CS/J5246EMJOkrCGC0vsXO5IoQqAEZRFd lEhvIUZfXLJ8kPeLt6E7nJAMQs3gn4Y0fYqj2il125U4+wV9qvtjAhi2lbTgQcp0/9MjHFINFtfN1 mP6aDhjn24VtOBH/Mi3lhJmgWCKxa1NLLfm1WJGAaPsy9LGn2BFHhmebu8oUOU2bGnDtNTNo+gDLh er6FREMz9M/PC8Wek+FA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pUfqb-00AbIo-9C; Wed, 22 Feb 2023 03:31:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pUfqZ-00AbGc-54 for linux-riscv@lists.infradead.org; Wed, 22 Feb 2023 03:31:12 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id B4A3C6123A; Wed, 22 Feb 2023 03:31:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80929C433D2; Wed, 22 Feb 2023 03:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677036670; bh=NU2D9m2f+OBXEEFPkBj55AyydgpUBKeOwXAIsCjdO1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdHZ/xn3PjRbbdAOXrh+rV2ZDUn4Bdki5FuC3j7BK/P+6tl9/rJ3XlLaC54xlCmFl nx1t89Q+ic/YVNEUyL3BwMIO2FOpwJ7XEc2mJdUUO9tknv7Bii8zb6ksU+QckXzhO3 aKCDBMnWWqoZ507u7f0Ahc45pa0hH+aNpZQ3Df3ZDUsOC1hQyRWda2rat/gp5c7M9E Zcd95+w0+adlQmOZFb6Qty0hCsmh6Mai1ZkvyF8+e91EzfuRLV/AzNmdwB0iCpST2c YaRoBKEM+pWnoQF4Wa4eeI7JwowAFLS+LFggynDEjwrgQlgLmBfOoYYEIB8aY8RcWV 2se6fwh7Evigg== 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, mark.rutland@arm.com, ben@decadent.org.uk, bjorn@kernel.org, palmer@dabbelt.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= Subject: [PATCH -next V17 3/7] riscv: entry: Add noinstr to prevent instrumentation inserted Date: Tue, 21 Feb 2023 22:30:17 -0500 Message-Id: <20230222033021.983168-4-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230222033021.983168-1-guoren@kernel.org> References: <20230222033021.983168-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230221_193111_294203_780D9DFF X-CRM114-Status: GOOD ( 12.65 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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/ 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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index f6fda94e8e59..02727a4fe8be 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -119,9 +119,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) \