[MIPS] Fix swap entry for MIPS32 36-bit physical address With 64-bit physical address enabled, 'swapon' was causing kernel oops on Alchemy CPUs (MIPS32) because of the swap entry type field corrupting the _PAGE_FILE bit in 'pte_low' field. So, switch to storing the swap entry in 'pte_high' field using all its bits except _PAGE_GLOBAL and _PAGE_VALID which gives 25 bits for the swap entry offset. 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 6ebba0e2 79e0bc37

+15 -3
+15 -3
include/asm-mips/pgtable-32.h
··· 191 191 #else 192 192 193 193 /* Swap entries must have VALID and GLOBAL bits cleared. */ 194 - #define __swp_type(x) (((x).val >> 8) & 0x1f) 195 - #define __swp_offset(x) ((x).val >> 13) 194 + #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) 195 + #define __swp_type(x) (((x).val >> 2) & 0x1f) 196 + #define __swp_offset(x) ((x).val >> 7) 196 197 #define __swp_entry(type,offset) \ 197 - ((swp_entry_t) { ((type) << 8) | ((offset) << 13) }) 198 + ((swp_entry_t) { ((type) << 2) | ((offset) << 7) }) 199 + #else 200 + #define __swp_type(x) (((x).val >> 8) & 0x1f) 201 + #define __swp_offset(x) ((x).val >> 13) 202 + #define __swp_entry(type,offset) \ 203 + ((swp_entry_t) { ((type) << 8) | ((offset) << 13) }) 204 + #endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */ 198 205 199 206 /* 200 207 * Bits 0, 1, 2, 7 and 8 are taken, split up the 27 bits of offset ··· 225 218 226 219 #endif 227 220 221 + #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) 222 + #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_high }) 223 + #define __swp_entry_to_pte(x) ((pte_t) { 0, (x).val }) 224 + #else 228 225 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 229 226 #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 227 + #endif 230 228 231 229 #endif /* _ASM_PGTABLE_32_H */