From patchwork Wed Nov 30 03:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13059418 X-Patchwork-Delegate: palmer@dabbelt.com 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 60E64C352A1 for ; Wed, 30 Nov 2022 03:42:45 +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=aD1xbVK6mWAScSCPRvcv4t+z8b+g5MkjH0OviotdW74=; b=EI3ndXVyUwm7Y6 kTo+oJ6cQ0R9gAXf6w0s+5v3W+Zos6aMxJWJ4fkHHutK1uM26KWuNzRdjjgUncR66ocaD/5rDCjdK VBzrH2OnC6z86iAQa4iFAYCVm2dRLAkdCPxxnYaf1yjpvB+ftzt3IG44xvXxHsvZEWM04+dgBRhTu QQu9Gu4jRHxIdwOXhHNj0JQ7eTQqyrBxSt7iRAziiUc/5nwdg+5YIJYn/5SuXa2X/nh+FlY4NVDRm adiKs2oqwRoDToimx6ZRZV07tP4N6MselAY/eETCNSBf6I2wxQy4Bh0OUWlKxCwSl9bzB9Fb7HRQb vUMZ5Q5pGcVPuRMtdF2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0DzZ-00CeRl-75; Wed, 30 Nov 2022 03:42:37 +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 1p0DzV-00CeNk-7E for linux-riscv@lists.infradead.org; Wed, 30 Nov 2022 03:42:34 +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 C1EB7619F3; Wed, 30 Nov 2022 03:42:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6FB7C43470; Wed, 30 Nov 2022 03:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669779752; bh=m/A9xb4bgo9ywaAF/nOHCziALkNLqcaygAT8lXBG3nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QqqwyUfyrD05BXBsNOF8t/q9LJpf4okYoGZyK8yKA4JKrUJD4NWjj+qOVsCnKlDB4 GehDMofjCAH93bP2TlYup+zowFUjBLeq9MdgHPD6j5qbwH9+81/l5NekspnIDUt2+E rQOhsRNG7lAiM+eX2D+1vRDWKiJX1OwoWRypbwkP0mH9F6dpWZ6sTtC4U6t8VGjClp a5tXZDfXEf4tYzEvGN+xk8xqc9Xy0DrvHd3Qk11VCtyAxtiTK6iKohtoLRxULNBS9I Jf8UpHH9ReuYV9ThB0usJHiX0O/gyn+jJ6C8ewiQ04VGi2xrToHFjCBjWERwOWakjZ hVfiANMQcyYlg== 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 Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Subject: [PATCH -next V9 05/14] riscv: traps: Add noinstr to prevent instrumentation inserted Date: Tue, 29 Nov 2022 22:40:50 -0500 Message-Id: <20221130034059.826599-6-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221130034059.826599-1-guoren@kernel.org> References: <20221130034059.826599-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221129_194233_323062_20DB7A4C X-CRM114-Status: GOOD ( 14.12 ) 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/ 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;