diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2013-09-11 17:22:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:58:06 -0400 |
commit | fa0f281cf9de8e6877e6536f18a3fc77368df64d (patch) | |
tree | f542d0f6b19d56f4bfddca7d971bac6c00fca63b /arch/x86 | |
parent | 5a53748568f79641eaf40e41081a2f4987f005c2 (diff) |
mm: make sure _PAGE_SWP_SOFT_DIRTY bit is not set on present pte
_PAGE_SOFT_DIRTY bit should never be set on present pte so add VM_BUG_ON
to catch any potential future abuse.
Also add a comment on _PAGE_SWP_SOFT_DIRTY definition explaining scope of
its usage.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/pgtable.h | 34 | ||||
-rw-r--r-- | arch/x86/include/asm/pgtable_types.h | 3 |
2 files changed, 22 insertions, 15 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 8d16befdec88..3d1999458709 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -315,21 +315,6 @@ static inline pmd_t pmd_mksoft_dirty(pmd_t pmd) | |||
315 | return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY); | 315 | return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY); |
316 | } | 316 | } |
317 | 317 | ||
318 | static inline pte_t pte_swp_mksoft_dirty(pte_t pte) | ||
319 | { | ||
320 | return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY); | ||
321 | } | ||
322 | |||
323 | static inline int pte_swp_soft_dirty(pte_t pte) | ||
324 | { | ||
325 | return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY; | ||
326 | } | ||
327 | |||
328 | static inline pte_t pte_swp_clear_soft_dirty(pte_t pte) | ||
329 | { | ||
330 | return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY); | ||
331 | } | ||
332 | |||
333 | static inline pte_t pte_file_clear_soft_dirty(pte_t pte) | 318 | static inline pte_t pte_file_clear_soft_dirty(pte_t pte) |
334 | { | 319 | { |
335 | return pte_clear_flags(pte, _PAGE_SOFT_DIRTY); | 320 | return pte_clear_flags(pte, _PAGE_SOFT_DIRTY); |
@@ -446,6 +431,7 @@ pte_t *populate_extra_pte(unsigned long vaddr); | |||
446 | 431 | ||
447 | #ifndef __ASSEMBLY__ | 432 | #ifndef __ASSEMBLY__ |
448 | #include <linux/mm_types.h> | 433 | #include <linux/mm_types.h> |
434 | #include <linux/mmdebug.h> | ||
449 | #include <linux/log2.h> | 435 | #include <linux/log2.h> |
450 | 436 | ||
451 | static inline int pte_none(pte_t pte) | 437 | static inline int pte_none(pte_t pte) |
@@ -864,6 +850,24 @@ static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, | |||
864 | { | 850 | { |
865 | } | 851 | } |
866 | 852 | ||
853 | static inline pte_t pte_swp_mksoft_dirty(pte_t pte) | ||
854 | { | ||
855 | VM_BUG_ON(pte_present(pte)); | ||
856 | return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY); | ||
857 | } | ||
858 | |||
859 | static inline int pte_swp_soft_dirty(pte_t pte) | ||
860 | { | ||
861 | VM_BUG_ON(pte_present(pte)); | ||
862 | return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY; | ||
863 | } | ||
864 | |||
865 | static inline pte_t pte_swp_clear_soft_dirty(pte_t pte) | ||
866 | { | ||
867 | VM_BUG_ON(pte_present(pte)); | ||
868 | return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY); | ||
869 | } | ||
870 | |||
867 | #include <asm-generic/pgtable.h> | 871 | #include <asm-generic/pgtable.h> |
868 | #endif /* __ASSEMBLY__ */ | 872 | #endif /* __ASSEMBLY__ */ |
869 | 873 | ||
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index f4843e031131..0ecac257fb26 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
@@ -75,6 +75,9 @@ | |||
75 | * with swap entry format. On x86 bits 6 and 7 are *not* involved | 75 | * with swap entry format. On x86 bits 6 and 7 are *not* involved |
76 | * into swap entry computation, but bit 6 is used for nonlinear | 76 | * into swap entry computation, but bit 6 is used for nonlinear |
77 | * file mapping, so we borrow bit 7 for soft dirty tracking. | 77 | * file mapping, so we borrow bit 7 for soft dirty tracking. |
78 | * | ||
79 | * Please note that this bit must be treated as swap dirty page | ||
80 | * mark if and only if the PTE has present bit clear! | ||
78 | */ | 81 | */ |
79 | #ifdef CONFIG_MEM_SOFT_DIRTY | 82 | #ifdef CONFIG_MEM_SOFT_DIRTY |
80 | #define _PAGE_SWP_SOFT_DIRTY _PAGE_PSE | 83 | #define _PAGE_SWP_SOFT_DIRTY _PAGE_PSE |