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)); }