提交 7cb710c9 编写于 作者: S Sergei Shtylyov 提交者: Ralf Baechle

[MIPS] Fix non-linear memory mapping on MIPS

    
Fix the non-linear memory mapping done via remap_file_pages() -- it
didn't work on any MIPS CPU because the page offset clashing with
_PAGE_FILE and some other page protection bits which should have been left
zeros for this kind of pages.
Signed-off-by: NKonstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: NSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
上级 aa32374a
...@@ -177,16 +177,18 @@ pfn_pte(unsigned long pfn, pgprot_t prot) ...@@ -177,16 +177,18 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
((swp_entry_t) { ((type) << 10) | ((offset) << 15) }) ((swp_entry_t) { ((type) << 10) | ((offset) << 15) })
/* /*
* Bits 0, 1, 2, 9 and 10 are taken, split up the 27 bits of offset * Bits 0, 4, 8, and 9 are taken, split up 28 bits of offset into this range:
* into this range:
*/ */
#define PTE_FILE_MAX_BITS 27 #define PTE_FILE_MAX_BITS 28
#define pte_to_pgoff(_pte) \ #define pte_to_pgoff(_pte) ((((_pte).pte >> 1 ) & 0x07) | \
((((_pte).pte >> 3) & 0x3f ) + (((_pte).pte >> 11) << 8 )) (((_pte).pte >> 2 ) & 0x38) | \
(((_pte).pte >> 10) << 6 ))
#define pgoff_to_pte(off) \ #define pgoff_to_pte(off) ((pte_t) { (((off) & 0x07) << 1 ) | \
((pte_t) { (((off) & 0x3f) << 3) + (((off) >> 8) << 11) + _PAGE_FILE }) (((off) & 0x38) << 2 ) | \
(((off) >> 6 ) << 10) | \
_PAGE_FILE })
#else #else
...@@ -203,24 +205,29 @@ pfn_pte(unsigned long pfn, pgprot_t prot) ...@@ -203,24 +205,29 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
((swp_entry_t) { ((type) << 8) | ((offset) << 13) }) ((swp_entry_t) { ((type) << 8) | ((offset) << 13) })
#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */ #endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */
#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
/* /*
* Bits 0, 1, 2, 7 and 8 are taken, split up the 27 bits of offset * Bits 0 and 1 of pte_high are taken, use the rest for the page offset...
* into this range:
*/ */
#define PTE_FILE_MAX_BITS 27 #define PTE_FILE_MAX_BITS 30
#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) #define pte_to_pgoff(_pte) ((_pte).pte_high >> 2)
/* fixme */ #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) << 2 })
#define pte_to_pgoff(_pte) (((_pte).pte_high >> 6) + ((_pte).pte_high & 0x3f))
#define pgoff_to_pte(off) \
((pte_t){(((off) & 0x3f) + ((off) << 6) + _PAGE_FILE)})
#else #else
#define pte_to_pgoff(_pte) \ /*
((((_pte).pte >> 3) & 0x1f ) + (((_pte).pte >> 9) << 6 )) * Bits 0, 4, 6, and 7 are taken, split up 28 bits of offset into this range:
*/
#define PTE_FILE_MAX_BITS 28
#define pte_to_pgoff(_pte) ((((_pte).pte >> 1) & 0x7) | \
(((_pte).pte >> 2) & 0x8) | \
(((_pte).pte >> 8) << 4))
#define pgoff_to_pte(off) \ #define pgoff_to_pte(off) ((pte_t) { (((off) & 0x7) << 1) | \
((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE }) (((off) & 0x8) << 2) | \
(((off) >> 4) << 8) | \
_PAGE_FILE })
#endif #endif
#endif #endif
......
...@@ -224,15 +224,12 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset) ...@@ -224,15 +224,12 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
/* /*
* Bits 0, 1, 2, 7 and 8 are taken, split up the 32 bits of offset * Bits 0, 4, 6, and 7 are taken. Let's leave bits 1, 2, 3, and 5 alone to
* into this range: * make things easier, and only use the upper 56 bits for the page offset...
*/ */
#define PTE_FILE_MAX_BITS 32 #define PTE_FILE_MAX_BITS 56
#define pte_to_pgoff(_pte) \ #define pte_to_pgoff(_pte) ((_pte).pte >> 8)
((((_pte).pte >> 3) & 0x1f ) + (((_pte).pte >> 9) << 6 )) #define pgoff_to_pte(off) ((pte_t) { ((off) << 8) | _PAGE_FILE })
#define pgoff_to_pte(off) \
((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE })
#endif /* _ASM_PGTABLE_64_H */ #endif /* _ASM_PGTABLE_64_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册