Skip to contentSkip to conversation

FAILED: patch "[PATCH] arm64: Restrict pagetable teardown to avoid false warning" failed to apply to 5.15-stable tree

PATCH In review [email protected] 3 participants 3 messages Jun 23, 2025 – Jul 2, 2025

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 650768c512faba8070bf4cfbb28c95eb5cd203f3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025062304-prune-getup-2943@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 650768c512faba8070bf4cfbb28c95eb5cd203f3 Mon Sep 17 00:00:00 2001
From: Dev Jain <[email protected]>
Date: Tue, 27 May 2025 13:56:33 +0530
Subject: [PATCH] arm64: Restrict pagetable teardown to avoid false warning

Commit 9c006972c3fe ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") removes the pxd_present() checks because the caller checks pxd_present(). But, in case of vmap_try_huge_pud(), the caller only checks pud_present(); pud_free_pmd_page() recurses on each pmd through pmd_free_pte_page(), wherein the pmd may be none. Thus it is possible to hit a warning in the latter, since pmd_none => !pmd_table(). Thus, add a pmd_present() check in pud_free_pmd_page().

This problem was found by code inspection.

arch/arm64/mm/mmu.c +2 -1
index 8fcf59ba39db..00ab1d648db6 100644
@@ -1305,7 +1305,8 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
 	next = addr;
 	end = addr + PUD_SIZE;
 	do {
-		pmd_free_pte_page(pmdp, next);
+		if (pmd_present(pmdp_get(pmdp)))
+			pmd_free_pte_page(pmdp, next);
 	} while (pmdp++, next += PMD_SIZE, next != end);
 
 	pud_clear(pudp);
#1 lore raw

PATCH 1/1 arm64: Restrict pagetable teardown to avoid false warning

[Commit 650768c512faba8070bf4cfbb28c95eb5cd203f3 upstream]

Commit 9c006972c3fe ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") removes the pxd_present() checks because the caller checks pxd_present(). But, in case of vmap_try_huge_pud(), the caller only checks pud_present(); pud_free_pmd_page() recurses on each pmd through pmd_free_pte_page(), wherein the pmd may be none. Thus it is possible to hit a warning in the latter, since pmd_none => !pmd_table(). Thus, add a pmd_present() check in pud_free_pmd_page().

This problem was found by code inspection.

Fixes 9c006972c3fe ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()")
(cherry picked from commit 650768c512faba8070bf4cfbb28c95eb5cd203f3)

(use READ_ONCE since pmdp_get() is not defined)

---
 arch/arm64/mm/mmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/mm/mmu.c +2 -1
index fc86e7465df4..e3e4defdea42 100644
@@ -1466,7 +1466,8 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
 	next = addr;
 	end = addr + PUD_SIZE;
 	do {
-		pmd_free_pte_page(pmdp, next);
+		if (pmd_present(READ_ONCE(*pmdp)))
+			pmd_free_pte_page(pmdp, next);
 	} while (pmdp++, next += PMD_SIZE, next != end);
 
 	pud_clear(pudp);
Signature · 1 line
2.30.2
maintainer Reviewed-by Ryan Roberts on v1 1/1
#2 lore raw

Re: [PATCH 5.15.y] arm64: Restrict pagetable teardown to avoid false warning

[ Sasha's backport helper bot ]

Hi,

✅ All tests passed successfully. No issues detected. No action required from the submitter.

The upstream commit SHA1 provided is correct: 650768c512faba8070bf4cfbb28c95eb5cd203f3

Status in newer kernel trees:
6.15.y | Present (different SHA1: 1d03bbcb2b98) 6.12.y | Present (different SHA1: 47f34289d100) 6.6.y | Present (different SHA1: 6562806f3200) 6.1.y | Not found

Note: The patch differs from the upstream commit:
---
1: 650768c512fab ! 1: fe24ec1815e3d arm64: Restrict pagetable teardown to avoid false warning
@@ Metadata
## Commit message ##
arm64: Restrict pagetable teardown to avoid false warning

+ [Commit 650768c512faba8070bf4cfbb28c95eb5cd203f3 upstream]
+
Commit 9c006972c3fe ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") removes the pxd_present() checks because the caller checks pxd_present(). But, in case of vmap_try_huge_pud(), the
@@ Commit message

+ (cherry picked from commit 650768c512faba8070bf4cfbb28c95eb5cd203f3)
+ (use READ_ONCE since pmdp_get() is not defined)

## arch/arm64/mm/mmu.c ##
@@ arch/arm64/mm/mmu.c: int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
@@ arch/arm64/mm/mmu.c: int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
end = addr + PUD_SIZE;
do {
- pmd_free_pte_page(pmdp, next);
-+ if (pmd_present(pmdp_get(pmdp)))
++ if (pmd_present(READ_ONCE(*pmdp)))
+ pmd_free_pte_page(pmdp, next);
} while (pmdp++, next += PMD_SIZE, next != end);

---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-5.15.y       |  Success    |  Success   |