[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: Konstantin Baydarov <kbaidarov@ru.mvista.com> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by Sergei Shtylyov and committed by Ralf Baechle 7cb710c9 aa32374a

+31 -27
+26 -19
include/asm-mips/pgtable-32.h
··· 177 ((swp_entry_t) { ((type) << 10) | ((offset) << 15) }) 178 179 /* 180 - * Bits 0, 1, 2, 9 and 10 are taken, split up the 27 bits of offset 181 - * into this range: 182 */ 183 - #define PTE_FILE_MAX_BITS 27 184 185 - #define pte_to_pgoff(_pte) \ 186 - ((((_pte).pte >> 3) & 0x3f ) + (((_pte).pte >> 11) << 8 )) 187 188 - #define pgoff_to_pte(off) \ 189 - ((pte_t) { (((off) & 0x3f) << 3) + (((off) >> 8) << 11) + _PAGE_FILE }) 190 191 #else 192 ··· 205 ((swp_entry_t) { ((type) << 8) | ((offset) << 13) }) 206 #endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */ 207 208 /* 209 - * Bits 0, 1, 2, 7 and 8 are taken, split up the 27 bits of offset 210 - * into this range: 211 */ 212 - #define PTE_FILE_MAX_BITS 27 213 214 - #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 215 - /* fixme */ 216 - #define pte_to_pgoff(_pte) (((_pte).pte_high >> 6) + ((_pte).pte_high & 0x3f)) 217 - #define pgoff_to_pte(off) \ 218 - ((pte_t){(((off) & 0x3f) + ((off) << 6) + _PAGE_FILE)}) 219 220 #else 221 - #define pte_to_pgoff(_pte) \ 222 - ((((_pte).pte >> 3) & 0x1f ) + (((_pte).pte >> 9) << 6 )) 223 224 - #define pgoff_to_pte(off) \ 225 - ((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE }) 226 #endif 227 228 #endif
··· 177 ((swp_entry_t) { ((type) << 10) | ((offset) << 15) }) 178 179 /* 180 + * Bits 0, 4, 8, and 9 are taken, split up 28 bits of offset into this range: 181 */ 182 + #define PTE_FILE_MAX_BITS 28 183 184 + #define pte_to_pgoff(_pte) ((((_pte).pte >> 1 ) & 0x07) | \ 185 + (((_pte).pte >> 2 ) & 0x38) | \ 186 + (((_pte).pte >> 10) << 6 )) 187 188 + #define pgoff_to_pte(off) ((pte_t) { (((off) & 0x07) << 1 ) | \ 189 + (((off) & 0x38) << 2 ) | \ 190 + (((off) >> 6 ) << 10) | \ 191 + _PAGE_FILE }) 192 193 #else 194 ··· 203 ((swp_entry_t) { ((type) << 8) | ((offset) << 13) }) 204 #endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */ 205 206 + #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) 207 /* 208 + * Bits 0 and 1 of pte_high are taken, use the rest for the page offset... 209 */ 210 + #define PTE_FILE_MAX_BITS 30 211 212 + #define pte_to_pgoff(_pte) ((_pte).pte_high >> 2) 213 + #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) << 2 }) 214 215 #else 216 + /* 217 + * Bits 0, 4, 6, and 7 are taken, split up 28 bits of offset into this range: 218 + */ 219 + #define PTE_FILE_MAX_BITS 28 220 221 + #define pte_to_pgoff(_pte) ((((_pte).pte >> 1) & 0x7) | \ 222 + (((_pte).pte >> 2) & 0x8) | \ 223 + (((_pte).pte >> 8) << 4)) 224 + 225 + #define pgoff_to_pte(off) ((pte_t) { (((off) & 0x7) << 1) | \ 226 + (((off) & 0x8) << 2) | \ 227 + (((off) >> 4) << 8) | \ 228 + _PAGE_FILE }) 229 #endif 230 231 #endif
+5 -8
include/asm-mips/pgtable-64.h
··· 224 #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 225 226 /* 227 - * Bits 0, 1, 2, 7 and 8 are taken, split up the 32 bits of offset 228 - * into this range: 229 */ 230 - #define PTE_FILE_MAX_BITS 32 231 232 - #define pte_to_pgoff(_pte) \ 233 - ((((_pte).pte >> 3) & 0x1f ) + (((_pte).pte >> 9) << 6 )) 234 - 235 - #define pgoff_to_pte(off) \ 236 - ((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE }) 237 238 #endif /* _ASM_PGTABLE_64_H */
··· 224 #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 225 226 /* 227 + * Bits 0, 4, 6, and 7 are taken. Let's leave bits 1, 2, 3, and 5 alone to 228 + * make things easier, and only use the upper 56 bits for the page offset... 229 */ 230 + #define PTE_FILE_MAX_BITS 56 231 232 + #define pte_to_pgoff(_pte) ((_pte).pte >> 8) 233 + #define pgoff_to_pte(off) ((pte_t) { ((off) << 8) | _PAGE_FILE }) 234 235 #endif /* _ASM_PGTABLE_64_H */