From patchwork Mon Dec 11 18:07:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1874672 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=PrHWewsE; 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=U3pYGlun; 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 4SpqVJ68Kcz1ySd for ; Tue, 12 Dec 2023 05:08:08 +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=d2+TGMrtQhFqjxGdYl5VTk+6tRgYkAB0rB+hOUH3EA4=; b=PrHWewsEN23TrO /A41QcVjdJO7HzTePcg9OuAHg6+SgY5yRtPI2jMgXkN+UfP5HqNaIfQ5mXue3qjEBpAcmQQxxsCA7 8TjzI+iBwPc22FUGKF5mBakzvqov7McKIpiSTAhwIhs44wQ41oBeRX6ib+ittAfa/UNcsAXTnudBW dSLfaNb3pN0ySVRFMgDndEHSqkDfqOEak08z49nQP3NWWyiAQoDtJcbfX55L5W0FRAUHlYnoub8JS wzKRdY+Si3w/M7UQxzvkqdcxePxQ3MdX54HUdo91KQdqIn6KjGRJtDFtMSyJGd3qJKE94IoZDwHeK 9H3DUHiK5cXXeN1nSVgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCkh7-006hHm-2d; Mon, 11 Dec 2023 18:07:54 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rCkh3-006hEU-0b for opensbi@lists.infradead.org; Mon, 11 Dec 2023 18:07:51 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c699b44dddso2475464a12.1 for ; Mon, 11 Dec 2023 10:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702318068; x=1702922868; 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=HDLNQwGQFE+levWFD/G5DNSyJM6Wr4FNdG+7uewyXt8=; b=U3pYGlunnW7+eQepajkLHdtKsyywUvPlVz4ZiPX2PEMSo59jTXSarYQI6tAiFTAydh Ti7eafThrME2wHtjMN0JswGicRpGrDwHOFz8qulTYEVuPClskRQQgWajlzKE0iYRg5rh I3ZXetTIpIvhEvsxZZT/6TfO5DhcnXaVowpScIwsfmImhDqqCtsLe/ofuCZVV3dk5kij lydXOYEXQaeMkN1Gfg49je/McOeH8/O4nSiveJ4U93hGrFIkMQnMWTMAkfQcbnom0w8A ZRS5vwvLhnMhZ85ThhTXmp0uqK9ASEfQA7KwQZv3DemA56RAtTyMR4E2qKxQ1kzLW/84 pPQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702318068; x=1702922868; 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=HDLNQwGQFE+levWFD/G5DNSyJM6Wr4FNdG+7uewyXt8=; b=hbcqUWunFv5w788Tm6s8F+PxjJ3qNP+ahf7Fz0si94hVcPKwSqRmfFZQuttaZyBKty g4bEZO2wXX1YH6V9l2yLG4TZg9hMqbCC4C3ThAGBqLl87XyvWh3CAxJxOkJDZFzB+2ns lXz1RaxspPJJNlxG1Wy5NyR0hqp7O3HMOFs9j+lLafQMeF/tInCWwxCFZjCj+hvCYqI3 2p+zLYTuStGDxssZGkSV4Q9PYGH5LSsOjHNntxqWq4z/ZEQTR9yfwMTXav8odo4sYslf TN2TkySOcDF018A8aijG1r0j/4gRhnY31Pb7n/GHEA3nOEyLQHlSMe6TqL1o9KogSmUf pbNg== X-Gm-Message-State: AOJu0YzRKaC1bT0LQioYVDqlTJcL2vek5lHr+D3adakCZjk2emkg1+yX 6BD3BS2aHob4CJ99ahnZjxBgQA== X-Google-Smtp-Source: AGHT+IG3RTZlsmzkVyVFkJW7BSl/90/jdESGDhHVZ0gwMtTI4eSIKtxTpSvKkpsdqVECMl+zMP6wdQ== X-Received: by 2002:a17:90a:c7cf:b0:286:b8a1:f1a2 with SMTP id gf15-20020a17090ac7cf00b00286b8a1f1a2mr2028989pjb.44.1702318068048; Mon, 11 Dec 2023 10:07:48 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.12]) by smtp.gmail.com with ESMTPSA id u15-20020a17090ae00f00b002800e0b4852sm8641641pjy.22.2023.12.11.10.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:07:47 -0800 (PST) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 1/5] lib: sbi_tlb: Reduce size of struct sbi_tlb_info Date: Mon, 11 Dec 2023 23:37:34 +0530 Message-Id: <20231211180738.891727-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211180738.891727-1-apatel@ventanamicro.com> References: <20231211180738.891727-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_100749_552037_680A25AA X-CRM114-Status: GOOD ( 16.17 ) 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: Let us reduce the size of struct sbi_tlb_info by doing the following: 1) Change the data type of asid and vmid fields to uint16_t 2) Replace local_fn() function pointer with an enum Based on the above, the size of struct sbi_tlb_info is reduced by 16 bytes on RV64 and 4 bytes on RV32. 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:533 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Let us reduce the size of struct sbi_tlb_info by doing the following: 1) Change the data type of asid and vmid fields to uint16_t 2) Replace local_fn() function pointer with an enum Based on the above, the size of struct sbi_tlb_info is reduced by 16 bytes on RV64 and 4 bytes on RV32. Signed-off-by: Anup Patel --- include/sbi/sbi_tlb.h | 29 +++++++------ lib/sbi/sbi_ecall_legacy.c | 8 ++-- lib/sbi/sbi_ecall_rfence.c | 16 +++---- lib/sbi/sbi_tlb.c | 89 ++++++++++++++++++++++++++++---------- 4 files changed, 92 insertions(+), 50 deletions(-) diff --git a/include/sbi/sbi_tlb.h b/include/sbi/sbi_tlb.h index 55dcab0..2c50fe8 100644 --- a/include/sbi/sbi_tlb.h +++ b/include/sbi/sbi_tlb.h @@ -22,30 +22,33 @@ struct sbi_scratch; +enum sbi_tlb_type { + SBI_TLB_FENCE_I = 0, + SBI_TLB_SFENCE_VMA, + SBI_TLB_SFENCE_VMA_ASID, + SBI_TLB_HFENCE_GVMA_VMID, + SBI_TLB_HFENCE_GVMA, + SBI_TLB_HFENCE_VVMA_ASID, + SBI_TLB_HFENCE_VVMA, + SBI_TLB_TYPE_MAX, +}; + struct sbi_tlb_info { unsigned long start; unsigned long size; - unsigned long asid; - unsigned long vmid; - void (*local_fn)(struct sbi_tlb_info *tinfo); + uint16_t asid; + uint16_t vmid; + enum sbi_tlb_type type; struct sbi_hartmask smask; }; -void sbi_tlb_local_hfence_vvma(struct sbi_tlb_info *tinfo); -void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo); -void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo); -void sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo); -void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo); -void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo); -void sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo); - -#define SBI_TLB_INFO_INIT(__p, __start, __size, __asid, __vmid, __lfn, __src) \ +#define SBI_TLB_INFO_INIT(__p, __start, __size, __asid, __vmid, __type, __src) \ do { \ (__p)->start = (__start); \ (__p)->size = (__size); \ (__p)->asid = (__asid); \ (__p)->vmid = (__vmid); \ - (__p)->local_fn = (__lfn); \ + (__p)->type = (__type); \ SBI_HARTMASK_INIT_EXCEPT(&(__p)->smask, (__src)); \ } while (0) diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c index 99e862e..556f629 100644 --- a/lib/sbi/sbi_ecall_legacy.c +++ b/lib/sbi/sbi_ecall_legacy.c @@ -80,8 +80,7 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, &hmask, out_trap); if (ret != SBI_ETRAP) { SBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0, 0, - sbi_tlb_local_fence_i, - source_hart); + SBI_TLB_FENCE_I, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } break; @@ -90,8 +89,7 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, &hmask, out_trap); if (ret != SBI_ETRAP) { SBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, 0, 0, - sbi_tlb_local_sfence_vma, - source_hart); + SBI_TLB_SFENCE_VMA, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } break; @@ -101,7 +99,7 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, if (ret != SBI_ETRAP) { SBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, regs->a3, 0, - sbi_tlb_local_sfence_vma_asid, + SBI_TLB_SFENCE_VMA_ASID, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } diff --git a/lib/sbi/sbi_ecall_rfence.c b/lib/sbi/sbi_ecall_rfence.c index 22c6652..4b74d41 100644 --- a/lib/sbi/sbi_ecall_rfence.c +++ b/lib/sbi/sbi_ecall_rfence.c @@ -33,43 +33,41 @@ static int sbi_ecall_rfence_handler(unsigned long extid, unsigned long funcid, switch (funcid) { case SBI_EXT_RFENCE_REMOTE_FENCE_I: SBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0, 0, - sbi_tlb_local_fence_i, source_hart); + SBI_TLB_FENCE_I, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA: SBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, 0, - sbi_tlb_local_hfence_gvma, source_hart); + SBI_TLB_HFENCE_GVMA, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID: SBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, regs->a4, - sbi_tlb_local_hfence_gvma_vmid, - source_hart); + SBI_TLB_HFENCE_GVMA_VMID, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA: vmid = (csr_read(CSR_HGATP) & HGATP_VMID_MASK); vmid = vmid >> HGATP_VMID_SHIFT; SBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, vmid, - sbi_tlb_local_hfence_vvma, source_hart); + SBI_TLB_HFENCE_VVMA, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID: vmid = (csr_read(CSR_HGATP) & HGATP_VMID_MASK); vmid = vmid >> HGATP_VMID_SHIFT; SBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, regs->a4, - vmid, sbi_tlb_local_hfence_vvma_asid, - source_hart); + vmid, SBI_TLB_HFENCE_VVMA_ASID, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA: SBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, 0, - sbi_tlb_local_sfence_vma, source_hart); + SBI_TLB_SFENCE_VMA, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID: SBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, regs->a4, 0, - sbi_tlb_local_sfence_vma_asid, source_hart); + SBI_TLB_SFENCE_VMA_ASID, source_hart); ret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info); break; default: diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index d3ed56d..a00a795 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -34,7 +34,7 @@ static void tlb_flush_all(void) __asm__ __volatile("sfence.vma"); } -void sbi_tlb_local_hfence_vvma(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_hfence_vvma(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; @@ -59,7 +59,7 @@ done: csr_write(CSR_HGATP, hgatp); } -void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; @@ -77,7 +77,7 @@ void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo) } } -void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; @@ -98,7 +98,7 @@ void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo) } } -void sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; @@ -124,7 +124,7 @@ done: csr_write(CSR_HGATP, hgatp); } -void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; @@ -143,7 +143,7 @@ void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo) } } -void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; @@ -169,32 +169,75 @@ void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) } } -void sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo) +static void sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo) { sbi_pmu_ctr_incr_fw(SBI_PMU_FW_FENCE_I_RECVD); __asm__ __volatile("fence.i"); } +static void tlb_entry_local_process(struct sbi_tlb_info *data) +{ + if (unlikely(!data)) + return; + + switch (data->type) { + case SBI_TLB_FENCE_I: + sbi_tlb_local_fence_i(data); + break; + case SBI_TLB_SFENCE_VMA: + sbi_tlb_local_sfence_vma(data); + break; + case SBI_TLB_SFENCE_VMA_ASID: + sbi_tlb_local_sfence_vma_asid(data); + break; + case SBI_TLB_HFENCE_GVMA_VMID: + sbi_tlb_local_hfence_gvma_vmid(data); + break; + case SBI_TLB_HFENCE_GVMA: + sbi_tlb_local_hfence_gvma(data); + break; + case SBI_TLB_HFENCE_VVMA_ASID: + sbi_tlb_local_hfence_vvma_asid(data); + break; + case SBI_TLB_HFENCE_VVMA: + sbi_tlb_local_hfence_vvma(data); + break; + default: + break; + }; +} + static void tlb_pmu_incr_fw_ctr(struct sbi_tlb_info *data) { if (unlikely(!data)) return; - if (data->local_fn == sbi_tlb_local_fence_i) + switch (data->type) { + case SBI_TLB_FENCE_I: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_FENCE_I_SENT); - else if (data->local_fn == sbi_tlb_local_sfence_vma) + break; + case SBI_TLB_SFENCE_VMA: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_SENT); - else if (data->local_fn == sbi_tlb_local_sfence_vma_asid) + break; + case SBI_TLB_SFENCE_VMA_ASID: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_SENT); - else if (data->local_fn == sbi_tlb_local_hfence_gvma) - sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_SENT); - else if (data->local_fn == sbi_tlb_local_hfence_gvma_vmid) + break; + case SBI_TLB_HFENCE_GVMA_VMID: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_VMID_SENT); - else if (data->local_fn == sbi_tlb_local_hfence_vvma) - sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_SENT); - else if (data->local_fn == sbi_tlb_local_hfence_vvma_asid) + break; + case SBI_TLB_HFENCE_GVMA: + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_SENT); + break; + case SBI_TLB_HFENCE_VVMA_ASID: sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_ASID_SENT); + break; + case SBI_TLB_HFENCE_VVMA: + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_SENT); + break; + default: + break; + }; } static void tlb_entry_process(struct sbi_tlb_info *tinfo) @@ -203,7 +246,7 @@ static void tlb_entry_process(struct sbi_tlb_info *tinfo) struct sbi_scratch *rscratch = NULL; atomic_t *rtlb_sync = NULL; - tinfo->local_fn(tinfo); + tlb_entry_local_process(tinfo); sbi_hartmask_for_each_hartindex(rindex, &tinfo->smask) { rscratch = sbi_hartindex_to_scratch(rindex); @@ -305,12 +348,12 @@ static int tlb_update_cb(void *in, void *data) curr = (struct sbi_tlb_info *)data; next = (struct sbi_tlb_info *)in; - if (next->local_fn == sbi_tlb_local_sfence_vma_asid && - curr->local_fn == sbi_tlb_local_sfence_vma_asid) { + if (next->type == SBI_TLB_SFENCE_VMA_ASID && + curr->type == SBI_TLB_SFENCE_VMA_ASID) { if (next->asid == curr->asid) ret = tlb_range_check(curr, next); - } else if (next->local_fn == sbi_tlb_local_sfence_vma && - curr->local_fn == sbi_tlb_local_sfence_vma) { + } else if (next->type == SBI_TLB_SFENCE_VMA && + curr->type == SBI_TLB_SFENCE_VMA) { ret = tlb_range_check(curr, next); } @@ -332,7 +375,7 @@ static int tlb_update(struct sbi_scratch *scratch, * then just do a local flush and return; */ if (sbi_hartindex_to_hartid(remote_hartindex) == curr_hartid) { - tinfo->local_fn(tinfo); + tlb_entry_local_process(tinfo); return SBI_IPI_UPDATE_BREAK; } @@ -372,7 +415,7 @@ static u32 tlb_event = SBI_IPI_EVENT_MAX; int sbi_tlb_request(ulong hmask, ulong hbase, struct sbi_tlb_info *tinfo) { - if (!tinfo->local_fn) + if (tinfo->type < 0 || tinfo->type >= SBI_TLB_TYPE_MAX) return SBI_EINVAL; /* From patchwork Mon Dec 11 18:07:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1874674 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=GGby8TSL; 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=LF5qDB4T; 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 4SpqVN2QtPz20Gv for ; Tue, 12 Dec 2023 05:08:12 +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=qFz+tGGE2Z3GAnkZ6OtOG59GFY6WUSlhtdBmoB2uazI=; b=GGby8TSLj5Obb5 Ogk0XRqPlX95rC2xaudzh+dm9IY04wWzpP1RAvw0v2K3g5njGFZcvRYzLkBDA3BTATiURrXMnvI/L tzWx7eLPCRH/kQnkBJzgz0qf7nxNURjFHdvlTgXF3gqkHmyHo/bOCOgqC/N4c3ln2l32JA6U2TcNC 3SFEeiRXgeY3o48lVR63mPGkz3sQfbeFOWLtafRtOcEuJMZxOXXh12+CDKkz0ojE20gmHCiat4VAc tHBz938SsvwwjPqsUyv4LkKnKcJEmLUXcoAxEMFp6JoEedqVXW0h20ktw/Crd6eYY2rEjlW8XUXfo i0Fx0eUzY3Iz/1h9qa6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCkhC-006hLC-2w; Mon, 11 Dec 2023 18:07:59 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rCkh5-006hFt-30 for opensbi@lists.infradead.org; Mon, 11 Dec 2023 18:07:53 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-5c66e7eafabso3961519a12.0 for ; Mon, 11 Dec 2023 10:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702318070; x=1702922870; 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=4VMqve1x28el1rvquabTNUbkQ/CGXWRP9Ll7bOLC41w=; b=LF5qDB4TaZmv/tIYBMTKZhEbNM/FMbslmwLeFWOuMMWRT39VKFZ0OifpKeEeW+yf6x E8FPDg+73211d5/5H/h3wOanjgRrCjzmGUvRlWgtrWRmCKQCM5riiFfGUqPtwl79IDlC sbKQyTii1HXTPRLo4cFCzAXxPntXncf4bu/ZZXpUti9w2KyF+p3zrIbR4O98qnYq45yF 0bVZeZK9cCMHYs2fJ0ljAR3qvh82nei6g1Quf8ZrNpoD2V6LkR5D3gmIfya+NfAFcKRj w3gJIDiXQpsVzbY1AyGA8jPTufT8ljcmauEWGxKY5HIcipVCBCUaBJhdkZEs8urbrtye 5LZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702318070; x=1702922870; 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=4VMqve1x28el1rvquabTNUbkQ/CGXWRP9Ll7bOLC41w=; b=ImZg4AAsXamSQCeZDJAc6meZW5qPmbaa1Iye1Mcq+12meSzdwCKQm8eucOPGA5quX4 yMAt37/CLq4xUXn6zBE0qOvFlbcVTPQMqc8r7T82K8T3upIwsbR/c/Wa7/aEiUc/j6Kf Hf/1qfF16pIFbepuRve01hXLnYcZVbKPOhOW9WOhhb2STsO2ZNp2ULFRCCyQVPpL19Nf QFnoitH0+ihJg5oFbB+hC/4B3Ed0JT0g2e1ITP8FtkjoIlRcY1F4oeG6R3+Av7R0enOe TpZ1/++QwV6QtCl4i4UcP28ugupCZoh0+fBKDmrUa/nHJv9GPfsOXSQiVnVqy/bxWW6M 8rhg== X-Gm-Message-State: AOJu0YwuLgXMlm9RY83CdHi5MVK4tjSPz6nwT3OfAudcTMZhYPAURPtQ 9XGF0fd1zVn+kNxA4/QGqPWVkw== X-Google-Smtp-Source: AGHT+IHz4xyohBsvHTOlGI8s2Q4tfemIgD2JJ4rO1kvhojsXBi0LPyv6Pi6mX5M/xfD4HVF60O58oQ== X-Received: by 2002:a17:90a:7105:b0:286:6cc0:cadd with SMTP id h5-20020a17090a710500b002866cc0caddmr3833167pjk.84.1702318070450; Mon, 11 Dec 2023 10:07:50 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.12]) by smtp.gmail.com with ESMTPSA id u15-20020a17090ae00f00b002800e0b4852sm8641641pjy.22.2023.12.11.10.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:07:50 -0800 (PST) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 2/5] platform: generic: Fine tune fw_platform_calculate_heap_size() Date: Mon, 11 Dec 2023 23:37:35 +0530 Message-Id: <20231211180738.891727-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211180738.891727-1-apatel@ventanamicro.com> References: <20231211180738.891727-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_100752_041164_C3D44A42 X-CRM114-Status: UNSURE ( 8.83 ) 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: Let's use SBI_TLB_INFO_SIZE instead of hard-coded 0x40 in fw_platform_calculate_heap_size() to fine tune the heap size required for per-hart TLB fifos. Signed-off-by: Anup Patel --- platform/generic/platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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:530 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Let's use SBI_TLB_INFO_SIZE instead of hard-coded 0x40 in fw_platform_calculate_heap_size() to fine tune the heap size required for per-hart TLB fifos. Signed-off-by: Anup Patel --- platform/generic/platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 08ae92a..8507227 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ static u32 fw_platform_calculate_heap_size(u32 hart_count) heap_size = SBI_PLATFORM_DEFAULT_HEAP_SIZE(hart_count); /* For TLB fifo */ - heap_size += 0x40 * (hart_count) * (hart_count); + heap_size += SBI_TLB_INFO_SIZE * (hart_count) * (hart_count); return BIT_ALIGN(heap_size, HEAP_BASE_ALIGN); } From patchwork Mon Dec 11 18:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1874673 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=ECVN4lSn; 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=dXilhdOr; 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 4SpqVM4WnVz1ySd for ; Tue, 12 Dec 2023 05:08:11 +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=YXuSYYrfrVOgB0snVu04upar+ECLjszPLcDgvEJ/jXY=; b=ECVN4lSn2AFCmp 4kSsAMZFbpuzXJ1kRRuSdlSpSS7deF1A+pPlZ+9DdKVsM9Gh3KAQESl0xssDKiglCaeoJaG1j7BJd uj+3vkuzeDBTOhGK9uELnItB+8dIDkS2wByBa+2R3syzBkr0I9RPb3xRqvIccCic1PJzB0RC/7gTU M7/kn9Gdb5TqTqyljIJR7X7iyVbRRzVyfKP7LERwOsy6LXMshptaFluIrwgqFjH2xm3m2tl+MvmG/ 6jqLxC3y2OArUTpRlKmDzBEb1R0w+7YULlhBZy7Fb6x+uprIFyBMA40DkT+mOO26jD5plpap/sfEi CyrAYsSj4oK2HAn4tDcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCkhD-006hMU-2v; Mon, 11 Dec 2023 18:07:59 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rCkh8-006hHg-0B for opensbi@lists.infradead.org; Mon, 11 Dec 2023 18:07:55 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2866951b6e0so4646578a91.2 for ; Mon, 11 Dec 2023 10:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702318073; x=1702922873; 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=0SfoXbNNnygWFPjlimucUTZvSOHCzXfjNlm9GowIyfg=; b=dXilhdOrb6t9myZam8Vs0dmiP6dtZucyDWIsJswG5wG39GDZLZG55I93vzxrkeWlfp WVpY9N7doy32zw5zYUs+z1+hlR7aMI09ZUMShwlnWRN56ln2b6w9weekDGN9Qq+BJKhG b7LfO8cWTO0E6AxQmUn3ZKpi1wuS22LbcMW1IV7LHQeldTdQdgdXbtNjhkmV69+Hw55w AMLzvmZ3S2fHQ6ZSP/b2An29yD2jr8K7OWo3CbunIcF0m/aTs2Xo+r6l12LTaKhAemC2 04v7kNAl7ed/mtkaRDQukM83aF0exsks5jJHg0Udrg5N5tevgky9HLly/qP5Yokv8c30 +gmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702318073; x=1702922873; 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=0SfoXbNNnygWFPjlimucUTZvSOHCzXfjNlm9GowIyfg=; b=h4hFAyRUNUQa0+WPWvYYn5ppRR8akg343oK7HaC/q0CxrPWeRHAYwrse0S91u8qlRO d8Znq/RT0RxNDG7lhlSbAg0mZ4ECcunCBy7/kGM3GTcy5bkP9eOchviO7UefcQZSIlCJ Ci6d3AYyv9QN/MMWYryKueXN4FqqR0yPwOpUdXKqzHO1Fjvc/iGcg73dVfREiGX2uLgc fq383LNz6QebSYkeGfxocijtkkO/6mZavD7euMDTkZp5xhKjemAUipEk1kd0qqvEyCzo 2BMIFiNZVib9+qMqyzn5qIrrEsBPaZeI3hQkrasbkux6RtSuxb3LtbDwzsBZxT7L7DHZ 7+mg== X-Gm-Message-State: AOJu0Yx1jSJMbjkbCdWZ/8GDf+FX/pB8ibU7qQLvLFR3l53xLZ/vnMe6 KmpzT5e/eEd3eM8fOVK+J/2NPA== X-Google-Smtp-Source: AGHT+IEtfRsfzSnpJCfK2liwOZjCWIYoVJDIgj7tODmeeRu1LFeB5C8rsDicJhczxD/lcGIcNZnhbA== X-Received: by 2002:a17:90b:4f8a:b0:286:6cc0:cacf with SMTP id qe10-20020a17090b4f8a00b002866cc0cacfmr3385756pjb.70.1702318072877; Mon, 11 Dec 2023 10:07:52 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.12]) by smtp.gmail.com with ESMTPSA id u15-20020a17090ae00f00b002800e0b4852sm8641641pjy.22.2023.12.11.10.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:07:52 -0800 (PST) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 3/5] lib: utils/irqchip: Add shared MMIO region for PLIC in root domain Date: Mon, 11 Dec 2023 23:37:36 +0530 Message-Id: <20231211180738.891727-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211180738.891727-1-apatel@ventanamicro.com> References: <20231211180738.891727-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_100754_346912_1868FF10 X-CRM114-Status: GOOD ( 16.70 ) 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: On platforms with Smepmp, the MMIO regions accessed by M-mode need to be explicitly marked with M-mode only read/write or shared (both (M-mode and S-mode) read/write permission. If the above is not done then runtime PLIC access from M-mode on platforms with Smepmp will result in access fault when further results in CPU hotplug not working. 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:1036 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 On platforms with Smepmp, the MMIO regions accessed by M-mode need to be explicitly marked with M-mode only read/write or shared (both (M-mode and S-mode) read/write permission. If the above is not done then runtime PLIC access from M-mode on platforms with Smepmp will result in access fault when further results in CPU hotplug not working. Signed-off-by: Anup Patel --- include/sbi_utils/irqchip/plic.h | 1 + lib/utils/fdt/fdt_helper.c | 1 + lib/utils/irqchip/plic.c | 6 +++++- platform/fpga/ariane/platform.c | 3 +++ platform/fpga/openpiton/platform.c | 3 +++ platform/kendryte/k210/platform.c | 1 + platform/kendryte/k210/platform.h | 1 + platform/nuclei/ux600/platform.c | 3 +++ platform/template/platform.c | 3 +++ 9 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/sbi_utils/irqchip/plic.h b/include/sbi_utils/irqchip/plic.h index 112a714..2eda631 100644 --- a/include/sbi_utils/irqchip/plic.h +++ b/include/sbi_utils/irqchip/plic.h @@ -14,6 +14,7 @@ struct plic_data { unsigned long addr; + unsigned long size; unsigned long num_src; }; diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index 78c1f38..df74adb 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -878,6 +878,7 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic) if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; plic->addr = reg_addr; + plic->size = reg_size; val = fdt_getprop(fdt, nodeoffset, "riscv,ndev", &len); if (len > 0) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index d633514..193e320 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include #include @@ -171,5 +173,7 @@ int plic_cold_irqchip_init(const struct plic_data *plic) for (i = 1; i <= plic->num_src; i++) plic_set_priority(plic, i, 0); - return 0; + return sbi_domain_root_add_memrange(plic->addr, plic->size, BIT(20), + (SBI_DOMAIN_MEMREGION_MMIO | + SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW)); } diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 975528f..8be5e6c 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -25,6 +25,8 @@ #define ARIANE_UART_REG_WIDTH 4 #define ARIANE_UART_REG_OFFSET 0 #define ARIANE_PLIC_ADDR 0xc000000 +#define ARIANE_PLIC_SIZE (0x200000 + \ + (ARIANE_HART_COUNT * 0x1000)) #define ARIANE_PLIC_NUM_SOURCES 3 #define ARIANE_HART_COUNT 1 #define ARIANE_CLINT_ADDR 0x2000000 @@ -36,6 +38,7 @@ static struct plic_data plic = { .addr = ARIANE_PLIC_ADDR, + .size = ARIANE_PLIC_SIZE, .num_src = ARIANE_PLIC_NUM_SOURCES, }; diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index e59dc99..2317a89 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -24,6 +24,8 @@ #define OPENPITON_DEFAULT_UART_REG_WIDTH 1 #define OPENPITON_DEFAULT_UART_REG_OFFSET 0 #define OPENPITON_DEFAULT_PLIC_ADDR 0xfff1100000 +#define OPENPITON_DEFAULT_PLIC_SIZE (0x200000 + \ + (OPENPITON_DEFAULT_HART_COUNT * 0x1000)) #define OPENPITON_DEFAULT_PLIC_NUM_SOURCES 2 #define OPENPITON_DEFAULT_HART_COUNT 3 #define OPENPITON_DEFAULT_CLINT_ADDR 0xfff1020000 @@ -40,6 +42,7 @@ static struct platform_uart_data uart = { }; static struct plic_data plic = { .addr = OPENPITON_DEFAULT_PLIC_ADDR, + .size = OPENPITON_DEFAULT_PLIC_SIZE, .num_src = OPENPITON_DEFAULT_PLIC_NUM_SOURCES, }; diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 637a217..27b23f7 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -32,6 +32,7 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1, static struct plic_data plic = { .addr = K210_PLIC_BASE_ADDR, + .size = K210_PLIC_BASE_SIZE, .num_src = K210_PLIC_NUM_SOURCES, }; diff --git a/platform/kendryte/k210/platform.h b/platform/kendryte/k210/platform.h index be52aa3..9417403 100644 --- a/platform/kendryte/k210/platform.h +++ b/platform/kendryte/k210/platform.h @@ -27,6 +27,7 @@ #define K210_ACLINT_MTIMER_ADDR \ (K210_CLINT_BASE_ADDR + CLINT_MTIMER_OFFSET) #define K210_PLIC_BASE_ADDR 0x0C000000ULL +#define K210_PLIC_BASE_SIZE (0x200000ULL + (K210_HART_COUNT * 0x1000)) /* Registers */ #define K210_PLL0 0x08 diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 6fd6cd7..f688b50 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -39,6 +39,8 @@ CLINT_MTIMER_OFFSET) #define UX600_PLIC_ADDR 0x8000000 +#define UX600_PLIC_SIZE (0x200000 + \ + (UX600_HART_COUNT * 0x1000)) #define UX600_PLIC_NUM_SOURCES 0x35 #define UX600_PLIC_NUM_PRIORITIES 7 @@ -63,6 +65,7 @@ static u32 ux600_clk_freq = 8000000; static struct plic_data plic = { .addr = UX600_PLIC_ADDR, + .size = UX600_PLIC_SIZE, .num_src = UX600_PLIC_NUM_SOURCES, }; diff --git a/platform/template/platform.c b/platform/template/platform.c index 86381ca..4b3f2ac 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -19,6 +19,8 @@ #include #define PLATFORM_PLIC_ADDR 0xc000000 +#define PLATFORM_PLIC_SIZE (0x200000 + \ + (PLATFORM_HART_COUNT * 0x1000)) #define PLATFORM_PLIC_NUM_SOURCES 128 #define PLATFORM_HART_COUNT 4 #define PLATFORM_CLINT_ADDR 0x2000000 @@ -33,6 +35,7 @@ static struct plic_data plic = { .addr = PLATFORM_PLIC_ADDR, + .size = PLATFORM_PLIC_SIZE, .num_src = PLATFORM_PLIC_NUM_SOURCES, }; From patchwork Mon Dec 11 18:07:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1874676 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=aU3Ux3oc; 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=kHA2ive/; 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 4SpqVQ4wXKz1ySd for ; Tue, 12 Dec 2023 05:08:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bspws/b4kI4uwerD9t4akw1rAiZCIlvsywVMTyIna9Y=; b=aU3Ux3ocLW7rad J4RJY7LG+Qih2AXXdP2jgjE89g33p7eZMyddyXoVR3rUboJIt7Ed08vzzkG8Dxb+EgBSQguCLGpG6 L0/g8tZFj99qH5FpruX/93J01eMWRa67H1qaiuAeauOvf9tl29GrTwfKNAy7dG1ReUHguN358lukV VpOQCqAp/lXJFGKU7TrxAqCJs/xRf/dnSBPCOOQG3nehKo0calKahwXzvu1Oi+CGRZ2Pexokf7nQe bcT9B5k3xFxyVIqFSFedE978DtrGKEIuytlY2E6Kl5aEFHqqmjromsRvClDojsJeQUxvZVDiyMpBf ZLHFvaWvDHyYjaaOkXeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCkhF-006hNc-0B; Mon, 11 Dec 2023 18:08:01 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rCkh9-006hJs-3B for opensbi@lists.infradead.org; Mon, 11 Dec 2023 18:07:59 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-28ab5adae8dso92995a91.0 for ; Mon, 11 Dec 2023 10:07:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702318075; x=1702922875; 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=bzCRhud0QZT6FzhuwtSm9YT0hOucFbzysWkrLKeyHa4=; b=kHA2ive/SsXCq5jkrf/jnIBUSOtGdcEqAakyfdGZxac7DUOquiiyk9ssv3G2udWjRi vpK7e7cKhd0Y8wBf+V8ImBf+m3VagnyMNlar3QD8IyNvIIxFbP/lUoIn+Elj+8o13Rpy syEIXSeqANke7OPfDiX00ShytgK8oaH5shfnj5DsCpvlqW7gfyd9kHD+VhEfOOW1ma0o oF9J98pTxMD9gdhb/n8mOKbr7UY8m+Qpv35uCsk3LwSzKZTxXWacAEZaO1fvKgg4X5hd +WtgnqS+jjui+rawKI142YTSNPNeiFFg7K6c4wrXNApXRdvSQ8OZTzMNIVDw/MHjamKt sSFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702318075; x=1702922875; 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=bzCRhud0QZT6FzhuwtSm9YT0hOucFbzysWkrLKeyHa4=; b=gu6avzseSBzraEnL6n/hRLra9YKH6ZQE0xjbNKgFjhFKKcrKjiCNJy/i20Ws16euvx N7TBCDZGHgUO/Q+D0XC+aoBUYKW4xqMaNqbCnZ7xmR932YKT834JB5obAk0t5jljZ711 xcl0tvJm8ovh2uhwkF85V7K1NBuq6vpMO3WXgirC6tUfZMrNJcAE9njrnyRu/pVVZsoW AT37lpduclv86uarX6pszLpJO8mMRBOdrbwaR/KMMTW3tx4A87/2UeSW0zbPe066130J HhhvZ+774gabqdcjZ3HKBGq67uKeTY65XSqB5vDLWJJW6bDDBA+gfHRMCRu0YslANwo1 Cdrg== X-Gm-Message-State: AOJu0Yz24pPKRiz3cc6GWiqk26CHc8s4mCoI38Fdo16oTLK7I1fEm5g0 CQcRFXU1yki/7AiVk5wuQF6jie4BYwQ/HnMf2ys= X-Google-Smtp-Source: AGHT+IETplqQjWWydmEifVSncJymNkk41Li/f7e2MJV/kWVMwt/oXCtR6AuKCgW1UMJ/MWFKdq1GNQ== X-Received: by 2002:a17:90a:c292:b0:28a:9185:c956 with SMTP id f18-20020a17090ac29200b0028a9185c956mr999308pjt.46.1702318075255; Mon, 11 Dec 2023 10:07:55 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.12]) by smtp.gmail.com with ESMTPSA id u15-20020a17090ae00f00b002800e0b4852sm8641641pjy.22.2023.12.11.10.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:07:54 -0800 (PST) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 4/5] lib: sbi: Allow ecall handlers to directly update register state Date: Mon, 11 Dec 2023 23:37:37 +0530 Message-Id: <20231211180738.891727-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211180738.891727-1-apatel@ventanamicro.com> References: <20231211180738.891727-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_100756_255069_4B4D3C73 X-CRM114-Status: GOOD ( 18.36 ) 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: Some of the upcoming SBI extensions (such as SSE) will directly update register state so improve the prototype of ecall handler to accommodate this. Further, this flexibility allows us to push the tra [...] 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:102d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Some of the upcoming SBI extensions (such as SSE) will directly update register state so improve the prototype of ecall handler to accommodate this. Further, this flexibility allows us to push the trap redirection from sbi_ecall_handler() to the sbi_ecall_legacy_handler(). Signed-off-by: Anup Patel --- include/sbi/sbi_ecall.h | 12 +++++-- include/sbi/sbi_platform.h | 19 ++++------ lib/sbi/sbi_ecall.c | 13 +++---- lib/sbi/sbi_ecall_base.c | 27 +++++++------- lib/sbi/sbi_ecall_cppc.c | 13 ++++--- lib/sbi/sbi_ecall_dbcn.c | 9 +++-- lib/sbi/sbi_ecall_hsm.c | 7 ++-- lib/sbi/sbi_ecall_ipi.c | 5 ++- lib/sbi/sbi_ecall_legacy.c | 37 +++++++++++++++----- lib/sbi/sbi_ecall_pmu.c | 17 +++++---- lib/sbi/sbi_ecall_rfence.c | 5 ++- lib/sbi/sbi_ecall_srst.c | 5 ++- lib/sbi/sbi_ecall_susp.c | 7 ++-- lib/sbi/sbi_ecall_time.c | 5 ++- lib/sbi/sbi_ecall_vendor.c | 8 ++--- platform/generic/andes/andes_sbi.c | 7 ++-- platform/generic/include/andes/andes_sbi.h | 6 ++-- platform/generic/include/platform_override.h | 6 ++-- platform/generic/platform.c | 8 ++--- 19 files changed, 109 insertions(+), 107 deletions(-) diff --git a/include/sbi/sbi_ecall.h b/include/sbi/sbi_ecall.h index 027213c..0bf42d1 100644 --- a/include/sbi/sbi_ecall.h +++ b/include/sbi/sbi_ecall.h @@ -20,6 +20,13 @@ struct sbi_trap_regs; struct sbi_trap_info; +struct sbi_ecall_return { + /* Return flag to skip register update */ + bool skip_regs_update; + /* Return value */ + unsigned long value; +}; + struct sbi_ecall_extension { /* head is used by the extension list */ struct sbi_dlist head; @@ -62,9 +69,8 @@ struct sbi_ecall_extension { * never invoked with an invalid or unavailable extension ID. */ int (* handle)(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap); + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out); }; u16 sbi_ecall_version_major(void); diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 58b9069..2fb33e1 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -50,7 +50,7 @@ #include struct sbi_domain_memregion; -struct sbi_trap_info; +struct sbi_ecall_return; struct sbi_trap_regs; struct sbi_hart_features; @@ -137,9 +137,8 @@ struct sbi_platform_operations { bool (*vendor_ext_check)(void); /** platform specific SBI extension implementation provider */ int (*vendor_ext_provider)(long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_value, - struct sbi_trap_info *out_trap); + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out); }; /** Platform default per-HART stack size for exception/interrupt handling */ @@ -666,16 +665,12 @@ static inline bool sbi_platform_vendor_ext_check( static inline int sbi_platform_vendor_ext_provider( const struct sbi_platform *plat, long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_value, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { - if (plat && sbi_platform_ops(plat)->vendor_ext_provider) { + if (plat && sbi_platform_ops(plat)->vendor_ext_provider) return sbi_platform_ops(plat)->vendor_ext_provider(funcid, - regs, - out_value, - out_trap); - } + regs, out); return SBI_ENOTSUPP; } diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index 3eb4f0a..631c5dd 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -101,14 +101,12 @@ int sbi_ecall_handler(struct sbi_trap_regs *regs) struct sbi_ecall_extension *ext; unsigned long extension_id = regs->a7; unsigned long func_id = regs->a6; - struct sbi_trap_info trap = {0}; - unsigned long out_val = 0; + struct sbi_ecall_return out = {0}; bool is_0_1_spec = 0; ext = sbi_ecall_find_extension(extension_id); if (ext && ext->handle) { - ret = ext->handle(extension_id, func_id, - regs, &out_val, &trap); + ret = ext->handle(extension_id, func_id, regs, &out); if (extension_id >= SBI_EXT_0_1_SET_TIMER && extension_id <= SBI_EXT_0_1_SHUTDOWN) is_0_1_spec = 1; @@ -116,10 +114,7 @@ int sbi_ecall_handler(struct sbi_trap_regs *regs) ret = SBI_ENOTSUPP; } - if (ret == SBI_ETRAP) { - trap.epc = regs->mepc; - sbi_trap_redirect(regs, &trap); - } else { + if (!out.skip_regs_update) { if (ret < SBI_LAST_ERR || (extension_id != SBI_EXT_0_1_CONSOLE_GETCHAR && SBI_SUCCESS < ret)) { @@ -140,7 +135,7 @@ int sbi_ecall_handler(struct sbi_trap_regs *regs) regs->mepc += 4; regs->a0 = ret; if (!is_0_1_spec) - regs->a1 = out_val; + regs->a1 = out.value; } return 0; diff --git a/lib/sbi/sbi_ecall_base.c b/lib/sbi/sbi_ecall_base.c index 74f05eb..b7178ea 100644 --- a/lib/sbi/sbi_ecall_base.c +++ b/lib/sbi/sbi_ecall_base.c @@ -33,37 +33,36 @@ static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val) } static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; switch (funcid) { case SBI_EXT_BASE_GET_SPEC_VERSION: - *out_val = (SBI_ECALL_VERSION_MAJOR << - SBI_SPEC_VERSION_MAJOR_OFFSET) & - (SBI_SPEC_VERSION_MAJOR_MASK << - SBI_SPEC_VERSION_MAJOR_OFFSET); - *out_val = *out_val | SBI_ECALL_VERSION_MINOR; + out->value = (SBI_ECALL_VERSION_MAJOR << + SBI_SPEC_VERSION_MAJOR_OFFSET) & + (SBI_SPEC_VERSION_MAJOR_MASK << + SBI_SPEC_VERSION_MAJOR_OFFSET); + out->value = out->value | SBI_ECALL_VERSION_MINOR; break; case SBI_EXT_BASE_GET_IMP_ID: - *out_val = sbi_ecall_get_impid(); + out->value = sbi_ecall_get_impid(); break; case SBI_EXT_BASE_GET_IMP_VERSION: - *out_val = OPENSBI_VERSION; + out->value = OPENSBI_VERSION; break; case SBI_EXT_BASE_GET_MVENDORID: - *out_val = csr_read(CSR_MVENDORID); + out->value = csr_read(CSR_MVENDORID); break; case SBI_EXT_BASE_GET_MARCHID: - *out_val = csr_read(CSR_MARCHID); + out->value = csr_read(CSR_MARCHID); break; case SBI_EXT_BASE_GET_MIMPID: - *out_val = csr_read(CSR_MIMPID); + out->value = csr_read(CSR_MIMPID); break; case SBI_EXT_BASE_PROBE_EXT: - ret = sbi_ecall_base_probe(regs->a0, out_val); + ret = sbi_ecall_base_probe(regs->a0, &out->value); break; default: ret = SBI_ENOTSUPP; diff --git a/lib/sbi/sbi_ecall_cppc.c b/lib/sbi/sbi_ecall_cppc.c index b54d54e..c26bb40 100644 --- a/lib/sbi/sbi_ecall_cppc.c +++ b/lib/sbi/sbi_ecall_cppc.c @@ -12,9 +12,8 @@ #include static int sbi_ecall_cppc_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; uint64_t temp; @@ -22,14 +21,14 @@ static int sbi_ecall_cppc_handler(unsigned long extid, unsigned long funcid, switch (funcid) { case SBI_EXT_CPPC_READ: ret = sbi_cppc_read(regs->a0, &temp); - *out_val = temp; + out->value = temp; break; case SBI_EXT_CPPC_READ_HI: #if __riscv_xlen == 32 ret = sbi_cppc_read(regs->a0, &temp); - *out_val = temp >> 32; + out->value = temp >> 32; #else - *out_val = 0; + out->value = 0; #endif break; case SBI_EXT_CPPC_WRITE: @@ -38,7 +37,7 @@ static int sbi_ecall_cppc_handler(unsigned long extid, unsigned long funcid, case SBI_EXT_CPPC_PROBE: ret = sbi_cppc_probe(regs->a0); if (ret >= 0) { - *out_val = ret; + out->value = ret; ret = 0; } break; diff --git a/lib/sbi/sbi_ecall_dbcn.c b/lib/sbi/sbi_ecall_dbcn.c index 18cd6c8..49a7713 100644 --- a/lib/sbi/sbi_ecall_dbcn.c +++ b/lib/sbi/sbi_ecall_dbcn.c @@ -17,9 +17,8 @@ #include static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { ulong smode = (csr_read(CSR_MSTATUS) & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; @@ -49,9 +48,9 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, return SBI_ERR_INVALID_PARAM; sbi_hart_map_saddr(regs->a1, regs->a0); if (funcid == SBI_EXT_DBCN_CONSOLE_WRITE) - *out_val = sbi_nputs((const char *)regs->a1, regs->a0); + out->value = sbi_nputs((const char *)regs->a1, regs->a0); else - *out_val = sbi_ngets((char *)regs->a1, regs->a0); + out->value = sbi_ngets((char *)regs->a1, regs->a0); sbi_hart_unmap_saddr(); return 0; case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: diff --git a/lib/sbi/sbi_ecall_hsm.c b/lib/sbi/sbi_ecall_hsm.c index 20705c3..93170b0 100644 --- a/lib/sbi/sbi_ecall_hsm.c +++ b/lib/sbi/sbi_ecall_hsm.c @@ -17,9 +17,8 @@ #include static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); @@ -47,7 +46,7 @@ static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, } if (ret >= 0) { - *out_val = ret; + out->value = ret; ret = 0; } diff --git a/lib/sbi/sbi_ecall_ipi.c b/lib/sbi/sbi_ecall_ipi.c index a40d6b8..50ef41d 100644 --- a/lib/sbi/sbi_ecall_ipi.c +++ b/lib/sbi/sbi_ecall_ipi.c @@ -15,9 +15,8 @@ #include static int sbi_ecall_ipi_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c index 556f629..48bd227 100644 --- a/lib/sbi/sbi_ecall_legacy.c +++ b/lib/sbi/sbi_ecall_legacy.c @@ -43,13 +43,13 @@ static int sbi_load_hart_mask_unpriv(ulong *pmask, ulong *hmask, } static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; struct sbi_tlb_info tlb_info; u32 source_hart = current_hartid(); + struct sbi_trap_info trap = {0}; ulong hmask = 0; switch (extid) { @@ -71,37 +71,58 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, break; case SBI_EXT_0_1_SEND_IPI: ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, out_trap); - if (ret != SBI_ETRAP) + &hmask, &trap); + if (ret != SBI_ETRAP) { ret = sbi_ipi_send_smode(hmask, 0); + } else { + ret = 0; + trap.epc = regs->mepc; + sbi_trap_redirect(regs, &trap); + out->skip_regs_update = true; + } break; case SBI_EXT_0_1_REMOTE_FENCE_I: ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, out_trap); + &hmask, &trap); if (ret != SBI_ETRAP) { SBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0, 0, SBI_TLB_FENCE_I, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); + } else { + ret = 0; + trap.epc = regs->mepc; + sbi_trap_redirect(regs, &trap); + out->skip_regs_update = true; } break; case SBI_EXT_0_1_REMOTE_SFENCE_VMA: ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, out_trap); + &hmask, &trap); if (ret != SBI_ETRAP) { SBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, 0, 0, SBI_TLB_SFENCE_VMA, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); + } else { + ret = 0; + trap.epc = regs->mepc; + sbi_trap_redirect(regs, &trap); + out->skip_regs_update = true; } break; case SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID: ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, out_trap); + &hmask, &trap); if (ret != SBI_ETRAP) { SBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, regs->a3, 0, SBI_TLB_SFENCE_VMA_ASID, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); + } else { + ret = 0; + trap.epc = regs->mepc; + sbi_trap_redirect(regs, &trap); + out->skip_regs_update = true; } break; case SBI_EXT_0_1_SHUTDOWN: diff --git a/lib/sbi/sbi_ecall_pmu.c b/lib/sbi/sbi_ecall_pmu.c index c585911..40a63a6 100644 --- a/lib/sbi/sbi_ecall_pmu.c +++ b/lib/sbi/sbi_ecall_pmu.c @@ -18,9 +18,8 @@ #include static int sbi_ecall_pmu_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; uint64_t temp; @@ -29,12 +28,12 @@ static int sbi_ecall_pmu_handler(unsigned long extid, unsigned long funcid, case SBI_EXT_PMU_NUM_COUNTERS: ret = sbi_pmu_num_ctr(); if (ret >= 0) { - *out_val = ret; + out->value = ret; ret = 0; } break; case SBI_EXT_PMU_COUNTER_GET_INFO: - ret = sbi_pmu_ctr_get_info(regs->a0, out_val); + ret = sbi_pmu_ctr_get_info(regs->a0, &out->value); break; case SBI_EXT_PMU_COUNTER_CFG_MATCH: #if __riscv_xlen == 32 @@ -45,21 +44,21 @@ static int sbi_ecall_pmu_handler(unsigned long extid, unsigned long funcid, ret = sbi_pmu_ctr_cfg_match(regs->a0, regs->a1, regs->a2, regs->a3, temp); if (ret >= 0) { - *out_val = ret; + out->value = ret; ret = 0; } break; case SBI_EXT_PMU_COUNTER_FW_READ: ret = sbi_pmu_ctr_fw_read(regs->a0, &temp); - *out_val = temp; + out->value = temp; break; case SBI_EXT_PMU_COUNTER_FW_READ_HI: #if __riscv_xlen == 32 ret = sbi_pmu_ctr_fw_read(regs->a0, &temp); - *out_val = temp >> 32; + out->value = temp >> 32; #else - *out_val = 0; + out->value = 0; #endif break; case SBI_EXT_PMU_COUNTER_START: diff --git a/lib/sbi/sbi_ecall_rfence.c b/lib/sbi/sbi_ecall_rfence.c index 4b74d41..ded16c2 100644 --- a/lib/sbi/sbi_ecall_rfence.c +++ b/lib/sbi/sbi_ecall_rfence.c @@ -16,9 +16,8 @@ #include static int sbi_ecall_rfence_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; unsigned long vmid; diff --git a/lib/sbi/sbi_ecall_srst.c b/lib/sbi/sbi_ecall_srst.c index dcd560d..46cfaca 100644 --- a/lib/sbi/sbi_ecall_srst.c +++ b/lib/sbi/sbi_ecall_srst.c @@ -15,9 +15,8 @@ #include static int sbi_ecall_srst_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { if (funcid == SBI_EXT_SRST_RESET) { if ((((u32)-1U) <= ((u64)regs->a0)) || diff --git a/lib/sbi/sbi_ecall_susp.c b/lib/sbi/sbi_ecall_susp.c index 2bfd99a..7b66bfc 100644 --- a/lib/sbi/sbi_ecall_susp.c +++ b/lib/sbi/sbi_ecall_susp.c @@ -6,9 +6,8 @@ #include static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = SBI_ENOTSUPP; @@ -16,7 +15,7 @@ static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid, ret = sbi_system_suspend(regs->a0, regs->a1, regs->a2); if (ret >= 0) { - *out_val = ret; + out->value = ret; ret = 0; } diff --git a/lib/sbi/sbi_ecall_time.c b/lib/sbi/sbi_ecall_time.c index e79196f..5a2316e 100644 --- a/lib/sbi/sbi_ecall_time.c +++ b/lib/sbi/sbi_ecall_time.c @@ -15,9 +15,8 @@ #include static int sbi_ecall_time_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { int ret = 0; diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c index 700f475..ebebc58 100644 --- a/lib/sbi/sbi_ecall_vendor.c +++ b/lib/sbi/sbi_ecall_vendor.c @@ -23,13 +23,11 @@ static inline unsigned long sbi_ecall_vendor_id(void) } static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_val, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { return sbi_platform_vendor_ext_provider(sbi_platform_thishart_ptr(), - funcid, regs, - out_val, out_trap); + funcid, regs, out); } struct sbi_ecall_extension ecall_vendor; diff --git a/platform/generic/andes/andes_sbi.c b/platform/generic/andes/andes_sbi.c index 3e89fb9..267c663 100644 --- a/platform/generic/andes/andes_sbi.c +++ b/platform/generic/andes/andes_sbi.c @@ -33,14 +33,13 @@ static bool andes45_apply_iocp_sw_workaround(void) } int andes_sbi_vendor_ext_provider(long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_value, - struct sbi_trap_info *out_trap, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out, const struct fdt_match *match) { switch (funcid) { case SBI_EXT_ANDES_IOCP_SW_WORKAROUND: - *out_value = andes45_apply_iocp_sw_workaround(); + out->value = andes45_apply_iocp_sw_workaround(); break; default: diff --git a/platform/generic/include/andes/andes_sbi.h b/platform/generic/include/andes/andes_sbi.h index e5dc250..1288af8 100644 --- a/platform/generic/include/andes/andes_sbi.h +++ b/platform/generic/include/andes/andes_sbi.h @@ -3,13 +3,13 @@ #ifndef _RISCV_ANDES_SBI_H #define _RISCV_ANDES_SBI_H +#include #include #include int andes_sbi_vendor_ext_provider(long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_value, - struct sbi_trap_info *out_trap, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out, const struct fdt_match *match); #endif /* _RISCV_ANDES_SBI_H */ diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index f2a4327..b0585c2 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -10,6 +10,7 @@ #ifndef __PLATFORM_OVERRIDE_H__ #define __PLATFORM_OVERRIDE_H__ +#include #include #include #include @@ -30,9 +31,8 @@ struct platform_override { int (*pmu_init)(const struct fdt_match *match); void (*fw_init)(void *fdt, const struct fdt_match *match); int (*vendor_ext_provider)(long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_value, - struct sbi_trap_info *out_trap, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out, const struct fdt_match *match); }; diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 8507227..bfd7d31 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -203,12 +203,10 @@ static bool generic_vendor_ext_check(void) } static int generic_vendor_ext_provider(long funcid, - const struct sbi_trap_regs *regs, - unsigned long *out_value, - struct sbi_trap_info *out_trap) + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) { - return generic_plat->vendor_ext_provider(funcid, regs, - out_value, out_trap, + return generic_plat->vendor_ext_provider(funcid, regs, out, generic_plat_match); } From patchwork Mon Dec 11 18:07:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1874675 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=qflr1eaD; 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=ZZMLkBky; 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 4SpqVP4hKbz1ySd for ; Tue, 12 Dec 2023 05:08:13 +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=ztqquP7j1inCyCFqScqUi8TOE8zwU+C/+d2IZlPIGBA=; b=qflr1eaDKU/WZh SPs2BHx4Au8JgN0yeBRM9im+zEs2AuoicRAAH/yIjB2AsMIUy4m+U/t2AnM8Oap8p5ZZdzws20H67 cpHUUaX48AvRxO0V9b/+Nd/uJk+AWquhsw2iHR09F4BL/iY1wCzMvubml1o3SMNttVdIP0T2dAZDJ MQMFYI6fOes3IuSdaNqP43MXaRFDeiBAvdFcBqVe0KzVuA+YhmDlBttfpRS70u9qYSvxpvWQ/uwaf 0SI3y4syKoMcOQqJ2/By+40sOAKuX0rrZTCvA9XRuxoI/J15urqzrbrzb3JQxq7keDrDTJgcJjLL/ DPkEmiTUw4sqAS6jlPrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCkhF-006hOM-2N; Mon, 11 Dec 2023 18:08:01 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rCkhC-006hKz-2b for opensbi@lists.infradead.org; Mon, 11 Dec 2023 18:08:00 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-286b45c5a8dso4973439a91.1 for ; Mon, 11 Dec 2023 10:07:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702318078; x=1702922878; 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=y3Bvwe1m3vrSDKcW3Om29U9GrWeyZE+oEmwLyaBGGnQ=; b=ZZMLkBkyLdCEQOwVBJAvU3ex6z6Fhy3Z5iSqSH6JwR0SvEo9ShRBgCbgtTnM+vojhw HvKZcqHEH7oIK/W26WUDdHPbdGaDzXgAfyHeactjsU2do9mLRZSwOgfbRkClql+X7Eus eySKEyB7tH8jZWiS9i4pxao/IJtm5Ilmy/8ctwO9qE4NPHYjkjo0cuNRfAuyIcajSTWQ o0FxcAPo+QtPB3zchg0VDWoPV+ZFuj/yuYN8tytEJ8Uw1Erw1sn5rGfxu+RJsMoWmqP+ ezCvFYhiBTVtQOtYgoPrXKnpAFZlfOBKnnYQNM/DEO3P/3Kp++gR+7QtZQjT1CkMaugB J7QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702318078; x=1702922878; 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=y3Bvwe1m3vrSDKcW3Om29U9GrWeyZE+oEmwLyaBGGnQ=; b=AkrA7BgVkt+jzlYKa87uGoW0vLYot5SQRt324SXjbM/vHZH8rdoN1d8ylBz3ZAbVyi 88WwjuLAx6G7Xg2+HbiID141nkBfyRnajjYmKVy39KejUIvEMoRgrFFs1h/3wF85PMkz gUeYLikN/9ZFlqWIP1/hH3A/9XeRLV01mQzJvn1VH6aJNaGG6qO835y5VD4LwAVcjDNv 4RWWXBAa3hUZV9myFo92SybhYcut9DsKk2E5Z8u6cvya+p+F7eCN+55jlzrN7+hg9xcx FGYLVxM72aNVyYpBjJODy/KO/y3ciUUyJU6OunN/MUwDviEy68oRuXDPPri0zOzb9B9U DLUg== X-Gm-Message-State: AOJu0YyRB1JgopTIH8vs1yozu+Mk1MqXpj0i0Z8hj0Vi0VJQDHp7oa7r YUug+x6T0CWZvRZy6z2Hl947PA== X-Google-Smtp-Source: AGHT+IEzvZmqk/iTq4GUR1en56lWP8cxsTpnGSDM+/rgALVODseu3nt8GnYqYMsVHnE92OTf/3NTNQ== X-Received: by 2002:a17:90a:7446:b0:28a:3457:d7fc with SMTP id o6-20020a17090a744600b0028a3457d7fcmr3999191pjk.37.1702318077642; Mon, 11 Dec 2023 10:07:57 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.12]) by smtp.gmail.com with ESMTPSA id u15-20020a17090ae00f00b002800e0b4852sm8641641pjy.22.2023.12.11.10.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:07:57 -0800 (PST) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 5/5] lib: sbi: Remove the SBI_ETRAP error code Date: Mon, 11 Dec 2023 23:37:38 +0530 Message-Id: <20231211180738.891727-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211180738.891727-1-apatel@ventanamicro.com> References: <20231211180738.891727-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_100758_914429_0D623E40 X-CRM114-Status: GOOD ( 11.10 ) 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_ETRAP error code was introduced only for doing trap redirection in generic sbi_ecall_handler(). Now the trap redirection is moved into sbi_ecall_legacy.c and SBI_ETRAP error code is only used [...] 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:102b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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_ETRAP error code was introduced only for doing trap redirection in generic sbi_ecall_handler(). Now the trap redirection is moved into sbi_ecall_legacy.c and SBI_ETRAP error code is only used in this source file so let us remove it. Signed-off-by: Anup Patel --- include/sbi/sbi_error.h | 5 ++--- lib/sbi/sbi_ecall_legacy.c | 32 ++++++++++++-------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/include/sbi/sbi_error.h b/include/sbi/sbi_error.h index 7f97506..a77e3f8 100644 --- a/include/sbi/sbi_error.h +++ b/include/sbi/sbi_error.h @@ -32,9 +32,8 @@ #define SBI_EILL -1004 #define SBI_ENOSPC -1005 #define SBI_ENOMEM -1006 -#define SBI_ETRAP -1007 -#define SBI_EUNKNOWN -1008 -#define SBI_ENOENT -1009 +#define SBI_EUNKNOWN -1007 +#define SBI_ENOENT -1008 /* clang-format on */ diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c index 48bd227..14913c9 100644 --- a/lib/sbi/sbi_ecall_legacy.c +++ b/lib/sbi/sbi_ecall_legacy.c @@ -24,22 +24,22 @@ #include #include -static int sbi_load_hart_mask_unpriv(ulong *pmask, ulong *hmask, - struct sbi_trap_info *uptrap) +static bool sbi_load_hart_mask_unpriv(ulong *pmask, ulong *hmask, + struct sbi_trap_info *uptrap) { ulong mask = 0; if (pmask) { mask = sbi_load_ulong(pmask, uptrap); if (uptrap->cause) - return SBI_ETRAP; + return false; } else { sbi_hsm_hart_interruptible_mask(sbi_domain_thishart_ptr(), 0, &mask); } *hmask = mask; - return 0; + return true; } static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, @@ -70,56 +70,48 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, sbi_ipi_clear_smode(); break; case SBI_EXT_0_1_SEND_IPI: - ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, &trap); - if (ret != SBI_ETRAP) { + if (sbi_load_hart_mask_unpriv((ulong *)regs->a0, + &hmask, &trap)) { ret = sbi_ipi_send_smode(hmask, 0); } else { - ret = 0; trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } break; case SBI_EXT_0_1_REMOTE_FENCE_I: - ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, &trap); - if (ret != SBI_ETRAP) { + if (sbi_load_hart_mask_unpriv((ulong *)regs->a0, + &hmask, &trap)) { SBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0, 0, SBI_TLB_FENCE_I, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } else { - ret = 0; trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } break; case SBI_EXT_0_1_REMOTE_SFENCE_VMA: - ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, &trap); - if (ret != SBI_ETRAP) { + if (sbi_load_hart_mask_unpriv((ulong *)regs->a0, + &hmask, &trap)) { SBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, 0, 0, SBI_TLB_SFENCE_VMA, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } else { - ret = 0; trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true; } break; case SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID: - ret = sbi_load_hart_mask_unpriv((ulong *)regs->a0, - &hmask, &trap); - if (ret != SBI_ETRAP) { + if (sbi_load_hart_mask_unpriv((ulong *)regs->a0, + &hmask, &trap)) { SBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, regs->a3, 0, SBI_TLB_SFENCE_VMA_ASID, source_hart); ret = sbi_tlb_request(hmask, 0, &tlb_info); } else { - ret = 0; trap.epc = regs->mepc; sbi_trap_redirect(regs, &trap); out->skip_regs_update = true;