FAILED: patch "[PATCH] mm: hugetlb: Add huge page size param to" failed to apply to 6.1-stable tree
Subsystems (13)
[email protected]
maintainerThe patch below does not apply to the 6.1-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-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 02410ac72ac3707936c07ede66e94360d0d65319
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025030437-specks-impotency-d026@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 02410ac72ac3707936c07ede66e94360d0d65319 Mon Sep 17 00:00:00 2001
From: Ryan Roberts <[email protected]>
Date: Wed, 26 Feb 2025 12:06:51 +0000
Subject: [PATCH] mm: hugetlb: Add huge page size param to
huge_ptep_get_and_clear()
In order to fix a bug, arm64 needs to be told the size of the huge page for which the huge_pte is being cleared in huge_ptep_get_and_clear(). Provide for this by adding an unsigned long sz parameter to the function. This follows the same pattern as huge_pte_clear() and set_huge_pte_at().
This commit makes the required interface modifications to the core mm as well as all arches that implement this function (arm64, loongarch, mips, parisc, powerpc, riscv, s390, sparc). The actual arm64 bug will be fixed in a separate commit.
arch/arm64/include/asm/hugetlb.h +2 -2
@@ -42,8 +42,8 @@ extern int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty);#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR -extern pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep); +extern pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECTextern void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep);
arch/arm64/mm/hugetlbpage.c +5 -3
@@ -396,8 +396,8 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr,__pte_clear (mm, addr, ptep); } -pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long sz) {int ncontig;size_t pgsize;
@@ -549,6 +549,8 @@ bool __init arch_hugetlb_valid_size(unsigned long size)pte_t huge_ptep_modify_prot_start (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) { +unsigned long psize =huge_page_size (hstate_vma (vma)); +if (alternative_has_cap_unlikely (ARM64_WORKAROUND_2645198 )) {/* * Break-before-make (BBM) is required for all user space mappings
@@ -558,7 +560,7 @@ pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addrif (pte_user_exec (__ptep_get (ptep)))return huge_ptep_clear_flush (vma, addr, ptep); } -return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); +return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, psize); } void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep,
arch/loongarch/include/asm/hugetlb.h +4 -2
@@ -36,7 +36,8 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep, +unsigned long sz) {pte_t clear;pte_t pte =ptep_get (ptep);
@@ -51,8 +52,9 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { pte_t pte; +unsigned long sz =huge_page_size (hstate_vma (vma)); - pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); + pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, sz);flush_tlb_page (vma, addr);return pte; }
arch/mips/include/asm/hugetlb.h +4 -2
@@ -27,7 +27,8 @@ static inline int prepare_hugepage_range(struct file *file,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep, +unsigned long sz) {pte_t clear;pte_t pte = *ptep;
@@ -42,13 +43,14 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { pte_t pte; +unsigned long sz =huge_page_size (hstate_vma (vma));/* * clear the huge pte entry firstly, so that the other smp threads will * not get old pte entry after finishing flush_tlb_page and before * setting new huge pte entry */ - pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); + pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, sz);flush_tlb_page (vma, addr);return pte; }
arch/parisc/include/asm/hugetlb.h +1 -1
@@ -10,7 +10,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARpte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep); +pte_t *ptep,unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
arch/parisc/mm/hugetlbpage.c +1 -1
@@ -126,7 +126,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {pte_t entry;
arch/powerpc/include/asm/hugetlb.h +4 -2
@@ -45,7 +45,8 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep, +unsigned long sz) {return __pte (pte_update (mm, addr, ptep, ~0UL ,0 ,1 )); }
@@ -55,8 +56,9 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { pte_t pte; +unsigned long sz =huge_page_size (hstate_vma (vma)); - pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); + pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, sz);flush_hugetlb_page (vma, addr);return pte; }
arch/riscv/include/asm/hugetlb.h +2 -1
@@ -28,7 +28,8 @@ void set_huge_pte_at(struct mm_struct *mm,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARpte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep); +unsigned long addr,pte_t *ptep, +unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
arch/riscv/mm/hugetlbpage.c +1 -1
@@ -293,7 +293,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {pte_t orig_pte =ptep_get (ptep);int pte_num;
arch/s390/include/asm/hugetlb.h +12 -4
@@ -25,8 +25,16 @@ void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GETpte_t huge_ptep_get (struct mm_struct *mm,unsigned long addr,pte_t *ptep); +pte_t __huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep); +#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR -pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep); +static inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep, +unsigned long sz) +{ +return __huge_ptep_get_and_clear (mm, addr, ptep); +}static inline void arch_clear_hugetlb_flags (struct folio *folio) {
@@ -48,7 +56,7 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,static inline pte_t huge_ptep_clear_flush (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) { -return huge_ptep_get_and_clear (vma->vm_mm, address, ptep); +return __huge_ptep_get_and_clear (vma->vm_mm, address, ptep); }#define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
@@ -59,7 +67,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,int changed = !pte_same (huge_ptep_get (vma->vm_mm, addr, ptep), pte);if (changed) { -huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); +__huge_ptep_get_and_clear (vma->vm_mm, addr, ptep);__set_huge_pte_at (vma->vm_mm, addr, ptep, pte); }return changed;
@@ -69,7 +77,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,static inline void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -pte_t pte =huge_ptep_get_and_clear (mm, addr, ptep); +pte_t pte =__huge_ptep_get_and_clear (mm, addr, ptep);__set_huge_pte_at (mm, addr, ptep,pte_wrprotect (pte)); }
arch/s390/mm/hugetlbpage.c +2 -2
@@ -188,8 +188,8 @@ pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)return __rste_to_pte (pte_val (*ptep)); } -pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +pte_t __huge_ptep_get_and_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) {pte_t pte =huge_ptep_get (mm, addr, ptep);pmd_t *pmdp = (pmd_t *) ptep;
arch/sparc/include/asm/hugetlb.h +1 -1
@@ -20,7 +20,7 @@ void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARpte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep); +pte_t *ptep,unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
arch/sparc/mm/hugetlbpage.c +1 -1
@@ -260,7 +260,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, }pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {unsigned int i, nptes, orig_shift, shift;unsigned long size;
include/asm-generic/hugetlb.h +1 -1
@@ -90,7 +90,7 @@ static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#ifndef __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep,unsigned long sz) {return ptep_get_and_clear (mm, addr, ptep); }
include/linux/hugetlb.h +3 -1
@@ -1004,7 +1004,9 @@ static inline void hugetlb_count_sub(long l, struct mm_struct *mm)static inline pte_t huge_ptep_modify_prot_start (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) { -return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); +unsigned long psize =huge_page_size (hstate_vma (vma)); + +return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, psize); }#endif
mm/hugetlb.c +2 -2
@@ -5447,7 +5447,7 @@ static void move_huge_pte(struct vm_area_struct *vma, unsigned long old_addr,if (src_ptl != dst_ptl)spin_lock_nested (src_ptl,SINGLE_DEPTH_NESTING ); - pte =huge_ptep_get_and_clear (mm, old_addr, src_pte); + pte =huge_ptep_get_and_clear (mm, old_addr, src_pte, sz);if (need_clear_uffd_wp &&pte_marker_uffd_wp (pte))huge_pte_clear (mm, new_addr, dst_pte, sz);
@@ -5622,7 +5622,7 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,set_vma_resv_flags (vma,HPAGE_RESV_UNMAPPED ); } - pte =huge_ptep_get_and_clear (mm, address, ptep); + pte =huge_ptep_get_and_clear (mm, address, ptep, sz);tlb_remove_huge_tlb_entry (h, tlb, ptep, address);if (huge_pte_dirty (pte))set_page_dirty (page);
Quoted 5 lines · On 04/03/2025 16:41, [email protected] wrote:
The patch below does not apply to the 6.1-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]>.
From v6.1 it becomes non-trivial to backport this patch as it depends on a patch that is only present from v6.5; Commit 935d4f0c6dc8 ("mm: hugetlb: add huge page size param to set_huge_pte_at()").
Given this is fixing a theoretical bug for which I'm not aware of any actual real world triggering, I'm proposing not to backport any further back than v6.6. I've already sent the backports for v6.13, v6.12 and v6.6.
Thanks,
Ryan
Quoted 371 lines
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-6.1.y
git checkoutFETCH_HEAD
git cherry-pick -x02410ac72ac3707936c07ede66e94360d0d65319
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025030437-specks-impotency-d026@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
02410ac72ac3707936c07ede66e94360d0d65319Mon Sep 17 00:00:00 2001
From: Ryan Roberts <[email protected]>
Date: Wed, 26 Feb 2025 12:06:51 +0000
Subject: [PATCH] mm: hugetlb: Add huge page size param to
huge_ptep_get_and_clear()In order to fix a bug, arm64 needs to be told the size of the huge page for which the
huge_pteis being cleared inhuge_ptep_get_and_clear(). Provide for this by adding anunsigned long szparameter to the function. This follows the same pattern ashuge_pte_clear()andset_huge_pte_at().This commit makes the required interface modifications to the core mm as well as all arches that implement this function (arm64, loongarch, mips, parisc, powerpc, riscv, s390, sparc). The actual arm64 bug will be fixed in a separate commit.
Fixes 66b3923a1a0f ("arm64: hugetlb: add support for PTE contiguous bit")Reviewed-by Alexandre Ghiti <[email protected]> # riscvReviewed-by Christophe Leroy <[email protected]>Reviewed-by Catalin Marinas <[email protected]>Reviewed-by Anshuman Khandual <[email protected]>Signed-off-by Ryan Roberts <[email protected]>Signed-off-by Will Deacon <[email protected]>arch/arm64/include/asm/hugetlb.h +2
-2@@ -42,8 +42,8 @@ extern int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty);#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR -extern pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep); +extern pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECTextern void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep);arch/arm64/mm/hugetlbpage.c +5
-3@@ -396,8 +396,8 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr,__pte_clear (mm, addr, ptep); } -pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long sz) {int ncontig;size_t pgsize;@@ -549,6 +549,8 @@ bool __init arch_hugetlb_valid_size(unsigned long size)pte_t huge_ptep_modify_prot_start (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) { +unsigned long psize =huge_page_size (hstate_vma (vma)); +if (alternative_has_cap_unlikely (ARM64_WORKAROUND_2645198 )) {/* * Break-before-make (BBM) is required for all user space mappings @@ -558,7 +560,7 @@ pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addrif (pte_user_exec (__ptep_get (ptep)))return huge_ptep_clear_flush (vma, addr, ptep); } -return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); +return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, psize); } void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep,arch/loongarch/include/asm/hugetlb.h +4
-2@@ -36,7 +36,8 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep, +unsigned long sz) {pte_t clear;pte_t pte =ptep_get (ptep);@@ -51,8 +52,9 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { pte_t pte; +unsigned long sz =huge_page_size (hstate_vma (vma)); - pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); + pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, sz);flush_tlb_page (vma, addr);return pte; }arch/mips/include/asm/hugetlb.h +4
-2@@ -27,7 +27,8 @@ static inline int prepare_hugepage_range(struct file *file,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep, +unsigned long sz) {pte_t clear;pte_t pte = *ptep;@@ -42,13 +43,14 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { pte_t pte; +unsigned long sz =huge_page_size (hstate_vma (vma));/* * clear the huge pte entry firstly, so that the other smp threads will * not get old pte entry after finishing flush_tlb_page and before * setting new huge pte entry */ - pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); + pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, sz);flush_tlb_page (vma, addr);return pte; }arch/parisc/include/asm/hugetlb.h +1
-1@@ -10,7 +10,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARpte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep); +pte_t *ptep,unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,arch/parisc/mm/hugetlbpage.c +1
-1@@ -126,7 +126,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {pte_t entry;arch/powerpc/include/asm/hugetlb.h +4
-2@@ -45,7 +45,8 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep, +unsigned long sz) {return __pte (pte_update (mm, addr, ptep, ~0UL ,0 ,1 )); }@@ -55,8 +56,9 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { pte_t pte; +unsigned long sz =huge_page_size (hstate_vma (vma)); - pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); + pte =huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, sz);flush_hugetlb_page (vma, addr);return pte; }arch/riscv/include/asm/hugetlb.h +2
-1@@ -28,7 +28,8 @@ void set_huge_pte_at(struct mm_struct *mm,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARpte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep); +unsigned long addr,pte_t *ptep, +unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,arch/riscv/mm/hugetlbpage.c +1
-1@@ -293,7 +293,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {pte_t orig_pte =ptep_get (ptep);int pte_num;arch/s390/include/asm/hugetlb.h +12
-4@@ -25,8 +25,16 @@ void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GETpte_t huge_ptep_get (struct mm_struct *mm,unsigned long addr,pte_t *ptep); +pte_t __huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep); +#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR -pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep); +static inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep, +unsigned long sz) +{ +return __huge_ptep_get_and_clear (mm, addr, ptep); +}static inline void arch_clear_hugetlb_flags (struct folio *folio) {@@ -48,7 +56,7 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,static inline pte_t huge_ptep_clear_flush (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) { -return huge_ptep_get_and_clear (vma->vm_mm, address, ptep); +return __huge_ptep_get_and_clear (vma->vm_mm, address, ptep); }#define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS@@ -59,7 +67,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,int changed = !pte_same (huge_ptep_get (vma->vm_mm, addr, ptep), pte);if (changed) { -huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); +__huge_ptep_get_and_clear (vma->vm_mm, addr, ptep);__set_huge_pte_at (vma->vm_mm, addr, ptep, pte); }return changed;@@ -69,7 +77,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,static inline void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -pte_t pte =huge_ptep_get_and_clear (mm, addr, ptep); +pte_t pte =__huge_ptep_get_and_clear (mm, addr, ptep);__set_huge_pte_at (mm, addr, ptep,pte_wrprotect (pte)); }arch/s390/mm/hugetlbpage.c +2
-2@@ -188,8 +188,8 @@ pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)return __rste_to_pte (pte_val (*ptep)); } -pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +pte_t __huge_ptep_get_and_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) {pte_t pte =huge_ptep_get (mm, addr, ptep);pmd_t *pmdp = (pmd_t *) ptep;arch/sparc/include/asm/hugetlb.h +1
-1@@ -20,7 +20,7 @@ void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARpte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep); +pte_t *ptep,unsigned long sz);#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,arch/sparc/mm/hugetlbpage.c +1
-1@@ -260,7 +260,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, }pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) +pte_t *ptep,unsigned long sz) {unsigned int i, nptes, orig_shift, shift;unsigned long size;include/asm-generic/hugetlb.h +1
-1@@ -90,7 +90,7 @@ static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,#ifndef __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) +unsigned long addr,pte_t *ptep,unsigned long sz) {return ptep_get_and_clear (mm, addr, ptep); }include/linux/hugetlb.h +3
-1@@ -1004,7 +1004,9 @@ static inline void hugetlb_count_sub(long l, struct mm_struct *mm)static inline pte_t huge_ptep_modify_prot_start (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) { -return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep); +unsigned long psize =huge_page_size (hstate_vma (vma)); + +return huge_ptep_get_and_clear (vma->vm_mm, addr, ptep, psize); }#endif mm/hugetlb.c +2
-2@@ -5447,7 +5447,7 @@ static void move_huge_pte(struct vm_area_struct *vma, unsigned long old_addr,if (src_ptl != dst_ptl)spin_lock_nested (src_ptl,SINGLE_DEPTH_NESTING ); - pte =huge_ptep_get_and_clear (mm, old_addr, src_pte); + pte =huge_ptep_get_and_clear (mm, old_addr, src_pte, sz);if (need_clear_uffd_wp &&pte_marker_uffd_wp (pte))huge_pte_clear (mm, new_addr, dst_pte, sz);@@ -5622,7 +5622,7 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,set_vma_resv_flags (vma,HPAGE_RESV_UNMAPPED ); } - pte =huge_ptep_get_and_clear (mm, address, ptep); + pte =huge_ptep_get_and_clear (mm, address, ptep, sz);tlb_remove_huge_tlb_entry (h, tlb, ptep, address);if (huge_pte_dirty (pte))set_page_dirty (page);
Catalin Marinas
maintainerQuoted 7 lines · Ryan Roberts
Quoted 5 lines · On 04/03/2025 16:41, [email protected] wrote:
The patch below does not apply to the 6.1-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]>.
Quoted 7 lines
From v6.1 it becomes non-trivial to backport this patch as it depends on a patch that is only present from v6.5; Commit
935d4f0c6dc8("mm: hugetlb: add huge page size param toset_huge_pte_at()").Given this is fixing a theoretical bug for which I'm not aware of any actual real world triggering, I'm proposing not to backport any further back than v6.6. I've already sent the backports for v6.13, v6.12 and v6.6.
It makes sense to me. Thanks Ryan.
Signature · 1 line
Catalin
Greg KH
maintainerQuoted 7 lines · Ryan Roberts
Quoted 5 lines · On 04/03/2025 16:41, [email protected] wrote:
The patch below does not apply to the 6.1-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]>.
Quoted 7 lines
Quoted 1 line
From v6.1 it becomes non-trivial to backport this patch as it depends on a patch
that is only present from v6.5; Commit
935d4f0c6dc8("mm: hugetlb: add huge page size param toset_huge_pte_at()").Given this is fixing a theoretical bug for which I'm not aware of any actual real world triggering, I'm proposing not to backport any further back than v6.6. I've already sent the backports for v6.13, v6.12 and v6.6.
That's fine, thanks for the backports, I'll go queue them up.
greg k-h