From patchwork Sun Mar 17 13:02:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1912907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wMzx4Lru; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=c5zH76FQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TyJ7Y49TZz23sC for ; Mon, 18 Mar 2024 00:03:04 +1100 (AEDT) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CJzRpl6N5sWjnCbMvSKqJQtFX+IYcBx7Hj67rTz9cP0=; b=wMzx4LruFQ9t1r 71JpEy1/OEcBvDPRg6A9QIYpThYNCsWsxpP8sKy0KqN+KFhGjCjI/fO3+6CSC3vVFVIFVENqaPfHL 2luCconn+A0a/77ayQl7lqvMBgSA40m2YN9GMSwP80f6BVXJW/zvaiYNBEK/iRjR5OIBzt2KlI0RX hwLKZVSrDEHPdnrjjNa2iGRsCG8mFXcEeXzcSxto5ZL8qEpqweS4BrTokmfv4A4C3MSzHsKjvCZT5 yfOcjf0BwfhzluoFhF2q2FPTVedCNwcNA7Rp2jmJlvdWlPizaTGrQCJLiew51v6AwPmMNa38XAfzI k/K2Xrg+x7NCJgBPkhng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlqAC-00000005E4V-1JIT; Sun, 17 Mar 2024 13:02:56 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlqA7-00000005E2a-0dck for opensbi@lists.infradead.org; Sun, 17 Mar 2024 13:02:54 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5a4a14c52fcso303598eaf.1 for ; Sun, 17 Mar 2024 06:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710680569; x=1711285369; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iLrSFgY9VXYzINWgHm0nlMeDcnPIpT4eDYoRFB0DZYs=; b=c5zH76FQVWnsu2+RVGeb384J+Xwwld9iMr9WjHkclEfhlGmJMZ+f7jk8jVM7R/hSH9 Nh2yDe+zF+7xX12r5zmOnxKcfu2jGzS0sOsy9BFI0CoxLolbP076VSLwl8RWH+AJnZLm q6MpnV1AImMo/8r9cqOT4V37bh/fGH97WcpTek2dB9+YPU/rRFjQVibI84TVdUR5ufYB S6zZMmAvEkys0+YfLr2P0NkUbLJKZW2swDlok6rJVQ/Xn0m2u1tyJ2zC/dq2ptzBg19w 1jzUs6i5HMN/k/yUDN9O48UiveGnJfixcoxh1UvTN488EhUhLT0MUL4U2YAz1wl5YoC5 GRZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710680569; x=1711285369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iLrSFgY9VXYzINWgHm0nlMeDcnPIpT4eDYoRFB0DZYs=; b=e9NwP1XjtZPedZyka9auxWi918G8R8RK9YTVmhZjXkevmvnNnNiy6EZve3SNs0wLVV MN2A4H0FlGFGXe4YW54UDFPl1mIgB0HfTNMnnrq50Hcaefz+uZfSujDIsxNrLXEe5s2h vT3hpHXg8UHvWSnWf/aZjWEcfsVEwEN9kx87c9pjeH+e0sW6aUY16SHLgu/2rjGbvKcc xrfIWvUPMjldF75c0g9pFAPy8/HX75JdPL3Cqb8j3uYvun5IRwOFdZzfFkABeIyNzjr5 5rYvuASZMdeqCq4gxt05JsYoVJwVZ0VGrMi/X5/Kc/96ghtqPo8dVKbBmF9Pc6wxctXr lQ2Q== X-Forwarded-Encrypted: i=1; AJvYcCVghVtiYHSXEqVl+Hlyjm2EtQqUoG7usDIbNns7wGCIQvEyrYxf7vHZVJPwYXGVQX02xSMS/m0qtkauv5xW8QjPUN3e1EWDcnu5QHo= X-Gm-Message-State: AOJu0Yy0Lp8/RHsyQ9ikc70EKIYJUKqycKQMjxW+e52YbFnanhyetbE+ 0EdJ4DE8HDj7QZxJgkaxsDHqRgLqiSknHs86WQIDBGK+aisoaEMxqt3oWKhnwi8= X-Google-Smtp-Source: AGHT+IHwdsVXlJYXj6MvMzd8UzvprMupypopb+Ej1Jd3bgZxvJQN/oU9ICix85LRocY7A+LWClqapA== X-Received: by 2002:a05:6808:118b:b0:3c2:3109:7574 with SMTP id j11-20020a056808118b00b003c231097574mr9139852oil.20.1710680569477; Sun, 17 Mar 2024 06:02:49 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id cc12-20020a056808324c00b003c37ccb47c1sm613103oib.51.2024.03.17.06.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 06:02:49 -0700 (PDT) From: Anup Patel To: Atish Patra Subject: [PATCH v3 02/10] lib: sbi: Remove sbi_trap_exit() and related code Date: Sun, 17 Mar 2024 18:32:23 +0530 Message-Id: <20240317130231.1705888-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240317130231.1705888-1-apatel@ventanamicro.com> References: <20240317130231.1705888-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240317_060251_223628_4E9162B7 X-CRM114-Status: GOOD ( 11.58 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.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: Over the years, no uses of sbi_trap_exit() have been found so remove it and also remove related code from fw_base.S and sbi_scratch.h. Signed-off-by: Anup Patel Reviewed-by: Samuel Holland Tested-by: Samuel Holland --- firmware/fw_base.S | 11 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:c32 listed in] [list.dnswl.org] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org, Andrew Jones Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Over the years, no uses of sbi_trap_exit() have been found so remove it and also remove related code from fw_base.S and sbi_scratch.h. Signed-off-by: Anup Patel Reviewed-by: Samuel Holland Tested-by: Samuel Holland --- firmware/fw_base.S | 11 ----------- include/sbi/sbi_scratch.h | 15 +++------------ include/sbi/sbi_trap.h | 2 -- lib/sbi/sbi_trap.c | 19 ------------------- 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 126b067..c404d8b 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -298,9 +298,6 @@ _scratch_init: /* Store hartid-to-scratch function address in scratch space */ lla a4, _hartid_to_scratch REG_S a4, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET(tp) - /* Store trap-exit function address in scratch space */ - lla a4, _trap_exit - REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(tp) /* Clear tmp0 in scratch space */ REG_S zero, SBI_SCRATCH_TMP0_OFFSET(tp) /* Store firmware options in scratch space */ @@ -453,10 +450,6 @@ _start_warm: srli a5, a5, ('H' - 'A') andi a5, a5, 0x1 beq a5, zero, _skip_trap_handler_rv32_hyp - /* Override trap exit for H-extension */ - csrr a5, CSR_MSCRATCH - lla a4, _trap_exit_rv32_hyp - REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(a5) lla a4, _trap_handler_rv32_hyp _skip_trap_handler_rv32_hyp: #endif @@ -695,7 +688,6 @@ memcmp: .section .entry, "ax", %progbits .align 3 .globl _trap_handler - .globl _trap_exit _trap_handler: TRAP_SAVE_AND_SETUP_SP_T0 @@ -705,7 +697,6 @@ _trap_handler: TRAP_CALL_C_ROUTINE -_trap_exit: TRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0 TRAP_RESTORE_MEPC_MSTATUS 0 @@ -718,7 +709,6 @@ _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 @@ -728,7 +718,6 @@ _trap_handler_rv32_hyp: TRAP_CALL_C_ROUTINE -_trap_exit_rv32_hyp: TRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0 TRAP_RESTORE_MEPC_MSTATUS 1 diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index e6a33ba..55b937f 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -36,14 +36,12 @@ #define SBI_SCRATCH_PLATFORM_ADDR_OFFSET (9 * __SIZEOF_POINTER__) /** Offset of hartid_to_scratch member in sbi_scratch */ #define SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET (10 * __SIZEOF_POINTER__) -/** Offset of trap_exit member in sbi_scratch */ -#define SBI_SCRATCH_TRAP_EXIT_OFFSET (11 * __SIZEOF_POINTER__) /** Offset of tmp0 member in sbi_scratch */ -#define SBI_SCRATCH_TMP0_OFFSET (12 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_TMP0_OFFSET (11 * __SIZEOF_POINTER__) /** Offset of options member in sbi_scratch */ -#define SBI_SCRATCH_OPTIONS_OFFSET (13 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_OPTIONS_OFFSET (12 * __SIZEOF_POINTER__) /** Offset of extra space in sbi_scratch */ -#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (14 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (13 * __SIZEOF_POINTER__) /** Maximum size of sbi_scratch (4KB) */ #define SBI_SCRATCH_SIZE (0x1000) @@ -77,8 +75,6 @@ struct sbi_scratch { unsigned long platform_addr; /** Address of HART ID to sbi_scratch conversion function */ unsigned long hartid_to_scratch; - /** Address of trap exit function */ - unsigned long trap_exit; /** Temporary storage */ unsigned long tmp0; /** Options for OpenSBI library */ @@ -129,11 +125,6 @@ _Static_assert( == SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET, "struct sbi_scratch definition has changed, please redefine " "SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET"); -_Static_assert( - offsetof(struct sbi_scratch, trap_exit) - == SBI_SCRATCH_TRAP_EXIT_OFFSET, - "struct sbi_scratch definition has changed, please redefine " - "SBI_SCRATCH_TRAP_EXIT_OFFSET"); _Static_assert( offsetof(struct sbi_scratch, tmp0) == SBI_SCRATCH_TMP0_OFFSET, diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index 3757694..a6032ab 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -225,8 +225,6 @@ int sbi_trap_redirect(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); - #endif #endif diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index c9db73f..b059c4b 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -334,22 +334,3 @@ trap_error: sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); return regs; } - -typedef void (*trap_exit_t)(const struct sbi_trap_regs *regs); - -/** - * Exit trap/interrupt handling - * - * This function is called by non-firmware code to abruptly exit - * trap/interrupt handling and resume execution at context pointed - * by given register state. - * - * @param regs pointer to register state - */ -void __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs) -{ - struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); - - ((trap_exit_t)scratch->trap_exit)(regs); - __builtin_unreachable(); -}