From patchwork Mon Sep 2 10:21:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Kondratiev X-Patchwork-Id: 1979592 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=LyPQBo3A; dkim=fail reason="key not found in DNS" header.d=mobileye.com header.i=@mobileye.com header.a=rsa-sha256 header.s=MoEyIP header.b=ixlfYMtu; 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 4Wy4j16Jflz1yXY for ; Mon, 2 Sep 2024 20:28:19 +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: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:In-Reply-To:References: List-Owner; bh=iN6crtFOfEpL1YNrUBId7fJ4wiZOW4qMeIRirIHIkA8=; b=LyPQBo3AlMgBh5 rdR+wGUJ+gVgbt8zrA4zz1Xvz3ctNyX/Z0LTeWBriwaYfAhKyGCqoh74YklyZd1bBE2LFn2xYqqs1 QTLQ/rKxTtRvAA3T8K+cG3WEmp36CukUf5Cjr8wVtTg2diY9CXoUyoAyDlXL4uklPGQfVlbkUu5Pw rEFltAOLYJQPowYCfCWvf+mwbcXL10s5DqC4O12z51jYYyP8QajR+6WiQ/RRDiQkev1s8AEXZsQ5I WJ0hzvEWn8LaP3r79jyOtlMjUvfkrTy7CVxu+5lshTGGS1YJbgCj9XcG9R9fCrGuzRKiHMQy/CHG5 UJXrE5TYFGU3URA8iNcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl4I4-0000000DuPe-17BL; Mon, 02 Sep 2024 10:28:08 +0000 Received: from esa3.hc555-34.eu.iphmx.com ([207.54.77.50]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl4C5-0000000DtDF-3m5V for opensbi@lists.infradead.org; Mon, 02 Sep 2024 10:22:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mobileye.com; i=@mobileye.com; q=dns/txt; s=MoEyIP; t=1725272517; x=1756808517; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UQ0m84PKNihCXv1F9BqwxsPpEti/0RZi79OBm7Cg51M=; b=ixlfYMtu8NbpWEyomxXTB9XUksHBbJGvK5FM4/A1kwJ60Vcof4hAE/fu 33/XTMkh9pwDhdxr5bwjJXAUgCGVj/Wv0/DOBXufhCZEbdtR3jmrbakZG atR6KC5Cty1kacGM/E6wreCYc0K9dXGKRqwZ7lzuhFcdxwEKTE67zrFvj upGwtoTS37oZTRfqycAnEtqzTJGC+zSMwLHbXY5hQTRpCDZXTUmu890Fp 7mLoipMB/0ZTTb7U0cG4IaREjd71lhhb1+D7Y9GBDFr5qIydlQti1XjlP P9G54jfaYYH1dbea7JY41NK2RsTsVnFNE0koeGkhaS/d+nnIo5F0xaRHC Q==; X-CSE-ConnectionGUID: QshD45qsQ4eSA+eonS8myA== X-CSE-MsgGUID: SS46PjfmS4qqvOSt1PVWEw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from unknown (HELO ces02_data.me-corp.lan) ([146.255.191.134]) by esa3.hc555-34.eu.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2024 13:21:51 +0300 X-CSE-ConnectionGUID: Sg2Wwo+dTNO8+1o21U9A0Q== X-CSE-MsgGUID: aEfbCWU3TJuIgJ56/VW7LA== Received: from unknown (HELO epgd022.me-corp.lan) ([10.154.54.6]) by ces02_data.me-corp.lan with SMTP; 02 Sep 2024 13:21:50 +0300 Received: by epgd022.me-corp.lan (sSMTP sendmail emulation); Mon, 02 Sep 2024 13:21:50 +0300 From: Vladimir Kondratiev To: opensbi@lists.infradead.org Cc: Vladimir Kondratiev Subject: [PATCH] lib: sbi: fix number of PMP entries detection Date: Mon, 2 Sep 2024 13:21:10 +0300 Message-Id: <20240902102110.1311636-1-vladimir.kondratiev@mobileye.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_032158_434191_4BEAD7FB X-CRM114-Status: GOOD ( 12.29 ) X-Spam-Score: -4.0 (----) 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: CSR_PMPADDRn lower bits may read all-0 or all-1, depending on the configuration. For TOR it is all-0, for NAPOT - all-1. Thus if PMP entry was pre-configured as NAPOT, original code would stop scanning because value read back not equal to the written one. Content analysis details: (-4.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [207.54.77.50 listed in list.dnswl.org] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [207.54.77.50 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [207.54.77.50 listed in sa-accredit.habeas.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [207.54.77.50 listed in bl.score.senderscore.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org CSR_PMPADDRn lower bits may read all-0 or all-1, depending on the configuration. For TOR it is all-0, for NAPOT - all-1. Thus if PMP entry was pre-configured as NAPOT, original code would stop scanning because value read back not equal to the written one. Mask lower bits before comparison to fix this Signed-off-by: Vladimir Kondratiev --- lib/sbi/sbi_hart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index cc364fac2cc8..61cddc2b1d0f 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -817,7 +817,7 @@ static int hart_detect_features(struct sbi_scratch *scratch) } else { \ csr_write_allowed(__csr, &trap, __wrval); \ if (!trap.cause) { \ - if (csr_swap(__csr, oldval) == __wrval) \ + if ((csr_swap(__csr, oldval) & __wrval) == __wrval) \ (hfeatures->__field)++; \ else \ goto __skip; \