From patchwork Sat Jul 20 17:12:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737857 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 33032C3DA64 for ; Sat, 20 Jul 2024 17:27:03 +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=t0UB1GlTGIeoVCwOQWDdajSxrrLlMJZA/ZmkME5ala4=; b=vzSNIFRJyaVi7j p0x/nXWbHngAlK2G01mxvcxdt2dKEIKrjLI+hmfT4tLcj4OgRHEYc5DITbzbGt7nJ9lek8xzLdf8G Ktfjdh5uWSJvg+qrjLWzcvAR+rXiC/i3yF06ngLRcr+H4HWmgfJQYoidTBh01/4v5tIJDhjxYupsB V7aZsWXYCuHcBGnBkZWPIIP20PNbHsdUtLKvx9v9xI4D+dqTk42iFddHlGqeQ+PWQpzQ48O26trWw MrUGOng/lJWzQHakAPACM/CFgtC5x5APGkVjUGjZh12CwpWQeNG5H2A4k4hCJ0EgXvaEXS44rUaYt MNvtBP0n0DkxUQqbjW7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrI-00000005Qau-1KMX; Sat, 20 Jul 2024 17:27:00 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrC-00000005QXm-36GD for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:26:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 888D7CE010F; Sat, 20 Jul 2024 17:26:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06E95C4AF09; Sat, 20 Jul 2024 17:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496411; bh=NCFdc/pkut4LwN+MrcPmxA5eUoeddsannScPQZtdY/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hvlTkTWXkGaIxigUYa1gwQar5xanhbF93SHCip2ilWq5sLv5uxDeIy8BPjMTDtNRO 80D+AfczK9MoaU8hayhUVOcKkecYo114IlB7xBsFuQj1f1uc2UJwjZeYGFu5Rt6ycV 1yzyTb8oUNS8Tr1PYk8LjNALSCij22dli9rSGZGa6E/0qS0DjYzKTLdf7iUm4TPqBZ lhxdComq3ce51D2+v9CZUsbaLcLLkXWqlUu11XOlhN5siC3kcPRVhCk8FoA0SJluuJ Us5Hc+/eSm3qupIEKSBT3LkHnvKe3u+eamNdnwE7Lwjd7oSdMV5OxSOqMYUPos5aY1 toGQ3Pzc5Ca1A== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] riscv: traps: staticalize handle_break() Date: Sun, 21 Jul 2024 01:12:26 +0800 Message-ID: <20240720171232.1753-2-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102654_983081_B0720FCD X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. 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 handle_break() is only called in traps.c, make it static. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/entry-common.h | 1 - arch/riscv/kernel/traps.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/entry-common.h b/arch/riscv/include/asm/entry-common.h index 2293e535f865..1458a41c6536 100644 --- a/arch/riscv/include/asm/entry-common.h +++ b/arch/riscv/include/asm/entry-common.h @@ -23,7 +23,6 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare void handle_page_fault(struct pt_regs *regs); -void handle_break(struct pt_regs *regs); #ifdef CONFIG_RISCV_MISALIGNED int handle_misaligned_load(struct pt_regs *regs); diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 05a16b1f0aee..84dff89f435d 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -270,7 +270,7 @@ static bool probe_breakpoint_handler(struct pt_regs *regs) return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs); } -void handle_break(struct pt_regs *regs) +static void handle_break(struct pt_regs *regs) { if (probe_single_step_handler(regs)) return; From patchwork Sat Jul 20 17:12:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737856 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 C5F57C3DA49 for ; Sat, 20 Jul 2024 17:27:02 +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=AkoSmKoHZEi3GHqoZ3KOzM9W97G8M7B4U6mhYNlmQbk=; b=kvmTixTasXD1nT nk2u7JIIq7vl8HRGruNDhwRY7YWI1oHU+SnpnX3KhfZ0saxBM4H/u8yItttEmiyLG8xhWXJyYmluu RVDBlZJ/9A34fb+ajjcojhrDmyomJSGJY2T30yi1dDLrOJm8ocgOU/+aJUwhwYx2ACztj1BG4k0OZ 7y0SEMRh/2fPDOUqeLPt8sXOlFzNSI7sDtCAJKqbrEEhy6BSeGOF7S9FrugrCEngFfU38511pkF8N t9ZojEJGLhmK4aOlKE0HPzbRqcWbzkPB1GhAaomZ4LtwaYMPLC0gJWnvz+GelqP+cQGv0FQm9X4bh Cq0HRKxO6BDG5kksEW9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrH-00000005QaF-0lOV; Sat, 20 Jul 2024 17:26:59 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrC-00000005QY2-1no3 for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:26:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8DD9560FDB; Sat, 20 Jul 2024 17:26:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCCC0C4AF0E; Sat, 20 Jul 2024 17:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496413; bh=98NBtrS/SMiq12hZfID75Yi7wQQ0UoZjx4bDe8JfM7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4ztOcRFtt/L8y27kj71vaMp/hVPX2rJ4XGAvHs2lK82jNMi7tHf63+X4gZ6ikrOL 5NCdG91/FjCSWTnPZu0DN4v81Pr99PSPEt+JF4DRdNQlGLiu3drOFFWs/9qycQOl09 9S9DDIlttmYex+ufURu9cwx76Gvu24azkKA5HYf1gCU4spDsZIOu9s9gPYIR9j2uC0 xdJEajhAV4WWiKPviJXA/F4ibDbR3WgZbCf/uHvyP34sUPLkD+DPo6wvU01GaZUIlr mDcqR/ITjGxO1s+H2Ms9xAScH0925ep10jddLPR8UESmKdZSnh2QJbMouFH8zx5gfH p0Ijsu6L28aJg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] riscv: traps: remove __visible annotation Date: Sun, 21 Jul 2024 01:12:27 +0800 Message-ID: <20240720171232.1753-3-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102654_589318_12F84A55 X-CRM114-Status: UNSURE ( 8.07 ) X-CRM114-Notice: Please train this message. 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 Commit f307307992bf ("riscv: for C functions called only from assembly, mark with __visible") resolve sparse warnings for C functions called only by assembly code by adding __visible annotations instead of adding prototypes. But after commit 030f1dfa8550 ("riscv: traps: Fix no prototype warnings"), prototypes were added. So the __visible annotations are not needed any more, remove them. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/traps.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 84dff89f435d..3d1f84cb6eac 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -147,7 +147,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, #define __trap_section noinstr #endif #define DO_ERROR_INFO(name, signo, code, str) \ -asmlinkage __visible __trap_section void name(struct pt_regs *regs) \ +asmlinkage __trap_section void name(struct pt_regs *regs) \ { \ if (user_mode(regs)) { \ irqentry_enter_from_user_mode(regs); \ @@ -167,7 +167,7 @@ DO_ERROR_INFO(do_trap_insn_misaligned, DO_ERROR_INFO(do_trap_insn_fault, SIGSEGV, SEGV_ACCERR, "instruction access fault"); -asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *regs) +asmlinkage __trap_section void do_trap_insn_illegal(struct pt_regs *regs) { bool handled; @@ -198,7 +198,7 @@ asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *re DO_ERROR_INFO(do_trap_load_fault, SIGSEGV, SEGV_ACCERR, "load access fault"); -asmlinkage __visible __trap_section void do_trap_load_misaligned(struct pt_regs *regs) +asmlinkage __trap_section void do_trap_load_misaligned(struct pt_regs *regs) { if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); @@ -219,7 +219,7 @@ asmlinkage __visible __trap_section void do_trap_load_misaligned(struct pt_regs } } -asmlinkage __visible __trap_section void do_trap_store_misaligned(struct pt_regs *regs) +asmlinkage __trap_section void do_trap_store_misaligned(struct pt_regs *regs) { if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); @@ -294,7 +294,7 @@ static void handle_break(struct pt_regs *regs) die(regs, "Kernel BUG"); } -asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs) +asmlinkage __trap_section void do_trap_break(struct pt_regs *regs) { if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); @@ -311,7 +311,7 @@ asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs) } } -asmlinkage __visible __trap_section __no_stack_protector +asmlinkage __trap_section __no_stack_protector void do_trap_ecall_u(struct pt_regs *regs) { if (user_mode(regs)) { @@ -355,7 +355,7 @@ void do_trap_ecall_u(struct pt_regs *regs) } #ifdef CONFIG_MMU -asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs) +asmlinkage noinstr void do_page_fault(struct pt_regs *regs) { irqentry_state_t state = irqentry_enter(regs); From patchwork Sat Jul 20 17:12:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737858 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 8021EC3DA49 for ; Sat, 20 Jul 2024 17:27:06 +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=Eaw2KwEWwcXV8A2AbKJBL4+aiZF5Ms5WGYSoZLDOLmE=; b=qrX/UyLFdTVjWS K+JRk3qHxCtJTSpdIEt87KW/igSiPkQqeKGu1gJ3i9VjQKiHABOUBT/7aVTLYngSg5rnsAFfcRUfV HcgyI4aM/n+Azudn1s3kkDZI/7xNJKPNfzw8DIae7UASRTlbrHVm5rM3wHwW7VwhyV/LOuj+h3XOt TqXs0QzdBUi6ybnIA9lp9b23DLkWE1OhB0q6OyKwqUJl9AiRrUkcHWisFPKYedB17zIudLP7NgJlX Sh9JPxSvlUVx15Qi5KrT9/nvZwgHNW44yslG/HuB5Lxl1pc3zG21UY/rGhvbHY8XkMH6K8/vm5fCw o6CghadkBd26DP0NGGgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrL-00000005Qdn-2K8R; Sat, 20 Jul 2024 17:27:03 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrF-00000005QYo-1Qtv for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:26:59 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 523E661173; Sat, 20 Jul 2024 17:26:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFB94C2BD10; Sat, 20 Jul 2024 17:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496415; bh=4mfzfBuI5w4GYD/fit9dlYuOHBy27wsKPXlA84/NLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZRNKnrrt4f/JLNrILzEZrulIdE1aK+z6WCFBcwfHrbArWJN0twEMJCpU2bLeGbAI NtpPhOx7V1C0D9fA69dZVbLiLHFmCxJ5XrRFZMsmLaxQGrA/WxoMrFqj8BKRTUGYD+ BRk/DejhE0/KW2u1qtzZ2BIAbH70++8IIqJkge0xK7HFDllRajPwGv6CEEHMi9tvjF S4oadAj6SUTqlcoF7aj0zCQk1g6xQ6mZ2SFJYhul9K4/0De+LJFXDR6TIYG8ggc/sm W8n7CfwJBgEp0qrbvT80b1o9fj1o6y1mU7tlpnJMFuU1END+IPmxoIO5u85qNsuaU+ HNaox/Kg5Uwpg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] riscv: convert bottom half of exception handling to C Date: Sun, 21 Jul 2024 01:12:28 +0800 Message-ID: <20240720171232.1753-4-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102657_556629_46AA2333 X-CRM114-Status: GOOD ( 21.96 ) 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 For readability, maintainability and future scalability, convert the bottom half of the exception handling to C. Mostly the assembly code is converted to C in a relatively straightforward manner. However, there are two modifications I need to mention: 1. the cause I.E the CSR_CAUSE value is passed to do_traps() via. 2nd param, do_traps() doesn't get it from pt_regs because this way an extra memory load is needed, the exception handling sits in hot code path, every instruction matters. 2.To cope with SIFIVE_CIP_453 errata, it looks like we don't need alternative mechanism any more after the asm->c conversion. Just replace the excp_vect_table two entries. Signed-off-by: Jisheng Zhang --- arch/riscv/errata/sifive/errata.c | 25 ++++++++--- arch/riscv/include/asm/asm-prototypes.h | 1 + arch/riscv/include/asm/errata_list.h | 5 +-- arch/riscv/kernel/entry.S | 57 +------------------------ arch/riscv/kernel/traps.c | 37 ++++++++++++++++ 5 files changed, 61 insertions(+), 64 deletions(-) diff --git a/arch/riscv/errata/sifive/errata.c b/arch/riscv/errata/sifive/errata.c index 716cfedad3a2..bbba99f207ca 100644 --- a/arch/riscv/errata/sifive/errata.c +++ b/arch/riscv/errata/sifive/errata.c @@ -10,9 +10,14 @@ #include #include #include +#include #include #include +extern void (*excp_vect_table[])(struct pt_regs *regs); +extern void sifive_cip_453_insn_fault_trp(struct pt_regs *regs); +extern void sifive_cip_453_page_fault_trp(struct pt_regs *regs); + struct errata_info_t { char name[32]; bool (*check_func)(unsigned long arch_id, unsigned long impid); @@ -20,6 +25,9 @@ struct errata_info_t { static bool errata_cip_453_check_func(unsigned long arch_id, unsigned long impid) { + if (!IS_ENABLED(CONFIG_ERRATA_SIFIVE_CIP_453)) + return false; + /* * Affected cores: * Architecture ID: 0x8000000000000007 @@ -51,10 +59,6 @@ static bool errata_cip_1200_check_func(unsigned long arch_id, unsigned long imp } static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = { - { - .name = "cip-453", - .check_func = errata_cip_453_check_func - }, { .name = "cip-1200", .check_func = errata_cip_1200_check_func @@ -62,11 +66,20 @@ static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = { }; static u32 __init_or_module sifive_errata_probe(unsigned long archid, - unsigned long impid) + unsigned long impid, + unsigned int stage) { int idx; u32 cpu_req_errata = 0; + if (stage == RISCV_ALTERNATIVES_BOOT) { + if (IS_ENABLED(CONFIG_MMU) && + errata_cip_453_check_func(archid, impid)) { + excp_vect_table[EXC_INST_ACCESS] = sifive_cip_453_insn_fault_trp; + excp_vect_table[EXC_INST_PAGE_FAULT] = sifive_cip_453_page_fault_trp; + } + } + for (idx = 0; idx < ERRATA_SIFIVE_NUMBER; idx++) if (errata_list[idx].check_func(archid, impid)) cpu_req_errata |= (1U << idx); @@ -99,7 +112,7 @@ void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end, if (stage == RISCV_ALTERNATIVES_EARLY_BOOT) return; - cpu_req_errata = sifive_errata_probe(archid, impid); + cpu_req_errata = sifive_errata_probe(archid, impid, stage); for (alt = begin; alt < end; alt++) { if (alt->vendor_id != SIFIVE_VENDOR_ID) diff --git a/arch/riscv/include/asm/asm-prototypes.h b/arch/riscv/include/asm/asm-prototypes.h index cd627ec289f1..c6691e9032dd 100644 --- a/arch/riscv/include/asm/asm-prototypes.h +++ b/arch/riscv/include/asm/asm-prototypes.h @@ -55,5 +55,6 @@ DECLARE_DO_ERROR_INFO(do_trap_break); asmlinkage void handle_bad_stack(struct pt_regs *regs); asmlinkage void do_page_fault(struct pt_regs *regs); asmlinkage void do_irq(struct pt_regs *regs); +asmlinkage void do_traps(struct pt_regs *regs, unsigned long cause); #endif /* _ASM_RISCV_PROTOTYPES_H */ diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h index 7c8a71a526a3..95b79afc4061 100644 --- a/arch/riscv/include/asm/errata_list.h +++ b/arch/riscv/include/asm/errata_list.h @@ -17,9 +17,8 @@ #endif #ifdef CONFIG_ERRATA_SIFIVE -#define ERRATA_SIFIVE_CIP_453 0 -#define ERRATA_SIFIVE_CIP_1200 1 -#define ERRATA_SIFIVE_NUMBER 2 +#define ERRATA_SIFIVE_CIP_1200 0 +#define ERRATA_SIFIVE_NUMBER 1 #endif #ifdef CONFIG_ERRATA_THEAD diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index 81dec627a8d4..37c3c2068fef 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -83,36 +83,10 @@ SYM_CODE_START(handle_exception) /* Load the kernel shadow call stack pointer if coming from userspace */ scs_load_current_if_task_changed s5 -#ifdef CONFIG_RISCV_ISA_V_PREEMPTIVE - move a0, sp - call riscv_v_context_nesting_start -#endif move a0, sp /* pt_regs */ - - /* - * MSB of cause differentiates between - * interrupts and exceptions - */ - bge s4, zero, 1f - - /* Handle interrupts */ - call do_irq + move a1, s4 /* cause */ + call do_traps j ret_from_exception -1: - /* Handle other exceptions */ - slli t0, s4, RISCV_LGPTR - la t1, excp_vect_table - la t2, excp_vect_table_end - add t0, t1, t0 - /* Check if exception code lies within bounds */ - bgeu t0, t2, 3f - REG_L t1, 0(t0) -2: jalr t1 - j ret_from_exception -3: - - la t1, do_trap_unknown - j 2b SYM_CODE_END(handle_exception) ASM_NOKPROBE(handle_exception) @@ -329,33 +303,6 @@ SYM_FUNC_START(__switch_to) ret SYM_FUNC_END(__switch_to) -#ifndef CONFIG_MMU -#define do_page_fault do_trap_unknown -#endif - - .section ".rodata" - .align LGREG - /* Exception vector table */ -SYM_DATA_START_LOCAL(excp_vect_table) - RISCV_PTR do_trap_insn_misaligned - ALT_INSN_FAULT(RISCV_PTR do_trap_insn_fault) - RISCV_PTR do_trap_insn_illegal - RISCV_PTR do_trap_break - RISCV_PTR do_trap_load_misaligned - RISCV_PTR do_trap_load_fault - RISCV_PTR do_trap_store_misaligned - RISCV_PTR do_trap_store_fault - RISCV_PTR do_trap_ecall_u /* system call */ - RISCV_PTR do_trap_ecall_s - RISCV_PTR do_trap_unknown - RISCV_PTR do_trap_ecall_m - /* instruciton page fault */ - ALT_PAGE_FAULT(RISCV_PTR do_page_fault) - RISCV_PTR do_page_fault /* load page fault */ - RISCV_PTR do_trap_unknown - RISCV_PTR do_page_fault /* store page fault */ -SYM_DATA_END_LABEL(excp_vect_table, SYM_L_LOCAL, excp_vect_table_end) - #ifndef CONFIG_MMU SYM_DATA_START(__user_rt_sigreturn) li a7, __NR_rt_sigreturn diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 3d1f84cb6eac..3eaa7c72f2be 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -390,6 +390,43 @@ asmlinkage void noinstr do_irq(struct pt_regs *regs) irqentry_exit(regs, state); } +void (*excp_vect_table[])(struct pt_regs *regs) __ro_after_init = { + do_trap_insn_misaligned, /* 0 Instruction address misaligned */ + do_trap_insn_fault, /* 1 Instruction access fault */ + do_trap_insn_illegal, /* 2 Illegal instruction */ + do_trap_break, /* 3 Breakpoint */ + do_trap_load_misaligned, /* 4 Load address misaligned */ + do_trap_load_fault, /* 5 Load access fault */ + do_trap_store_misaligned, /* 6 Store/AMO address misaligned */ + do_trap_store_fault, /* 7 Store/AMO access fault */ + do_trap_ecall_u, /* 8 Environment call from U-mode */ + do_trap_ecall_s, /* 9 Environment call from S-mode */ + do_trap_unknown, /* 10 Reserved */ + do_trap_ecall_m, /* 11 Environment call from M-mode */ +#ifdef CONFIG_MMU + do_page_fault, /* 12 Instruciton page fault */ + do_page_fault, /* 13 Load page fault */ + do_trap_unknown, /* 14 Reserved */ + do_page_fault, /* 15 Store/AMO page fault */ +#endif +}; + +asmlinkage void noinstr do_traps(struct pt_regs *regs, unsigned long cause) +{ +#ifdef CONFIG_RISCV_ISA_V_PREEMPTIVE + riscv_v_context_nesting_start(regs); +#endif + if (cause & CAUSE_IRQ_FLAG) { + do_irq(regs); + } else { + if (cause >= ARRAY_SIZE(excp_vect_table)) { + do_trap_unknown(regs); + return; + } + excp_vect_table[cause](regs); + } +} + #ifdef CONFIG_GENERIC_BUG int is_valid_bugaddr(unsigned long pc) { From patchwork Sat Jul 20 17:12:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737859 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 22F0EC3DA7E for ; Sat, 20 Jul 2024 17:27:07 +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=NT7lom85bM9Db7ddOVM/2AiuoCAJ6NNI42X3LowZyuc=; b=H8lvpLrKBGU3UN oHvG4aNCu53tlUf4CYtfv3SNZNeZqV4l63udzG0E/7mWUDZ7+3R8lbkI09TNjOHuKi9kpSKVxBaMO h8UNfHlQbDKdBs5X+kGoKim6UnN2tbod3tEA02UWT0OZeRQrg4x37TdpGyR1gn+qfEV6KYTdY7MPP AUGrF5TKXHKuOo5gkOipYAvLIe72oh4F7+TCium+O96bmYgFtOTem9QxiTkNaDgEV4letA/jLVYYQ gvAOq1lsDyL5oEia3EL+2jYZ6otP8zKduvvxv2rOlvDEoyMsIpnUlq+Ty3EoPqSLfzIkN04KI1CEx 1//WjrIMwNyxOf8di9ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrM-00000005Qes-3M4l; Sat, 20 Jul 2024 17:27:04 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrG-00000005QZY-0k21 for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:27:00 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6DA4C61171; Sat, 20 Jul 2024 17:26:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EA31C4AF0F; Sat, 20 Jul 2024 17:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496417; bh=PS9GETIFotMXHbuFrtVxV4bYZ42Bdzp9+Zn0gjyOdnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s/rP/PyGYs4PM91YBMl0YbrBayzt4Kt/jSe62G6momR9f39KhwggHvETfJRuFWbjb lrmjhNUkFw6spRPMkBRpQpY1mSdm04chjCkZcA4Ug5ONjd1NJn+uQUdHQ5TpVNALeL Ajogh2zDCPgwIxQ0zebSHVrDSUSX7EiFqgsWuNViCda7BwUn+bJOSKOo1ZhEx0Q9Hl bhMTwUjyww2Y3zktoq7+ABmGksGl/86pifrZvxVYHIDQmxIbHj910AlLeCxyTrlvZc F/kFUngUxFt+iAZZsOTOuaybDumo7n1kDhed5stC1a5zPZtbKjSSxkYnGB2cEcCK8t AYdeziyZy0pxA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] riscv: errata: remove ALT_INSN_FAULT and ALT_PAGE_FAULT Date: Sun, 21 Jul 2024 01:12:29 +0800 Message-ID: <20240720171232.1753-5-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102658_299798_0962A872 X-CRM114-Status: UNSURE ( 8.86 ) X-CRM114-Notice: Please train this message. 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 They are used for SIFIVE_CIP_453 errata, which has been solved by replacing the excp_vect_table[] two entries in last commit. So these two macros are useless now, remove them. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/errata_list.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h index 95b79afc4061..46bf00c4a57a 100644 --- a/arch/riscv/include/asm/errata_list.h +++ b/arch/riscv/include/asm/errata_list.h @@ -27,21 +27,7 @@ #define ERRATA_THEAD_NUMBER 2 #endif -#ifdef __ASSEMBLY__ - -#define ALT_INSN_FAULT(x) \ -ALTERNATIVE(__stringify(RISCV_PTR do_trap_insn_fault), \ - __stringify(RISCV_PTR sifive_cip_453_insn_fault_trp), \ - SIFIVE_VENDOR_ID, ERRATA_SIFIVE_CIP_453, \ - CONFIG_ERRATA_SIFIVE_CIP_453) - -#define ALT_PAGE_FAULT(x) \ -ALTERNATIVE(__stringify(RISCV_PTR do_page_fault), \ - __stringify(RISCV_PTR sifive_cip_453_page_fault_trp), \ - SIFIVE_VENDOR_ID, ERRATA_SIFIVE_CIP_453, \ - CONFIG_ERRATA_SIFIVE_CIP_453) -#else /* !__ASSEMBLY__ */ - +#ifndef __ASSEMBLY__ #define ALT_SFENCE_VMA_ASID(asid) \ asm(ALTERNATIVE("sfence.vma x0, %0", "sfence.vma", SIFIVE_VENDOR_ID, \ ERRATA_SIFIVE_CIP_1200, CONFIG_ERRATA_SIFIVE_CIP_1200) \ From patchwork Sat Jul 20 17:12:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737860 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 912D7C3DA64 for ; Sat, 20 Jul 2024 17:27:08 +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=rxb6P9bniuqAdyOtJaqZylvciMnU1o4oBPBRXpgEm5k=; b=P/uVFKQaSMvf5G C/B0DOl94QrWXtjSoyocltV4XYxwoTjHzTkKAMb1+KXogfpNKXKetBgq7Wp9fTSPzWOQ/L6O31ru6 srXX5qr+ZyXoRCH6kA/+KqFKXBCwtQOQyznVzJ+lHVn+EsUntAQYFyXvsVwdySxX6a2SGscK8E98p 7CSVNfwrCFrOy3UsxhAVu/dMV9v767CNV8SPhWkg6Y0IgNahtH9/Jacz3tkjsDgFBTybzGTe5iGq9 MTcpBWYkuR3WCuwk/EBgrf56zva+trd6ulyFrcfhEW1/XF75ogxz0kVuoxQD3WvvZMbVWvy+L0+qL u/fGXwv6nm5CV6imwRVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrO-00000005Qfu-0JNa; Sat, 20 Jul 2024 17:27:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrI-00000005QaW-0fUU for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:27:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 34B6D61168; Sat, 20 Jul 2024 17:26:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84504C4AF0A; Sat, 20 Jul 2024 17:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496419; bh=Xt3rus8MTwutIvQ5H763TfjQNRRFpnqcC5IzkxuWKNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QihgeSnvf2PG6PDvXw42EUn9W2Oi9atxy4Nf7WqIlvZyRTC4qpgDd43bxadaHLI8o G7TVwBqzG9gC9FOAqBErLA9cR1tph4INUWAYs/GaWoQuthn76MwevRLw+oBVXpxsYw QI8kpRYJGwRWvkACHfZtzQ5N7F9OMML+EPWNft5t3UUI9MSAaWT9SLH6EcfTXgX2jn eTqRuMFQtySTtIJP/MeDVsb6yVHCFN6iTkA5CWHMn01XwPx6IA1DAjrZFPRwvVd+ct gfkP4W7c3SC+BZ+aASXMRVuewUoo2jvRede2Xbp+Q3R2VxVuw8qaED7MjWaDz1pip3 YBG1UIfA5btfQ== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] riscv: errata: sifive: remove NOMMU handling Date: Sun, 21 Jul 2024 01:12:30 +0800 Message-ID: <20240720171232.1753-6-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102700_302805_71ACFEEC X-CRM114-Status: UNSURE ( 6.62 ) X-CRM114-Notice: Please train this message. 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 Since NOMMU is now properly handling in generic do_traps() which will call do_trap_unknown() for instruciton page fault for NOMMU. Signed-off-by: Jisheng Zhang --- arch/riscv/errata/sifive/errata_cip_453.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/riscv/errata/sifive/errata_cip_453.S b/arch/riscv/errata/sifive/errata_cip_453.S index b1f7b636fe9a..6f004a1610f6 100644 --- a/arch/riscv/errata/sifive/errata_cip_453.S +++ b/arch/riscv/errata/sifive/errata_cip_453.S @@ -23,11 +23,7 @@ SYM_FUNC_START(sifive_cip_453_page_fault_trp) ADD_SIGN_EXT a0, t0, t1 -#ifdef CONFIG_MMU la t0, do_page_fault -#else - la t0, do_trap_unknown -#endif jr t0 SYM_FUNC_END(sifive_cip_453_page_fault_trp) From patchwork Sat Jul 20 17:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737862 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 13410C3DA49 for ; Sat, 20 Jul 2024 17:27:13 +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=EQJPGLeH6Jqm6t5g3lqk8un0hiW6O70RT6Z7CP7BKLs=; b=Vdmn3LO00frYNp lQmizd3hyLjVPcOrUIdd4TM98z+9g5j/31r7fE+MpA+RxDsRuTj5MdHWyoRAy6QREM3nNJc6/NWOS /FvUUHj9l7LyqTE7Ym77EdJ0j4P6YiFXNLcAQ9IUNKZsMkOZsk344CnEEhFIFm+j+VqspiM/OySct fpi5lNkcVdnOXS3uupODUV/cRNJrB/x34iVMIsQFkXzGh1Q+Mi78jD9Qcz4FLpylpEuc/Qr+wrlDG r9AJdq8m/WXhYig0Nm6sGbD0x/WZ28Iu+fE/A3UmfQD12e85BI3Dr2Dt38WzKQQ6p1LmqVBtaNYgA Psy0iDZpBOUh/L4Tzg2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrR-00000005Qhk-0wom; Sat, 20 Jul 2024 17:27:09 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrK-00000005Qbq-03IM for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:27:03 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 29AF161180; Sat, 20 Jul 2024 17:27:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AE32C4AF0A; Sat, 20 Jul 2024 17:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496421; bh=Y6v1+nAyzX6PLWXUQO4fYkr+VRI6pL0daNUbphTp9Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mo1NidTgWe4gaqa1uhLGqnaHg5Lw0GfB7cXA2DLf78lDSt9LMzySiZAzXFuGsfTu9 FDnJOOoFjIyPazatV3Ug8h0PqPHAkHPAcbvSGjrokipmTMPAQPnsJNRxgmP9G3jtKp MIKNSf0+s9SB+anrQYQRRYASrqCfnBEjAQRZiEeXxxfhsWctjs48eSrv2aVoiQNa/z 5dWVUwW5P89QqGsHHrOtoPHWxsR2Hhz7Hfzc2PYU4YNM+wPvG7RrCNXi5myMqD4Q1T DoGnsRlzagv7bVnSzB5Yv4w0Mbd7pmz1IgPTotQOcVwqR/3+BHuCm5OYoOX91TtLSn Hdvj0BPDY6Ofg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] riscv: staticalize and remove asmlinkage from updated functions Date: Sun, 21 Jul 2024 01:12:31 +0800 Message-ID: <20240720171232.1753-7-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102702_301731_7859452F X-CRM114-Status: GOOD ( 10.61 ) 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 Now that the callers of these functions have moved into C, they are only called in trap.c and no longer need the asmlinkage annotation. So make them static and remove asmlinkage from them. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/asm-prototypes.h | 19 +------------------ arch/riscv/kernel/kernel_mode_vector.c | 2 +- arch/riscv/kernel/traps.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/arch/riscv/include/asm/asm-prototypes.h b/arch/riscv/include/asm/asm-prototypes.h index c6691e9032dd..067e93e3b400 100644 --- a/arch/riscv/include/asm/asm-prototypes.h +++ b/arch/riscv/include/asm/asm-prototypes.h @@ -31,30 +31,13 @@ void xor_regs_5_(unsigned long bytes, unsigned long *__restrict p1, const unsigned long *__restrict p5); #ifdef CONFIG_RISCV_ISA_V_PREEMPTIVE -asmlinkage void riscv_v_context_nesting_start(struct pt_regs *regs); +void riscv_v_context_nesting_start(struct pt_regs *regs); asmlinkage void riscv_v_context_nesting_end(struct pt_regs *regs); #endif /* CONFIG_RISCV_ISA_V_PREEMPTIVE */ #endif /* CONFIG_RISCV_ISA_V */ -#define DECLARE_DO_ERROR_INFO(name) asmlinkage void name(struct pt_regs *regs) - -DECLARE_DO_ERROR_INFO(do_trap_unknown); -DECLARE_DO_ERROR_INFO(do_trap_insn_misaligned); -DECLARE_DO_ERROR_INFO(do_trap_insn_fault); -DECLARE_DO_ERROR_INFO(do_trap_insn_illegal); -DECLARE_DO_ERROR_INFO(do_trap_load_fault); -DECLARE_DO_ERROR_INFO(do_trap_load_misaligned); -DECLARE_DO_ERROR_INFO(do_trap_store_misaligned); -DECLARE_DO_ERROR_INFO(do_trap_store_fault); -DECLARE_DO_ERROR_INFO(do_trap_ecall_u); -DECLARE_DO_ERROR_INFO(do_trap_ecall_s); -DECLARE_DO_ERROR_INFO(do_trap_ecall_m); -DECLARE_DO_ERROR_INFO(do_trap_break); - asmlinkage void handle_bad_stack(struct pt_regs *regs); -asmlinkage void do_page_fault(struct pt_regs *regs); -asmlinkage void do_irq(struct pt_regs *regs); asmlinkage void do_traps(struct pt_regs *regs, unsigned long cause); #endif /* _ASM_RISCV_PROTOTYPES_H */ diff --git a/arch/riscv/kernel/kernel_mode_vector.c b/arch/riscv/kernel/kernel_mode_vector.c index 6afe80c7f03a..a6995429ddf5 100644 --- a/arch/riscv/kernel/kernel_mode_vector.c +++ b/arch/riscv/kernel/kernel_mode_vector.c @@ -152,7 +152,7 @@ static int riscv_v_start_kernel_context(bool *is_nested) } /* low-level V context handling code, called with irq disabled */ -asmlinkage void riscv_v_context_nesting_start(struct pt_regs *regs) +void riscv_v_context_nesting_start(struct pt_regs *regs) { int depth; diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 3eaa7c72f2be..dc1bc84cfe15 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -147,7 +147,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, #define __trap_section noinstr #endif #define DO_ERROR_INFO(name, signo, code, str) \ -asmlinkage __trap_section void name(struct pt_regs *regs) \ +static __trap_section void name(struct pt_regs *regs) \ { \ if (user_mode(regs)) { \ irqentry_enter_from_user_mode(regs); \ @@ -167,7 +167,7 @@ DO_ERROR_INFO(do_trap_insn_misaligned, DO_ERROR_INFO(do_trap_insn_fault, SIGSEGV, SEGV_ACCERR, "instruction access fault"); -asmlinkage __trap_section void do_trap_insn_illegal(struct pt_regs *regs) +static __trap_section void do_trap_insn_illegal(struct pt_regs *regs) { bool handled; @@ -198,7 +198,7 @@ asmlinkage __trap_section void do_trap_insn_illegal(struct pt_regs *regs) DO_ERROR_INFO(do_trap_load_fault, SIGSEGV, SEGV_ACCERR, "load access fault"); -asmlinkage __trap_section void do_trap_load_misaligned(struct pt_regs *regs) +static __trap_section void do_trap_load_misaligned(struct pt_regs *regs) { if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); @@ -219,7 +219,7 @@ asmlinkage __trap_section void do_trap_load_misaligned(struct pt_regs *regs) } } -asmlinkage __trap_section void do_trap_store_misaligned(struct pt_regs *regs) +static __trap_section void do_trap_store_misaligned(struct pt_regs *regs) { if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); @@ -294,7 +294,7 @@ static void handle_break(struct pt_regs *regs) die(regs, "Kernel BUG"); } -asmlinkage __trap_section void do_trap_break(struct pt_regs *regs) +static __trap_section void do_trap_break(struct pt_regs *regs) { if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); @@ -311,7 +311,7 @@ asmlinkage __trap_section void do_trap_break(struct pt_regs *regs) } } -asmlinkage __trap_section __no_stack_protector +static __trap_section __no_stack_protector void do_trap_ecall_u(struct pt_regs *regs) { if (user_mode(regs)) { @@ -355,7 +355,7 @@ void do_trap_ecall_u(struct pt_regs *regs) } #ifdef CONFIG_MMU -asmlinkage noinstr void do_page_fault(struct pt_regs *regs) +static noinstr void do_page_fault(struct pt_regs *regs) { irqentry_state_t state = irqentry_enter(regs); @@ -378,7 +378,7 @@ static void noinstr handle_riscv_irq(struct pt_regs *regs) irq_exit_rcu(); } -asmlinkage void noinstr do_irq(struct pt_regs *regs) +static void noinstr do_irq(struct pt_regs *regs) { irqentry_state_t state = irqentry_enter(regs); From patchwork Sat Jul 20 17:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13737861 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 153CDC3DA59 for ; Sat, 20 Jul 2024 17:27:14 +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=Utw4Bt2j5AE9hpsjcAXWbeFXph1wUGyQ51AsSw1LymE=; b=cDuYQUD0dpO9x6 RqGOPR9RyFYPJoH0SZQfCOIxkLonhR/Nm0lz63WW8rmo+uUwMmQHSui+QD9ZzQzMGnwKX0O2o5uMD 1rm7NvjQtXYIl/S3RxvHM1Lf0F7N7bz+GgAz50fKJUiMiTgK2p/STCsBrbURki7Nq2qo87VvcySoe v3Bztolo2dVqttNg3X+RqCSqwIIaeS9Ssl9bIg6cjqlSjX/n/qXomxDkor5WK6Wjm4D5VwOYoNoAT +4iay31fOTWbIaqSD1xdxZ6uNtENzH/Bg24fUpx8g9Pc1Rk42EAPKpQ7rWS46/IWwTC4O2VaosVEW 1wiSd7yqY8MeBXpvujkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrS-00000005Qj0-316g; Sat, 20 Jul 2024 17:27:10 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVDrL-00000005Qdh-3Lc8 for linux-riscv@lists.infradead.org; Sat, 20 Jul 2024 17:27:05 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2439861171; Sat, 20 Jul 2024 17:27:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DCEFC2BD10; Sat, 20 Jul 2024 17:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721496422; bh=8YWEf7rK4+5tGsSPanUmb4XQE9I8vrOKfPCp7u9NCeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Re7GD1nJZkP6/TKDh5zaK6UJbwlRjD13WrXU+U/uWsoCTIPCz+KkS+FWe8qzlMP59 wlaMSl5RD1er1zJPgMqSYWPvsRLTM2wGkplZ1jJf3w9Yv4HlMpoV9jdkNRSlb1bdiS W0Z/iKOvCHmdepNmvdU10tVh0iDJuzMb4asXBIb36F+00MK6omqL5EqD3KHJ3eG9M6 Ib8eUV8z3NHnirkWteJ6P3BCBfD2UasMSk6lEjEzNX/qKJYolpbyxvDk1QsCPgq1jX WZx2mswB0I3ykRY//D+kMEiNz+QxYkm6s7EEKaloqxysN9SlVnZ8impwwvBZnQAzL2 yz5VoNN3s1ktw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Deepak Gupta , Clement Leger Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] riscv: traps: mark do_irq() as __always_inline Date: Sun, 21 Jul 2024 01:12:32 +0800 Message-ID: <20240720171232.1753-8-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240720171232.1753-1-jszhang@kernel.org> References: <20240720171232.1753-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240720_102703_990241_023EFA35 X-CRM114-Status: GOOD ( 10.49 ) 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 Since do_irq() is only called in traps.c, so mark it as __always_inline this will allow the compiler to get rid of the stack setup/tear down code and eliminate a handful of instructions. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index dc1bc84cfe15..030c50cb4e78 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -378,7 +378,7 @@ static void noinstr handle_riscv_irq(struct pt_regs *regs) irq_exit_rcu(); } -static void noinstr do_irq(struct pt_regs *regs) +static __always_inline void do_irq(struct pt_regs *regs) { irqentry_state_t state = irqentry_enter(regs);