From patchwork Wed Aug 7 15:16:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1970110 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=2UlyWvyM; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Fg5NgsoJ; 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=kvm-riscv-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 4WfDKv4TdGz1yfM for ; Thu, 8 Aug 2024 01:16:50 +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=/CWUBbwpm7+rQJW/OQ7Y7jRVaCldoVHmN5DvvEOvYss=; b=2UlyWvyMKvIc5Y RyqdApR4k98N+OEV/W8vfjj2iLEa78so9yS3EJc2PyKwKaJsPqAGhytaUgqCl5oW3R0QqFzgqos0l Ut+ppGKNaTugtfKX0RwM/tzAUOK4lSe+OxWZH3idev5Yg78gtchn93/qAzeCUHY1DTOuHMIGKQeN+ DInld2CFLSqSE6BY1HKnpHwkKrscRwOSnfHIaDQxvjBW/lQDPZW7VqZ4uh1CyhtYJmIbmFM4KCfN0 VSTcGr2O//kH6ZFZ5eW3B/IlM15rnrNhVj96oP/GBFarmCn34C5Ex6OJkU7BkIgbwje6iCk6UdXs+ iLSCdSu+aY07sJ6mtK7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbiPA-00000005TSF-13t0; Wed, 07 Aug 2024 15:16:48 +0000 Received: from out-174.mta1.migadu.com ([95.215.58.174]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbiP8-00000005TRR-0m4E for kvm-riscv@lists.infradead.org; Wed, 07 Aug 2024 15:16:47 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723043803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0JnWydVRlcUj9MsWlBjRPKAbHtiO4c0GMGL7PGlxT7Y=; b=Fg5NgsoJGBQLwal8r4tS97dNmfiatXZJdjpoo1nO5VjIz7WBTp5KVLkLOD4Jx2Wi7BKaV7 uwFAFvZsI6c869zXzNpZWMkqSLvy7p8ht12cyW0sag+FPBq46gyrdXZ6Dh97MonrJsFEfh 86JpRJ9yCUQ+OdKobsJtZxuwk7SB3zo= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: atishp@rivosinc.com, cade.richard@berkeley.edu, jamestiotio@gmail.com Subject: [kvm-unit-tests PATCH 1/3] riscv: Fix virt_to_phys again Date: Wed, 7 Aug 2024 17:16:31 +0200 Message-ID: <20240807151629.144168-6-andrew.jones@linux.dev> In-Reply-To: <20240807151629.144168-5-andrew.jones@linux.dev> References: <20240807151629.144168-5-andrew.jones@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240807_081646_395276_0FDDFC5D X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.8 (--) 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 last fix was a bit hasty since we didn't double check that virt_to_phys() was the right place for the fix, rather than virt_to_pte_phys(), and of course it was the latter... All architectures add [...] Content analysis details: (-2.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [95.215.58.174 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches 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_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 -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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. [95.215.58.174 listed in sa-accredit.habeas.com] 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. [95.215.58.174 listed in sa-trusted.bondedsender.org] 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. [95.215.58.174 listed in bl.score.senderscore.com] X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The last fix was a bit hasty since we didn't double check that virt_to_phys() was the right place for the fix, rather than virt_to_pte_phys(), and of course it was the latter... All architectures add on the offset in virt_to_pte_phys() and then simply wrap virt_to_pte_phys() with virt_to_phys(), if they implement virt_to_phys() at all. RISCV shouldn't be different. Fixes: e1dd4ea76894 ("riscv: Fix virt_to_phys") Fixes: 23100d972705 ("riscv: Enable vmalloc") Signed-off-by: Andrew Jones --- lib/riscv/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/riscv/mmu.c b/lib/riscv/mmu.c index 165a7034bc69..2c9c4f376ac9 100644 --- a/lib/riscv/mmu.c +++ b/lib/riscv/mmu.c @@ -179,7 +179,7 @@ phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *virt) if (!pte_val(*ptep)) return 0; - return __pa(pteval_to_ptep(pte_val(*ptep))); + return __pa(pteval_to_ptep(pte_val(*ptep))) | offset_in_page(virt); } unsigned long virt_to_phys(volatile void *address) @@ -194,7 +194,7 @@ unsigned long virt_to_phys(volatile void *address) paddr = virt_to_pte_phys(pgtable, (void *)address); assert(sizeof(long) == 8 || !(paddr >> 32)); - return (unsigned long)paddr | offset_in_page(address); + return (unsigned long)paddr; } void *phys_to_virt(unsigned long address)