From patchwork Fri May 3 13:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1931042 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=iH2k2D95; 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=NRPqQpk6; 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 4VWC4Y103yz1ybC for ; Fri, 3 May 2024 23:55:41 +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=kjY/BBTmtoRrHN3WRV5UHCyL8Dwncki4JqC/OQaxHv8=; b=iH2k2D954CDP7+ YR7KVItuMHST32irpJzagrO5aztG0crmCDHb3Dk0EZiCbTrCA3gv+Gr/rFXEw4lwrci5jjjFGL/fR 2f9MPgcl+TM9Ln9zgYTSOql5QzJWaiEqGNKg61KH/oDehLnO5wvFgy4d9spFzHBeTaBsSJ10JFFgV aslmIhn+SQDjdZZ5PfqcIbe2oOToNdbxIJNj+KzpO2BkflazyRW5UN8bsG2zGDixsci29atL5r26B phRqxq52hQ0y8meArgX0QUArYqElWDf5qXujAaDMM0iq/oXEG7M11CtXZu6CwgFrjbKoNkX+XD0AI 1XrL6jrqMbCMgaduXGQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tNu-0000000GkN2-1q1v; Fri, 03 May 2024 13:55:34 +0000 Received: from m16.mail.126.com ([220.197.31.8]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tNq-0000000GkJK-3qFK for opensbi@lists.infradead.org; Fri, 03 May 2024 13:55:32 +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=n3tku uOYzZ7igt/ikR9bRNfOtz4T5OgmupfZcT9E2Qw=; b=NRPqQpk60N8CGx8xJ8BSF 843jPNgwSTQWbNuwiEiat3ZuX22IH5BrDdNWGbxGkxMAylKuXFPn6fLHyFR7bm+n VoCxO6f/cC4ZY/a032WRIvPkF9BZB8k3f0zLckGea4aT4qnM+JhtWNQ8G84zK+KJ etcKQ+mmSgeNFzs5lVRdwg= Received: from T490.lan (unknown [36.153.54.93]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL3Fl7DRmyPi6Bg--.47168S3; Fri, 03 May 2024 21:53:44 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v3 1/6] lib: sbi: fix hart_shmem_base Date: Fri, 3 May 2024 21:53:33 +0800 Message-ID: <20240503135340.310030-2-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503135340.310030-1-wxjstz@126.com> References: <20240503135340.310030-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDnL3Fl7DRmyPi6Bg--.47168S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Gw4UWFy3Xry8uFWxXr43ZFb_yoW8JrWxpw 4kuF18tayIqry0kFWDKa1rZF1UGw18G3W5Kas8Cr1Yv3Z5Zw18tr13G3yq9rySqry8Ga10 yr10qFW7uF43XaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEE_MxUUUUU= X-Originating-IP: [36.153.54.93] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdR-TOmSdL7NZAQADs9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_065531_472747_607D7784 X-CRM114-Status: UNSURE ( 8.67 ) 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 Reviewed-by: Himanshu Chauhan --- 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.8 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_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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.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.8 listed in bl.mailspike.net] 0.0 RCVD_IN_MSPIKE_BL Mailspike blocklisted 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 Fri May 3 13:53:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1931037 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=Ii9R+Roz; 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=dFJ9UC/c; 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 4VWC3f0lqKz1ydX for ; Fri, 3 May 2024 23:54:54 +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=bUpqnMTl2osotXix3iYfjCYaN/B25WQYPWOPhqdUVNU=; b=Ii9R+RozugSkPo zkgvA4hrZlbKz6EpotbQ1QIgaQIEWpShUxMlqkWC38Eu1rvsXGVJgYAsufXvo+tddcuNQjTSGVPVQ FeonBeetDTczFxS5o5MwJtd6TO+hodlDgwUDqZ5f6RJ1zdmxaa56UTOPO80JHRTjcQPoFOQO6EG8/ OEeXgAj0W09nirTZHpRO7O9EnjrRcIBx9cxKeN+OqWD1fDqeTKbd7JfWOqnBT1eHGyoBwq4pPnmJJ 64tZ5vZ0de6fMy4piylqVqqXKgaUfuioCacVUDiA//of/h0sVssFXaW1yqYnxBcgfQxI7H4QVm3dh Ih/TtfqMAn9Hi0owzJ7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tN7-0000000Gk2Q-1hJV; Fri, 03 May 2024 13:54:45 +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 1s2tN4-0000000Gk1H-09uX for opensbi@lists.infradead.org; Fri, 03 May 2024 13:54:43 +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=luqkk W4NOdA7b9IA6G9+VjM8ZoXd68DSOFqPrXwGD1Q=; b=dFJ9UC/cAcTbOPS3RgSV2 CdJRkQOOi2tYP0ghOhodbyXfkAuoJ9+fk7xFMPZtNVUVVp5fitzdQ91MhiV+1o9i AhoIY2/xxoC9+C/ezg1EL8Y29lU4Y82fKihMYxvMNiXrSpLe8x7bGt0sHVIJ5kq6 f3c6cxk1oJOYOZwC20qcZA= Received: from T490.lan (unknown [36.153.54.93]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL3Fl7DRmyPi6Bg--.47168S4; Fri, 03 May 2024 21:53:44 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v3 2/6] lib: sbi: Removal unnecessary check dbtr_thishart_state_ptr Date: Fri, 3 May 2024 21:53:34 +0800 Message-ID: <20240503135340.310030-3-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503135340.310030-1-wxjstz@126.com> References: <20240503135340.310030-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDnL3Fl7DRmyPi6Bg--.47168S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFy3ZrWkCF45KFyDWr1fXrb_yoWxtrc_Z3 y8ZF1vgFs8XwsF9w1q9r42vrZ0yr42qr12q3Z3ArZrZr43tr45XF98twn8GFW5Xw1j9F92 yrsrWr93CF98ujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRPpndUUUUUU== X-Originating-IP: [36.153.54.93] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdQrTOmSdL7NfKwAAsH X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_065442_449093_D6426616 X-CRM114-Status: UNSURE ( 4.89 ) 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 Reviewed-by: Himanshu Chauhan --- lib/sbi/sbi_dbtr.c | 2 -- 1 file changed, 2 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_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.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 5b07285..3cc1ef8 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -684,8 +684,6 @@ int sbi_dbtr_update_trig(unsigned long smode, shmem_base = hart_shmem_base(); 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 Fri May 3 13:53:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1931038 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=zkxWBMLe; 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=U+2uKKwm; 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 4VWC3f33nFz20fb for ; Fri, 3 May 2024 23:54:54 +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=Hf5KZyoyyFWprEBowoTp1LmOeekKbyjQ78F1vHHki04=; b=zkxWBMLecPU0Yv ++mIza6eFHQ14ccaf1Mw5qlkh2PhF/7rRPVhkfLF7lwwf5zqwASGDax75gB+7scoUTMXURRER/HDS Y0h6CGdH8Vx+gkW9txA/+i/zydPTHknQYVflem+SzskLajHcI+jgm/xVJg4YNGgQG6Hd9qd1/wZXA TANUwQtj+pN4PnBRMjDBqFiNJDzhm+MZq7mB3cf33aJ+ATVet9cAhrPD90/VlRShudza3aXnFQtDF DwwN5JB07oa2rM2cbFm+YTc1TGUldJOYoX0x0EYAnUBbn0OBYKNNedbEnRQlsCrruHXQ1dp3DSO1g zhxlepSO83wO6UI2pvKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tN7-0000000Gk2Y-3kn1; Fri, 03 May 2024 13:54:45 +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 1s2tN4-0000000Gk1J-3Jr7 for opensbi@lists.infradead.org; Fri, 03 May 2024 13:54:44 +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=kJsi3 qbQXtP3OSL+1SraZxgDrshMJWl2mKsUgfAuFTc=; b=U+2uKKwm8gS1gmOIu8Fuk 3dW9GyraTBukDU0fwxiMI9WC550tjlhd0T+ODAmGAzwO9s9p5wa5xybWd03BZT8a PWcs+cJFIzahj5pTVi8vJJTi7wJsD13slhKRc1fK7pJsEWsJIZIdxg6S4QH0+yGg cWLjkeIA4aKeZgUhqA3b/Q= Received: from T490.lan (unknown [36.153.54.93]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL3Fl7DRmyPi6Bg--.47168S5; Fri, 03 May 2024 21:53:45 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v3 3/6] lib: sbi: fix DBTR_SHMEM_MAKE_PHYS for RV64 Date: Fri, 3 May 2024 21:53:35 +0800 Message-ID: <20240503135340.310030-4-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503135340.310030-1-wxjstz@126.com> References: <20240503135340.310030-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDnL3Fl7DRmyPi6Bg--.47168S5 X-Coremail-Antispam: 1Uf129KBjvdXoW7XrWUAF4rZFWkCF43JF4fZrb_yoW3Xrb_G3 48Ar1kurZ8ua92gw1aqr42qr4S9FsY9rsrZ3s3AFWDJ3y3tF4Yk345XFWqgan8Jr429F17 Z3W2gr13Gr1YgjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKWrWUUUUUU== X-Originating-IP: [36.153.54.93] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdR-TOmSdL7NZAQAFs7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_065443_207692_C737D4F8 X-CRM114-Status: UNSURE ( 7.72 ) 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 3cc1ef8..94fd049 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_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.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 --- 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 3cc1ef8..94fd049 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 Fri May 3 13:53:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1931043 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=lcP85Nw7; 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=V1a7OqWi; 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 4VWC4b5WZhz1ybC for ; Fri, 3 May 2024 23:55:43 +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=x+ygSCIXZ89OH+r2UdY2j8u5JPtH74zTLdRnlJm2mEM=; b=lcP85Nw7y3XYe+ G7v4AJ5/7Q9I9IAY23jbG3/kGvdAjf7FNKURPCaRM4zOL/fS/Rte0O8c+tw1XZcUlP/LdIeDllz8o 05S63Ky2UqMwo3NXFCYaGKHtH95Re2XImytokfG7J26doSCgjiJCvEj0oi5c0FsKY32ibnWCxsyVR wCP0bbg3nPwyqKAlpbV6mfpvxp/bLCY+h+yvGAWvqJdYORQ9S1jNg5VvHWs2UaXHvMj1p3a1D1VcX ojPHDI0j3LynzJXmjGhDb3upvAe9Ufse0RFsyDIgYoGWgyLv5nwCoABNPQnMD5QZlulIgsl3SyYX6 aLhmt+to88wwlhFrsK8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tNx-0000000GkOn-3d3W; Fri, 03 May 2024 13:55:37 +0000 Received: from m16.mail.126.com ([117.135.210.9]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tNt-0000000GkLG-0nqa for opensbi@lists.infradead.org; Fri, 03 May 2024 13:55:35 +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=LQBZs RVD5CD+tX7YrKmrpyf2GjbW/1lK29VD+hs+uHc=; b=V1a7OqWiG2/CBJEf/tuOG UkvKvl6HZedUx6Bm/pDer/EWQfCxftLrl8xfl7Tv0DseCJse5MFn0DZWDnmvLqee dAKUcbDRuuE7TI0zK6KFU0Hq8wTsFXdfo2y57/7WPps31XfsUF3xrPXPo5A4zYkK am6eI3uqJebCCb2qGC2i3o= Received: from T490.lan (unknown [36.153.54.93]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL3Fl7DRmyPi6Bg--.47168S6; Fri, 03 May 2024 21:53:45 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v3 4/6] lib: sbi: Fixed memory permission check in sbi_dbtr_setup_shmem Date: Fri, 3 May 2024 21:53:36 +0800 Message-ID: <20240503135340.310030-5-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503135340.310030-1-wxjstz@126.com> References: <20240503135340.310030-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDnL3Fl7DRmyPi6Bg--.47168S6 X-Coremail-Antispam: 1Uf129KBjvJXoWrKFyxCry3ZF1DuFWrGFW8Xrb_yoW8Jryfpr 4kWFyxtrW0qryIyasrK3Z5Za4jkw40ya1jga9FkFnYya1kZw18Cr4agw1q9Fy3AFykJw17 C3W8CF47ZF43XF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziLSdDUUUUU= X-Originating-IP: [36.153.54.93] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdArTOmSdL5OEgAAAsW X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_065534_017897_935EF606 X-CRM114-Status: UNSURE ( 7.77 ) 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 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(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.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 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 94fd049..a95f087 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; From patchwork Fri May 3 13:53: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: 1931039 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=0kKCJOXb; 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=V3DLSx6y; 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 4VWC3h6m9cz1ydX for ; Fri, 3 May 2024 23:54:56 +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=7xqn18Gs/Bac3iOMY4m1FLbmcsMdw0v/dOWIs3wp3mI=; b=0kKCJOXb3QKIiX nWI/I5KWN/tIMcFclreIFLQngBrclZsC2jbBPSPmFgfZOlzFaGiChwi56Vco3Tgxd3A7OUf+BJYL5 SAgF7rhr7CrnaIoqpHZnY+pqBx5pgEZ7MNkELXwEqkDPpkp2U8V4gPgPZBDdGWg3Mkm+xBirQmJa2 KaLPVF1jxK51SRRZVaKHp2QRguBlWyLIuijO9U0TwtbUtDfD/bl9RyRVztmTtVI/7Fcnb270SzlxE jB/qWwnHfjhSHiJps2FOTmnY3qoigVJ5CvjjAmwnpwDSVvAHiweDUPrDAJpL2ibZ57ZbxIG+pnSMW WL4ENeL8hPT+knQ93M8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tNC-0000000Gk5M-2Ss4; Fri, 03 May 2024 13:54:50 +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 1s2tN8-0000000Gk2f-2vsh for opensbi@lists.infradead.org; Fri, 03 May 2024 13:54:48 +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=GYbO2 HZT+/YWuOyBHIEV9xgWsRhnayCMUNeDTQN8wf0=; b=V3DLSx6yO/VS/ZuGFwYxf zHAvXgBDxX+fEwWZbBCF+KZ/tEIEM1Qv36YPhxvZLVYP3kxyGjurV8FcEtbZy6jR NkKGk1iz53TT9+jL5ZKBiMr1pbWb2wjNYCstSFdbvgHwo1eVy6vVyaEsiS1ZfWUj I3bFBZPpHzGMIZCuqfvqmU= Received: from T490.lan (unknown [36.153.54.93]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL3Fl7DRmyPi6Bg--.47168S7; Fri, 03 May 2024 21:53:46 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v3 5/6] lib: sbi: fix return type of sbi_dbtr_shmem_disabled Date: Fri, 3 May 2024 21:53:37 +0800 Message-ID: <20240503135340.310030-6-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503135340.310030-1-wxjstz@126.com> References: <20240503135340.310030-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDnL3Fl7DRmyPi6Bg--.47168S7 X-Coremail-Antispam: 1Uf129KBjvdXoW7XF45ZF1UAr13uF4ktF4kXrb_yoWfKrg_Gw 4xuw18Kan8ZrsruF1qkr4SvrWvgw42vr1qqwn2qa9Fyry3tr45ZFWUJwnIqFWUXr4UtF12 krnruFyrCFya9jkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRNuWl3UUUUU== X-Originating-IP: [36.153.54.93] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdAvTOmSdL5OEgQADsV X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_065447_160975_955319F3 X-CRM114-Status: UNSURE ( 7.93 ) 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: Modify the return value of the sbi_dbtr_shmem_disabled function to bool to make the semantics clearer. Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 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_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.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 Modify the return value of the sbi_dbtr_shmem_disabled function to bool to make the semantics clearer. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- lib/sbi/sbi_dbtr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index a95f087..6950378 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -55,18 +55,18 @@ static unsigned long hart_state_ptr_offset; #error "Undefined XLEN" #endif -static inline int sbi_dbtr_shmem_disabled(void) +static inline bool sbi_dbtr_shmem_disabled(void) { struct sbi_dbtr_hart_triggers_state *hs = NULL; hs = dbtr_get_hart_state_ptr(sbi_scratch_thishart_ptr()); if (!hs) - return 1; + return true; return (hs->shmem.phys_lo == SBI_DBTR_SHMEM_INVALID_ADDR && hs->shmem.phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR - ? 1 : 0); + ? true : false); } static inline void sbi_dbtr_disable_shmem(void) From patchwork Fri May 3 13:53: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: 1931040 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=ujx4epYQ; 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=T/e/WMNr; 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 4VWC3j22cPz20fb for ; Fri, 3 May 2024 23:54:57 +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=71oEI57xzYxnw53vK646IUFunlURIKpcjQFdjnpmMao=; b=ujx4epYQnKMMVe NI9fv7b0BOlGNvmKs21P+kx004oLT+MzsE8w+68ca9Z6tFriWePNpSkoqjZsKdwufK5HTmsZyt2Yw 3iErqATH4hBdlF2885pz0bFJUPI0osuj8IvDbgBAJm/HtWfVmXa2zIuWWeg8Q3rEJXMZG43bDRlQh 67KcgfwAhy92/z8oqHBOa52jLibNNfl1/+HQvwdSb2yG1uvPIKqDIM0PjHPKpWptYhsh3dXE8reKZ EXPC/fXGKxO6ygVQNZdG38txznXOUlSgQgYIYnZCoWUsLswA3UtGnaVBASwiBdMuSXFArAFjtORaA wtGevqR3xzW8aoyxknvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tND-0000000Gk5k-0sOU; Fri, 03 May 2024 13:54:51 +0000 Received: from m16.mail.126.com ([220.197.31.9]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2tN9-0000000Gk3A-3C1y for opensbi@lists.infradead.org; Fri, 03 May 2024 13:54:49 +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=2ePLY B3vZavRNAgpSKSPN5+hT5j3kD8ljoM37+VGAGA=; b=T/e/WMNrO48kTU0sLuyw6 Hjj9YMMzoHDA3sQTJ6kzqMkb5V5v3ifc6SHIiBHJJyXTXlLXjH2Ufo9qYdNzzGB0 qaZ2NgMmxA3RYYEAUY5sV3OODmRAGnP6UKwW6+n3oihI8w82xPn+EkaHp42BP9a0 yPN53Gx69CQjDvgVRZ0HHQ= Received: from T490.lan (unknown [36.153.54.93]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL3Fl7DRmyPi6Bg--.47168S8; Fri, 03 May 2024 21:53:47 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , hchauhan@ventanamicro.com, anup@brainfault.org Subject: [PATCH v3 6/6] lib: sbi: simplify inline function in sbi_dtbr.c Date: Fri, 3 May 2024 21:53:38 +0800 Message-ID: <20240503135340.310030-7-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503135340.310030-1-wxjstz@126.com> References: <20240503135340.310030-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDnL3Fl7DRmyPi6Bg--.47168S8 X-Coremail-Antispam: 1Uf129KBjvJXoW3XryktF4xXFyxWF1xGr43GFg_yoW7XFyDpF Z3uFWxtrsFqry0yFW7J3W8W345Kr4xJa45K3s8CF95Aas8Zr1rJr13tw1qvFyfJry8Wa42 yw40yFW7uF43tF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziqXHiUUUUU= X-Originating-IP: [36.153.54.93] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdAvTOmSdL5OEgQABsX X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_065448_243226_5BE257C8 X-CRM114-Status: GOOD ( 11.75 ) 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 inline function can simplify the code by setting some call restrictions. This ensures logical smoothness Signed-off-by: Xiang W --- lib/sbi/sbi_dbtr.c | 78 +++++++++++++++++++ 1 file changed, 32 insertions(+), 46 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.9 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_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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.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 inline function can simplify the code by setting some call restrictions. This ensures logical smoothness Signed-off-by: Xiang W Reviewed-by: Anup Patel --- lib/sbi/sbi_dbtr.c | 78 +++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 6950378..9c92af6 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -55,49 +55,29 @@ static unsigned long hart_state_ptr_offset; #error "Undefined XLEN" #endif -static inline bool sbi_dbtr_shmem_disabled(void) +/* must call with hs != NULL */ +static inline bool sbi_dbtr_shmem_disabled( + struct sbi_dbtr_hart_triggers_state *hs) { - struct sbi_dbtr_hart_triggers_state *hs = NULL; - - hs = dbtr_get_hart_state_ptr(sbi_scratch_thishart_ptr()); - - if (!hs) - return true; - return (hs->shmem.phys_lo == SBI_DBTR_SHMEM_INVALID_ADDR && hs->shmem.phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR ? true : false); } -static inline void sbi_dbtr_disable_shmem(void) +/* must call with hs != NULL */ +static inline void sbi_dbtr_disable_shmem( + struct sbi_dbtr_hart_triggers_state *hs) { - struct sbi_dbtr_hart_triggers_state *hs = NULL; - - hs = dbtr_get_hart_state_ptr(sbi_scratch_thishart_ptr()); - - if (!hs) - return; - hs->shmem.phys_lo = SBI_DBTR_SHMEM_INVALID_ADDR; hs->shmem.phys_hi = SBI_DBTR_SHMEM_INVALID_ADDR; } -static inline void *hart_shmem_base(void) +/* must call with hs which is not disabled */ +static inline void *hart_shmem_base( + struct sbi_dbtr_hart_triggers_state *hs) { - 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; - - phys_hi = hs->shmem.phys_hi; - phys_lo = hs->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)); + return ((void *)(unsigned long)DBTR_SHMEM_MAKE_PHYS( + hs->shmem.phys_hi, hs->shmem.phys_lo)); } static void sbi_trigger_init(struct sbi_dbtr_trigger *trig, @@ -186,7 +166,7 @@ int sbi_dbtr_init(struct sbi_scratch *scratch, bool coldboot) } /* disable the shared memory */ - sbi_dbtr_disable_shmem(); + sbi_dbtr_disable_shmem(hart_state); /* Skip probing triggers if already probed */ if (hart_state->probed) @@ -278,15 +258,19 @@ int sbi_dbtr_setup_shmem(const struct sbi_domain *dom, unsigned long smode, return SBI_ERR_DENIED; } + hart_state = dbtr_thishart_state_ptr(); + if (!hart_state) + return SBI_ERR_FAILED; + /* call is to disable shared memory */ if (shmem_phys_lo == SBI_DBTR_SHMEM_INVALID_ADDR && shmem_phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR) { - sbi_dbtr_disable_shmem(); + sbi_dbtr_disable_shmem(hart_state); return SBI_SUCCESS; } /* the shared memory must be disabled on this hart */ - if (!sbi_dbtr_shmem_disabled()) + if (!sbi_dbtr_shmem_disabled(hart_state)) return SBI_ERR_ALREADY_AVAILABLE; /* lower physical address must be XLEN/8 bytes aligned */ @@ -298,10 +282,6 @@ int sbi_dbtr_setup_shmem(const struct sbi_domain *dom, unsigned long 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; - hart_state->shmem.phys_lo = shmem_phys_lo; hart_state->shmem.phys_hi = shmem_phys_hi; @@ -531,10 +511,10 @@ 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()) + if (sbi_dbtr_shmem_disabled(hs)) return SBI_ERR_NO_SHMEM; - shmem_base = hart_shmem_base(); + shmem_base = hart_shmem_base(hs); for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) { sbi_hart_map_saddr((unsigned long)entry, sizeof(*entry)); @@ -561,11 +541,14 @@ 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()) + hs = dbtr_thishart_state_ptr(); + if (!hs) + return SBI_ERR_FAILED; + + if (sbi_dbtr_shmem_disabled(hs)) return SBI_ERR_NO_SHMEM; - shmem_base = hart_shmem_base(); - hs = dbtr_thishart_state_ptr(); + shmem_base = hart_shmem_base(hs); /* Check requested triggers configuration */ for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) { @@ -673,11 +656,14 @@ 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()) + hs = dbtr_thishart_state_ptr(); + if (!hs) + return SBI_ERR_FAILED; + + if (sbi_dbtr_shmem_disabled(hs)) return SBI_ERR_NO_SHMEM; - shmem_base = hart_shmem_base(); - hs = dbtr_thishart_state_ptr(); + shmem_base = hart_shmem_base(hs); for_each_set_bit_from(idx, &trig_mask, hs->total_trigs) { trig = INDEX_TO_TRIGGER(idx);