From: Alexandre Ghiti <alex@xxxxxxxx> Subject: hugetlb: introduce generic version of huge_ptep_set_wrprotect() arm, ia64, mips, powerpc, sh, x86 architectures use the same version of huge_ptep_set_wrprotect, so move this generic implementation into asm-generic/hugetlb.h. Link: http://lkml.kernel.org/r/20180920060358.16606-10-alex@xxxxxxxx Signed-off-by: Alexandre Ghiti <alex@xxxxxxxx> Reviewed-by: Luiz Capitulino <lcapitulino@xxxxxxxxxx> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Tested-by: Helge Deller <deller@xxxxxx> [parisc] Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx> [arm64] Acked-by: Paul Burton <paul.burton@xxxxxxxx> [MIPS] Acked-by: Ingo Molnar <mingo@xxxxxxxxxx> [x86] Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Cc: David S. Miller <davem@xxxxxxxxxxxxx> Cc: Fenghua Yu <fenghua.yu@xxxxxxxxx> Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx> Cc: H. Peter Anvin <hpa@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: James E.J. Bottomley <jejb@xxxxxxxxxxxxxxxx> Cc: James Hogan <jhogan@xxxxxxxxxx> Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx> Cc: Rich Felker <dalias@xxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Tony Luck <tony.luck@xxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/arm/include/asm/hugetlb-3level.h | 6 ------ arch/arm64/include/asm/hugetlb.h | 1 + arch/ia64/include/asm/hugetlb.h | 6 ------ arch/mips/include/asm/hugetlb.h | 6 ------ arch/parisc/include/asm/hugetlb.h | 1 + arch/powerpc/include/asm/book3s/32/pgtable.h | 6 ------ arch/powerpc/include/asm/book3s/64/pgtable.h | 1 + arch/powerpc/include/asm/nohash/32/pgtable.h | 6 ------ arch/powerpc/include/asm/nohash/64/pgtable.h | 1 + arch/sh/include/asm/hugetlb.h | 6 ------ arch/sparc/include/asm/hugetlb.h | 1 + arch/x86/include/asm/hugetlb.h | 6 ------ include/asm-generic/hugetlb.h | 8 ++++++++ 13 files changed, 13 insertions(+), 42 deletions(-) --- a/arch/arm64/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/arm64/include/asm/hugetlb.h @@ -48,6 +48,7 @@ extern int huge_ptep_set_access_flags(st #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); +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT extern void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep); #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH --- a/arch/arm/include/asm/hugetlb-3level.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/arm/include/asm/hugetlb-3level.h @@ -37,12 +37,6 @@ static inline pte_t huge_ptep_get(pte_t return retval; } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty) --- a/arch/ia64/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/ia64/include/asm/hugetlb.h @@ -27,12 +27,6 @@ static inline void huge_ptep_clear_flush { } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty) --- a/arch/mips/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/mips/include/asm/hugetlb.h @@ -63,12 +63,6 @@ static inline int huge_pte_none(pte_t pt return !val || (val == (unsigned long)invalid_pte_table); } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, --- a/arch/parisc/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/parisc/include/asm/hugetlb.h @@ -39,6 +39,7 @@ static inline void huge_ptep_clear_flush { } +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep); --- a/arch/powerpc/include/asm/book3s/32/pgtable.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -221,12 +221,6 @@ static inline void ptep_set_wrprotect(st { pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), _PAGE_RO); } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline void __ptep_set_access_flags(struct vm_area_struct *vma, pte_t *ptep, pte_t entry, --- a/arch/powerpc/include/asm/book3s/64/pgtable.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -461,6 +461,7 @@ static inline void ptep_set_wrprotect(st pte_update(mm, addr, ptep, 0, _PAGE_PRIVILEGED, 0); } +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { --- a/arch/powerpc/include/asm/nohash/32/pgtable.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -246,12 +246,6 @@ static inline void ptep_set_wrprotect(st { pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), _PAGE_RO); } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline void __ptep_set_access_flags(struct vm_area_struct *vma, pte_t *ptep, pte_t entry, --- a/arch/powerpc/include/asm/nohash/64/pgtable.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -239,6 +239,7 @@ static inline void ptep_set_wrprotect(st pte_update(mm, addr, ptep, _PAGE_RW, 0, 0); } +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { --- a/arch/sh/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/sh/include/asm/hugetlb.h @@ -32,12 +32,6 @@ static inline void huge_ptep_clear_flush { } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty) --- a/arch/sparc/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/sparc/include/asm/hugetlb.h @@ -32,6 +32,7 @@ static inline void huge_ptep_clear_flush { } +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { --- a/arch/x86/include/asm/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/arch/x86/include/asm/hugetlb.h @@ -13,12 +13,6 @@ static inline int is_hugepage_only_range return 0; } -static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - ptep_set_wrprotect(mm, addr, ptep); -} - static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty) --- a/include/asm-generic/hugetlb.h~hugetlb-introduce-generic-version-of-huge_ptep_set_wrprotect +++ a/include/asm-generic/hugetlb.h @@ -102,4 +102,12 @@ static inline int prepare_hugepage_range } #endif +#ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT +static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + ptep_set_wrprotect(mm, addr, ptep); +} +#endif + #endif /* _ASM_GENERIC_HUGETLB_H */ _