From patchwork Tue Mar 30 12:07:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1460006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=h6u3nPZO; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=ZrlqWmvb; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F8pBc5jQfz9sVm for ; Tue, 30 Mar 2021 23:08:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=pNZwsdIFzIpOKW4mElbXwACdRcCyA2L+NDgpJzUrosE=; b=h6u3nPZOKVgUHZ7FUD2bFt7WDl 9LLySoMUYzpYx0l2LNdft/WROMgUppNJx9I+SOjjjYBchc2zPlq4i/B7twWsBpXD3IW0BKsGOb8Vg 5zIfFjWGiC3aO2gbYCt3F9IylzZOEuh+T7EGVsWMMLI3KMWQCTHWRKYDpghDszLJ/mQAyPg6e1G/7 BsnWMVdsnKOpV9W+DkOjbLILIaaRIIh/EsSBHPtMA0TFshqi6ec2X3qGJAtfzUZtO5Emy3Q8VpeMw 98Yzt6R3qJYLPyBWb5mA3gr9NNdH2laIa0Lb4dKj0codH/yPtA0KGc5m+A53XDlBaRW+PHfLPtdpR 5/aR+g7Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRDAh-003eRD-6q; Tue, 30 Mar 2021 12:08:35 +0000 Received: from mail-m965.mail.126.com ([123.126.96.5]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRDAb-003ePn-NT for opensbi@lists.infradead.org; Tue, 30 Mar 2021 12:08:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=iUA6+ Nyom1bz/vB38it7JZZJXeevzWeuVHXeE8Q2ngo=; b=ZrlqWmvbH5NdOXJanvQ/O 805GvdRoeAzZUy8Vli43rUAg4EApEk5lI878PtdCrU19TieGffNjwJWfVMlx/gQf AjjcTs7Yml2oxsHXbtZmUGR01RGcKsHzqC4gVgmtE75cIEUM6BHuqk8DWieScgzT GVqwA/AjCGdMh4k3/Bzvtg= Received: from localhost.localdomain (unknown [120.85.147.252]) by smtp10 (Coremail) with SMTP id NuRpCgDXccK3FGNgj0pOmQ--.6895S2; Tue, 30 Mar 2021 20:08:25 +0800 (CST) From: wxjstz@126.com To: opensbi@lists.infradead.org Cc: anup.patel@wdc.com, Xiang W Subject: [PATCH] firware: optimize the exception exit code Date: Tue, 30 Mar 2021 20:07:35 +0800 Message-Id: <20210330120735.22198-1-wxjstz@126.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: NuRpCgDXccK3FGNgj0pOmQ--.6895S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZF17CryxXr47JryUtr4fKrg_yoW5WrW5pF 90v3ZIkr48t3WF9ry8Ja1UuFWktw4Fgw42kw4kA3WSkw18Ar1rXF4UAr10yFyrWryDGFWY qF1Ivr18CF1agwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zReuWJUUUUU= X-Originating-IP: [120.85.147.252] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi8xllOlpc6G7ujQAAsW X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210330_130831_319588_6087FAF8 X-CRM114-Status: UNSURE ( 8.31 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Xiang W There are two copies of the same abnormal exit code, this patch deletes one Signed-off-by: Xiang W --- firmware/fw_base.S | 24 ++ include/sbi/sbi_trap.h | 2 +- lib/sbi/sbi_trap.c | 5 +++-- 3 files changed, 6 insertions(+), 25 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [123.126.96.5 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Xiang W There are two copies of the same abnormal exit code, this patch deletes one Signed-off-by: Xiang W Reviewed-by: Anup Patel --- firmware/fw_base.S | 24 ++---------------------- include/sbi/sbi_trap.h | 2 +- lib/sbi/sbi_trap.c | 5 +++-- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 2ce3851..c897ed0 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -711,6 +711,7 @@ fw_platform_init: .section .entry, "ax", %progbits .align 3 .globl _trap_handler + .globl _trap_exit _trap_handler: TRAP_SAVE_AND_SETUP_SP_T0 @@ -720,17 +721,6 @@ _trap_handler: TRAP_CALL_C_ROUTINE - TRAP_RESTORE_GENERAL_REGS_EXCEPT_SP_T0 - - TRAP_RESTORE_MEPC_MSTATUS 0 - - TRAP_RESTORE_SP_T0 - - mret - - .section .entry, "ax", %progbits - .align 3 - .globl _trap_exit _trap_exit: add sp, a0, zero @@ -746,6 +736,7 @@ _trap_exit: .section .entry, "ax", %progbits .align 3 .globl _trap_handler_rv32_hyp + .globl _trap_exit_rv32_hyp _trap_handler_rv32_hyp: TRAP_SAVE_AND_SETUP_SP_T0 @@ -755,17 +746,6 @@ _trap_handler_rv32_hyp: TRAP_CALL_C_ROUTINE - TRAP_RESTORE_GENERAL_REGS_EXCEPT_SP_T0 - - TRAP_RESTORE_MEPC_MSTATUS 1 - - TRAP_RESTORE_SP_T0 - - mret - - .section .entry, "ax", %progbits - .align 3 - .globl _trap_exit_rv32_hyp _trap_exit_rv32_hyp: add sp, a0, zero diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index 070d000..0ed10df 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -205,7 +205,7 @@ struct sbi_trap_info { int sbi_trap_redirect(struct sbi_trap_regs *regs, struct sbi_trap_info *trap); -void sbi_trap_handler(struct sbi_trap_regs *regs); +struct sbi_trap_regs* sbi_trap_handler(struct sbi_trap_regs *regs); void __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs); diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index b7349d2..07d5acb 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -210,7 +210,7 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, * * @param regs pointer to register state */ -void sbi_trap_handler(struct sbi_trap_regs *regs) +struct sbi_trap_regs* sbi_trap_handler(struct sbi_trap_regs *regs) { int rc = SBI_ENOTSUPP; const char *msg = "trap handler failed"; @@ -236,7 +236,7 @@ void sbi_trap_handler(struct sbi_trap_regs *regs) msg = "unhandled external interrupt"; goto trap_error; }; - return; + return regs; } switch (mcause) { @@ -271,6 +271,7 @@ void sbi_trap_handler(struct sbi_trap_regs *regs) trap_error: if (rc) sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); + return regs; } typedef void (*trap_exit_t)(const struct sbi_trap_regs *regs);