From patchwork Tue Apr 23 14:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1926620 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=Auzi+jPn; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=E5xDkFvo; 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 4VP4xc16b7z1yZP for ; Wed, 24 Apr 2024 00:58:28 +1000 (AEST) 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=Z3JVPnxVMezb4IVgZ8kX5E9+ofzXrUiClb8VCYf6R+4=; b=Auzi+jPnKCYNS1 LESk5CQ6VvNytJwx9S/PdeLqcirBMYALAL9vLdxHSqwoFsx+vzSNMIGU3b20uxmEZtfRwFM9BANjK Ruz5keTDh/PQ6fbe0P8tipNeLBBwMHtJ1s6QIsPjFdylI5GRiRBVRcRlTUjtdFstsCc7WTjVXjukD KtHyeOA0HUtH3umknhZ+wKupan60LHksr5S9SgfKTLQdRr8EV8wEleSEOv8WnCYnmmedlWKRpr9gF gWn0/sm8a/fpWuDfAzSZ614iIEtxbdqqbxPc0nz9RVgQetcEDR9lSx2F69ok6P2LBi/Yrb/kSYmT3 O8Piy+BYaO4kf944dU0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHbA-00000000OA1-3vZb; Tue, 23 Apr 2024 14:58:20 +0000 Received: from m16.mail.126.com ([220.197.31.7]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHal-00000000O2V-0xc3 for opensbi@lists.infradead.org; Tue, 23 Apr 2024 14:57:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=O6xdp GK0PAjAxjFbXHeDcX6h1ZyFopDEA/ARMXwTLHk=; b=E5xDkFvo0UJDT+KyDhmbG NnPorYsZlmuHPndq/7oIfyDFgFtuTYc7o10cYfPbh5NwkNGG24X9afmI7JBxglXv 8rGKRgFsVuKBAU+JapgD8IX5CecrMhepWEMPAin6lKcy2wkkZdydcN0NkjnYdn1l QaUcqLurtfYl3J5fHhQ1J0= Received: from T490.lan (unknown [112.83.183.156]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wDXT7lpzCdmN00xAg--.23722S3; Tue, 23 Apr 2024 22:57:46 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v2 1/5] lib: sbi: fix hart_shmem_base Date: Tue, 23 Apr 2024 22:57:37 +0800 Message-ID: <20240423145743.392718-2-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240423145743.392718-1-wxjstz@126.com> References: <20240423145743.392718-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDXT7lpzCdmN00xAg--.23722S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gw4UWFy3Xry8uFWxXr43ZFb_yoWktrc_Kw 4fAr4j9Fs8Xrs7uw1vkrW5Ar1kKr40yrykZas7XrZIy343tr4DJFy0gwn3XFZ8Xr4rKrsr Jrs8uF1fCFyYkjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRu9a97UUUUU== X-Originating-IP: [112.83.183.156] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdAzJOmSdL4hRaAAFsp X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_075755_900908_6A885CAC X-CRM114-Status: UNSURE ( 8.46 ) 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: When only phys_hi is equal to SBI_DBTR_SHMEM_INVALID_ADDR, it may be a legal address. The old code would modify the legal address. Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 11 ++++------- 1 file changed, 4 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 [220.197.31.7 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_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_AU Message has a valid DKIM or DK signature from author's domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz(at)126.com] 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 When only phys_hi is equal to SBI_DBTR_SHMEM_INVALID_ADDR, it may be a legal address. The old code would modify the legal address. Signed-off-by: Xiang W Reviewed-by: Himanshu Chauhan --- lib/sbi/sbi_dbtr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 7142fed..5b07285 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -84,21 +84,18 @@ static inline void sbi_dbtr_disable_shmem(void) static inline void *hart_shmem_base(void) { - struct sbi_dbtr_shmem* shmem; unsigned long phys_hi, phys_lo; struct sbi_dbtr_hart_triggers_state *hs = NULL; hs = dbtr_get_hart_state_ptr(sbi_scratch_thishart_ptr()); - if (!hs) return NULL; - shmem = &hs->shmem; + phys_hi = hs->shmem.phys_hi; + phys_lo = hs->shmem.phys_lo; - phys_hi = (shmem->phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR - ? shmem->phys_hi : 0); - phys_lo = (shmem->phys_lo == SBI_DBTR_SHMEM_INVALID_ADDR - ? 0 : shmem->phys_lo); + if (phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR && phys_hi == phys_lo) + return NULL; return ((void *)(unsigned long)DBTR_SHMEM_MAKE_PHYS(phys_hi, phys_lo)); } From patchwork Tue Apr 23 14:57:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1926624 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=nJ7ajdOC; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=FRS93ETB; 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 4VP4xg2dVgz1yZt for ; Wed, 24 Apr 2024 00:58:31 +1000 (AEST) 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=t7viJAN/bpHwMEz+krvvs8jpl8y2L5aLsYGC0F9fc0Q=; b=nJ7ajdOCmuHbfr j7Z1qodeITv1ZJcY49rcmREbPWnZiq31nZlTN2WJG2re74WMoYQu7H+fYVhb+g0kJWtgaiy6Kixy/ kjDfZuPBL/MCSv6XozgUNSnx1vtfyqGOovOviKc0LoT9PyYBrrEAlOjE/A7v1Ms/ZvQMnV5lZZL7i HvZemUvcswduj/51AYGnJhErUnuqy584sTqDkNEAoP8uF5c1ELHhBfqNd3h+1ZxRtcq+O59iT7TYj 9vHjF2ncG2X2AHp3Ca85L6fDyrbDp8k8heqF5mgHd6AOoqeL5fCAZclTa+jZ5PTf7GuJrM0f19zGu BUKwSKYvzKPLXyu3CfYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHbE-00000000OCZ-3OHs; Tue, 23 Apr 2024 14:58:24 +0000 Received: from m16.mail.126.com ([117.135.210.7]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHak-00000000O24-10kI for opensbi@lists.infradead.org; Tue, 23 Apr 2024 14:58:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=V+/FO QmMpHUvLbFFJoqskSh7SXpV1Jf4TGuAJ/NAupI=; b=FRS93ETBmjQa5cip3S4i4 eR8PHhZjY7mN272LX+Yd3q1KJ5tKLXdjo2spO4sL/Wep4cW57p5Rfj7YL+dvBx2c 4GLJ5CMETLpL9qe83jiGvHyMqyI7G6JGMNrO4aaijULUa9X5oyh+o9oMLtF4e6ke sD1zWmYh9UdL+Np48HqoSA= Received: from T490.lan (unknown [112.83.183.156]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wDXT7lpzCdmN00xAg--.23722S4; Tue, 23 Apr 2024 22:57:46 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v2 2/5] lib: sbi: Remove unnecessary sbi_dbtr_shmem_disabled Date: Tue, 23 Apr 2024 22:57:38 +0800 Message-ID: <20240423145743.392718-3-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240423145743.392718-1-wxjstz@126.com> References: <20240423145743.392718-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDXT7lpzCdmN00xAg--.23722S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7AFWkWFyDGF1fWFW3WF1xZrb_yoW8Ww1kpF 97GFW3Kr4xXryvyrWxJ3y8K3yYqw4xA348tr9I9rZYyas5Zw18Jw43J3WqqFyfArWkZa12 vF10kF4jkF4YvF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zNXdbkUUUUU= X-Originating-IP: [112.83.183.156] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdAzJOmSdL4hRaAABst X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_075800_298357_87D67092 X-CRM114-Status: UNSURE ( 7.59 ) 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 code of hart_shmem_base is similar to sbi_dbtr_shmem_disabled. When hart_shmem_base is used, sbi_dbtr_shmem_disabled can be removed. Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_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_AU Message has a valid DKIM or DK signature from author's domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz(at)126.com] 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 code of hart_shmem_base is similar to sbi_dbtr_shmem_disabled. When hart_shmem_base is used, sbi_dbtr_shmem_disabled can be removed. Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 5b07285..ceff185 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -537,10 +537,9 @@ int sbi_dbtr_read_trig(unsigned long smode, trig_idx_base + trig_count >= hs->total_trigs) return SBI_ERR_INVALID_PARAM; - if (sbi_dbtr_shmem_disabled()) - return SBI_ERR_NO_SHMEM; - shmem_base = hart_shmem_base(); + if (shmem_base == NULL) + return SBI_ERR_NO_SHMEM; for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) { sbi_hart_map_saddr((unsigned long)entry, sizeof(*entry)); @@ -567,10 +566,10 @@ int sbi_dbtr_install_trig(unsigned long smode, struct sbi_dbtr_trigger *trig; struct sbi_dbtr_hart_triggers_state *hs = NULL; - if (sbi_dbtr_shmem_disabled()) + shmem_base = hart_shmem_base(); + if (shmem_base == NULL) return SBI_ERR_NO_SHMEM; - shmem_base = hart_shmem_base(); hs = dbtr_thishart_state_ptr(); /* Check requested triggers configuration */ @@ -679,10 +678,10 @@ int sbi_dbtr_update_trig(unsigned long smode, void *shmem_base = NULL; struct sbi_dbtr_hart_triggers_state *hs = NULL; - if (sbi_dbtr_shmem_disabled()) + shmem_base = hart_shmem_base(); + if (shmem_base == NULL) return SBI_ERR_NO_SHMEM; - shmem_base = hart_shmem_base(); hs = dbtr_thishart_state_ptr(); if (!hs) return SBI_ERR_FAILED; From patchwork Tue Apr 23 14:57:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1926622 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=NOxEFTwk; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=bpjAs78f; 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 4VP4xf0z1Xz1yZP for ; Wed, 24 Apr 2024 00:58:30 +1000 (AEST) 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=Pg1TsDFRrG6q3mxfY/UAm0EaoHK3rQS/VzQEcijDs4I=; b=NOxEFTwkEYsbDY vQLzwlDt/8Mle8RbiW45NdySUZjVWOxmYCKutynao+dD2nn2xbdE3BMsmn1ZmoHiku3ls+IB6MGw8 7OxP7Q/BqVOK+70z1fi39T/6yz+ERK5RjsBTl6zKzXGF7dpxZcMy1nFrNulRmWq13unXbAuOwdQMP PnWkV8E8TQwqdL5U9T9RCQkoRDRQnrz6U8P2QYiI7I62tobBMtHIX+EA02i1ItE0qd8wbsHbWMAOT 8XTgjTXIlB6K+Iik4ZnmGHmV/w+2p/ytFLJXAEpLoFkS1rRHH3q4E3jv2NlH6VADGItfhE8MYdKgM 4WdzTwCPJ/Y8hhSVOw1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHbC-00000000OAn-2rwQ; Tue, 23 Apr 2024 14:58:23 +0000 Received: from m16.mail.126.com ([117.135.210.8]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHak-00000000O1a-1JPE for opensbi@lists.infradead.org; Tue, 23 Apr 2024 14:57:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=q38cD maayBv/XxD5D3Y2NYzjYUA6xmxd90kUAGhFXso=; b=bpjAs78fvWY/Y+quvDzXJ ARcwQrf1SVkwf9nZr94gVS50lIULPy/r+N25/1I+FBYrDqxvHoedbqJVaqJBdv3h rr6aPbZvmVUDn904bsbYycgBRjCadDGMXvwCbDQMpkZQo8/Y/VZv/8wvEQ5auLgS atYJKyIMDgIdwnHL/TIFJc= Received: from T490.lan (unknown [112.83.183.156]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wDXT7lpzCdmN00xAg--.23722S5; Tue, 23 Apr 2024 22:57:46 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v2 3/5] lib: sbi: Removal unnecessary check dbtr_thishart_state_ptr Date: Tue, 23 Apr 2024 22:57:39 +0800 Message-ID: <20240423145743.392718-4-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240423145743.392718-1-wxjstz@126.com> References: <20240423145743.392718-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDXT7lpzCdmN00xAg--.23722S5 X-Coremail-Antispam: 1Uf129KBjvdXoWrJr1DKF18Zr4xXFW3ZF18Xwb_yoWxXrc_A3 y8ZF1vgan0qrsrur4q9wsFqr90yr12gr47X3Z3A39rZr43tr4UWF98Jwn8KFW5Zr4jgFn2 9rsrWr93CFy5ujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRK_M3tUUUUU== X-Originating-IP: [112.83.183.156] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdAzJOmSdL4hRaAADsv X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_075756_255492_5A2AFDF6 X-CRM114-Status: UNSURE ( 4.57 ) 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: After getting hart_shmem_base, dbtr_thishart_state_ptr cannot be empty. So remove check code. Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index ceff185..4093a82 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -683,8 +683,6 @@ int sbi_dbtr_update_trig(unsigned long smode, r [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_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_AU Message has a valid DKIM or DK signature from author's domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz(at)126.com] 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 After getting hart_shmem_base, dbtr_thishart_state_ptr cannot be empty. So remove check code. Signed-off-by: Xiang W Reviewed-by: Himanshu Chauhan --- lib/sbi/sbi_dbtr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index ceff185..4093a82 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -683,8 +683,6 @@ int sbi_dbtr_update_trig(unsigned long smode, return SBI_ERR_NO_SHMEM; hs = dbtr_thishart_state_ptr(); - if (!hs) - return SBI_ERR_FAILED; for_each_set_bit_from(idx, &trig_mask, hs->total_trigs) { trig = INDEX_TO_TRIGGER(idx); From patchwork Tue Apr 23 14:57:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1926623 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=zW5NAtah; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=NIGNj0Et; 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 4VP4xg2R8hz1yZP for ; Wed, 24 Apr 2024 00:58:31 +1000 (AEST) 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=Hmm0Asz/6JoZOhhcc2KJmZPG+m3HSKnccoEoBkRKQsI=; b=zW5NAtahHtBVBV gqNAFtSxIzJFfyz8en6qCZgBVfD3OQQFm2TmwYWkOn8lVC2+PxRw3onMoldiTvJMrWirgL649fMfu /XYsKGyEmGUzP2AaJWnV6t/lHxbNOEoCn5GrHepiZsg2flvN0JO7mKFYKYkF1DBhMZ5u6PQ7JaucO ijNLwgtudbORNRnzdU5SkhZ4FeAAu+SxMhnw9Hoycwv3qZ89ySKfzpFOTBgshgyfIaNrbBnr5o9/t hrxcDajighilImjAUyl7jWy5GeUkl3AbU2XVE8XT6yMFzNqC5qqY0T0sDS5EUIoAdR/JsGC6e/2zK rMWdOSyAyK4GfyzLst7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHbE-00000000OBj-0Nhn; Tue, 23 Apr 2024 14:58:24 +0000 Received: from m16.mail.126.com ([117.135.210.8]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHao-00000000O2n-1tWd for opensbi@lists.infradead.org; Tue, 23 Apr 2024 14:58:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=gfkKc LK6INLA/ng5lPZVuH/QtnQYT3ivVvwvLYBX8iI=; b=NIGNj0Et6e21LRdrwmxFI O0iCHS/ze7FOzopRnipsqmaJr0CNC8x8lFfd1/oUcZZl5hzN2n/xtLHbFqP24uQg eeTD5NL1Y2TGl+m6T1ysFZZOyT9E/nMpgzPLUvTLp+AhXdrquT6wshV4gzcec5mr RLAB0CwcpESvj3vFhZQKG0= Received: from T490.lan (unknown [112.83.183.156]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wDXT7lpzCdmN00xAg--.23722S6; Tue, 23 Apr 2024 22:57:47 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v2 4/5] lib: sbi: fix DBTR_SHMEM_MAKE_PHYS for RV64 Date: Tue, 23 Apr 2024 22:57:40 +0800 Message-ID: <20240423145743.392718-5-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240423145743.392718-1-wxjstz@126.com> References: <20240423145743.392718-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDXT7lpzCdmN00xAg--.23722S6 X-Coremail-Antispam: 1Uf129KBjvdXoW7XrWUAF4rZFWkCr1rZryDtrb_yoW3Xrb_G3 48Ar4v9rs8ua92gw1aqr4jqF4S9Fn09FsrZ3s3AFWDJw43tF4Yk345XFZ0gan8Jr429F12 y3W7Wr13Gr15KjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRWBTYUUUUUU== X-Originating-IP: [112.83.183.156] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdQ7JOmSdL6grRQAAsY X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_075800_256470_CF0582E9 X-CRM114-Status: UNSURE ( 7.19 ) 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: Obtaining a 64-bit address under rv64 does not require combining 32-bit registers Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 4093a82..29be9bb 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -48,7 +48,7 @@ static unsigned long hart_state_ptr_offset; _idx+ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_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_AU Message has a valid DKIM or DK signature from author's domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz(at)126.com] 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 Obtaining a 64-bit address under rv64 does not require combining 32-bit registers Signed-off-by: Xiang W Reviewed-by: Himanshu Chauhan --- lib/sbi/sbi_dbtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 4093a82..29be9bb 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -48,7 +48,7 @@ static unsigned long hart_state_ptr_offset; _idx++, _entry = ((_etype *)_base + _idx)) #if __riscv_xlen == 64 -#define DBTR_SHMEM_MAKE_PHYS(_p_hi, _p_lo) (((u64)(_p_hi) << 32) | (_p_lo)) +#define DBTR_SHMEM_MAKE_PHYS(_p_hi, _p_lo) (_p_lo) #elif __riscv_xlen == 32 #define DBTR_SHMEM_MAKE_PHYS(_p_hi, _p_lo) (((u64)(_p_hi) << 32) | (_p_lo)) #else From patchwork Tue Apr 23 14:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1926621 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=Vs8oL4ZP; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=EC9gasfx; 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 4VP4xc6HrXz1yZt for ; Wed, 24 Apr 2024 00:58:28 +1000 (AEST) 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=C65f/swfJDXkUlzy+jJnjo/AeSWd2VG4HoEOh/YOJA4=; b=Vs8oL4ZPvyvGTJ yTzLQ8AkJyBVW2SDt4UzSHWN1Mnd5P2rE6p1IqLcStdRTeditdbWyXpTf9I38EOA0JlG3j4ryExYm OCuVCIGFlrrYHsdjonoeJFCHcD5qvJhB0reoK7RlFRrbQZhZFGBNjHEn1nYTByK1+l/MGPevQmp+6 y5ov8ilxy39RrELryzEmF2TUoYv+sO2mPPj1/Jh5YT4OYnXYr+VUKeIJ47dl0QyrA8uCl7gHJF35B 0LnNRALt4yIacWoQg5Jet4LbjIZyS5fKYHXx/W4Qzn5oAVr1XIanFIm7TYKK+TjtVfFJ8QoaDd+Fy PAoPhSv5uaXcMIlLmvFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHbB-00000000OAM-3FcQ; Tue, 23 Apr 2024 14:58:21 +0000 Received: from m16.mail.126.com ([220.197.31.6]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzHan-00000000O3P-0Lth for opensbi@lists.infradead.org; Tue, 23 Apr 2024 14:57:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=Jc+0l 36WTO61tCN+p0MFPenPsnWI19qhQfpTVM65DDw=; b=EC9gasfx+nV1AEKqhNXQ7 kOAwyWMvqcVmJY+wqWLqDD6kkxrG2QXQxRNRgW3H/dRLZbru7Y4l27oCuRJTif6S wJGyyxttXMUfI0knTwaln4wukFJIllfl9DfTrqb+nmqEdsxkRj3hkXGbQHjTvAL0 Nbt31SaNYHlzvB7iE0LqZ4= Received: from T490.lan (unknown [112.83.183.156]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wDXT7lpzCdmN00xAg--.23722S7; Tue, 23 Apr 2024 22:57:47 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v2 5/5] lib: sbi: Fixed memory permission check in sbi_dbtr_setup_shmem Date: Tue, 23 Apr 2024 22:57:41 +0800 Message-ID: <20240423145743.392718-6-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240423145743.392718-1-wxjstz@126.com> References: <20240423145743.392718-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDXT7lpzCdmN00xAg--.23722S7 X-Coremail-Antispam: 1Uf129KBjvdXoWrKFyxCry3ZF1DuFWrGFW8Xrb_yoWkurX_Gw 4rAF4DGrs8XFsrZ3Wvy3yYqrn7KrsrKrnY93Z7A39Fyw43tr47Gr95twn3ZFW7Zw48tw1I yr4xCF13CFy5CjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRMYLvPUUUUU== X-Originating-IP: [112.83.183.156] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdBDJOmSdL4hSnAAAsH X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_075757_694983_F602A05C X-CRM114-Status: UNSURE ( 7.36 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.1 (+) 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 previous code detected shmem_phys_hi and shmem_phys_lo as two addresses. fix this bug Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) Content analysis details: (1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [220.197.31.6 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_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_AU Message has a valid DKIM or DK signature from author's domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz(at)126.com] 0.0 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [220.197.31.6 listed in bl.mailspike.net] 0.0 RCVD_IN_MSPIKE_BL Mailspike blocklisted 1.3 RCVD_IN_VALIDITY_RPBL RBL: Relay in Validity RPBL, https://senderscore.org/blocklistlookup/ [220.197.31.6 listed in bl.score.senderscore.com] 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 previous code detected shmem_phys_hi and shmem_phys_lo as two addresses. fix this bug Signed-off-by: Xiang W Reviewed-by: Himanshu Chauhan --- lib/sbi/sbi_dbtr.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 29be9bb..f1b53e9 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -293,17 +293,11 @@ int sbi_dbtr_setup_shmem(const struct sbi_domain *dom, unsigned long smode, if (shmem_phys_lo & SBI_DBTR_SHMEM_ALIGN_MASK) return SBI_ERR_INVALID_PARAM; - if (dom && !sbi_domain_check_addr(dom, shmem_phys_lo, smode, - SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) + if (dom && !sbi_domain_check_addr(dom, + DBTR_SHMEM_MAKE_PHYS(shmem_phys_hi, shmem_phys_lo), smode, + SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) return SBI_ERR_INVALID_ADDRESS; - if (shmem_phys_hi != SBI_DBTR_SHMEM_INVALID_ADDR) { - if (dom && - !sbi_domain_check_addr(dom, shmem_phys_hi, smode, - SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) - return SBI_ERR_INVALID_ADDRESS; - } - hart_state = dbtr_thishart_state_ptr(); if (!hart_state) return SBI_ERR_FAILED;