From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from outbound.baidu.com (mx16.baidu.com [111.202.115.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E00C13DCDB3 for ; Thu, 25 Jun 2026 11:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.202.115.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782387749; cv=none; b=pVyFzkMnpSFODAhvuH1cEPcdR2WReYPnQWO4ROEI8+Fe3kJks9PmPmfTVCehsMmORwvbc4UQEi7NIoPBU7GiZetIfhOx/qYBRAO2/5DaY/wfRv1sNLehSoPtmBf2iAFJFh1cH2w+JhUsUfkpA1otQcPl/ueN57lp4S+TcSWGGz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782387749; c=relaxed/simple; bh=54gFFKk6/0mBPOmH75hC802rfzzMTzurHiPatxfbzIg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eNSbYhrF+SDbUVH4GD3jSoA1eJcG5XTRFWcDKw3NnITNVOOXoPS65fK6QRrbkvPX1e6ElIQ834IbVFV4zQEWo151eoos6Zk2mKKEB8Us801it2oHeeqKX31hR+m33YwyLEaes3oxeV0XdUwFfI/yy0rzAxYrJiwC3PzaAKhGndA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; dkim=pass (2048-bit key) header.d=baidu.com header.i=@baidu.com header.b=WmzdD1ii; arc=none smtp.client-ip=111.202.115.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baidu.com header.i=@baidu.com header.b="WmzdD1ii" X-MD-Sfrom: lirongqing@baidu.com X-MD-SrcIP: 172.31.50.47 From: lirongqing To: Catalin Marinas , Will Deacon , Ryan Roberts , Ard Biesheuvel , David Hildenbrand , Anshuman Khandual , Kevin Brodsky , Yang Shi , Chaitanya S Prakash , , CC: Li RongQing Subject: [PATCH] arm64: mm: refresh stale pmd snapshot after split_contpmd() Date: Thu, 25 Jun 2026 19:39:53 +0800 Message-ID: <20260625113953.2332-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: bjkjy-exc11.internal.baidu.com (172.31.51.11) To bjkjy-exc3.internal.baidu.com (172.31.50.47) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baidu.com; s=selector1; t=1782387605; bh=N8+uh5P1UEnewbpnSH35VnyhMvb2TQ0IOnKec09Ie7w=; h=From:To:CC:Subject:Date:Message-ID:Content-Type; b=WmzdD1iimOPkGUOynCYEM/gMwMxacA49PzeKHk8Xo2m6oJGnaHLMfVMjxHvcJ3MWE FXQB3OkbDCWGwajnrfNiyrTuokRuyZeewcAuHUw3s72VJXlWY6s7Kup8WXJ27cq0ou AsmH3lZueUpsHxqfYoMya9zjRNjPDMTAROqHnjJ8kOMKKbt+HfkfgNOWigyOLQAwKQ KvUMVdpNbLx/ofyMh4mO35NRDWjNztUumSYW2sfAvKQZ5w6KOu2knPFs6oaJL/aYZy GZI5h7SbxGazUiXVhNihdqHaCY3JDZ9VU4iz+S8N9kYjhW7uvSzdM239NAhCTTrUQD HKKedX6yThFiA== From: Li RongQing split_contpmd() modifies the pmd entries in-place by clearing the CONT bit, but the local 'pmd' variable still holds the old snapshot with CONT set. The subsequent split_pmd() call uses this stale value to derive the pgprot for the new PTE entries via pmd_pgprot(), causing the resulting PTEs to be populated with incorrect protection bits. Fix this by re-reading the pmd from memory after split_contpmd() returns in both call sites: split_kernel_leaf_mapping_locked() and split_to_ptes_pmd_entry(). Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full") Signed-off-by: Li RongQing --- arch/arm64/mm/mmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 12e862c..e510336 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -746,8 +746,10 @@ static int split_kernel_leaf_mapping_locked(unsigned long addr) if (!pmd_present(pmd)) goto out; if (pmd_leaf(pmd)) { - if (pmd_cont(pmd)) + if (pmd_cont(pmd)) { split_contpmd(pmdp); + pmd = pmdp_get(pmdp); + } /* * PMD: If addr is PMD aligned then addr already describes a * leaf boundary. Otherwise, split to contpte. @@ -891,8 +893,10 @@ static int split_to_ptes_pmd_entry(pmd_t *pmdp, unsigned long addr, int ret = 0; if (pmd_leaf(pmd)) { - if (pmd_cont(pmd)) + if (pmd_cont(pmd)) { split_contpmd(pmdp); + pmd = pmdp_get(pmdp); + } ret = split_pmd(pmdp, pmd, gfp, false); /* -- 2.9.4