From patchwork Mon Mar 11 16:09:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910503 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=XWhXluEo; 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=gPN11k9t; 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 4TthZG6r29z1yWy for ; Tue, 12 Mar 2024 03:10:14 +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: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=w4oyvLgP3GmLZCETOz+EUtZvg8TubgTw1pWDiYnSZGQ=; b=XWhXluEo8kJZbc VCKUC+vbq1leUJALeVfx5gEGqK8kSoUjYmdtzrCQ2i9y2JTkO+032h/kVWqw2y6yoTjfi21cTT6SI kFKsmWTaPZsjnVqGcgfbpJ2k6XPfJeywvsWk0N3ErbBALJw/xJD32bgiSff7eA6clCVEw2lkLozj4 EJeRgzKaKwdZPf65jBQ5D9tn3VH/GzO1XAZQO5634SoaybOkAmujcJsttZNWEbOeKigSZ6vFuo5oG lrS4QNDWCSiRG2/8jl2aCUGOaa1IyKsmnGcbnggybOlZhVvtsLXC37fAVGL4FG7XHcEZPNqrfshmp sY6dtmoeitlbENC8jrMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE3-00000002Dto-0vgG; Mon, 11 Mar 2024 16:10:07 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE0-00000002DsH-0yO5 for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:05 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5a1d83a86e8so1049782eaf.0 for ; Mon, 11 Mar 2024 09:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173401; x=1710778201; 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=FxweAyo6WyQxWXV4M5Otp1S+I4wnm/AdTpH5jCXrarc=; b=gPN11k9tHTGB8+ZHRI3cphPZLNdJCuPdL0deuHXWSvBKPTXGA7kmQjWErB9f5LDA1B rgfq2AQcI9YoH25CsjsG0uh3Ms6+OhIx8w78w2d3GJhewn2eycMY7r5V20aqP10kUM3t Pge5oHPbPvAjz1H48s/NqVNai9Ojf1/vkWiRWgxySqeNhjSF42tsbOz28EZQGtnQGGy0 vX3++Vo0thg+ziB/KGY09NC6kzkveWSP4ARV/uwpInXFpixMpaP6LNfkZnkWZl8BnuvR 4yJo3x8m9MS6k8erf8jZyek8CHPA5H9FdLPyoT/6nxiDG458lLFhGyYwWlkc1chgs4KM F3mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173401; x=1710778201; 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=FxweAyo6WyQxWXV4M5Otp1S+I4wnm/AdTpH5jCXrarc=; b=VLDxJnuMhdK5lu/KfS0EalYfULZrDtyKf1UBGtJ47A+vGHGTJZUK1W/LHkR/zbP+EP GjDks3vYy1aaz+Or0Q2q/NwP9JooSK280XkGJX8QAa+8EGB+IatYE6FQ32fW3AuxTJ2u ITtyzDpEyrY3/st72OIRqVjxQrLkUs4LBQgjzt6Ok7KgXYs/GA1qa8+WhFZS4GUzsYbo 7Wc46lc3pmp4ITMrmEdGBnsP4i5YVf5jwNT/yOMZGw16ZyYnAFjFip59resH0xnpOjH7 vqrlaEC8Ypb5jtdpxy5YIevhPfboeJ6r0HWDTe130f05gP+i78Cmwww1cJx1lFM/y/CH TFSw== X-Forwarded-Encrypted: i=1; AJvYcCX9m3/k3MtVz6AGAZOyILDH7UQbj4zH0DZqvxe3od7rUNaxpvP5PSK3mpQj5yv1hdywrAz/1hmdewj5Jz76xE+pZH8C4DdkMu+kmhs= X-Gm-Message-State: AOJu0Ywa5ktrtGElfwg8wVZ4X8TuswO4lxwXxWDXZLiZJaDSIUIy2mp0 Ro1rFXWWSqhtGlkvWJC7GgI5RxgmLT5wlJL/9jB+dWcUv3MYI70VUj0lZKBED7Y= X-Google-Smtp-Source: AGHT+IFN0bOFB5zI7KkOSMiyJ5q33C8T8tfpqY4pzNq7DfJLFUPwL4pqokTuD1JiYlprVAflWjnH0g== X-Received: by 2002:a4a:9d59:0:b0:5a2:1e76:c884 with SMTP id f25-20020a4a9d59000000b005a21e76c884mr634109ook.9.1710173401466; Mon, 11 Mar 2024 09:10:01 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:01 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 1/9] lib: sbi: Remove sbi_trap_exit() and related code Date: Mon, 11 Mar 2024 21:39:36 +0530 Message-Id: <20240311160944.1233523-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091004_308331_2F8A72C6 X-CRM114-Status: GOOD ( 12.16 ) 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 --- firmware/fw_base.S | 11 include/sbi/sbi_scratch.h | 15 +++ include/sbi/sbi_trap.h | 2 -- lib/sbi/sbi_trap.c | 19 ------- [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:c2c 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: , 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 --- 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 2727bdb..15ccd0b 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -229,8 +229,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 c665013..e514066 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -335,22 +335,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(); -} From patchwork Mon Mar 11 16:09:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910505 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=Cr7gtypR; 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=nanHMOAN; 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 4TthZL5LZKz1yWy for ; Tue, 12 Mar 2024 03:10:18 +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: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=oYTdKY5MlAQ29gO6EyNXIqqKP9QSKI8xdJxsq6YwXiA=; b=Cr7gtypRt/isJf 7qIziWGL4AqfSkL+yLqrNtfwy2dg0XJccKOpyHRVQH+/tapkONOIdCJ0paSBSBE0GJcJKdoVl87O2 4qA4lfJhTjuP9RiNA+KRcaoQZ/gCyF4ycRi6+xHVuZu+jbKfpK1d3zon1fvpgksd8tbVAvPhTWWvi 0qGas+3JKco3v3vxsDAwP8ohy0ulBZaFhiRxoESYyjoJhD7B+GJZG//fe3YYx/ie33RDFEZiPhRtf tuBSE/wjpKRJ5sjkOvZdWeDXj1Uvwd4FfO7gF2OtIRCBhCbTgM+xPX9QTbuOehQ8eSnAWW2K8KyuB 4/h7IIvsYucIYbdBxruw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE6-00000002DwK-3ne0; Mon, 11 Mar 2024 16:10:10 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE4-00000002DtE-0IAv for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:09 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-5a1f24cc010so885235eaf.1 for ; Mon, 11 Mar 2024 09:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173405; x=1710778205; 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=Sm4yl6qAZODlUDfBJsNaieGPFhKCms8KHbUMT1tEYhY=; b=nanHMOANLc+k4lATFnN7kxzIZaFnA8RNGA5DSI3E11nvptRU39Pllgt/L8XRYdoTKx PUFF4jitprqM9Cfwb4oIzOEGg2P7GIiNnVc74dGtQ0bEZ88M9OsyRcycqM3qinD2AG7z Y+hHXqqtsWR9Thz+AW1o+45nCoVvtAAVx7dz64ZYgtRHgBiPeuaZOfZ9Yxy71rz0Aid2 g15pMeb4BZrbhPmgKtujdNK1LwuiltLwGklo7AzOPSneEJAUu0I4eVDPTqtutNQo+B8c FvsKYJIEY1L368scf623GveJId8cmPGs1hz9pWgHbjn43xPEjLo6BBHj4sjEm5UPfaX2 ZwAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173405; x=1710778205; 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=Sm4yl6qAZODlUDfBJsNaieGPFhKCms8KHbUMT1tEYhY=; b=e1xLtXgkSl36qGDFitUIg8MUxmfoFf9IXOGExlv7U8BlgoVZOX1IzrzS8AFN5TQj3F zcD33oboD0deYPS41PLHIxaWRVEReAMLRjumdTpHKpdvT7VOlmxGQnGRK31kA1k+yJcj Jp2g1rzkrtYzUrcszQ1RPYhBt6JIIUWUE359rFovf0mRded71NzMNv82akbaHnbajfKm JLN3qzyPpNjffS9A+L1hK8UsUk1cNMUCwDyjN4FkMsgq0MK/gDVBh2RsgkRv1o22Gs/l fLp40N6qPHGcpINN1oaCuywVmrliRz8DoRzc1KuEj8FGuBl+rwccpxU5sNPPeoIxTWLY M0oQ== X-Forwarded-Encrypted: i=1; AJvYcCUX009TELptBT2DuRXwDtk2FnB+I61TTzZe7rtUgh/9a3RtG+9DNmQ9s3wUJGwVZR4msNN/qkyxdrhnlluAj8m0Z9Gs3+4PSQUBEkI= X-Gm-Message-State: AOJu0Ywtw35xk/wisnW0U7OHRqJzGioaHyS0ZVC0Td0p3Dheqi7iZEPN aBQdR2i6S6Ac1Rs4PIaqT65sQr38uxpENaWW12JOd5heh2f+S05p7XzGjk0tMfk= X-Google-Smtp-Source: AGHT+IGCKO4zc0QTHXlAALjnHlyzEncByHekUwL6JCftoS8k5xhdr3LnEwey48CYZ3wZgDHsSJaJxQ== X-Received: by 2002:a4a:8511:0:b0:5a1:8ca1:ae47 with SMTP id k17-20020a4a8511000000b005a18ca1ae47mr5542399ooh.5.1710173404998; Mon, 11 Mar 2024 09:10:04 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:04 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 2/9] include: sbi: Add trap_context pointer in struct sbi_scratch Date: Mon, 11 Mar 2024 21:39:37 +0530 Message-Id: <20240311160944.1233523-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091008_260732_ACA024BD X-CRM114-Status: GOOD ( 10.63 ) 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: To track nested traps, the struct sbi_scratch needs a pointer the current trap context so add trap_context pointer in struct sbi_context. Signed-off-by: Anup Patel --- firmware/fw_base.S | 3 ++- include/sbi/sbi_scratch.h | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 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 [2607:f8b0:4864:20:0:0:0:c2d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To track nested traps, the struct sbi_scratch needs a pointer the current trap context so add trap_context pointer in struct sbi_context. Signed-off-by: Anup Patel --- firmware/fw_base.S | 3 ++- include/sbi/sbi_scratch.h | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index c404d8b..539fd1d 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -298,7 +298,8 @@ _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) - /* Clear tmp0 in scratch space */ + /* Clear trap_context and tmp0 in scratch space */ + REG_S zero, SBI_SCRATCH_TRAP_CONTEXT_OFFSET(tp) REG_S zero, SBI_SCRATCH_TMP0_OFFSET(tp) /* Store firmware options in scratch space */ MOV_3R s0, a0, s1, a1, s2, a2 diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index 55b937f..12e6a98 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -36,12 +36,14 @@ #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_context member in sbi_scratch */ +#define SBI_SCRATCH_TRAP_CONTEXT_OFFSET (11 * __SIZEOF_POINTER__) /** Offset of tmp0 member in sbi_scratch */ -#define SBI_SCRATCH_TMP0_OFFSET (11 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_TMP0_OFFSET (12 * __SIZEOF_POINTER__) /** Offset of options member in sbi_scratch */ -#define SBI_SCRATCH_OPTIONS_OFFSET (12 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_OPTIONS_OFFSET (13 * __SIZEOF_POINTER__) /** Offset of extra space in sbi_scratch */ -#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (13 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (14 * __SIZEOF_POINTER__) /** Maximum size of sbi_scratch (4KB) */ #define SBI_SCRATCH_SIZE (0x1000) @@ -75,6 +77,8 @@ struct sbi_scratch { unsigned long platform_addr; /** Address of HART ID to sbi_scratch conversion function */ unsigned long hartid_to_scratch; + /** Address of current trap context */ + unsigned long trap_context; /** Temporary storage */ unsigned long tmp0; /** Options for OpenSBI library */ @@ -125,6 +129,11 @@ _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_context) + == SBI_SCRATCH_TRAP_CONTEXT_OFFSET, + "struct sbi_scratch definition has changed, please redefine " + "SBI_SCRATCH_TRAP_CONTEXT_OFFSET"); _Static_assert( offsetof(struct sbi_scratch, tmp0) == SBI_SCRATCH_TMP0_OFFSET, From patchwork Mon Mar 11 16:09:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910506 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=QR0fYPr+; 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=VkOToecQ; 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 4TthZP3B2Yz1yWy for ; Tue, 12 Mar 2024 03:10:21 +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: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=n1bMI+o2sTeJbR71oXTig47AO+Le1gNCljiL2RC8Iqg=; b=QR0fYPr+VKujo9 r74M5xGba8LEB2aUMAFkfY3lvf+pzMesc35ElE90PLL2qJ1V0/ck2A8uv4+D+vhAk2Q1CSjSh/zr9 ndJf5B/JhUzUjvMQqjvgy+9bZz7D/0rUqafZczaKFM/rKwg5iCgIJ43NnvVa02JNZl+swpyFoag5d xBSEB/25VlffAYoV2y4Uqb+mEOJGGZnD/0ADuF3JuB9H+JR9PzlwiYkdh1llJlb68l5nk0KY74/s6 ZsImfPvJBieK6SFUpob8lTqKWT1kqekKQaAtCBKKm+RxqyRpoGIl0MkawKbIInN3GNbJMwRuMn0JW VNkqZpf92h7MsZi7+jPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE9-00000002DyN-3AgA; Mon, 11 Mar 2024 16:10:13 +0000 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE5-00000002Dv6-3hvd for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:11 +0000 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5a1f24cc010so885303eaf.1 for ; Mon, 11 Mar 2024 09:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173408; x=1710778208; 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=P6Cm5jJjxX94GpgWmmc5wWe76qk0G0FsFCea62NZPWs=; b=VkOToecQV0Tq2Ivbqox4zX7xXzT9PtJTDO3wVxDerCk5TpK+GPBTjho9w83l9kaxR/ //BggfoPBOG3VyYC5wEp5X+uviu6Gom4qyeJVLcJ+0ztMB/KAoJ8wA0aeRaE393VkuUZ AyukomIOWuKeEXdIWa9LkROtPZJoQx6eMeSworO6Ougdm9reTR6Dtnoxgw3o9bbSfcfj MuiwPod15aHSb95YUqERYQIBiqUYwkN/8hPZ360vfCETsvLHCc7Isw0ZTtNrVMIYi9u5 8UyTnDXwj70eiIbOk/xJrOOLpyOYRrYZaoHbyYuiiQREPK1l0w6SBP6Ci39FOvwdXvyY 61vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173408; x=1710778208; 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=P6Cm5jJjxX94GpgWmmc5wWe76qk0G0FsFCea62NZPWs=; b=NOdS74pUsz8xtMSS0e1uG3n31/IYMS6FbgaFYvEUcYEmBfX5iIp/Uu8OGAhr4HsFXm fVV33bQhx8ihsqYRj2lHXoK6tBhYa5/bw+8xR7CNdQjig8kXQV0SfZlLDvQhojvRtSHv 1an2KP8zO6bztWTA004iSMO2nUCuou+Jpm9hs5rXYMTPmYdvEdKPVlgcZ8PPp0e+q2Cl WnmJSsaKoGWijcRvYcwy1omHNE6TKtzw/6rWlVjiBjq5NZ/bLIdGVPnj9wfIJnEsdS81 n/wfHmtyY5g6tVbrVi3KbwxLiryXj/i1hAY8H+1aMcXbbwJBhrWzpJBLnhve5AyqiHPL s7ow== X-Forwarded-Encrypted: i=1; AJvYcCVetdx4sJ7+yPY+rigej4JWQnugl+OJCAhxIDbF4fLs/PtekZ1LJjWDLiwYls8VVxgupX2saDicl1MctXK9REQAnVpWabIn1Zifs8Q= X-Gm-Message-State: AOJu0YwyPM4ViSyGHlf7UE7lC0M5sAyVEG2rIF6VevQkiuY5lP6L0lka UUlSB1LarzaOJ54jBJx8Ga6PcnjLWsY8bZKTRWAaCUa4Bf4/2ZRdal/H5Tvqa6g= X-Google-Smtp-Source: AGHT+IHtEMQedPXNM3fIhOYLvk5Pe1xCvtdnoUCRPNi/SX0HjqxHsHhSRT90XPel34DaKXYd3pmnpQ== X-Received: by 2002:a4a:7019:0:b0:5a1:a7b3:3d0 with SMTP id r25-20020a4a7019000000b005a1a7b303d0mr5197093ooc.4.1710173408278; Mon, 11 Mar 2024 09:10:08 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:07 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 3/9] lib: sbi: Introduce trap context Date: Mon, 11 Mar 2024 21:39:38 +0530 Message-Id: <20240311160944.1233523-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091010_038220_BA5AEE5E X-CRM114-Status: GOOD ( 13.39 ) 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: Club pointers to struct sbi_trap_regs and struct sbi_trap_info a new struct sbi_trap_context (aka trap context). To track nested traps, the struct sbi_scratch points to the current trap context and the trap context has pointer to pervious context of previous trap. 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 [2607:f8b0:4864:20:0:0:0:c31 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Club pointers to struct sbi_trap_regs and struct sbi_trap_info a new struct sbi_trap_context (aka trap context). To track nested traps, the struct sbi_scratch points to the current trap context and the trap context has pointer to pervious context of previous trap. Signed-off-by: Anup Patel --- include/sbi/sbi_trap.h | 22 ++++++++++++++++++++++ lib/sbi/sbi_trap.c | 35 ++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index 15ccd0b..513a82e 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -117,6 +117,7 @@ #ifndef __ASSEMBLER__ #include +#include /** Representation of register state at time of trap/interrupt */ struct sbi_trap_regs { @@ -208,6 +209,16 @@ struct sbi_trap_info { unsigned long gva; }; +/** Representation of trap context saved on stack */ +struct sbi_trap_context { + /** Pointer to previous trap context */ + struct sbi_trap_context *prev_context; + /** Pointer to register state */ + struct sbi_trap_regs *regs; + /** Pointer to trap details */ + const struct sbi_trap_info *trap; +}; + static inline unsigned long sbi_regs_gva(const struct sbi_trap_regs *regs) { /* @@ -227,6 +238,17 @@ static inline unsigned long sbi_regs_gva(const struct sbi_trap_regs *regs) int sbi_trap_redirect(struct sbi_trap_regs *regs, const struct sbi_trap_info *trap); +static inline struct sbi_trap_context *sbi_trap_get_context(struct sbi_scratch *scratch) +{ + return (scratch) ? (void *)scratch->trap_context : NULL; +} + +static inline void sbi_trap_set_context(struct sbi_scratch *scratch, + struct sbi_trap_context *tcntx) +{ + scratch->trap_context = (unsigned long)tcntx; +} + struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs); #endif diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index e514066..dba267c 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -266,6 +266,8 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) const char *msg = "trap handler failed"; ulong mcause = csr_read(CSR_MCAUSE); ulong mtval = csr_read(CSR_MTVAL), mtval2 = 0, mtinst = 0; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); + struct sbi_trap_context tcntx; struct sbi_trap_info trap; if (misa_extension('H')) { @@ -273,25 +275,31 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) mtinst = csr_read(CSR_MTINST); } + /* Original trap_info */ + trap.epc = regs->mepc; + trap.cause = mcause; + trap.tval = mtval; + trap.tval2 = mtval2; + trap.tinst = mtinst; + trap.gva = sbi_regs_gva(regs); + + /* Setup trap context */ + tcntx.prev_context = sbi_trap_get_context(scratch); + tcntx.regs = regs; + tcntx.trap = &trap; + + /* Update trap context pointer */ + sbi_trap_set_context(scratch, &tcntx); + if (mcause & (1UL << (__riscv_xlen - 1))) { if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(), SBI_HART_EXT_SMAIA)) rc = sbi_trap_aia_irq(regs, mcause); else rc = sbi_trap_nonaia_irq(regs, mcause); - if (rc) { - msg = "unhandled local interrupt"; - goto trap_error; - } - return regs; + msg = "unhandled local interrupt"; + goto trap_done; } - /* Original trap_info */ - trap.epc = regs->mepc; - trap.cause = mcause; - trap.tval = mtval; - trap.tval2 = mtval2; - trap.tinst = mtinst; - trap.gva = sbi_regs_gva(regs); switch (mcause) { case CAUSE_ILLEGAL_INSTRUCTION: @@ -330,8 +338,9 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) break; } -trap_error: +trap_done: if (rc) sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); + sbi_trap_set_context(scratch, tcntx.prev_context); return regs; } From patchwork Mon Mar 11 16:09:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910507 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=Ri+u3n+j; 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=GYVSe79Z; 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 4TthZV1Fgbz1yWy for ; Tue, 12 Mar 2024 03:10:26 +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: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=CVEjFlDhiCssmHERPLKdE1VAcXdLzFrPNLpldKnauBw=; b=Ri+u3n+jE0gZB0 xxzO3Ol/JAy6RG8j+xmDgfCJ96m6+S/xmGbCDh4msH8r4HzuOhxTbxt1jbxwHhh376BvPUDIH89Fu +8Bm6rRrWTepsOZHEqqqCoMnjVl7sVbgeFzaU0DYRTfz8zpGEVsIRkX4X6MYiTXvEiQ8Pct60sP4I HZq02+WVIILtGpuJc+QnqvaW0SKTfdiPBqcJCSKgaNp1xCnpb1HlFtj3RTHECjPkDpZ3qoKo3k1px FbuMFku0oBBpuf3fsFKOFRIiHjIgC9LtsoumwfTCV0ZmwEv8++bih/VO0gMMgj5zvUQWuURLPcD6h 104xEw1ugaDVw1rTX/Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEC-00000002E0Q-2nJD; Mon, 11 Mar 2024 16:10:16 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiE9-00000002DxC-1gez for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:15 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5a1cbbad6ecso1382613eaf.0 for ; Mon, 11 Mar 2024 09:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173412; x=1710778212; 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=bt9mmTszXG8xEgKccEsILvAibIM7adgxYgqMrbKVEG0=; b=GYVSe79ZVByd/wH3c40gfBoFuq+mfMcRb4EBaKJMQBDnxhXoFUuZybwMlqNFCCtj4/ IiWFwqVtbGwQ3m6lSNlGgox09jbMDLC+bgcGNkSfjMAdAUbz/t5+9JqC+BGZiaR7Jut7 GSaN9I1Aoxgj/Pa3cmR8H56Go9p/g8sD5ZEQ6UZN8RInaqEVg0KigGomIVP6FsvEyaR/ rX/wAKwPBpxQTAmtxbPCd+HVSz7dRiHk8xPaswS3fpWtQJ8XG6waBHnL3/bTfZXGbYgP OdBkBgprobONOy1w9d+qwJ+vDHjbzSG4A4IKXzv4oCXhQ0VSEbgDm0oRqjyaLERAH/Ll VVZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173412; x=1710778212; 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=bt9mmTszXG8xEgKccEsILvAibIM7adgxYgqMrbKVEG0=; b=nLgQkHMUPj9Q2qElNtxQbKXedMl7p3glndrJGpo9b+PntrA8cBgtPAM+dEkZxn5+Cb 3Rzf9NrlKe/UIqtbqy3zZ8m0PGYadnaf0pflz/izVxo+Zm5pob5dRwbll+mEvAaCMLg9 OjwjHEBaqNbU35xZ5sWJdiSXznxgAS5KwUw2ge0ls0zR4uRe6HkCW9xqM3N4SqGeiEFh brcRcZosxdqNwwdp0AIQSKRvwYw5H6TTVNkiusWfehfQepy+V6JmKGCvUvJrAB3ZkWd3 2aZBIQ/u9FVfcPajc0FRi3Myb1W/UZ7fW1Fv/Gey4fwsdAMXqSdcr/i5YzTedz9gaw5I 2+vA== X-Forwarded-Encrypted: i=1; AJvYcCWenLSoLxH5fMW6cwp/HczBMt+tGEb+s8DFnT9wSLDLypkJ8EZXaYjmrWHhjSHQVN2KtEHiVlYJdoGh2R3H/6iN/i/8ZU2UmXWK6JU= X-Gm-Message-State: AOJu0YyIdJD0ieHM679wwHsQTnpRX2TrLsGv8D6B8qL2Y2IR8EA7Vy8W odyGIT/RWbfsN5NWwt7DHPrrPJBGLif1caaIpLYBXSEMmcXI7VsXqOmyNWzXMx8= X-Google-Smtp-Source: AGHT+IHzmKuQwr4uKJdSktdVevkEerGDWAIr8X+XoShc6/Yn7rglfnswUVOqIid+4DYpSBckjy6AWg== X-Received: by 2002:a4a:800c:0:b0:5a2:7c3:82e9 with SMTP id x12-20020a4a800c000000b005a207c382e9mr1183612oof.4.1710173411646; Mon, 11 Mar 2024 09:10:11 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:11 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 4/9] lib: sbi: Simplify parameters of misaligned and access fault handlers Date: Mon, 11 Mar 2024 21:39:39 +0530 Message-Id: <20240311160944.1233523-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091013_574061_1D6DF08E X-CRM114-Status: GOOD ( 11.87 ) 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: The struct sbi_trap_context already has the information needed by misaligned load/store and access fault load/store handlers so directly pass struct sbi_trap_context pointer to these functions. Signed-off-by: Anup Patel --- include/sbi/sbi_trap_ldst.h | 12 +++---- lib/sbi/sbi_trap.c | 8 ++--- lib/sbi/sbi_trap_ldst.c | 67 ++++++++++++++++++ 3 files [...] 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 [2607:f8b0:4864:20:0:0:0:c30 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The struct sbi_trap_context already has the information needed by misaligned load/store and access fault load/store handlers so directly pass struct sbi_trap_context pointer to these functions. Signed-off-by: Anup Patel --- include/sbi/sbi_trap_ldst.h | 12 +++---- lib/sbi/sbi_trap.c | 8 ++--- lib/sbi/sbi_trap_ldst.c | 67 ++++++++++++++++++------------------- 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/include/sbi/sbi_trap_ldst.h b/include/sbi/sbi_trap_ldst.h index 9cab4e4..8aee316 100644 --- a/include/sbi/sbi_trap_ldst.h +++ b/include/sbi/sbi_trap_ldst.h @@ -20,16 +20,12 @@ union sbi_ldst_data { ulong data_ulong; }; -int sbi_misaligned_load_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap); +int sbi_misaligned_load_handler(struct sbi_trap_context *tcntx); -int sbi_misaligned_store_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap); +int sbi_misaligned_store_handler(struct sbi_trap_context *tcntx); -int sbi_load_access_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap); +int sbi_load_access_handler(struct sbi_trap_context *tcntx); -int sbi_store_access_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap); +int sbi_store_access_handler(struct sbi_trap_context *tcntx); #endif diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index dba267c..359749f 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -308,12 +308,12 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) break; case CAUSE_MISALIGNED_LOAD: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_LOAD); - rc = sbi_misaligned_load_handler(regs, &trap); + rc = sbi_misaligned_load_handler(&tcntx); msg = "misaligned load handler failed"; break; case CAUSE_MISALIGNED_STORE: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_STORE); - rc = sbi_misaligned_store_handler(regs, &trap); + rc = sbi_misaligned_store_handler(&tcntx); msg = "misaligned store handler failed"; break; case CAUSE_SUPERVISOR_ECALL: @@ -323,12 +323,12 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) break; case CAUSE_LOAD_ACCESS: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ACCESS_LOAD); - rc = sbi_load_access_handler(regs, &trap); + rc = sbi_load_access_handler(&tcntx); msg = "load fault handler failed"; break; case CAUSE_STORE_ACCESS: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ACCESS_STORE); - rc = sbi_store_access_handler(regs, &trap); + rc = sbi_store_access_handler(&tcntx); msg = "store fault handler failed"; break; default: diff --git a/lib/sbi/sbi_trap_ldst.c b/lib/sbi/sbi_trap_ldst.c index d864ad1..2694e88 100644 --- a/lib/sbi/sbi_trap_ldst.c +++ b/lib/sbi/sbi_trap_ldst.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -23,8 +22,7 @@ * @return rlen=success, 0=success w/o regs modification, or negative error */ typedef int (*sbi_trap_ld_emulator)(int rlen, union sbi_ldst_data *out_val, - struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap); + struct sbi_trap_context *tcntx); /** * Store emulator callback: @@ -32,8 +30,7 @@ typedef int (*sbi_trap_ld_emulator)(int rlen, union sbi_ldst_data *out_val, * @return wlen=success, 0=success w/o regs modification, or negative error */ typedef int (*sbi_trap_st_emulator)(int wlen, union sbi_ldst_data in_val, - struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap); + struct sbi_trap_context *tcntx); static ulong sbi_misaligned_tinst_fixup(ulong orig_tinst, ulong new_tinst, ulong addr_offset) @@ -47,10 +44,11 @@ static ulong sbi_misaligned_tinst_fixup(ulong orig_tinst, ulong new_tinst, return orig_tinst | (addr_offset << SH_RS1); } -static int sbi_trap_emulate_load(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap, +static int sbi_trap_emulate_load(struct sbi_trap_context *tcntx, sbi_trap_ld_emulator emu) { + const struct sbi_trap_info *orig_trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; ulong insn, insn_len; union sbi_ldst_data val = { 0 }; struct sbi_trap_info uptrap; @@ -151,8 +149,7 @@ static int sbi_trap_emulate_load(struct sbi_trap_regs *regs, return sbi_trap_redirect(regs, orig_trap); } - rc = emu(len, &val, regs, orig_trap); - + rc = emu(len, &val, tcntx); if (rc <= 0) return rc; @@ -170,10 +167,11 @@ static int sbi_trap_emulate_load(struct sbi_trap_regs *regs, return 0; } -static int sbi_trap_emulate_store(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap, +static int sbi_trap_emulate_store(struct sbi_trap_context *tcntx, sbi_trap_st_emulator emu) { + const struct sbi_trap_info *orig_trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; ulong insn, insn_len; union sbi_ldst_data val; struct sbi_trap_info uptrap; @@ -256,8 +254,7 @@ static int sbi_trap_emulate_store(struct sbi_trap_regs *regs, return sbi_trap_redirect(regs, orig_trap); } - rc = emu(len, val, regs, orig_trap); - + rc = emu(len, val, tcntx); if (rc <= 0) return rc; @@ -267,9 +264,10 @@ static int sbi_trap_emulate_store(struct sbi_trap_regs *regs, } static int sbi_misaligned_ld_emulator(int rlen, union sbi_ldst_data *out_val, - struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) + struct sbi_trap_context *tcntx) { + const struct sbi_trap_info *orig_trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; struct sbi_trap_info uptrap; int i; @@ -286,17 +284,16 @@ static int sbi_misaligned_ld_emulator(int rlen, union sbi_ldst_data *out_val, return rlen; } -int sbi_misaligned_load_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) +int sbi_misaligned_load_handler(struct sbi_trap_context *tcntx) { - return sbi_trap_emulate_load(regs, orig_trap, - sbi_misaligned_ld_emulator); + return sbi_trap_emulate_load(tcntx, sbi_misaligned_ld_emulator); } static int sbi_misaligned_st_emulator(int wlen, union sbi_ldst_data in_val, - struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) + struct sbi_trap_context *tcntx) { + const struct sbi_trap_info *orig_trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; struct sbi_trap_info uptrap; int i; @@ -313,17 +310,17 @@ static int sbi_misaligned_st_emulator(int wlen, union sbi_ldst_data in_val, return wlen; } -int sbi_misaligned_store_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) +int sbi_misaligned_store_handler(struct sbi_trap_context *tcntx) { - return sbi_trap_emulate_store(regs, orig_trap, - sbi_misaligned_st_emulator); + return sbi_trap_emulate_store(tcntx, sbi_misaligned_st_emulator); } static int sbi_ld_access_emulator(int rlen, union sbi_ldst_data *out_val, - struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) + struct sbi_trap_context *tcntx) { + const struct sbi_trap_info *orig_trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; + /* If fault came from M mode, just fail */ if (((regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT) == PRV_M) return SBI_EINVAL; @@ -336,16 +333,17 @@ static int sbi_ld_access_emulator(int rlen, union sbi_ldst_data *out_val, return rlen; } -int sbi_load_access_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) +int sbi_load_access_handler(struct sbi_trap_context *tcntx) { - return sbi_trap_emulate_load(regs, orig_trap, sbi_ld_access_emulator); + return sbi_trap_emulate_load(tcntx, sbi_ld_access_emulator); } static int sbi_st_access_emulator(int wlen, union sbi_ldst_data in_val, - struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) + struct sbi_trap_context *tcntx) { + const struct sbi_trap_info *orig_trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; + /* If fault came from M mode, just fail */ if (((regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT) == PRV_M) return SBI_EINVAL; @@ -358,8 +356,7 @@ static int sbi_st_access_emulator(int wlen, union sbi_ldst_data in_val, return wlen; } -int sbi_store_access_handler(struct sbi_trap_regs *regs, - const struct sbi_trap_info *orig_trap) +int sbi_store_access_handler(struct sbi_trap_context *tcntx) { - return sbi_trap_emulate_store(regs, orig_trap, sbi_st_access_emulator); + return sbi_trap_emulate_store(tcntx, sbi_st_access_emulator); } From patchwork Mon Mar 11 16:09:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910508 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=d3ffUkJ3; 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=VJllw6e6; 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 4TthZW2WsGz1yWy for ; Tue, 12 Mar 2024 03:10:27 +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: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=bl/g1768nqS8KfbsDk8rxEXEOmQfLLJv3cEn9g8wADE=; b=d3ffUkJ3C5cs7h QTp6ldEkW827d5+KhoQN1Y/loW4KoKNsH8vCdLBAID6Jep78h89yzaBSOpAXLIZ+H/e7CnX6gIiex ukRvvG9/ZjeYoo+81eXIfNgWJnzXz6W8SUreSPStyOYgJJTRgLL8zYgipT4hZPTFs8OpUaFaD5HF8 ComKMX8ORDmi4cFjp+1ngKhEj6TjCJXASbNZM0QbLVOhTEPIbiJNTntj20n9m0ro/LeUi8T06JHAX Jxvbj5GQQBSoshVbEyuAcYFoYg1pHI81MOGJC1MK2XAHePhfPlgncKR5WKhJQ8Ki/GMqiVgXli/l4 hOOh12XOAVdx66553Z+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEE-00000002E1c-1WyK; Mon, 11 Mar 2024 16:10:18 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEB-00000002Dzm-3dAw for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:17 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5a207813b1dso445915eaf.2 for ; Mon, 11 Mar 2024 09:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173415; x=1710778215; 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=ngDZpR91MyOv+ynCl5GJXwJNNMzqO1boAtfDzaloqcs=; b=VJllw6e6mZEcfhkQxV36+xRLLYnRJVO92jPOgTs6QfVOy+qK3b8NAAjBAYH+Th+iqm Ev9QNWWkRg391Y/thOhKzvhtnQsCZKwmlY1ro89IYlctN3DiMXHwRzvvIEwtFVSoo95O h6BbrYemOyJ09NYa6mDmUtMxgiDZI3vpiYRv0fpmfxDxEF84+1lN2EuZIkZnn5vXFCqI 1DIMCq00e05HeL/kkf4i16IBaEr3VO9U7uOAX60Mx7g9GxSOeyXI2OXup4n/iUYPj3I/ q4sUDpjxDcUy3lMFzOxSk95kR7C8B9AoBdp8Rgwj5Cfll8Cp/4BuRXcQSD1Gd+sRFDPJ Skfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173415; x=1710778215; 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=ngDZpR91MyOv+ynCl5GJXwJNNMzqO1boAtfDzaloqcs=; b=qEyalQPWH7RzA9LckpiPAWNuaskgLJuWotBHesYMNVqmCQzFAYxqI/aTUA1+ZYLCm9 tfJ4pWWfWxhizMoNK9N7S1002gOeuOmIGyFSHefvGLhIUXbtAg4iKdXHjDbWEbmaZYAw cTe40tZM7Qb+0HwFyRAdF1lof6rB24yceETjJN+QwA1vv01cxEi0yQscrbnIDkTRrSWe wcIx91gaLJ12puEcIvPIG1oY9wRsCNRj378QsQw6MF6NSwn8V4YHW9as/af76stiihbq TX6RWYMwIHMgcURw5DFd85qN2XnRq2OV6kiVHOYN7qXEeYnZ49VHsgua16Iy2sQNYasU vPpg== X-Forwarded-Encrypted: i=1; AJvYcCWsnD8QWyHUF9BmQ/3yNZN53ryXaM6F07ao7eG/V4RMcm7Ed/HXg9JrX9OsoerndtZ8QcL0mUhJtMpmhQyzjc8NcjvMSbkSqcpb0as= X-Gm-Message-State: AOJu0YzpAX8t29s/FT97KP7RmdVz8uoPS3YaaguU1Z7+XDv9DyfminK/ oco6qiPumdomrFXPlVEzPdebZi1b7a0MY9eFoBcJ81wKjzJ4go3cvc5YaCVE+Jw= X-Google-Smtp-Source: AGHT+IHA1CO+XK4NURPxWFzcqo0ARsmk2x85XrCR0M61viOo87JnZX1dhpAGHw9VhSGFA4N++MJCKA== X-Received: by 2002:a05:6820:1ac7:b0:5a1:2c19:23d8 with SMTP id bu7-20020a0568201ac700b005a12c1923d8mr6459918oob.5.1710173415039; Mon, 11 Mar 2024 09:10:15 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:14 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 5/9] lib: sbi: Simplify parameters of sbi_illegal_insn_handler() Date: Mon, 11 Mar 2024 21:39:40 +0530 Message-Id: <20240311160944.1233523-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091016_037067_370D7B1F X-CRM114-Status: GOOD ( 11.20 ) 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: The struct sbi_trap_context already has the information needed by sbi_illegal_insn_handler() so directly pass struct sbi_trap_context pointer to this function. Signed-off-by: Anup Patel --- include/sbi/sbi_illegal_insn.h | 4 ++-- lib/sbi/sbi_illegal_insn.c | 14 ++++++++------ lib/sbi/sbi_trap.c | 2 +- 3 files changed, 11 insertions( [...] 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 [2607:f8b0:4864:20:0:0:0:c30 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The struct sbi_trap_context already has the information needed by sbi_illegal_insn_handler() so directly pass struct sbi_trap_context pointer to this function. Signed-off-by: Anup Patel --- include/sbi/sbi_illegal_insn.h | 4 ++-- lib/sbi/sbi_illegal_insn.c | 14 ++++++++------ lib/sbi/sbi_trap.c | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/sbi/sbi_illegal_insn.h b/include/sbi/sbi_illegal_insn.h index 0397935..7be72ac 100644 --- a/include/sbi/sbi_illegal_insn.h +++ b/include/sbi/sbi_illegal_insn.h @@ -12,8 +12,8 @@ #include -struct sbi_trap_regs; +struct sbi_trap_context; -int sbi_illegal_insn_handler(ulong insn, struct sbi_trap_regs *regs); +int sbi_illegal_insn_handler(struct sbi_trap_context *tcntx); #endif diff --git a/lib/sbi/sbi_illegal_insn.c b/lib/sbi/sbi_illegal_insn.c index 2be4757..0c8ad1e 100644 --- a/lib/sbi/sbi_illegal_insn.c +++ b/lib/sbi/sbi_illegal_insn.c @@ -137,8 +137,9 @@ static const illegal_insn_func illegal_insn_table[32] = { truly_illegal_insn /* 31 */ }; -int sbi_illegal_insn_handler(ulong insn, struct sbi_trap_regs *regs) +int sbi_illegal_insn_handler(struct sbi_trap_context *tcntx) { + ulong mepc, insn = tcntx->trap->tval; struct sbi_trap_info uptrap; /* @@ -154,14 +155,15 @@ int sbi_illegal_insn_handler(ulong insn, struct sbi_trap_regs *regs) sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ILLEGAL_INSN); if (unlikely((insn & 3) != 3)) { - insn = sbi_get_insn(regs->mepc, &uptrap); + mepc = tcntx->regs->mepc; + insn = sbi_get_insn(mepc, &uptrap); if (uptrap.cause) { - uptrap.epc = regs->mepc; - return sbi_trap_redirect(regs, &uptrap); + uptrap.epc = mepc; + return sbi_trap_redirect(tcntx->regs, &uptrap); } if ((insn & 3) != 3) - return truly_illegal_insn(insn, regs); + return truly_illegal_insn(insn, tcntx->regs); } - return illegal_insn_table[(insn & 0x7c) >> 2](insn, regs); + return illegal_insn_table[(insn & 0x7c) >> 2](insn, tcntx->regs); } diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 359749f..3d300c3 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -303,7 +303,7 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) switch (mcause) { case CAUSE_ILLEGAL_INSTRUCTION: - rc = sbi_illegal_insn_handler(mtval, regs); + rc = sbi_illegal_insn_handler(&tcntx); msg = "illegal instruction handler failed"; break; case CAUSE_MISALIGNED_LOAD: From patchwork Mon Mar 11 16:09:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910509 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=BB2uqzh3; 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=myg7gnZn; 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 4TthZd6FDMz1yWy for ; Tue, 12 Mar 2024 03:10:33 +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: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=WaUoru4ORr3336geUlWT6x6J1DoYFOBhf1x49iL4sBo=; b=BB2uqzh3ilfKEq 0FyljdDq6dliRLll5jqUnPB1VGvlc1gwTB+E7E35xKX2zT6QOwZNjBff2j2Ll4O57yUzstUAb1D6c pPnLjQ5AaMLme6+1IvZmR/BvE4lyHxGTaU1Z2i1JVU4sKW5bSmMK9kt5JS+96BTgWGcaPZhhxZUjr ZGqr0Fj4OLU/HMmbIZYHAUw2A4zjeA5AH9M2t97Jjy4YtlnPwteuUaof+LAan27hHjAZCIqw0ElaK TNJsF4/Nwuk3DC3YL44upt7o60q3grE0wst11cFiQjSexS8XzxK2ffMyM2uhuWUmZ9rC48Wh91M9N j+qt7auXP1uykFatpPzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEM-00000002E65-02ju; Mon, 11 Mar 2024 16:10:26 +0000 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEF-00000002E24-49JO for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:21 +0000 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5a1d1a28da2so663354eaf.1 for ; Mon, 11 Mar 2024 09:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173418; x=1710778218; 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=pHP3dbIt68KQ6+EVMVR8WxSQiD4adlYZW9e38uiAQQM=; b=myg7gnZnbLnh4k7qf5AeDfTw88aSosJAcjl9sbrEByLsiUnMgda+j6cYKqsU7fGtCt 0JXZwbZ7jMB5fV7UOZkXJnBZmyw6R8fOqxN3wv25ywHnUy6Jd/VBkTjcMm9Z7UtUTsO9 uZq1wNcxRxGpi/I5Pw2n62BkuM/yFGiz2Gfg3egNEecfn11SAa/D+ZgEbYvg+EBOHAkw Vo4QGC61lXTzz142USmOkkBU6AJ5D6azQDXE6N6i13nFfsyAt7iw7r2wJ+NwBtp0MAuA pR07C4L/NL4Va3Z6tnFeHZ2ncVutDtanKTJCKv9TZWMBFYmYPEcT5lpi6bnQfpWfxHtm Xc8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173418; x=1710778218; 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=pHP3dbIt68KQ6+EVMVR8WxSQiD4adlYZW9e38uiAQQM=; b=XISxzcTExWzN0ZRwCcvml/3KrxTWvsNKIioZXEyOnyMlC87SINeLn65DcYiDwzdAz2 0tncB9nvWe7HNFaearP61RIicCEt9eI6Pt0n2jEsexNjxo46BHVFzhBCo36R2zdo1RPs tGRsomSsSvM60FRBzVlzZOjM8ZapAfYET2vecMBwGfAafE/KyVTrzBIatGsFjySRhltQ KX8CZ4egkJuBD23uWRBM3nisai7km/tVcDJoMEYFJZyMQ4QW8FP6hIAIVjxbBHnAwPJl X+9h/myHhFVZ5Y3+BXWxohjXu0uu+cUI3KU0t8ESKbaANwgZOFkt6AAJ3rCx7crput2R aiIw== X-Forwarded-Encrypted: i=1; AJvYcCXAJDfzfTkh1QEOZWLyWsDAJL4pOBs9NOykwiVPaTTyieHuButG4IYgJ6eNBoqNcBpUwr3DM7mNBCIkysKZT9WaHu/jAr5fECxXviE= X-Gm-Message-State: AOJu0YwBedA3t7uXGssWSg0E3ApbEB9MpqvczlbnaA8bjChatrqG33d8 TlzotCtwHrRCsFsWOOEsTx5eD4AGk39NUw8EO3XXXF0qvIqWxHbBHpT9Mm1IAcqOtPnVr/kGKuh 1lyA= X-Google-Smtp-Source: AGHT+IGlbsmLrkDdYymR936xlhrPMuO0DJNQLTfdJjernDVVk+L5j6aNC5RUFNIaHI7cSh+U2jJz8Q== X-Received: by 2002:a05:6820:813:b0:5a1:dd31:a38d with SMTP id bg19-20020a056820081300b005a1dd31a38dmr5970634oob.6.1710173418276; Mon, 11 Mar 2024 09:10:18 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:17 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 6/9] lib: sbi: Remove regs paramter of sbi_irqchip_process() Date: Mon, 11 Mar 2024 21:39:41 +0530 Message-Id: <20240311160944.1233523-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091020_146345_0EAAD424 X-CRM114-Status: GOOD ( 12.54 ) 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: The irqchip handlers will typically not need pointer to trap registers so remove regs paramter of sbi_irqchip_process(). Signed-off-by: Anup Patel --- include/sbi/sbi_irqchip.h | 5 ++--- lib/sbi/sbi_irqchip.c | 10 +++++----- lib/sbi/sbi_trap.c | 4 ++-- lib/utils/irqchip/imsic.c | 2 +- 4 files c [...] 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 [2607:f8b0:4864:20:0:0:0:c33 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The irqchip handlers will typically not need pointer to trap registers so remove regs paramter of sbi_irqchip_process(). Signed-off-by: Anup Patel --- include/sbi/sbi_irqchip.h | 5 ++--- lib/sbi/sbi_irqchip.c | 10 +++++----- lib/sbi/sbi_trap.c | 4 ++-- lib/utils/irqchip/imsic.c | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/sbi/sbi_irqchip.h b/include/sbi/sbi_irqchip.h index 6acc6e3..0ed02eb 100644 --- a/include/sbi/sbi_irqchip.h +++ b/include/sbi/sbi_irqchip.h @@ -13,7 +13,6 @@ #include struct sbi_scratch; -struct sbi_trap_regs; /** * Set external interrupt handling function @@ -23,7 +22,7 @@ struct sbi_trap_regs; * * @param fn function pointer for handling external irqs */ -void sbi_irqchip_set_irqfn(int (*fn)(struct sbi_trap_regs *regs)); +void sbi_irqchip_set_irqfn(int (*fn)(void)); /** * Process external interrupts @@ -33,7 +32,7 @@ void sbi_irqchip_set_irqfn(int (*fn)(struct sbi_trap_regs *regs)); * * @param regs pointer for trap registers */ -int sbi_irqchip_process(struct sbi_trap_regs *regs); +int sbi_irqchip_process(void); /** Initialize interrupt controllers */ int sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot); diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c index 24128be..0ae604a 100644 --- a/lib/sbi/sbi_irqchip.c +++ b/lib/sbi/sbi_irqchip.c @@ -10,22 +10,22 @@ #include #include -static int default_irqfn(struct sbi_trap_regs *regs) +static int default_irqfn(void) { return SBI_ENODEV; } -static int (*ext_irqfn)(struct sbi_trap_regs *regs) = default_irqfn; +static int (*ext_irqfn)(void) = default_irqfn; -void sbi_irqchip_set_irqfn(int (*fn)(struct sbi_trap_regs *regs)) +void sbi_irqchip_set_irqfn(int (*fn)(void)) { if (fn) ext_irqfn = fn; } -int sbi_irqchip_process(struct sbi_trap_regs *regs) +int sbi_irqchip_process(void) { - return ext_irqfn(regs); + return ext_irqfn(); } int sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot) diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 3d300c3..e6ef6d1 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -209,7 +209,7 @@ static int sbi_trap_nonaia_irq(struct sbi_trap_regs *regs, ulong mcause) sbi_ipi_process(); break; case IRQ_M_EXT: - return sbi_irqchip_process(regs); + return sbi_irqchip_process(); default: return SBI_ENOENT; } @@ -232,7 +232,7 @@ static int sbi_trap_aia_irq(struct sbi_trap_regs *regs, ulong mcause) sbi_ipi_process(); break; case IRQ_M_EXT: - rc = sbi_irqchip_process(regs); + rc = sbi_irqchip_process(); if (rc) return rc; break; diff --git a/lib/utils/irqchip/imsic.c b/lib/utils/irqchip/imsic.c index 36ef66c..f2a35c6 100644 --- a/lib/utils/irqchip/imsic.c +++ b/lib/utils/irqchip/imsic.c @@ -140,7 +140,7 @@ int imsic_get_target_file(u32 hartid) return imsic_get_hart_file(scratch); } -static int imsic_external_irqfn(struct sbi_trap_regs *regs) +static int imsic_external_irqfn(void) { ulong mirq; From patchwork Mon Mar 11 16:09:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910510 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=edqlVMWO; 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=n88tdBEX; 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 4TthZh31xJz1yWy for ; Tue, 12 Mar 2024 03:10:36 +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: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=A3Gp3aMgeJhZT7XzGfg9ruK6W6dA5gRBSAW9pkpxMlM=; b=edqlVMWO7q/04h U+bW4JJwl+3ylKNAjDpuVebtylHBjJ2a4wV896ioV8BDoJP4m9J71poEFsWpipiGWYN1WR6L3Id7A 4X0S+49xhLMO0FdTl2nmPYG35WFXbKSlTggOeM18ETJg01EeP4nxDb3+Xc+JUURI2r6agiTglACe6 6MnB8oM91xJpRGmRhXnQIX2I12KYGnY1zcjlp6YG+8KI6nUtH4hvuaQTg3huDd/uISZ08+7Z65cph PYn2VSf+ZAKAzm3rQ+JWFiGGeXWiKoht0RgTaohXDWFlWQHhDBUVOp8ldjK9PPCzARxqGO2hrQAZn 5/t6jLCjNdFbVHLgb+Jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEO-00000002E81-2iaa; Mon, 11 Mar 2024 16:10:28 +0000 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEI-00000002E4G-1dqL for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:26 +0000 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5a1bd83d55dso1754462eaf.2 for ; Mon, 11 Mar 2024 09:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173421; x=1710778221; 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=GoMj09a4KYKJW5pNQ0191/9ks7H3XqAZBkmPr1CPB48=; b=n88tdBEXuvEmhQsIB8o/Smw11+WEaHoVr/3L8kaVYnP5h6pts4DSKpa4wePYqY0Uk8 ElZa5evX47MN9PvvGGH/HxyEnS0S7rRq0BrR0Mf/lA7X7WxBEqbAuDBEd3BppebxADmk lNwwPHbB7s3AV49z2Ty5zCRahJ0ETFzs6fxFhJEZmka8kyK7TBLzND8pOhDlFMx20zEa /l1rEmBjjA5PfMDWL6710xGhCXwbjPdr5kbdcLJ+lsRTJ7cAINNMVhdaj8s0d1/0RLLH j6DTdq0a25mgkBPCpNr4+UiOekzP7fVpKoP9psRWAOi+JOp15t28E5z1McJsmFc7DeLT Xdug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173421; x=1710778221; 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=GoMj09a4KYKJW5pNQ0191/9ks7H3XqAZBkmPr1CPB48=; b=KwIoj2C7fCe6NrU+9Lgv3DU9Kj8pMeao9+aExamftIo5Kk6heTEq1QFVIKw07NvOrB SBlez2ZGWjAL2YFH1P5DYr80+LRfhNpOsq/vBxe7m71YtNJbtyCGnEt4YnoEACT3G61l K1SMmii2uqQIevl3bbyuahREWTk5ZHr+S2sE4iHvIslqlVnAvZjBJNAb6p+qXr+lNXWG M7AWEl0Gp6vVQbBi1L3472OhEZf6dt64/1FvhvMMd+0pBT3AuvZei3l5Wjb2jUmIBBmM 8CtUx51FDpSQvekHZFqn590wNJtrrpPs9XLBEHvduj3nC5hr9Xndpj+MTeJAwQ13jVmt C4qw== X-Forwarded-Encrypted: i=1; AJvYcCWW8Ibq+H9XRs6U493hmj5CtQd1hGmL0hLAy2F903NWhc+MNb3pLYx25Trpq3D+4k1St95rV7h0VNZXw/LVgaQ122x3ZLjQvSspe9M= X-Gm-Message-State: AOJu0Yw02WU9Fhw+jPzH276SfxChjBD+3kT24GSG+m+gbLMEDGVF3VNV OmKne2dtcTG3cQmG5FdoHdSOwAG0BmWlNYiWYFPmw4LHqIaGM54UxSsDI2MoCEc= X-Google-Smtp-Source: AGHT+IGHsfXaBkMrCO6qH/pxCaZ7KkCafb9UuaRiSA8zjt4aF9x2SDrVfZRBdHgsRvbsq8o7DqTSgw== X-Received: by 2002:a4a:765e:0:b0:5a1:b571:4871 with SMTP id w30-20020a4a765e000000b005a1b5714871mr5872437ooe.5.1710173421384; Mon, 11 Mar 2024 09:10:21 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:21 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 7/9] lib: sbi: Remove regs parameter from trap irq handling functions Date: Mon, 11 Mar 2024 21:39:42 +0530 Message-Id: <20240311160944.1233523-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091024_371312_6D664EB9 X-CRM114-Status: UNSURE ( 9.37 ) X-CRM114-Notice: Please train this message. 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: The trap irq handling functions no longer require regs parameter so remove it. Signed-off-by: Anup Patel --- lib/sbi/sbi_trap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 [2607:f8b0:4864:20:0:0:0:c2f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The trap irq handling functions no longer require regs parameter so remove it. Signed-off-by: Anup Patel --- lib/sbi/sbi_trap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index e6ef6d1..a50e466 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -198,9 +198,9 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, return 0; } -static int sbi_trap_nonaia_irq(struct sbi_trap_regs *regs, ulong mcause) +static int sbi_trap_nonaia_irq(unsigned long mcause) { - mcause &= ~(1UL << (__riscv_xlen - 1)); + mcause &= ~BIT(__riscv_xlen - 1); switch (mcause) { case IRQ_M_TIMER: sbi_timer_process(); @@ -217,7 +217,7 @@ static int sbi_trap_nonaia_irq(struct sbi_trap_regs *regs, ulong mcause) return 0; } -static int sbi_trap_aia_irq(struct sbi_trap_regs *regs, ulong mcause) +static int sbi_trap_aia_irq(unsigned long mcause) { int rc; unsigned long mtopi; @@ -291,12 +291,12 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) /* Update trap context pointer */ sbi_trap_set_context(scratch, &tcntx); - if (mcause & (1UL << (__riscv_xlen - 1))) { + if (mcause & BIT(__riscv_xlen - 1)) { if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(), SBI_HART_EXT_SMAIA)) - rc = sbi_trap_aia_irq(regs, mcause); + rc = sbi_trap_aia_irq(mcause); else - rc = sbi_trap_nonaia_irq(regs, mcause); + rc = sbi_trap_nonaia_irq(mcause); msg = "unhandled local interrupt"; goto trap_done; } From patchwork Mon Mar 11 16:09:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910511 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=RO8nVGAT; 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=QeUFFC3C; 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 4TthZj5xlSz1yWy for ; Tue, 12 Mar 2024 03:10:37 +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: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=LOhA4/gLOJQsDQSsHQ8Kr6loHiGYgFtg6gOxgxzYs3A=; b=RO8nVGATrEDenF GrgUwrYLUSngJzvV/LkmmxS8N5jzfQN8XXq2kfP6G2oa5sKlAvSFFnE7TqwgNzGIx7wPrHvR+vs36 2iTy3+QBTh16JRavTWVZbWJvOEA94wssNYdN8AcvKwNZMG/fJvSUjiHqjMrpoScVONxtptEro1ugC s0r8S2E8lLgQthpQ+XhF7bJRPctypCOndxqfrJop+zVBNjrtYglqmBidHR5CCMrtZjYdDneXlZjFa eSZ38mke66zqnIp/OLvCtU7E+zbjRlUwgL9YYuQfaNiHJOPyE5r/jjLJzJwX8qzP8IQAYYWG3NIMB JALJGpS77wesbDngJf1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEP-00000002E8e-1by5; Mon, 11 Mar 2024 16:10:29 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEL-00000002E5n-2wiO for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:27 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-5a19de33898so2600969eaf.0 for ; Mon, 11 Mar 2024 09:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173425; x=1710778225; 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=tiFWubfGW+oNfjKBj/KDlXsHA/y7gpIILJYA2Xb1h8w=; b=QeUFFC3CdCPB4axyaCdWcAhKVVfBxZvZY45S13aqBumYvPCfu7SJOvPajuGD+f79Fe nufQ/x8c4mJm5NBH9CqzzhjSqf99jda5VO4XxqiYyWk5MJu8o9unTSDbLnZk+s78u1sM 5lw2+0t9J46kZSqh7f19/heivMv8Zq+XAHowfp4tewQZrXagNRmGSYZhGq3rF5zl8u/g 080jZoevQTKiUpx7E3xip9ZB1MmYW07yQJmkC+RffNrMlJL9tTsK7KS9GA+skofcQz60 3niQfRaD37qcYrpy7Da3+I9M/oAlutjZoYNULCFUPCv1jvByY2RWy7tjgkgSTfDrWCvI qYlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173425; x=1710778225; 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=tiFWubfGW+oNfjKBj/KDlXsHA/y7gpIILJYA2Xb1h8w=; b=cLLrkFcEH4GAZRpvnKIRB7wGIqWTADEqVT0aNvCrhsITZGvqO/lnNnmY5agGPNh9Md /9qg+k/rBqMscEaDVbb33v4KQtyaMHfg+lQ9cpwuqVhyNUsqYExnNMfItarxgr9kHoKu /TwGWrOSLh9TfHiV9m7n/xc5lgufqFMlFabdRdaQF0Ghk0xOBqTXzR/K2IQAj2lQhjfL 0nyf/+7uQmQlosWYZzcCDSOAXLjY9YJAN2C+dfHm4uvB5OBW1egUcJ+xNI2Rc1gCACuW gS2Q8dd+CzD1k+4fkwEdLlGW6k58DvCOdycnN2m/l+oY2IUyYxb7b9cgNZY7b/WFNOMi DvLw== X-Forwarded-Encrypted: i=1; AJvYcCVOfwthg8vU9+SZhiUHY9bMwc7DPp/k5jqIwel1lDk287SU1TtEyyKuY2hdeCrNoU2rvblosoqsrv3YZiLcVwqrnBMX5W0qL6DG7bs= X-Gm-Message-State: AOJu0YyOg9sRPo1XXpg5FtMn/baQ0uHeobLYnAoM73jLEw9WcecbVMxR XZ8pT1C/5t/wyy9hxq3jkGcqiQTwKM2E1Yl79pGMBWN4XxoNn4dKSNjno9PhVLZFoJ9pbltowD7 ON+E= X-Google-Smtp-Source: AGHT+IEz3JVLv6omaNzw5bI9DRwYWLCTN7Bah75nvD/5DmZx4KlK8Fy1DNdEhn8d1Iq2mYCUVmO10Q== X-Received: by 2002:a4a:9b5c:0:b0:5a1:a762:12af with SMTP id e28-20020a4a9b5c000000b005a1a76212afmr943585ook.3.1710173424749; Mon, 11 Mar 2024 09:10:24 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:24 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 8/9] lib: sbi: Pass trap context pointer to sbi_ecall_handler() Date: Mon, 11 Mar 2024 21:39:43 +0530 Message-Id: <20240311160944.1233523-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091025_910785_656B911D X-CRM114-Status: GOOD ( 11.30 ) 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: To be consistent with other trap handlers, pass trap context pointer to sbi_ecall_handler(). Signed-off-by: Anup Patel --- include/sbi/sbi_ecall.h | 4 ++-- lib/sbi/sbi_ecall.c | 3 ++- lib/sbi/sbi_trap.c | 2 +- 3 files changed, 5 insertions(+), 4 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 [2607:f8b0:4864:20:0:0:0:c2d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To be consistent with other trap handlers, pass trap context pointer to sbi_ecall_handler(). Signed-off-by: Anup Patel --- include/sbi/sbi_ecall.h | 4 ++-- lib/sbi/sbi_ecall.c | 3 ++- lib/sbi/sbi_trap.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/sbi/sbi_ecall.h b/include/sbi/sbi_ecall.h index 0bf42d1..0b35eff 100644 --- a/include/sbi/sbi_ecall.h +++ b/include/sbi/sbi_ecall.h @@ -18,7 +18,7 @@ #define SBI_OPENSBI_IMPID 1 struct sbi_trap_regs; -struct sbi_trap_info; +struct sbi_trap_context; struct sbi_ecall_return { /* Return flag to skip register update */ @@ -87,7 +87,7 @@ int sbi_ecall_register_extension(struct sbi_ecall_extension *ext); void sbi_ecall_unregister_extension(struct sbi_ecall_extension *ext); -int sbi_ecall_handler(struct sbi_trap_regs *regs); +int sbi_ecall_handler(struct sbi_trap_context *tcntx); int sbi_ecall_init(void); diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index 631c5dd..845e79b 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -95,9 +95,10 @@ void sbi_ecall_unregister_extension(struct sbi_ecall_extension *ext) sbi_list_del_init(&ext->head); } -int sbi_ecall_handler(struct sbi_trap_regs *regs) +int sbi_ecall_handler(struct sbi_trap_context *tcntx) { int ret = 0; + struct sbi_trap_regs *regs = tcntx->regs; struct sbi_ecall_extension *ext; unsigned long extension_id = regs->a7; unsigned long func_id = regs->a6; diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index a50e466..b0fa5fd 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -318,7 +318,7 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) break; case CAUSE_SUPERVISOR_ECALL: case CAUSE_MACHINE_ECALL: - rc = sbi_ecall_handler(regs); + rc = sbi_ecall_handler(&tcntx); msg = "ecall handler failed"; break; case CAUSE_LOAD_ACCESS: From patchwork Mon Mar 11 16:09:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910512 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=Hl/3rvuS; 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=g9py3Zye; 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 4TthZq6sj2z23ql for ; Tue, 12 Mar 2024 03:10:43 +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: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=1mWiUfnPpjZEjZpWfolr3afftotDlYYld3Qx4Vn0F6A=; b=Hl/3rvuSwBA2k+ TKXN3lZzaGAXa6pmUl/cIphU1KIZDvrF69y384Lmwwcq3sWih/MCIraU8F1bmTTWFmbGmgx9vnaZb BHnxTNADOxTzfTXLHRC43nSem8r0RSBYv1nfYQ+9cMlc7oaB2tQy6weH+T9GnINJTuKFDmoXDyvQb b/FexUc9emyVqQ+3YbfYlHL736aEXVRrH4fS9HwvyIbksmySUzxnlnId68pZPUsuQUdkrTrVlrogy hG1swzkANZAcFmg1gxmbLqIjK6AFZImHeT0Ps1FBAz7K6Mben6A+TWkTneHT24hwPm4BOhZB014En 0binxgGrOcCiJc8gbD4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiEV-00000002ECT-2rEs; Mon, 11 Mar 2024 16:10:35 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjiES-00000002E7y-3KMe for opensbi@lists.infradead.org; Mon, 11 Mar 2024 16:10:34 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5a127c1feb0so1572299eaf.2 for ; Mon, 11 Mar 2024 09:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710173428; x=1710778228; 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=evypSdJ48qeWZ+sjiVFDK61+3BkCDc3MnqIn6HA9FoA=; b=g9py3ZyekyQFWwokxABefECk8yVODEswVAppt7peW8c0XLrMo7FKgyuhVYt9uvEt67 zpN0TVqYYlE8tt6wuYUohPDA4jOFtyqHOdKmR1iKuCqnvysoNZ+snBOf2pwp5N3dmrnt iD443oI5V8P2CGf7Lp+NtbieYUS5VHitqEhVl1zCTMI01lbw50DMe/W7+5UFN/EFLIek 9Mul3sJ38pxZP6CE18Y2FGAYMgbYs2pZ5Wl2pUWsd+UOU6lqrQM4bA4YC+M5QdvRV7TK 2w5bNvoEMKZt9ZUcOOPeQTh8zx0mM1bbtY1EAgu3uvmPaPVelfahuapxZg8uETQRibEd X4SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710173428; x=1710778228; 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=evypSdJ48qeWZ+sjiVFDK61+3BkCDc3MnqIn6HA9FoA=; b=d+LWBxoB6no3ak0GvNvIyGndWZEccg2soVG+MyokwDeRoPgCmtiit3BIuzC2wDoqqZ YRPNVTROx2rZAl+W93GA+gXwMgx1DAOOKq/zvci3qeK47z30KYAx2XIfF2dfHz2tyjR0 TExTHnB7eHe9Xg26yQVlA0mnQhm9jSxmgzH+42AlTSjpAWWhd5UGqQU0nsW+W7EjSHLy 4Cch7uEbrJhQOWU4U/9ZBd0Zl/UXKAViWPJH1zIS73d2/DdEJRMyuTasqSxV/wIgPxaC Ye2h7NTy0peKYGDj+/rl6Dsk0Lr9o3PehARYJhzRBhBO3LsUeR1fdUlK0HUZbUOYalU9 Pxsg== X-Forwarded-Encrypted: i=1; AJvYcCX0WnNju0OrcPQwWcK2w/Mi94iYg4asLjTpGRVNXGpaTnAi5vixxyGQCKXS9Bnw+iYRwjukKkPILcjcwEcZUbfvuu7q2+ljDgG77Ak= X-Gm-Message-State: AOJu0Yzk+pL4uL+EH2IGR/hWSxCUzlx79RrG3wFi+2qE33lCfP3C7fEu MsgMGslo4k724S0wn7KvgvCL0LenE4Sve9ZCtSMDRrCZML/N199GL5SXdmrTZcw= X-Google-Smtp-Source: AGHT+IGZO9sFint7MLLzm+F3cTqvr/ZJ3e3PQAHf6eny/YjtoN0CcNy+jpck0wMwnZBl818FMBNfLQ== X-Received: by 2002:a4a:3c5a:0:b0:5a1:cb0c:a4b with SMTP id p26-20020a4a3c5a000000b005a1cb0c0a4bmr5947697oof.1.1710173427751; Mon, 11 Mar 2024 09:10:27 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id dc5-20020a056820278500b005a1ec8e04a7sm856912oob.25.2024.03.11.09.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:10:27 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 9/9] lib: sbi: Extend sbi_trap_error() to dump state in a nested trap Date: Mon, 11 Mar 2024 21:39:44 +0530 Message-Id: <20240311160944.1233523-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311160944.1233523-1-apatel@ventanamicro.com> References: <20240311160944.1233523-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_091032_919119_F76613C9 X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. 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: The sbi_trap_error() should dump state of all in-flight traps upon failure in a nested trap so extend it accordingly. Signed-off-by: Anup Patel --- lib/sbi/sbi_trap.c | 104 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+), 44 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 [2607:f8b0:4864:20:0:0:0:c29 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The sbi_trap_error() should dump state of all in-flight traps upon failure in a nested trap so extend it accordingly. Signed-off-by: Anup Patel --- lib/sbi/sbi_trap.c | 104 ++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index b0fa5fd..1c9cf1f 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -23,54 +23,70 @@ #include #include -static void __noreturn sbi_trap_error(const char *msg, int rc, - ulong mcause, ulong mtval, ulong mtval2, - ulong mtinst, struct sbi_trap_regs *regs) +static void sbi_trap_error_one(struct sbi_trap_context *tcntx, + const char *prefix, u32 hartid, u32 depth) { - u32 hartid = current_hartid(); + const struct sbi_trap_info *trap = tcntx->trap; + struct sbi_trap_regs *regs = tcntx->regs; - sbi_printf("%s: hart%d: %s (error %d)\n", __func__, hartid, msg, rc); - sbi_printf("%s: hart%d: mcause=0x%" PRILX " mtval=0x%" PRILX "\n", - __func__, hartid, mcause, mtval); + sbi_printf("\n"); + sbi_printf("%s: hart%d: trap%d: mcause=0x%" PRILX " mtval=0x%" PRILX "\n", + prefix, hartid, depth, trap->cause, trap->tval); if (misa_extension('H')) { - sbi_printf("%s: hart%d: mtval2=0x%" PRILX + sbi_printf("%s: hart%d: trap%d: mtval2=0x%" PRILX " mtinst=0x%" PRILX "\n", - __func__, hartid, mtval2, mtinst); + prefix, hartid, depth, trap->tval2, trap->tinst); } - sbi_printf("%s: hart%d: mepc=0x%" PRILX " mstatus=0x%" PRILX "\n", - __func__, hartid, regs->mepc, regs->mstatus); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "ra", regs->ra, "sp", regs->sp); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "gp", regs->gp, "tp", regs->tp); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "s0", regs->s0, "s1", regs->s1); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "a0", regs->a0, "a1", regs->a1); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "a2", regs->a2, "a3", regs->a3); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "a4", regs->a4, "a5", regs->a5); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "a6", regs->a6, "a7", regs->a7); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "s2", regs->s2, "s3", regs->s3); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "s4", regs->s4, "s5", regs->s5); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "s6", regs->s6, "s7", regs->s7); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "s8", regs->s8, "s9", regs->s9); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "s10", regs->s10, "s11", regs->s11); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "t0", regs->t0, "t1", regs->t1); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "t2", regs->t2, "t3", regs->t3); - sbi_printf("%s: hart%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", __func__, - hartid, "t4", regs->t4, "t5", regs->t5); - sbi_printf("%s: hart%d: %s=0x%" PRILX "\n", __func__, hartid, "t6", - regs->t6); + sbi_printf("%s: hart%d: trap%d: mepc=0x%" PRILX " mstatus=0x%" PRILX "\n", + prefix, hartid, depth, regs->mepc, regs->mstatus); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "ra", regs->ra, "sp", regs->sp); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "gp", regs->gp, "tp", regs->tp); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "s0", regs->s0, "s1", regs->s1); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "a0", regs->a0, "a1", regs->a1); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "a2", regs->a2, "a3", regs->a3); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "a4", regs->a4, "a5", regs->a5); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "a6", regs->a6, "a7", regs->a7); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "s2", regs->s2, "s3", regs->s3); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "s4", regs->s4, "s5", regs->s5); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "s6", regs->s6, "s7", regs->s7); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "s8", regs->s8, "s9", regs->s9); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "s10", regs->s10, "s11", regs->s11); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "t0", regs->t0, "t1", regs->t1); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "t2", regs->t2, "t3", regs->t3); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX " %s=0x%" PRILX "\n", prefix, + hartid, depth, "t4", regs->t4, "t5", regs->t5); + sbi_printf("%s: hart%d: trap%d: %s=0x%" PRILX "\n", prefix, + hartid, depth, "t6", regs->t6); +} + +static void __noreturn sbi_trap_error(const char *msg, int rc, + struct sbi_trap_context *tcntx) +{ + u32 depth = 0, hartid = current_hartid(); + struct sbi_trap_context *tc; + + for (tc = tcntx; tc; tc = tc->prev_context) + depth++; + + sbi_printf("\n"); + sbi_printf("%s: hart%d: trap%d: %s (error %d)\n", __func__, + hartid, depth - 1, msg, rc); + for (tc = tcntx; tc; tc = tc->prev_context) + sbi_trap_error_one(tc, __func__, hartid, --depth); sbi_hart_hang(); } @@ -340,7 +356,7 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) trap_done: if (rc) - sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); + sbi_trap_error(msg, rc, &tcntx); sbi_trap_set_context(scratch, tcntx.prev_context); return regs; }