Skip to content

Commit afccb08

Browse files
ryanhrobakpm00
authored andcommitted
mm: more ptep_get() conversion
Commit c33c794 ("mm: ptep_get() conversion") converted all (non-arch) call sites to use ptep_get() instead of doing a direct dereference of the pte. Full rationale can be found in that commit's log. Since then, three new call sites have snuck in, which directly dereference the pte, so let's fix those up. Unfortunately there is no reliable automated mechanism to catch these; I'm relying on a combination of Coccinelle (which throws up a lot of false positives) and some compiler magic to force a compiler error on dereference (While this approach finds dereferences, it also yields a non-booting kernel so can't be committed). Link: https://lkml.kernel.org/r/20231114154945.490401-1-ryan.roberts@arm.com Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 5f74f82 commit afccb08

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

mm/filemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3443,7 +3443,7 @@ static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf,
34433443
* handled in the specific fault path, and it'll prohibit the
34443444
* fault-around logic.
34453445
*/
3446-
if (!pte_none(vmf->pte[count]))
3446+
if (!pte_none(ptep_get(&vmf->pte[count])))
34473447
goto skip;
34483448

34493449
count++;

mm/ksm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static int break_ksm_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long nex
468468
page = pfn_swap_entry_to_page(entry);
469469
}
470470
/* return 1 if the page is an normal ksm page or KSM-placed zero page */
471-
ret = (page && PageKsm(page)) || is_ksm_zero_pte(*pte);
471+
ret = (page && PageKsm(page)) || is_ksm_zero_pte(ptent);
472472
pte_unmap_unlock(pte, ptl);
473473
return ret;
474474
}

mm/userfaultfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static int mfill_atomic_pte_poison(pmd_t *dst_pmd,
312312

313313
ret = -EEXIST;
314314
/* Refuse to overwrite any PTE, even a PTE marker (e.g. UFFD WP). */
315-
if (!pte_none(*dst_pte))
315+
if (!pte_none(ptep_get(dst_pte)))
316316
goto out_unlock;
317317

318318
set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);

0 commit comments

Comments
 (0)