From nobody Thu Dec 18 08:28:56 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7966185E5D for ; Thu, 25 Jul 2024 09:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721898662; cv=none; b=I+6qvwWNf8Hr3xs4oUr2VmNrpXXUw35qmAvjnc9I2/oLUL0v2ISOSdx0CFqDgol//VDJ3kZgs1+brwJ9jNM8iSOT7mqkXmC5Oh3+Fi1AUx78kxwCnYXxsIYnSSytcPlZ0hBuULz/NvNzRT9rZA3Me1xGONfOa/h1nOFB+TqXb7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721898662; c=relaxed/simple; bh=oJT8EbXNAOu9BTfU5rIcxECDldIh4IVQ12mqGsQToG4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Nxe0M7gl8DhubRTrwFK0r1T/xc/YQGBECwXKSrsaSSMtp8YZ2+NDgMiaFXXP9qmU4yK/MQ/04Mdnzwjegh7jg1g3/gAnCSc4OgS3zXLpHRbTtoIpU0CJpztOKOGOoWcxZbNqREif/1f+87UtxG6kfw58g7d224x0h7U1Gnybbvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 775781007; Thu, 25 Jul 2024 02:11:25 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.40.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E9C233F5A1; Thu, 25 Jul 2024 02:10:57 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Ryan Roberts , linux-kernel@vger.kernel.org Subject: [PATCH] arm64/mm: Avoid direct referencing page table enties in map_range() Date: Thu, 25 Jul 2024 14:40:52 +0530 Message-Id: <20240725091052.314750-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Like else where in arm64 platform, use WRITE_ONCE() in map_range() while creating page table entries. This avoids referencing page table entries directly. Cc: Catalin Marinas Cc: Will Deacon Cc: Ryan Roberts Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/kernel/pi/map_range.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/pi/map_range.c b/arch/arm64/kernel/pi/map_ra= nge.c index 5410b2cac590..b93b70cdfb62 100644 --- a/arch/arm64/kernel/pi/map_range.c +++ b/arch/arm64/kernel/pi/map_range.c @@ -56,8 +56,8 @@ void __init map_range(u64 *pte, u64 start, u64 end, u64 p= a, pgprot_t prot, * table mapping if necessary and recurse. */ if (pte_none(*tbl)) { - *tbl =3D __pte(__phys_to_pte_val(*pte) | - PMD_TYPE_TABLE | PMD_TABLE_UXN); + WRITE_ONCE(*tbl, __pte(__phys_to_pte_val(*pte) | + PMD_TYPE_TABLE | PMD_TABLE_UXN)); *pte +=3D PTRS_PER_PTE * sizeof(pte_t); } map_range(pte, start, next, pa, prot, level + 1, @@ -79,7 +79,7 @@ void __init map_range(u64 *pte, u64 start, u64 end, u64 p= a, pgprot_t prot, protval &=3D ~PTE_CONT; =20 /* Put down a block or page mapping */ - *tbl =3D __pte(__phys_to_pte_val(pa) | protval); + WRITE_ONCE(*tbl, __pte(__phys_to_pte_val(pa) | protval)); } pa +=3D next - start; start =3D next; --=20 2.30.2