ARM: update __swp_entry_to_pte() to use PTE_TYPE_FAULT
PATCH 1/1 ARM: update __swp_entry_to_pte() to use PTE_TYPE_FAULT
Swap entries use a faulting PTE which have the least two significant bits as zero. Due to this, the use of PTE_TYPE_FAULT was overlooked, but really should have been included in __swp_entry_to_pte().
Convert this macro to use PTE_TYPE_FAULT to properly document what is going on here, and use __pte() to convert the swp_entry_t to a pte_t.
This results in no change to the resulting kernel text.
--- arch/arm/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/pgtable.h +1 -1
@@ -303,7 +303,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)#define __swp_entry (type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) }) -#define __swp_entry_to_pte (swp) ((pte_t) { (swp).val }) +#define __swp_entry_to_pte (swp) __pte((swp).val | PTE_TYPE_FAULT)/* * It is an error for the kernel to have more swap files than we can
Signature · 1 line
2.20.1
Quoted 19 lines · Russell King
Swap entries use a faulting PTE which have the least two significant bits as zero. Due to this, the use of
PTE_TYPE_FAULTwas overlooked, but really should have been included in__swp_entry_to_pte().Convert this macro to use
PTE_TYPE_FAULTto properly document what is going on here, and use__pte()to convert theswp_entry_tto apte_t.This results in no change to the resulting kernel text.
Signed-off-by Russell King <[email protected]>--- arch/arm/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/include/asm/pgtable.h +0
-0
arch/arm/include/asm/pgtable.h static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) · line 306
Quoted 5 lines
arch/arm/include/asm/pgtable.h +1
-1@@ -303,7 +303,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)#define __swp_entry (type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) }) -#define __swp_entry_to_pte (swp) ((pte_t) { (swp).val }) +#define __swp_entry_to_pte (swp) __pte((swp).val | PTE_TYPE_FAULT)
LGTM and FWIW..
Quoted 4 lines
arch/arm/include/asm/pgtable.h +0
-0/* * It is an error for the kernel to have more swap files than we can
Quoted 10 lines · Russell King
Swap entries use a faulting PTE which have the least two significant bits as zero. Due to this, the use of
PTE_TYPE_FAULTwas overlooked, but really should have been included in__swp_entry_to_pte().Convert this macro to use
PTE_TYPE_FAULTto properly document what is going on here, and use__pte()to convert theswp_entry_tto apte_t.This results in no change to the resulting kernel text.
Signed-off-by Russell King <[email protected]>
Hmm. Speaking as one who occasionally has to trawl through all the architectures considering their __swp_entry() implementations, I would much prefer you to drop this patch: I don't think it helps anyone to insist on ORing in (something which when one searches further turns out to be) 0.
But if you really want to keep it, please remember it's not just __swp_entry_to_pte() that "needs" changing: __pte_to_swp_entry() ought to mask it off, pte_clear() ought to set it, pte_none() ought to compare against it, page table initialization ought to memset with it, and probably more :)
Thanks,
Hugh
Quoted 19 lines
--- arch/arm/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/include/asm/pgtable.h +1
-1@@ -303,7 +303,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)#define __swp_entry (type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) }) -#define __swp_entry_to_pte (swp) ((pte_t) { (swp).val }) +#define __swp_entry_to_pte (swp) __pte((swp).val | PTE_TYPE_FAULT)/* * It is an error for the kernel to have more swap files than we can Signature · 1 line
2.20.1