Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@ghiti.fr
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Tested-by: Helge Deller <deller@gmx.de> [parisc]
Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Acked-by: Paul Burton <paul.burton@mips.com> [MIPS]
Acked-by: Ingo Molnar <mingo@kernel.org> [x86]
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Ghiti and committed by
Linus Torvalds
8e581d43 78d6e4e8

+13 -42
-6
arch/arm/include/asm/hugetlb-3level.h
··· 37 37 return retval; 38 38 } 39 39 40 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 41 - unsigned long addr, pte_t *ptep) 42 - { 43 - ptep_set_wrprotect(mm, addr, ptep); 44 - } 45 - 46 40 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, 47 41 unsigned long addr, pte_t *ptep, 48 42 pte_t pte, int dirty)
+1
arch/arm64/include/asm/hugetlb.h
··· 48 48 #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR 49 49 extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 50 50 unsigned long addr, pte_t *ptep); 51 + #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 51 52 extern void huge_ptep_set_wrprotect(struct mm_struct *mm, 52 53 unsigned long addr, pte_t *ptep); 53 54 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
-6
arch/ia64/include/asm/hugetlb.h
··· 27 27 { 28 28 } 29 29 30 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 31 - unsigned long addr, pte_t *ptep) 32 - { 33 - ptep_set_wrprotect(mm, addr, ptep); 34 - } 35 - 36 30 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, 37 31 unsigned long addr, pte_t *ptep, 38 32 pte_t pte, int dirty)
-6
arch/mips/include/asm/hugetlb.h
··· 63 63 return !val || (val == (unsigned long)invalid_pte_table); 64 64 } 65 65 66 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 67 - unsigned long addr, pte_t *ptep) 68 - { 69 - ptep_set_wrprotect(mm, addr, ptep); 70 - } 71 - 72 66 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, 73 67 unsigned long addr, 74 68 pte_t *ptep, pte_t pte,
+1
arch/parisc/include/asm/hugetlb.h
··· 39 39 { 40 40 } 41 41 42 + #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 42 43 void huge_ptep_set_wrprotect(struct mm_struct *mm, 43 44 unsigned long addr, pte_t *ptep); 44 45
-6
arch/powerpc/include/asm/book3s/32/pgtable.h
··· 221 221 { 222 222 pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), _PAGE_RO); 223 223 } 224 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 225 - unsigned long addr, pte_t *ptep) 226 - { 227 - ptep_set_wrprotect(mm, addr, ptep); 228 - } 229 - 230 224 231 225 static inline void __ptep_set_access_flags(struct vm_area_struct *vma, 232 226 pte_t *ptep, pte_t entry,
+1
arch/powerpc/include/asm/book3s/64/pgtable.h
··· 461 461 pte_update(mm, addr, ptep, 0, _PAGE_PRIVILEGED, 0); 462 462 } 463 463 464 + #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 464 465 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 465 466 unsigned long addr, pte_t *ptep) 466 467 {
-6
arch/powerpc/include/asm/nohash/32/pgtable.h
··· 246 246 { 247 247 pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), _PAGE_RO); 248 248 } 249 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 250 - unsigned long addr, pte_t *ptep) 251 - { 252 - ptep_set_wrprotect(mm, addr, ptep); 253 - } 254 - 255 249 256 250 static inline void __ptep_set_access_flags(struct vm_area_struct *vma, 257 251 pte_t *ptep, pte_t entry,
+1
arch/powerpc/include/asm/nohash/64/pgtable.h
··· 239 239 pte_update(mm, addr, ptep, _PAGE_RW, 0, 0); 240 240 } 241 241 242 + #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 242 243 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 243 244 unsigned long addr, pte_t *ptep) 244 245 {
-6
arch/sh/include/asm/hugetlb.h
··· 32 32 { 33 33 } 34 34 35 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 36 - unsigned long addr, pte_t *ptep) 37 - { 38 - ptep_set_wrprotect(mm, addr, ptep); 39 - } 40 - 41 35 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, 42 36 unsigned long addr, pte_t *ptep, 43 37 pte_t pte, int dirty)
+1
arch/sparc/include/asm/hugetlb.h
··· 32 32 { 33 33 } 34 34 35 + #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 35 36 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 36 37 unsigned long addr, pte_t *ptep) 37 38 {
-6
arch/x86/include/asm/hugetlb.h
··· 13 13 return 0; 14 14 } 15 15 16 - static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 17 - unsigned long addr, pte_t *ptep) 18 - { 19 - ptep_set_wrprotect(mm, addr, ptep); 20 - } 21 - 22 16 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, 23 17 unsigned long addr, pte_t *ptep, 24 18 pte_t pte, int dirty)
+8
include/asm-generic/hugetlb.h
··· 102 102 } 103 103 #endif 104 104 105 + #ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 106 + static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 107 + unsigned long addr, pte_t *ptep) 108 + { 109 + ptep_set_wrprotect(mm, addr, ptep); 110 + } 111 + #endif 112 + 105 113 #endif /* _ASM_GENERIC_HUGETLB_H */