From patchwork Tue Mar 12 10:27:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910930 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=vShl9XFq; 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=dbseNnGb; 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 4Tv8xZ4zRYz1yWt for ; Tue, 12 Mar 2024 21:28:34 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mf09nAAjy1cycCp/cpWfe0hPo8MhJquO/k5Hj4zLt1A=; b=vShl9XFqkeBiCb RzcUgihKqc4pcxIvDPAy2TskQvvi0VyytRJou/s3i904xFRki7eBIF4oxJFht1Z/ssWlxwYX9eivO N6bN8GlneUItju+m9eBFzuq8xk1/GsWDviKwbK/JyByHs+ypaE76HP2qpWm3npxjdSt+A9ucFhrUt 63nC+Oc91Ahrumk6+lei4fVB+PiqbqtNzcg88g8AeRU2ALk0mEgvS2tm096TVF4Pq6RHzEmYpZR6U IdcHDsdgoLIlxN9bygPgxE7s6C55p4weuYekHs7afwkf2e36hFPaaZd+om59QtpRl0O5wUnhOhiOk 6BCUcK73ri/TPibqaT9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzMv-00000005LKE-2UU8; Tue, 12 Mar 2024 10:28:25 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzMr-00000005LHe-3VXp for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:24 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6ddca59e336so2823747a34.0 for ; Tue, 12 Mar 2024 03:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239300; x=1710844100; 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=CZJ3gKxQ97r4pe3sfIjIgQUxHh/PmtqrlxwxtSru6es=; b=dbseNnGbuxAYKaLSjvqL0jBcc5xmEsapXiJSD0Oxd/czDkn+1FjjEMyvwEz0g0qZS+ vigsVkjvpf5qmtYqKq4XhHUkCR8rf+U/jCsL62H1zyDl7IYD1U6Eovq4KO1VFpcAEiNQ tT/hEZdoi7Q3u6GXqm8ma+65e4QfWGhsZvZwe5eIdnO0PxwF2QKGinh9hbuNKNuXV4vz +Ga1TzVGRWmq+y7Xp0rVcF0za6z1XCuxGU7XZE7nOHoh+kq27guKC4dIOnvdVdYULYni UB2GX6HI9ZLbu+Ix7T66mHH7pZ4wGHJW+3aynT/rwZeEZEBbUt+1+toGA+tcyK1fml67 +hRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239300; x=1710844100; 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=CZJ3gKxQ97r4pe3sfIjIgQUxHh/PmtqrlxwxtSru6es=; b=VNxhYuh6yecWizmqwiQmI2/iN4ze6ScmFyJM6FT3msT0Ve4iInsi7x7cYt63+Ro6DS BUGtBo4ypG4xG0UQBZHjhYNup5OBBq3+R+i/hd1+ojlxRuw8nhvvHZDExqq1TjZZB6IA WEIGMmO4YxISE5JnH8uYzxQ0arG1vNaYSWPEqIqnCqyZo41xOuibVw77s4KZIKV83LFI oP8AVw7RKVfPpVV6eiEaltZS9jC2wh1DbdMQdlHACTw6Wt9Vxqlr2d721oWWCzKxPX2O +D26jERj7VfhWTkbb3oifEm+ofThpwnQXNCS2Er6M/l55QqHNwK/HPptkhUBUWCWcF/D MbqQ== X-Forwarded-Encrypted: i=1; AJvYcCVKuCkljqTSkHrC1a3Be1sLAlFzvW917+mEByz+nx7RfnRGE3GQ5XPDPDyuJ1OuBsT37sWdmRKs8I5mLTeKUmLeU7p4NmBQ3uMVZLM= X-Gm-Message-State: AOJu0YxSa8aJKv8gOCkzG+lHVkmOT9weMjiJyaoV4mMT2ApQ0bMRACRl Tk8dZHGv1dE6uOV30BMDIcor520+xU65sOoRgU9Mg+iiwSINtONX9W33iJCxsuA= X-Google-Smtp-Source: AGHT+IE7Gjl5rEOEwyTDkXqNJTvjRTwUxTPpA2P4dpPp2TVd9lv15r4SEDTD6rXnJ2k9ljUF1CLbJg== X-Received: by 2002:a05:6830:18f6:b0:6e5:3213:8126 with SMTP id d22-20020a05683018f600b006e532138126mr2011610otf.17.1710239300164; Tue, 12 Mar 2024 03:28:20 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:19 -0700 (PDT) From: Anup Patel To: Atish Patra Subject: [PATCH v2 01/10] lib: sbi: Remove epc from struct sbi_trap_info Date: Tue, 12 Mar 2024 15:57:55 +0530 Message-Id: <20240312102804.1436376-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032821_992161_76F854CE X-CRM114-Status: GOOD ( 13.50 ) 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: From: Samuel Holland In the only places this value is used, it duplicates mepc from struct sbi_trap_regs. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi/sbi_trap.h | 16 ++++++ lib/sbi/sbi_ecall_legacy.c | 4 ---- lib/sbi/sbi [...] 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:336 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , opensbi@lists.infradead.org, Andrew Jones Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Samuel Holland In the only places this value is used, it duplicates mepc from struct sbi_trap_regs. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi/sbi_trap.h | 16 ++++++---------- lib/sbi/sbi_ecall_legacy.c | 4 ---- lib/sbi/sbi_expected_trap.S | 4 ---- lib/sbi/sbi_illegal_insn.c | 2 -- lib/sbi/sbi_trap.c | 5 ++--- lib/sbi/sbi_trap_ldst.c | 4 ---- 6 files changed, 8 insertions(+), 27 deletions(-) diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index 2727bdb..3757694 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -87,20 +87,18 @@ /** Last member index in sbi_trap_regs */ #define SBI_TRAP_REGS_last 35 -/** Index of epc member in sbi_trap_info */ -#define SBI_TRAP_INFO_epc 0 /** Index of cause member in sbi_trap_info */ -#define SBI_TRAP_INFO_cause 1 +#define SBI_TRAP_INFO_cause 0 /** Index of tval member in sbi_trap_info */ -#define SBI_TRAP_INFO_tval 2 +#define SBI_TRAP_INFO_tval 1 /** Index of tval2 member in sbi_trap_info */ -#define SBI_TRAP_INFO_tval2 3 +#define SBI_TRAP_INFO_tval2 2 /** Index of tinst member in sbi_trap_info */ -#define SBI_TRAP_INFO_tinst 4 +#define SBI_TRAP_INFO_tinst 3 /** Index of gva member in sbi_trap_info */ -#define SBI_TRAP_INFO_gva 5 +#define SBI_TRAP_INFO_gva 4 /** Last member index in sbi_trap_info */ -#define SBI_TRAP_INFO_last 6 +#define SBI_TRAP_INFO_last 5 /* clang-format on */ @@ -194,8 +192,6 @@ struct sbi_trap_regs { /** Representation of trap details */ struct sbi_trap_info { - /** epc Trap program counter */ - unsigned long epc; /** cause Trap exception cause */ unsigned long cause; /** tval Trap value */ diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c index 14913c9..9a1ae1e 100644 --- a/lib/sbi/sbi_ecall_legacy.c +++ b/lib/sbi/sbi_ecall_legacy.c @@ -74,7 +74,6 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, &hmask, &trap)) { ret = sbi_ipi_send_smode(hmask, 0); } else { - trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } @@ -86,7 +85,6 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, SBI_TLB_FENCE_I, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } else { - trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } @@ -98,7 +96,6 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, SBI_TLB_SFENCE_VMA, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } else { - trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } @@ -112,7 +109,6 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } else { - trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } diff --git a/lib/sbi/sbi_expected_trap.S b/lib/sbi/sbi_expected_trap.S index 1f2d6b9..99dede5 100644 --- a/lib/sbi/sbi_expected_trap.S +++ b/lib/sbi/sbi_expected_trap.S @@ -23,8 +23,6 @@ .global __sbi_expected_trap __sbi_expected_trap: /* Without H-extension so, MTVAL2 and MTINST CSRs and GVA not available */ - csrr a4, CSR_MEPC - REG_S a4, SBI_TRAP_INFO_OFFSET(epc)(a3) csrr a4, CSR_MCAUSE REG_S a4, SBI_TRAP_INFO_OFFSET(cause)(a3) csrr a4, CSR_MTVAL @@ -41,8 +39,6 @@ __sbi_expected_trap: .global __sbi_expected_trap_hext __sbi_expected_trap_hext: /* With H-extension so, MTVAL2 and MTINST CSRs and GVA available */ - csrr a4, CSR_MEPC - REG_S a4, SBI_TRAP_INFO_OFFSET(epc)(a3) csrr a4, CSR_MCAUSE REG_S a4, SBI_TRAP_INFO_OFFSET(cause)(a3) csrr a4, CSR_MTVAL diff --git a/lib/sbi/sbi_illegal_insn.c b/lib/sbi/sbi_illegal_insn.c index 2be4757..dd0b3c1 100644 --- a/lib/sbi/sbi_illegal_insn.c +++ b/lib/sbi/sbi_illegal_insn.c @@ -25,7 +25,6 @@ static int truly_illegal_insn(ulong insn, struct sbi_trap_regs *regs) { struct sbi_trap_info trap; - trap.epc = regs->mepc; trap.cause = CAUSE_ILLEGAL_INSTRUCTION; trap.tval = insn; trap.tval2 = 0; @@ -156,7 +155,6 @@ int sbi_illegal_insn_handler(ulong insn, struct sbi_trap_regs *regs) if (unlikely((insn & 3) != 3)) { insn = sbi_get_insn(regs->mepc, &uptrap); if (uptrap.cause) { - uptrap.epc = regs->mepc; return sbi_trap_redirect(regs, &uptrap); } if ((insn & 3) != 3) diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index c665013..c9db73f 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -140,7 +140,7 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, if (next_virt) { /* Update VS-mode exception info */ csr_write(CSR_VSTVAL, trap->tval); - csr_write(CSR_VSEPC, trap->epc); + csr_write(CSR_VSEPC, regs->mepc); csr_write(CSR_VSCAUSE, trap->cause); /* Set MEPC to VS-mode exception vector base */ @@ -171,7 +171,7 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, } else { /* Update S-mode exception info */ csr_write(CSR_STVAL, trap->tval); - csr_write(CSR_SEPC, trap->epc); + csr_write(CSR_SEPC, regs->mepc); csr_write(CSR_SCAUSE, trap->cause); /* Set MEPC to S-mode exception vector base */ @@ -286,7 +286,6 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) return regs; } /* Original trap_info */ - trap.epc = regs->mepc; trap.cause = mcause; trap.tval = mtval; trap.tval2 = mtval2; diff --git a/lib/sbi/sbi_trap_ldst.c b/lib/sbi/sbi_trap_ldst.c index d864ad1..5a0537b 100644 --- a/lib/sbi/sbi_trap_ldst.c +++ b/lib/sbi/sbi_trap_ldst.c @@ -70,7 +70,6 @@ static int sbi_trap_emulate_load(struct sbi_trap_regs *regs, */ insn = sbi_get_insn(regs->mepc, &uptrap); if (uptrap.cause) { - uptrap.epc = regs->mepc; return sbi_trap_redirect(regs, &uptrap); } insn_len = INSN_LEN(insn); @@ -193,7 +192,6 @@ static int sbi_trap_emulate_store(struct sbi_trap_regs *regs, */ insn = sbi_get_insn(regs->mepc, &uptrap); if (uptrap.cause) { - uptrap.epc = regs->mepc; return sbi_trap_redirect(regs, &uptrap); } insn_len = INSN_LEN(insn); @@ -277,7 +275,6 @@ static int sbi_misaligned_ld_emulator(int rlen, union sbi_ldst_data *out_val, out_val->data_bytes[i] = sbi_load_u8((void *)(orig_trap->tval + i), &uptrap); if (uptrap.cause) { - uptrap.epc = regs->mepc; uptrap.tinst = sbi_misaligned_tinst_fixup( orig_trap->tinst, uptrap.tinst, i); return sbi_trap_redirect(regs, &uptrap); @@ -304,7 +301,6 @@ static int sbi_misaligned_st_emulator(int wlen, union sbi_ldst_data in_val, sbi_store_u8((void *)(orig_trap->tval + i), in_val.data_bytes[i], &uptrap); if (uptrap.cause) { - uptrap.epc = regs->mepc; uptrap.tinst = sbi_misaligned_tinst_fixup( orig_trap->tinst, uptrap.tinst, i); return sbi_trap_redirect(regs, &uptrap); From patchwork Tue Mar 12 10:27:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910931 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=IZmf7Sxr; 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=LxYv9buD; 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 4Tv8xd5bpVz1yWt for ; Tue, 12 Mar 2024 21:28: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0AB4YQC2jQEsaJBRElzr5OGujWSXAcG277azXCL1Tzc=; b=IZmf7SxrzOQoCO XK2v0rSDlisJiedzAvkgQvpraUDeuYlwxOvrof41U4MdyERpyGeUn/Jl5ld53+dD0kdKC9Zrt7M2l mPacpn6a5vwEhhxCzQlISWijH5VaeDMJAt2JErjQ0MDZZNbiupqeL7+FipTI0d5sCmCYSg00GvvkF l0aB0SQkxkjSdsIoAzZTspABlqb3RoWXiSv32BNg5UcTazqRZPtnQ/xB2WcjJDNKZdCqwadRbYSM2 hOzK9+BYhhF3av/StIxg7UynYpUeOPuSI+mZL5ubdhsV/fJ0p79IB5Vvl1/U5EDoMqJjotfbOtC/p KMYqulpUzwDsAuIUf/4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzMy-00000005LMY-23kJ; Tue, 12 Mar 2024 10:28:28 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzMw-00000005LJj-0C8k for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:27 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5a1b6800ba8so2394175eaf.0 for ; Tue, 12 Mar 2024 03:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239304; x=1710844104; 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=LOXOlrosRpbGPrAzzzEyZTcOCw3ptKQtBkoAFY8h298=; b=LxYv9buDV6E4+j0RKaa5nR/UWlqRQ8BklchP16zvaoK6LgsN3T5jiUQ30TOVZUfnTO m0yk40xTsUXAIgz7xr9UEYyigYx2KBew4CJ+32D4TUl61hRRNFXjcJ4gmvrjona3SyC1 ZOxdJcg8SP4yQ6UgTGCKlIF87M5YA84fVQb+81c8ja/S99qwlEQMOT2xNr1Evpna7tx6 xCRzyPpRWaUIRe3gRO0hEHx65/Bn5G7C/mROA4957juaMBxiyYQMS1Be8mIkNZiJLRPz YRU84AYbUFXlGJA5SIo9yJuK6NmMspLvGR653ff1sG02IVKTfqRHa1y4YVGAjKJiFglC 6j9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239304; x=1710844104; 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=LOXOlrosRpbGPrAzzzEyZTcOCw3ptKQtBkoAFY8h298=; b=v7n8gijHoeTRX0infJYQrb/s10FyS3C6DFA3QDiCrrdo0RGQX5sPB2Ed63TKMaG+i0 RPJqbLlQIFMAZzsgetLbHxa1SdPmZnHzKVhzFKNDoSxAqtwUyOGqX3WwH0HBz0+cwqcl qnDhyYOTsXdZUEdJUAL3O1UVR+QF74qcE/Fp4e78vG+Km8q5C9DR4oc95ymGW/PB7+10 iMiQ0+NZLjTzYdKTzVjTFL3crDhdts6d0AOoPgqP/LR6eo7gPnBnV3g0d3HNk+3bk2hH mvffPZSS723w1+OQKh3e2kQXDRDuNjIm3JS9bDsLQBGqi5D2wSgN251WDoIbsyTQnL0Y MDYw== X-Forwarded-Encrypted: i=1; AJvYcCXzB4Sp7Fq6ZWICzyZbscSlWVqYpnHVnKd2MGlYNiba11/h3whsPjM7rf+hqOTgf4GVNGEjwe2kqK2ojyuV0M7lUkOW0kUfllphFrw= X-Gm-Message-State: AOJu0Yz2F663LuyS6BaqtGA4mdp5kLFeF6C8D1q/5STkIoBkF6YdqZPk k2G7bF9MRRvzFJf886QmYqfJw5Bs6R10CP5BcDMYRIpnITQl5W2Rfb5yMxNtu3Q= X-Google-Smtp-Source: AGHT+IHWBDJ18h5iNrHU7UM5XBSyKClzRFL1gG68HthuTYbRUOEb24pwF//7AJkfsWEcfvw5+QQXkw== X-Received: by 2002:a4a:7302:0:b0:5a1:25fc:7bdb with SMTP id s2-20020a4a7302000000b005a125fc7bdbmr7111877ooc.6.1710239303747; Tue, 12 Mar 2024 03:28:23 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:23 -0700 (PDT) From: Anup Patel To: Atish Patra Subject: [PATCH v2 02/10] lib: sbi: Remove sbi_trap_exit() and related code Date: Tue, 12 Mar 2024 15:57:56 +0530 Message-Id: <20240312102804.1436376-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032826_148564_3D8147E5 X-CRM114-Status: GOOD ( 12.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Over the years, no uses of sbi_trap_exit() have been found so remove it and also remove related code from fw_base.S and sbi_scratch.h. Signed-off-by: Anup Patel Reviewed-by: Samuel Holland --- firmware/fw_base.S | 11 include/sbi/sbi_scratch.h | 15 +++ inclu [...] 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:c32 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org, Andrew Jones Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Over the years, no uses of sbi_trap_exit() have been found so remove it and also remove related code from fw_base.S and sbi_scratch.h. Signed-off-by: Anup Patel Reviewed-by: Samuel Holland --- firmware/fw_base.S | 11 ----------- include/sbi/sbi_scratch.h | 15 +++------------ include/sbi/sbi_trap.h | 2 -- lib/sbi/sbi_trap.c | 19 ------------------- 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 126b067..c404d8b 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -298,9 +298,6 @@ _scratch_init: /* Store hartid-to-scratch function address in scratch space */ lla a4, _hartid_to_scratch REG_S a4, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET(tp) - /* Store trap-exit function address in scratch space */ - lla a4, _trap_exit - REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(tp) /* Clear tmp0 in scratch space */ REG_S zero, SBI_SCRATCH_TMP0_OFFSET(tp) /* Store firmware options in scratch space */ @@ -453,10 +450,6 @@ _start_warm: srli a5, a5, ('H' - 'A') andi a5, a5, 0x1 beq a5, zero, _skip_trap_handler_rv32_hyp - /* Override trap exit for H-extension */ - csrr a5, CSR_MSCRATCH - lla a4, _trap_exit_rv32_hyp - REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(a5) lla a4, _trap_handler_rv32_hyp _skip_trap_handler_rv32_hyp: #endif @@ -695,7 +688,6 @@ memcmp: .section .entry, "ax", %progbits .align 3 .globl _trap_handler - .globl _trap_exit _trap_handler: TRAP_SAVE_AND_SETUP_SP_T0 @@ -705,7 +697,6 @@ _trap_handler: TRAP_CALL_C_ROUTINE -_trap_exit: TRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0 TRAP_RESTORE_MEPC_MSTATUS 0 @@ -718,7 +709,6 @@ _trap_exit: .section .entry, "ax", %progbits .align 3 .globl _trap_handler_rv32_hyp - .globl _trap_exit_rv32_hyp _trap_handler_rv32_hyp: TRAP_SAVE_AND_SETUP_SP_T0 @@ -728,7 +718,6 @@ _trap_handler_rv32_hyp: TRAP_CALL_C_ROUTINE -_trap_exit_rv32_hyp: TRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0 TRAP_RESTORE_MEPC_MSTATUS 1 diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index e6a33ba..55b937f 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -36,14 +36,12 @@ #define SBI_SCRATCH_PLATFORM_ADDR_OFFSET (9 * __SIZEOF_POINTER__) /** Offset of hartid_to_scratch member in sbi_scratch */ #define SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET (10 * __SIZEOF_POINTER__) -/** Offset of trap_exit member in sbi_scratch */ -#define SBI_SCRATCH_TRAP_EXIT_OFFSET (11 * __SIZEOF_POINTER__) /** Offset of tmp0 member in sbi_scratch */ -#define SBI_SCRATCH_TMP0_OFFSET (12 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_TMP0_OFFSET (11 * __SIZEOF_POINTER__) /** Offset of options member in sbi_scratch */ -#define SBI_SCRATCH_OPTIONS_OFFSET (13 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_OPTIONS_OFFSET (12 * __SIZEOF_POINTER__) /** Offset of extra space in sbi_scratch */ -#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (14 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (13 * __SIZEOF_POINTER__) /** Maximum size of sbi_scratch (4KB) */ #define SBI_SCRATCH_SIZE (0x1000) @@ -77,8 +75,6 @@ struct sbi_scratch { unsigned long platform_addr; /** Address of HART ID to sbi_scratch conversion function */ unsigned long hartid_to_scratch; - /** Address of trap exit function */ - unsigned long trap_exit; /** Temporary storage */ unsigned long tmp0; /** Options for OpenSBI library */ @@ -129,11 +125,6 @@ _Static_assert( == SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET, "struct sbi_scratch definition has changed, please redefine " "SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET"); -_Static_assert( - offsetof(struct sbi_scratch, trap_exit) - == SBI_SCRATCH_TRAP_EXIT_OFFSET, - "struct sbi_scratch definition has changed, please redefine " - "SBI_SCRATCH_TRAP_EXIT_OFFSET"); _Static_assert( offsetof(struct sbi_scratch, tmp0) == SBI_SCRATCH_TMP0_OFFSET, diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index 3757694..a6032ab 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -225,8 +225,6 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs); -void __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs); - #endif #endif diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index c9db73f..b059c4b 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -334,22 +334,3 @@ trap_error: sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); return regs; } - -typedef void (*trap_exit_t)(const struct sbi_trap_regs *regs); - -/** - * Exit trap/interrupt handling - * - * This function is called by non-firmware code to abruptly exit - * trap/interrupt handling and resume execution at context pointed - * by given register state. - * - * @param regs pointer to register state - */ -void __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs) -{ - struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); - - ((trap_exit_t)scratch->trap_exit)(regs); - __builtin_unreachable(); -} From patchwork Tue Mar 12 10:27:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910932 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=MNsO646q; 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=RdjhX23u; 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 4Tv8xh6rSgz1yWt for ; Tue, 12 Mar 2024 21:28:40 +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=MNsO646qtQm+6S cCMA0IkA8FG7U6qbcXNbRtvOBGY/Z/obvs7n+atmkNOWT+t0QU1UAx5iKrRHMQF03Z+7dDwwwZ3y6 bqBG4MTyJVMq3srZzFad3g3IxQ8B1OiozC7x7Vc8sj4cKpvVo8dkfNWYvOqyLlbpsdmtzp9a74avx vOy+g6ZDoIfPH8kXB9zh+4RvM+FxD8HIes5RyFBsztcsc7lK6kNznG/iqRCkIQvfBg4D29eu5jI7f b6RgCqrY2ZZB2rT6O6uCvJso2tZ/QC/dU+34AzYx7IccCzu59kbsF3WnTOhJmRQLGX+iS+wrA9oaN gnqBnylVDXh/yOK8ZAow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzN2-00000005LP1-1AHc; Tue, 12 Mar 2024 10:28:32 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzMx-00000005LLk-3Wlv for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:29 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6e4f8f140c1so2301055a34.2 for ; Tue, 12 Mar 2024 03:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239307; x=1710844107; 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=RdjhX23uJNd1ZMmb1RJUKReSN0pxOUdV/zzT9g/3CkYGilBLw4XRcFzt38qXiDqk0f iQbvtp2d5N5NGnDtZuUwpn+b3eV2eMF3g5tfp0w9nqA32ztUlyEaizEktVUtxftzMCyg HjTJtNvY4Iu27Nv87QjEjTfGwPVFMKJLYt/b0F+YszVAAlXIUH6T0CYCa1lDnz/rWPFo VntgVXh8EDrhwoPKNrIxtjCS/PFj7tQiPPvx4copy9ihaIWd9qKa7g54Csbn9tD1UBhH jCIKez1r7KNvdFayqUjBIZUOcaJpzFP6huxKBEBnkuKtMQI2LfyLKDRNEEeUq+wh6YgE BPrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239307; x=1710844107; 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=SVzGgHpkvep0qoKo8gO1t2PXIwMaZwHQZabN3TAqnoI72kQbgeDQyY3mx5XD9dKXXY SsaxhMLcojINUdL2j0yT9bxrqJzePIGoQ2w1fcbXp1Lao5y7RICM1UpVw7VSuaGsix9i 5eJyJED008eaot5dl2NF4beInQ/TzxYapMHqR5vrMEci+czhIPNSQMeYwskgdyOaquUe 6sFTq2C6FgyIPSTGqngSQW2rfQy601CHio7zkVhrEHokVuwjM8tAw30uRnNQCPJjkSaX vA75grqPHhW590j9XcmKF8dkv4EzIveCTUU0RhjcEA4i6YfOFpHcPINbjTn+qdcwwanJ nIGQ== X-Forwarded-Encrypted: i=1; AJvYcCU2Ngo3iMAZB5ELQaxC2+TUMhanX/xLOTcuRGC7tq2TPgkkK7vbmTL+68lGp+UWiS98KaqLQVZXMjBlA0thIavq5ai2MfWZYHFiyco= X-Gm-Message-State: AOJu0YyXHWA7gdVKGQs40TDsr0PSvkUi/+wg2jqUprUjBvXAeDg4gEgL QBOUirMnygDMwQi0mYAayXkrYtHgnW+r/8u9gUmaJkhoNcIuDewNW6z1syvHx6I= X-Google-Smtp-Source: AGHT+IF6Hi9MF9q8EPPiO3pKE58/gyPxhyxwSaIZCoEjBUGdq6opmSuZIO68TuMlu5NhIZRmP9tI4A== X-Received: by 2002:a9d:62c1:0:b0:6e5:319:39a3 with SMTP id z1-20020a9d62c1000000b006e5031939a3mr10272863otk.28.1710239307078; Tue, 12 Mar 2024 03:28:27 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:26 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 03/10] include: sbi: Add trap_context pointer in struct sbi_scratch Date: Tue, 12 Mar 2024 15:57:57 +0530 Message-Id: <20240312102804.1436376-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032827_897105_2FDAC9D2 X-CRM114-Status: GOOD ( 11.23 ) 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:336 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Reviewed-by: Samuel Holland --- 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 Tue Mar 12 10:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910933 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=s9bYTCn2; 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=NmQPAe+T; 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 4Tv8xl5NCLz1yWt for ; Tue, 12 Mar 2024 21:28: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=j+cUyLOiMcYcRtZnDMuhlM+9bX5i+zBc1h7I5MT3Nl8=; b=s9bYTCn28jqfnA 1hzHvErWgamletpWvzrFWEmScf90CUBWlrwKHpEm01K5BR2BqvA96qvcePPes5aeF0g1bv44nGiF5 V0K3rAPg02UbkEpOqbr7S0Ug5PcEmTVhxrufD7/Sx9Ed51xoW65l17kH1/g56f4c1noy0KtnI3Z03 4l4JQShgyTwIRGECygg6ZZm6DTcok/hriRtAvt5ca39wv6hSIvCXNEcmoR9w9tykj23JDKxmfqJo9 Gx0cPdACyX1Prcf/wJjE3wWvtS6C3QVY+E2c7Q2qZTsdIxkIL//D6vnCH4IIbMBBj39aQ24hYi7n/ Xf384gAbC2UWtqc5mCIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzN5-00000005LSY-361q; Tue, 12 Mar 2024 10:28:35 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzN1-00000005LNd-41UF for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:33 +0000 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6e4f874f958so1924787a34.3 for ; Tue, 12 Mar 2024 03:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239310; x=1710844110; 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=Fg2MLXAHcuh+3YqEQw/O83HAXgCajJ/dGwgG2yUrMaE=; b=NmQPAe+THD/LF+ex9PjgbsZQFu4hn1vU7S0pizJ9PD5Z2TCz4UEWflby3kWm/DJy6R n6sn/fX/NBWqgRLrN8he1G7gMjkkIMWg1WlUEvwbgQXRQfeiaEb/ZDMQ/UF5c92PuegK tiXhA54DYgMjPcuBXde6en5UFHMjuOXr3pGf7Mo2qnn7LDvuAgLhyF1V3gZXmlsf3paT 77VOqQ39o6VPPJPasFqlgzOyaIEKaN4WMX5DbKK05LRsGcJ4AkybDcee19Th7QKKb7Nt tBCPQLp0qoQw0uwbnuCoHmwlbiFL6qqjEPPyptVk0KeyOKnYe5CtncTb8k+r24DLbQQO HlzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239310; x=1710844110; 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=Fg2MLXAHcuh+3YqEQw/O83HAXgCajJ/dGwgG2yUrMaE=; b=Q9jwtCkt+qThZ9/493K3DJL+gZFXnqvT5eKD53NG251Z5MiyF5r9l4+5zxu9Hztm28 JgM+cRrqxvU1hoOxcK8biPmjtPHkscItUZy81eC8kfMJmE6D304nz2Alw3stSiC4lFmC PWRjekNtSL6YmC9MYvu7MTWB3rc6+A+UZO7iYosyamKw+tQM5EuxoYmoynruUlnm5PE1 DP/0Dxzl7CanYdfiV6rJTKSV+vfg3MLK13Yt5BRyHNg7bYc54B4z63E7P40IYtS6Rg0A YXZeWeM5Q1A2Jh/NPqi4Pa+XeluoYI5LjK+IOQpO7WH7P9TDsXep8mSzxwhiS//d4H6H O/DQ== X-Forwarded-Encrypted: i=1; AJvYcCUPS+v3i5qbPuVEItG+ZEHmNZwd3bcO2MoscS8oXcPpWYQ2fkHpovr1lFguJvXl2ddv1z+wqFhV5eleAcqDqhW6+t+mgiuRvtJt2WE= X-Gm-Message-State: AOJu0Yx4LVW0jR1bUw3+hygTmiSCjJ0vwENeq803nIZQWxIc9BIL6ohZ XoX0011laA+XaBaySTj0b7q3E/IhfUCDCRqmWtgh85a9LOD/bfr4y77JYXDaD7Q= X-Google-Smtp-Source: AGHT+IEqhR+Dcla/fKT3bCdhywrpLHtaNmdQGJUMEVSMwTHQQikeDar1OFdGiUUFBR/GoZCC8HfkpA== X-Received: by 2002:a9d:3e47:0:b0:6e4:e947:e98 with SMTP id h7-20020a9d3e47000000b006e4e9470e98mr10500527otg.34.1710239310322; Tue, 12 Mar 2024 03:28:30 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:29 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 04/10] lib: sbi: Introduce trap context Date: Tue, 12 Mar 2024 15:57:58 +0530 Message-Id: <20240312102804.1436376-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032832_040024_F13434D7 X-CRM114-Status: GOOD ( 16.50 ) 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 the struct sbi_trap_regs and struct sbi_trap_info a new struct sbi_trap_context (aka trap context) which must be saved by low-level trap handler before calling sbi_trap_handler(). 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:330 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 the struct sbi_trap_regs and struct sbi_trap_info a new struct sbi_trap_context (aka trap context) which must be saved by low-level trap handler before calling sbi_trap_handler(). 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 Reviewed-by: Samuel Holland --- firmware/fw_base.S | 62 ++++++++++++++++++++++++++++++++++-------- include/sbi/sbi_trap.h | 29 +++++++++++++++++++- lib/sbi/sbi_trap.c | 58 +++++++++++++++++---------------------- 3 files changed, 103 insertions(+), 46 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 539fd1d..967cca5 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -446,14 +446,12 @@ _start_warm: /* Setup trap handler */ lla a4, _trap_handler -#if __riscv_xlen == 32 csrr a5, CSR_MISA srli a5, a5, ('H' - 'A') andi a5, a5, 0x1 - beq a5, zero, _skip_trap_handler_rv32_hyp - lla a4, _trap_handler_rv32_hyp -_skip_trap_handler_rv32_hyp: -#endif + beq a5, zero, _skip_trap_handler_hyp + lla a4, _trap_handler_hyp +_skip_trap_handler_hyp: csrw CSR_MTVEC, a4 /* Initialize SBI runtime */ @@ -564,10 +562,10 @@ memcmp: xor t0, tp, t0 /* Save original SP on exception stack */ - REG_S sp, (SBI_TRAP_REGS_OFFSET(sp) - SBI_TRAP_REGS_SIZE)(t0) + REG_S sp, (SBI_TRAP_REGS_OFFSET(sp) - SBI_TRAP_CONTEXT_SIZE)(t0) - /* Set SP to exception stack and make room for trap registers */ - add sp, t0, -(SBI_TRAP_REGS_SIZE) + /* Set SP to exception stack and make room for trap context */ + add sp, t0, -(SBI_TRAP_CONTEXT_SIZE) /* Restore T0 from scratch space */ REG_L t0, SBI_SCRATCH_TMP0_OFFSET(tp) @@ -627,6 +625,32 @@ memcmp: REG_S t6, SBI_TRAP_REGS_OFFSET(t6)(sp) .endm +.macro TRAP_SAVE_INFO have_mstatush have_h_extension + csrr t0, CSR_MCAUSE + REG_S t0, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(cause))(sp) + csrr t0, CSR_MTVAL + REG_S t0, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(tval))(sp) +.if \have_h_extension + csrr t0, CSR_MTVAL2 + REG_S t0, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(tval2))(sp) + csrr t0, CSR_MTINST + REG_S t0, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(tinst))(sp) + .if \have_mstatush + csrr t0, CSR_MSTATUSH + srli t0, t0, MSTATUSH_GVA_SHIFT + .else + csrr t0, CSR_MSTATUS + srli t0, t0, MSTATUS_GVA_SHIFT + .endif + and t0, t0, 0x1 +.else + REG_S zero, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(tval2))(sp) + REG_S zero, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(tinst))(sp) + add t0, zero, zero +.endif + REG_S t0, (SBI_TRAP_REGS_SIZE + SBI_TRAP_INFO_OFFSET(gva))(sp) +.endm + .macro TRAP_CALL_C_ROUTINE /* Call C routine */ add a0, sp, zero @@ -696,6 +720,8 @@ _trap_handler: TRAP_SAVE_GENERAL_REGS_EXCEPT_SP_T0 + TRAP_SAVE_INFO 0 0 + TRAP_CALL_C_ROUTINE TRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0 @@ -706,27 +732,39 @@ _trap_handler: mret -#if __riscv_xlen == 32 .section .entry, "ax", %progbits .align 3 - .globl _trap_handler_rv32_hyp -_trap_handler_rv32_hyp: + .globl _trap_handler_hyp +_trap_handler_hyp: TRAP_SAVE_AND_SETUP_SP_T0 +#if __riscv_xlen == 32 TRAP_SAVE_MEPC_MSTATUS 1 +#else + TRAP_SAVE_MEPC_MSTATUS 0 +#endif TRAP_SAVE_GENERAL_REGS_EXCEPT_SP_T0 +#if __riscv_xlen == 32 + TRAP_SAVE_INFO 1 1 +#else + TRAP_SAVE_INFO 0 1 +#endif + TRAP_CALL_C_ROUTINE TRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0 +#if __riscv_xlen == 32 TRAP_RESTORE_MEPC_MSTATUS 1 +#else + TRAP_RESTORE_MEPC_MSTATUS 0 +#endif TRAP_RESTORE_A0_T0 mret -#endif .section .entry, "ax", %progbits .align 3 diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index a6032ab..f7c170e 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -112,9 +112,15 @@ /** Size (in bytes) of sbi_trap_info */ #define SBI_TRAP_INFO_SIZE SBI_TRAP_INFO_OFFSET(last) +/** Size (in bytes) of sbi_trap_context */ +#define SBI_TRAP_CONTEXT_SIZE (SBI_TRAP_REGS_SIZE + \ + SBI_TRAP_INFO_SIZE + \ + __SIZEOF_POINTER__) + #ifndef __ASSEMBLER__ #include +#include /** Representation of register state at time of trap/interrupt */ struct sbi_trap_regs { @@ -204,6 +210,16 @@ struct sbi_trap_info { unsigned long gva; }; +/** Representation of trap context saved on stack */ +struct sbi_trap_context { + /** Register state */ + struct sbi_trap_regs regs; + /** Trap details */ + struct sbi_trap_info trap; + /** Pointer to previous trap context */ + struct sbi_trap_context *prev_context; +}; + static inline unsigned long sbi_regs_gva(const struct sbi_trap_regs *regs) { /* @@ -223,7 +239,18 @@ 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); -struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs); +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_context *sbi_trap_handler(struct sbi_trap_context *tcntx); #endif diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index b059c4b..4dbda06 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -24,18 +24,18 @@ #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) + const struct sbi_trap_info *trap, + const struct sbi_trap_regs *regs) { u32 hartid = current_hartid(); 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); + __func__, hartid, trap->cause, trap->tval); if (misa_extension('H')) { sbi_printf("%s: hart%d: mtval2=0x%" PRILX " mtinst=0x%" PRILX "\n", - __func__, hartid, mtval2, mtinst); + __func__, hartid, trap->tval2, trap->tinst); } sbi_printf("%s: hart%d: mepc=0x%" PRILX " mstatus=0x%" PRILX "\n", __func__, hartid, regs->mepc, regs->mstatus); @@ -258,20 +258,20 @@ static int sbi_trap_aia_irq(struct sbi_trap_regs *regs, ulong mcause) * 6. Stack pointer (SP) is setup for current HART * 7. Interrupts are disabled in MSTATUS CSR * - * @param regs pointer to register state + * @param tcntx pointer to trap context */ -struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) +struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) { int rc = SBI_ENOTSUPP; const char *msg = "trap handler failed"; - ulong mcause = csr_read(CSR_MCAUSE); - ulong mtval = csr_read(CSR_MTVAL), mtval2 = 0, mtinst = 0; - struct sbi_trap_info trap; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); + const struct sbi_trap_info *trap = &tcntx->trap; + struct sbi_trap_regs *regs = &tcntx->regs; + ulong mcause = tcntx->trap.cause; - if (misa_extension('H')) { - mtval2 = csr_read(CSR_MTVAL2); - mtinst = csr_read(CSR_MTINST); - } + /* Update trap context pointer */ + tcntx->prev_context = sbi_trap_get_context(scratch); + sbi_trap_set_context(scratch, tcntx); if (mcause & (1UL << (__riscv_xlen - 1))) { if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(), @@ -279,32 +279,23 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) 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.cause = mcause; - trap.tval = mtval; - trap.tval2 = mtval2; - trap.tinst = mtinst; - trap.gva = sbi_regs_gva(regs); switch (mcause) { case CAUSE_ILLEGAL_INSTRUCTION: - rc = sbi_illegal_insn_handler(mtval, regs); + rc = sbi_illegal_insn_handler(tcntx->trap.tval, regs); msg = "illegal instruction handler failed"; 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(regs, trap); 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(regs, trap); msg = "misaligned store handler failed"; break; case CAUSE_SUPERVISOR_ECALL: @@ -314,23 +305,24 @@ 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(regs, trap); 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(regs, trap); msg = "store fault handler failed"; break; default: /* If the trap came from S or U mode, redirect it there */ msg = "trap redirect failed"; - rc = sbi_trap_redirect(regs, &trap); + rc = sbi_trap_redirect(regs, trap); break; } -trap_error: +trap_done: if (rc) - sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); - return regs; + sbi_trap_error(msg, rc, trap, regs); + sbi_trap_set_context(scratch, tcntx->prev_context); + return tcntx; } From patchwork Tue Mar 12 10:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910934 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=OkMOZuMZ; 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=BrOsKn8J; 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 4Tv8xq2p7Sz1yWt for ; Tue, 12 Mar 2024 21:28:47 +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=CQVQOzFMh5NlNeTfOH9dqF9YDkpIhbjG8/oOQLVqsoA=; b=OkMOZuMZHJgNgs NYQdfn23s7fPo39orPaZpZnb1JsV5mZU8Ht+BDdShLfwFxF2stHy2gKhoW1HxuEgDpn2COm8omCcJ pfo3DjQkipHXNc1Xauk3VWFAwZtJRQ1giLZa7Z8KBV/tOckv48PEz1cdjz7RblxWMIH5RlO/J6H9t 59YH/s1ja83VIoTK/1JTZAqda/zTD1/A10+jXLylLN76ThX7AW3V73+6IjbTtf4yNN7iXEVlNGLkX IhJil48Fza/3klu4VK1CEcCN4wWrH+golBY+CzN+s65suYOLqin3oYwc4Atpqt9cjbsANke7tDM2h B91SmZl+d9Pmrhh/grWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzN9-00000005LW8-1ztI; Tue, 12 Mar 2024 10:28:39 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzN4-00000005LRE-2zMR for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:37 +0000 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6e52b9234c0so906281a34.2 for ; Tue, 12 Mar 2024 03:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239314; x=1710844114; 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=eloQEcHkIZB8rfIJSIkH8drhLZQ3glwIMiM4p2UGQyE=; b=BrOsKn8J+H664cYRQCO6MMNqJBkUdUK6yj3AKCQspFdxy86oUrAhUOhuA5slLC8LV2 TdFNiA6woIfG3LseWrwDj0wOBuM9IUw9MN6xAWzTn3RfkDYyftYK0ryPYmMUWrXP5dRL CUybLsPzfuvr6n/CAOeoDW6G4z3f5004VeQSrEj5ZuIksxZyg84+smvdMTvaruDCFkBR MOi5jXZTOPtSOwKUew/fkCXSSCEyzys+l3GSM2rU8Tsad/lgcgS1BqoCgs5/Etze9Ffv DxvhwVX9YtYr4j9S+/uLy3s1ZRO7pOByGDruhPPinoHiQd1n3Nlw6pUoGwJ5MOGp3/pj MuaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239314; x=1710844114; 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=eloQEcHkIZB8rfIJSIkH8drhLZQ3glwIMiM4p2UGQyE=; b=ptFZZalz66EiJwr6aHlIED/Ia9u+kiO4uHHBjOqUvcFmBPahVB9C7BQN855mFdEQkO 231vgaoE0gqw4uhmJPiPa3DUXcGEe40xNekGiWGI/YEuO53yO60qDeFQ3udckOaHu94N opjmZeNxTWjta6qsLM152TKmJ8z2YkgPPp/qs3xcQvUqn8jItxvL1h7WTX4bC3ir2Gyj N7wHfiLk7GKJekwk4Dmi+xwcWXNAjYnOdbAyob16SHgT39Wc17q4QICm7qoUCQIMIKAs u4P6VHamJxCGZauTEpG22oeQSH3xJi1mlmZQY2xl7KAvcAKN1XDeXk2COZwgVPhndMRN hp8g== X-Forwarded-Encrypted: i=1; AJvYcCUyNky1yFazdtgsS1vAvGxGha6yFhyFEflcfXvvqQ+bm/kN7CWshYMOVhGNXGfbmWL2T7LlrfqQH8TGAlbpvuxYfeXl9VHA1q2vp+M= X-Gm-Message-State: AOJu0YzZmBaSAhe4oXohmPJvGtqCges5M7CcKSfVGei16xy4yKPRQ8Cb wd9WLTa5o5iu5nqP2jGnbe9ZS7JTBCRBEqIyewz7CreOyDUSiunBdURnAYYUjuzm6gxx33tyoUw OAtE= X-Google-Smtp-Source: AGHT+IHov7e7h+W49UbJOckyKCrI/bxru+0MpAgGavAoZF+QiFHZpMw3DckBjHu2urO0zpm56NKsrg== X-Received: by 2002:a9d:62d6:0:b0:6e5:1c3e:e931 with SMTP id z22-20020a9d62d6000000b006e51c3ee931mr9366814otk.16.1710239313600; Tue, 12 Mar 2024 03:28:33 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:33 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 05/10] lib: sbi: Simplify parameters of misaligned and access fault handlers Date: Tue, 12 Mar 2024 15:57:59 +0530 Message-Id: <20240312102804.1436376-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032834_936945_74FDD78E X-CRM114-Status: GOOD ( 12.40 ) 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:331 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Reviewed-by: Samuel Holland Reviewed-by: Clément Léger --- 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 4dbda06..a2afb0a 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -290,12 +290,12 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) 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: @@ -305,12 +305,12 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) 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 5a0537b..f9c0241 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; @@ -150,8 +148,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; @@ -169,10 +166,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; @@ -254,8 +252,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; @@ -265,9 +262,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; @@ -283,17 +281,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; @@ -309,17 +306,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; @@ -332,16 +329,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; @@ -354,8 +352,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 Tue Mar 12 10:28:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910935 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=SN6B0ugh; 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=L8WO1rpG; 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 4Tv8xs0t5Wz1yWt for ; Tue, 12 Mar 2024 21:28:49 +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=PxTrFHCci0nuH0817hSmYjOEZef3njLVnMA7SGY9W8s=; b=SN6B0ugh/ib9Yv 2IxkPsK7w/YhC1+C+Hf9rCgVERGzKQHp6As74Idd3Zx4inVcah+3DbJ9Sus61du4/MdARnfNpL0j9 ceSkgPvA2yvAqDNoXiRGCMgYkN00HamUt2WdltYX4XG6shGbcJZQqz4HSGF+vldfTjBHcFZ/gSZC8 Cg3tz9UrqGvCEWY0w6kMScUNtOaQGibDjR7FoOkxe4BKtMJZ9SzZ5DXrqW0n6VbbZJZGJwyfUuCvi Jt21IabNR12bflVfdj49atOTWQAB+rkEyoge5x/HNQYN81t7a7H9lZtlIzCmIWuPnscYvhHfJpVBq ReRZjWzAWBgDBS6WF2Aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNB-00000005LXR-2Nxu; Tue, 12 Mar 2024 10:28:41 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzN7-00000005LUO-3YFn for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:39 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6e4ea4ffafbso2576134a34.2 for ; Tue, 12 Mar 2024 03:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239317; x=1710844117; 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=P6TZ+2MuOYnv8xh5sUlKFwnGf7OkUsbjCF8JFnuPm9g=; b=L8WO1rpGkSaW+uGIcOiVQNVXGVnjjlf33nz3joINCWQ+HzehmUQ+11r8kBKa6mg8zW gMQb7lmhi9di9h1R5RJIzehLO9feaHULzxV+ylIwDC+KzLuyAU4u+L+51l8HvvH2qhQg Ms9VUPOgmcKkBtPfY3t0oJUO13fHL6cMhMuM4QzUsch0w+vDxRViojXNTfxb2A/wMLf8 buRMxREdnrP2W6NVvlat6b6VA0bkX4ASvo2GY4/XOoxVbBMPjgRtyZ8yhsnNg3ftjJen EZk/kQU4sce8FFIETYkgQr9P4J5MmAKQNY2PY1hnQvImAqw7mQzsnAgbier73Hu8AtBS WBeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239317; x=1710844117; 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=P6TZ+2MuOYnv8xh5sUlKFwnGf7OkUsbjCF8JFnuPm9g=; b=T6VIlRNZ+FRm998OcB+8UiPyWNMAsgq44nMExDBpjYUMhpUIOi5GMcVTxpF313yqyB /BHbJNRUYMFkTBJFpXlfAJtrjez2bmM5xJY2yurJLTjRx5K0ArPWEw4iEWqXinrWS1Aa tqQ0wYAOpoLn8sQ42tXgDWJ31M6G4r0aNRew/FkwXmZ6IdL5m3FERTNtEDIRlkuqS7XQ MZiGRuGp0ImHdVMN4unoSpqcv2xIivb0rQ+7NhxUIdS2yWK7PPNzendfQbD/u291K6r/ nH6nKr0vWANXU/D/APSsPeiZTB6Vt3BJGfcIlCUpdOfqU8MHEIVnrtbsdY8E74KcidpE A0lg== X-Forwarded-Encrypted: i=1; AJvYcCXSwfD1voCeG9bOfJrzjUUh//FtIKyTohwfrrlhWj1LtZCJs8U0K2VF8WkH3pb7iCyRgroWXPdC2iRCXGO0UQyxzUMZsnn/6s9IMFE= X-Gm-Message-State: AOJu0Yx7af/1NZJg0n79ZDcXXfkQ2bW9SrUPPaYElppcBfWNjB+Xqm1/ IUMdPyTUZDW7673oeC6qOtDdUXPuBQpAJten3dJ2+LBsEiFGR6niAj04FCdfIiM= X-Google-Smtp-Source: AGHT+IGnyFZBxVdbmOoOONN4yxqXYQntpm4ImZjfkhptft2T1Q6DKLSUIreQURcIVItI4qBbD+P9qA== X-Received: by 2002:a9d:6398:0:b0:6e4:e1c2:9465 with SMTP id w24-20020a9d6398000000b006e4e1c29465mr9079049otk.4.1710239316880; Tue, 12 Mar 2024 03:28:36 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:36 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 06/10] lib: sbi: Simplify parameters of sbi_illegal_insn_handler() Date: Tue, 12 Mar 2024 15:58:00 +0530 Message-Id: <20240312102804.1436376-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032838_018800_0FE83FE0 X-CRM114-Status: GOOD ( 11.73 ) 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, 10 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:336 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Reviewed-by: Samuel Holland --- include/sbi/sbi_illegal_insn.h | 4 ++-- lib/sbi/sbi_illegal_insn.c | 14 +++++++------- lib/sbi/sbi_trap.c | 2 +- 3 files changed, 10 insertions(+), 10 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 dd0b3c1..29c5d74 100644 --- a/lib/sbi/sbi_illegal_insn.c +++ b/lib/sbi/sbi_illegal_insn.c @@ -136,8 +136,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 insn = tcntx->trap.tval; struct sbi_trap_info uptrap; /* @@ -153,13 +154,12 @@ 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); - if (uptrap.cause) { - return sbi_trap_redirect(regs, &uptrap); - } + insn = sbi_get_insn(tcntx->regs.mepc, &uptrap); + if (uptrap.cause) + 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 a2afb0a..4e691df 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -285,7 +285,7 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) switch (mcause) { case CAUSE_ILLEGAL_INSTRUCTION: - rc = sbi_illegal_insn_handler(tcntx->trap.tval, regs); + rc = sbi_illegal_insn_handler(tcntx); msg = "illegal instruction handler failed"; break; case CAUSE_MISALIGNED_LOAD: From patchwork Tue Mar 12 10:28:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910936 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=Ek+EWbXs; 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=VsXCD09P; 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 4Tv8xx268Gz1yWt for ; Tue, 12 Mar 2024 21:28:53 +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=QdMgMrkgp5+NOmmvH8Xbm79ADu4DWHB2lExg5akq+kc=; b=Ek+EWbXsTlg8fG f1zAXAkrXTVvzQxHDNeTTwH9EUVUzn3QHqfCuX6fiIAcG4pWLcQNYG9aH+Te0M75bDSOFGq3J21m0 KPi/0jN74sGiCFHhvTbJR1hv8YLKvK2F5kGRynSQt05cRfSoe2Ke6H1LYgABhZTKsrZ75oDTEwrKM YG0o6vk3t3BWjpOjlqxO6lpVoJMF7aDNUmdXLwhiePSGEOZO0klVKDvaGUZ6ej6qQgOLF/TlBvXKC 9FBAgFf/cqalUMrKZ3RBmVuEtH5YH4HzDz6Q6yR04XBgGlIg3SIWJEhHirGsfOQX4dnuJBJythIOg TxgCUb/oZnSUV/mIB71g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNE-00000005LZY-1Gkv; Tue, 12 Mar 2024 10:28:44 +0000 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNB-00000005LX3-3dKz for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:43 +0000 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6e4e673d9abso1881180a34.3 for ; Tue, 12 Mar 2024 03:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239320; x=1710844120; 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=T71+Q4SHTVcbPpWWANf+SU7/0dISpEiUZe6MP2y4Fw0=; b=VsXCD09P4MAjwt6Mt/dYHcMtn7bfDpLvzd3IqFG/Xus0tNvgae/OGORsd2NjlwMye4 yyrfzPAUpGSwUH0DDRuk7jBCV9mYJKm3Hu7z69qldlyIRDDLXO57dWh70vQtshDGw87s r82458SarNDl/073ixCDb9c5/ayspwIONlvflX5yweizQlgtHzIAeFyFSqigjTLropNv HnG9igimAb/saQ+a1pO1GA/igkyeQQ4sF8WnsmrDQRvhJNmB8QvlbEVeSJxtjjczcJ+7 wip9erlv22rag0+usKZ+DCesQhlavMQNp65LaafLIs7bg63cAFoUQgp1+gYGIL6fw7wT W8sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239320; x=1710844120; 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=T71+Q4SHTVcbPpWWANf+SU7/0dISpEiUZe6MP2y4Fw0=; b=dgxC/vPD0IRMgf7GoSqY8ShRw5WfISOdqJY6iuOak7Sy8bR840CAjeZsPiauOt2HE4 AjY1IUfTv6r8iD7N4QfsZEBcZT1HK6HncLGiXz/9E4Z/T2wtzabFjecSgC18uvb1hnYH HjgUEqkrH/DaBdQYxWT6HJ0X6g/UD8iGD/izaGPKLpAr6Sdck96MAzGKBKZ0W5+XHJiQ 7KHdCdYSKBk3CJWtJpl/6fVJRIMPmJwBZhqrZ+8OHH615eawKW94A8POQPRgIfXZWatS zWf0OilaDhOdKPVb/uEiaiEW9i+ao6PeuV7NIQg7KR7ttd0IAdXJ6DF6CWGeY1aPj/yp Em0g== X-Forwarded-Encrypted: i=1; AJvYcCWwJy9/qQKxObHT3hYieTtTZaWL+Xau5e+CDPUdZNq54y0yOnRkRzAkEibHV4dsmv7fugTOAWk2kFSNXf6xPV8W4YuxegxuyimZzgU= X-Gm-Message-State: AOJu0Yyh9Vegf2m5PGa9Ty8PumGMHq1op9Alf5wypBqH1Paljsl7155x wkM5j3pSwrZJkWACmv8IZq9S9Ja8Nq++ofOxm+/9FJtRw40pw6sF+BLQP8HcaGY= X-Google-Smtp-Source: AGHT+IFKoKlHz45Wg+UOd4rsGfDY94mcQL3WeHnzeAmRJMuyFLmtKqq3qByT09ijGeZnpgsS3Xnoww== X-Received: by 2002:a9d:63da:0:b0:6e5:3f8d:eaf4 with SMTP id e26-20020a9d63da000000b006e53f8deaf4mr418789otl.21.1710239320080; Tue, 12 Mar 2024 03:28:40 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:39 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 07/10] lib: sbi: Remove regs paramter of sbi_irqchip_process() Date: Tue, 12 Mar 2024 15:58:01 +0530 Message-Id: <20240312102804.1436376-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032841_975725_27C8F5B5 X-CRM114-Status: GOOD ( 12.95 ) 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:332 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Reviewed-by: Samuel Holland Reviewed-by: Clément Léger --- 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 4e691df..72b1788 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 Tue Mar 12 10:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910937 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=09MxB2Hz; 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=QzDvbifq; 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 4Tv8y016S9z1yWt for ; Tue, 12 Mar 2024 21:28:56 +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=FMjkAPBcXuXGp+SSVDchw1d/bVTpjQKtpxRjCc13JGI=; b=09MxB2HzuAf2HM +aU4BvsAm6qLjJNYHcknPfzQgp6HqDfumamEoF/s+Uh4h5Dbv4i41gODQXEMpC0cl7qKmjN3mFLlg KDQdXMSgMKD9ZktfUN1QeTsjnpGlvGAbgjV3UB/KhBs4p6qJrWeftU26oeGI8+Nh8hbpm3+oRKgRw i+YV2ik7QaoeTYxG6h3InHN4W0SUGqnuIiCCAqnm9vhI9Q3eSXOgFm+mGc2E/DS2I7HW4wL4WzT69 mCz7Y3K9aYi6dSWS/o/9mkBCdWlO2roiV41aqLI3kZmE1OKqk1jgYibL0+UqPkMMOgLjFJHFqxJ07 mKoj3MrkpF0hK0EEdCMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNI-00000005Lca-0lPU; Tue, 12 Mar 2024 10:28:48 +0000 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNE-00000005LZN-3u7Z for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:46 +0000 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6e53893c559so500485a34.3 for ; Tue, 12 Mar 2024 03:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239323; x=1710844123; 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=qpQ4tsVAsPo+9HxnWcYx2lwjI9iMZuqgJNWzs4zSljE=; b=QzDvbifqsCX91B2gc8K2Dwoh00KIuyOwiCESrqZaDa2KOzzEt3I02renezFrZFxqMV RC++Y+vkE8Caj8hPnT+H6qhy3AM7nfuC+fNuJAADQvuFnf+PqzbSuGsEe3A9Tl/DU1Kq AC9vDzFCmTlaamOZMI/2f+e9rlC7IC/wppqPHpHz3vaqcWnWGepiS42wibAplCkDtL7k CrPuCCGn/TN9EWwM4BUY6oyS9dq1xAfjkc6mErwmFADPjZon9JpvmLxFAnpOGIpk7AAO mHOEBVxksa7ONOEtdnlLgDVEjuKNEeJFjLJcSdOOzLhIckjdrbnv4Er67PWrW9KS/K5X nuxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239323; x=1710844123; 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=qpQ4tsVAsPo+9HxnWcYx2lwjI9iMZuqgJNWzs4zSljE=; b=pPYHJYUtqvGtLXVNOuNIo07zUtgo2kNU+GMXyXGMrYj/TAKgESxTp5QKwT+nV14cMW Y6em4TfdMSeZCP68eW73SZWH+NaNljJWmkiTTvCTT1BqJDgTZzayfd1axw5eTBpcFEEj bksiz3KWF/bfQ7OYrS2snRj8FOav6DIKnjzzyJOIHe+QoEl/Jb+X2bC02zHkdAyI6h/K 63fbtmPEol3D9y6Lf5vzPKm2+HmV5EXnhNYTnKgh0pSyVvQsmapO2mPvDvg++zb1NltP gWY/dkvkMdhxATzQKoxLhHLkdNQbhYG4EJ9xbNDAAdH522rPxAY+prcDXQ1YlNYvPN5H R5/Q== X-Forwarded-Encrypted: i=1; AJvYcCWnknSdUxvszRl0ewkVs6ZE2n2XoS2SMQ0HDNYY4KT8/lbI9io8gzWHLK+gb6Z6DKLGPJ2ZOwePkp8wt1fDgQ8D7NRvtVwReuj+UNk= X-Gm-Message-State: AOJu0Ywl4puqmE/7NQ2v8VXRvtWRbCh8KEgFinVz/cb/qrp3bFQlV0v4 Daqwn/cBBjeWCz3A3GsjQsTpXAN/fGj5bfc5p7H5ILeR/gRW0UKLYWkMrmPiM04= X-Google-Smtp-Source: AGHT+IGa5hhmYsS5Us1uPoNw3RCdhqnPBHHBeRzMc/ZNLIIG4KhuU/Wp9hD7nhcHehnEEJg0zY1iBA== X-Received: by 2002:a05:6830:2683:b0:6e4:ea2d:fc66 with SMTP id l3-20020a056830268300b006e4ea2dfc66mr11011067otu.25.1710239323313; Tue, 12 Mar 2024 03:28:43 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:42 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 08/10] lib: sbi: Remove regs parameter from trap irq handling functions Date: Tue, 12 Mar 2024 15:58:02 +0530 Message-Id: <20240312102804.1436376-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032845_016896_D3B84881 X-CRM114-Status: UNSURE ( 9.47 ) 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 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 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:32c 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Reviewed-by: Samuel Holland --- lib/sbi/sbi_trap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 72b1788..ebf454d 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -198,10 +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 irq) { - mcause &= ~(1UL << (__riscv_xlen - 1)); - switch (mcause) { + switch (irq) { case IRQ_M_TIMER: sbi_timer_process(); break; @@ -217,7 +216,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(void) { int rc; unsigned long mtopi; @@ -273,12 +272,12 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) tcntx->prev_context = sbi_trap_get_context(scratch); 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(); else - rc = sbi_trap_nonaia_irq(regs, mcause); + rc = sbi_trap_nonaia_irq(mcause & ~BIT(__riscv_xlen - 1)); msg = "unhandled local interrupt"; goto trap_done; } From patchwork Tue Mar 12 10:28:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910938 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=IExuW0a7; 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=Nq55sDu+; 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 4Tv8y55mjFz1yWt for ; Tue, 12 Mar 2024 21:29:01 +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=tNAgAXaNGS8CgoustbukT67UcLjvBLByPsgygAl0Mis=; b=IExuW0a7I59087 HHppJXIEIR0V9RU8km6ibMAuilPMb40jtn7BDbfkJUVwMaQz7ZczM748kpX8m0aoiq0i9LkEETw48 IEMDUZUE0ssvC3DglD44XCtLQNI4HnFdt/nCOaMgRSkrEOxpwL8QQcb10jJV9FV2TmGxKKCVvd6c4 mxVVgBJbk5y7kNL152zYZYeFBdslp9o3SPKu0oqG6hUHXILfZ2clHeJ7Lp3vqdVg+5GVDWtGwFQB/ R7e1GX3xmK8ar7tzHYFzybtPbu+4uHhRiiwwS8djWBIxAWr3BdkuQ7ZmRjudp1Gs0IthZ4rqEAVp1 YVXh+h6A24/R9KdEZPpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNN-00000005Lg3-2GyM; Tue, 12 Mar 2024 10:28:53 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNI-00000005Lbp-01O6 for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:51 +0000 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6e52b9234c0so906377a34.2 for ; Tue, 12 Mar 2024 03:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239326; x=1710844126; 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=OO6iNISTGfAGS0A4MdDha01WofXhHPeT0ptdxU2zD/s=; b=Nq55sDu+JABtf91r9Aezy61EFfh7W4tlfb4vxojsqUq3EV+uwRnQsi3ELomLey2o6h 8VoaBXg6gRxoO8W63zgYyFqDamULVhdPEDZL+J3AfdeKn8veY07+GbJtpZXBGIxcrHnw rJ9v3h/QTeckOO+CSggz2MyFPm2mQHyUuJYMHURQS2sxAUZCG3TiMz5F7W6b/zzKYWAn QGuApQ8xsQLCHmSoPihGFG9tgpmcY7+IIwDOMvTQqE9Ur3MSEzhTz+Sc8FcsvO+bMa7N o8CaM/f2svPb704OIUtHVr5IKx5Bt3hB6hHOg49+b2vQe7svU/NUPqpOJnx90EsDxLlT MC0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239326; x=1710844126; 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=OO6iNISTGfAGS0A4MdDha01WofXhHPeT0ptdxU2zD/s=; b=bUrE7q10R1Xk3a/c6p5ZOLlBbGNq7dCwxM/oRPoVlqi8cB1SEF4ZPC/RK/4EL+toi/ V0yW/lBBxB+GzHqJO4YJxczzO7N9s+w5N0mZNpe5ejvlmwS7losa7J0MFj6uaQDninMI SYcaEk8E9lcpHKND3m0dRLgwmemjyCUhs7D9TuHZAUMgdQsWOAZ1HzTVtPCk5qpy3fte L5C7cd76ClNu4fsfnzKSa3jopWOreCp4iIGxQAGzE4rRifvjnx6kOirDJEqCYuXKlEjH FTvvLoADY9LnSKj857yckZdJbZlD46Xgh6NC5sNOnAw7wcNKDFl7l4TrvKXqFOz2mESn +a2w== X-Forwarded-Encrypted: i=1; AJvYcCU+TSOir7EZhaQFab6Z+0V98Gf7Aoz9mK1XMxTZqdnkSSWTPo6Fu0XEMqFa8x71kPeQ/WyvCm4QyATXKIm300jXmY07klaPmN/e7uQ= X-Gm-Message-State: AOJu0Yz0jpNIrRWroLyfAXWZ7pHF+KpfdniMlkNZfQOPx0uBvd4MgkVX DtyHi6gN+mkUZru8dP/DPm8n9MXP2VFK27ZeqAlFMfCB00Hl0KgAZhi14VhCcfA= X-Google-Smtp-Source: AGHT+IHYjkYNUm7lA6o8VoQDf0lRRw4MCHp0Sye9kAFEtmUYqvJor1aprr+WIwxoofUor+D26sA3RA== X-Received: by 2002:a9d:4b0b:0:b0:6e4:8a2b:40e8 with SMTP id q11-20020a9d4b0b000000b006e48a2b40e8mr8528957otf.32.1710239326480; Tue, 12 Mar 2024 03:28:46 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:46 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 09/10] lib: sbi: Pass trap context pointer to sbi_ecall_handler() Date: Tue, 12 Mar 2024 15:58:03 +0530 Message-Id: <20240312102804.1436376-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032848_217076_BE951E45 X-CRM114-Status: GOOD ( 12.14 ) 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:329 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Reviewed-by: Samuel Holland Reviewed-by: Clément Léger --- 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..d4fc58c 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 ebf454d..0b35d1a 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -299,7 +299,7 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) 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 Tue Mar 12 10:28:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1910939 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=QveKI/8g; 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=b41mcwXq; 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 4Tv8y74SY2z1yWt for ; Tue, 12 Mar 2024 21:29:03 +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=sCDHVx1W3SwgdfNV1SVQe+RzPukCl5QwQjRSNG33BCM=; b=QveKI/8gK8bImF XsOzmjVv44n6OoknSIzIAgJiVuTM00B9guxzbsPSq9iO44gVziTHYWl7+LNqYNdPkZFC+sHJBbOKj 8T8mm5EFg5olrMOK/VGX7U4sB9TjK1a14xq0mveacfyG3iqAC21rP3VuhGOmjJfc44qq991YdO3+W ljb0LxHrrg7CbCzu0NF7+7waDxJnmkLfrGkMdF5Hlm1TonOWiTpuHG1K5Wqx51LaYrF/+A+Iyyogr ioOx3/xfMji4vTMET3wxLkP5RRf1gpAVBZDIxP/bvpDsiw2bY4uZG0iexJr6oAgUmNBtFai6N6ciq gdx0eMGStYDtSKMJyrCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNP-00000005LhM-1qJ9; Tue, 12 Mar 2024 10:28:55 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjzNL-00000005LeG-21Dg for opensbi@lists.infradead.org; Tue, 12 Mar 2024 10:28:53 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6e4f874f958so1924881a34.3 for ; Tue, 12 Mar 2024 03:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1710239330; x=1710844130; 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=hKOBHA5EctrFSf4KenY4RiSRYRm+JuqC9ahwVmxxp2s=; b=b41mcwXqE/ghkPb1ldce1udf2od4PagOMdI81PaqwmubQsiBIh3lF3diVoeliVKrk/ /2uSaXCzaGo2VNmFMwd7z3radt7htdX+ojqI/aK1/LEOPVTml9UqVY5EBo3a5MzfKOmI F6sPCTzKc7t8HkvwNVgk690am36UQIbJmrVoXpztE/OvGIBtZo7QYyvVFr2DPVCkSuMs 5JB9MHSqtbaV13ep/nCrJ3+BQ4LO4UMUvR0QaDgu8Yi6L2lY/ijdyo3fzuNgGl+pI24z S1TFfcbZLdQOf8rNgmUjkrwtiuTu5oPVbLvplxwxAOCK+xOzAFm9/AWwnCwxd6xnHaD8 dkyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710239330; x=1710844130; 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=hKOBHA5EctrFSf4KenY4RiSRYRm+JuqC9ahwVmxxp2s=; b=kFWaXe3pIYu61ntF6K7ykuTBY78Ska3NyRUEZtX9MiNTRpSSxGGMkqMdc0+Krm/xwN LU9whT8V1m+GCITykZ9i3Gni/fc+3hTQGlO0b5SNnS81SqNvYW44F6AMkSFdWh+Y9NbF i4qI1HjrqUTf5EvEMbP+k+6uGGkgcsICr88khuR53ebD0ZA/56UH1kn+ZRMXH2H+NzFJ waO0D5sV7uz/1N9/YLv2rEmCiVTtaR+AraTIp2afknmMezmsWBM2sBkM0MnkTns92BBY snCida2LGSIJ3MmK6ikDLtavYF4gsdLeODYRYEUPa5iOdg7SH7b+4gW0+HzUBcyrsg7Z mO2Q== X-Forwarded-Encrypted: i=1; AJvYcCUCh12aCaLCTAViAJf5jm5hRoZaFmgM+C2CUx5NPt35kB62J0LnbkBTg6Nr7bvDHvAdGhNge+2ZlAD7rWBgcFnD/UgA/85VrFQ+W2I= X-Gm-Message-State: AOJu0Yxftnxhr7mtnGy2yhEkBdovkSvuPyw5RFQsDZOg5VQTT4aRT6Df dSEBpFHs/RW0WC/+8NXpORFhe7xUeGt00oEY9tmeOBNnhG07KpPsZvdVxUkeu+k= X-Google-Smtp-Source: AGHT+IEK8w3tE+2S5Hazf06Tidh4D3TKtKhVtPzUm1U+LKj6lbRf8yNxQm5HlVsFk8Fs6qndHg4M8Q== X-Received: by 2002:a05:6830:11c6:b0:6e5:2346:8e84 with SMTP id v6-20020a05683011c600b006e523468e84mr7274193otq.9.1710239329823; Tue, 12 Mar 2024 03:28:49 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7d89000000b006e12266433csm1374540otn.27.2024.03.12.03.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:28:49 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 10/10] lib: sbi: Extend sbi_trap_error() to dump state in a nested trap Date: Tue, 12 Mar 2024 15:58:04 +0530 Message-Id: <20240312102804.1436376-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312102804.1436376-1-apatel@ventanamicro.com> References: <20240312102804.1436376-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_032852_154034_3413ED1D X-CRM114-Status: UNSURE ( 9.71 ) 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:334 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 Tested-by: Samuel Holland --- 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 0b35d1a..83598a4 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, - const struct sbi_trap_info *trap, - const 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, trap->cause, trap->tval); + 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, trap->tval2, trap->tinst); + 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(); } @@ -321,7 +337,7 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) trap_done: if (rc) - sbi_trap_error(msg, rc, trap, regs); + sbi_trap_error(msg, rc, tcntx); sbi_trap_set_context(scratch, tcntx->prev_context); return tcntx; }