path: root/mm/pgtable-generic.c
diff options
authorKirill A. Shutemov <>2018-01-31 16:18:16 -0800
committerLinus Torvalds <>2018-01-31 17:18:38 -0800
commitd52605d7cb306aaf86d0e6dede275dbf8a020072 (patch)
tree2763bc71c0ebeb57c4ea93d95c030623ceb62060 /mm/pgtable-generic.c
parent86fa949b050184ffc53688516a6a83ae5f98d08a (diff)
mm: do not lose dirty and accessed bits in pmdp_invalidate()
Vlastimil noted that pmdp_invalidate() is not atomic and we can lose dirty and access bits if CPU sets them after pmdp dereference, but before set_pmd_at(). The patch change pmdp_invalidate() to make the entry non-present atomically and return previous value of the entry. This value can be used to check if CPU set dirty/accessed bits under us. The race window is very small and I haven't seen any reports that can be attributed to the bug. For this reason, I don't think backporting to stable trees needed. Link: Signed-off-by: Kirill A. Shutemov <> Reported-by: Vlastimil Babka <> Cc: Hugh Dickins <> Cc: Andrea Arcangeli <> Cc: Aneesh Kumar K.V <> Cc: Catalin Marinas <> Cc: David Daney <> Cc: David Miller <> Cc: H. Peter Anvin <> Cc: Ingo Molnar <> Cc: Martin Schwidefsky <> Cc: Michal Hocko <> Cc: Nitin Gupta <> Cc: Ralf Baechle <> Cc: Thomas Gleixner <> Cc: Vineet Gupta <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/pgtable-generic.c')
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 1e4ee763c190..cf2af04b34b9 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -181,12 +181,12 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp)
-void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
+pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
pmd_t *pmdp)
- pmd_t entry = *pmdp;
- set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry));
+ pmd_t old = pmdp_establish(vma, address, pmdp, pmd_mknotpresent(*pmdp));
flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
+ return old;