From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19AB93DB335 for ; Fri, 26 Jun 2026 13:03:30 +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=1782479012; cv=none; b=spU77AOHzcGcns/GB+Tk/PIr/dmH6ARy/PgW4qq7zHjwG33s1P6YAEzL+zj0RKVv5lSFXOGQBHpL8uPOOwlz2PFIRSWZVXv96Mo3VwmGuW6+xPKQLxWTiZutvfrFOEb16iNcJLGRoGQNx7K3SFlPvV0VEM7N1/9TLltA2NVn9zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782479012; c=relaxed/simple; bh=mLrqXzI6fndhpQWKl/d2+M3KKUFe6veWV+hQFDs0DeY=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=ThXnlM4F2J57WOGsXyYpj/unRwQfSpOJCjOcDl0GnlnV+/t6Lfj0W/7LCH98p1DnrsTSSpi6nghqcn6XENfmKAdklmvmPp6XPl2qmZaqaYflM8FfcRwTHZgZ4WBzFe/JjGQOm6bhCUIcWpxpfTvOIhFwEELxs247flhbM9PoEh4= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=fWVkimfK; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="fWVkimfK" 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 976401A9A; Fri, 26 Jun 2026 06:03:25 -0700 (PDT) Received: from [10.164.19.14] (unknown [10.164.19.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 061343F632; Fri, 26 Jun 2026 06:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1782479010; bh=mLrqXzI6fndhpQWKl/d2+M3KKUFe6veWV+hQFDs0DeY=; h=Date:Subject:To:References:From:In-Reply-To:From; b=fWVkimfK0mRUOX//wOlw1rDvquS+agvpJcAkS7YH0I9Iij80JRXnFNzWSSx73410H /LCvDunajkaQu7zfR9Ub8o+teDJWQm9KdOdC6CrtlF4zGNDAfgV0XM96pUYyvZf81x BJYdWAs0Al+kc/xmBkoBGspCIyTHPR5fYUuw0fIk= Message-ID: Date: Fri, 26 Jun 2026 18:33:24 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64: mm: refresh stale pmd snapshot after split_contpmd() To: lirongqing , Catalin Marinas , Will Deacon , Ryan Roberts , Ard Biesheuvel , David Hildenbrand , Anshuman Khandual , Kevin Brodsky , Yang Shi , Chaitanya S Prakash , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260625113953.2332-1-lirongqing@baidu.com> Content-Language: en-US From: Dev Jain In-Reply-To: <20260625113953.2332-1-lirongqing@baidu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 25/06/26 5:09 pm, lirongqing wrote: > 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. Since the block was CONTPMD, it means the pgprot was uniform on that block, so after splitting, it should be safe to derive the pgprot from individual pmd's right? > > 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); > > /*