Skip to content

Commit 481e980

Browse files
chleroympe
authored andcommitted
mm: Allow arches to provide ptep_get()
Since commit 9e343b4 ("READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses") it is not possible anymore to use READ_ONCE() to access complex page table entries like the one defined for powerpc 8xx with 16k size pages. Define a ptep_get() helper that architectures can override instead of performing a READ_ONCE() on the page table entry pointer. Fixes: 9e343b4 ("READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses") Signed-off-by: Christophe Leroy <[email protected]> Acked-by: Will Deacon <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/087fa12b6e920e32315136b998aa834f99242695.1592225558.git.christophe.leroy@csgroup.eu
1 parent 55ca226 commit 481e980

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

include/asm-generic/hugetlb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
122122
#ifndef __HAVE_ARCH_HUGE_PTEP_GET
123123
static inline pte_t huge_ptep_get(pte_t *ptep)
124124
{
125-
return READ_ONCE(*ptep);
125+
return ptep_get(ptep);
126126
}
127127
#endif
128128

include/linux/pgtable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
249249
}
250250
#endif
251251

252+
#ifndef __HAVE_ARCH_PTEP_GET
253+
static inline pte_t ptep_get(pte_t *ptep)
254+
{
255+
return READ_ONCE(*ptep);
256+
}
257+
#endif
258+
252259
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
253260
#ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
254261
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,

mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ static inline pte_t gup_get_pte(pte_t *ptep)
21962196
*/
21972197
static inline pte_t gup_get_pte(pte_t *ptep)
21982198
{
2199-
return READ_ONCE(*ptep);
2199+
return ptep_get(ptep);
22002200
}
22012201
#endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */
22022202

0 commit comments

Comments
 (0)