Skip to contentSkip to conversation

Fix for 2.6.5/2.6.6 Swap issue

PATCH New Kumba 1 participant 1 message May 27, 2004 MIPS

lore
Share & tools
lore

Kumba

author
#0 lore raw

PATCH 1/1 Fix for 2.6.5/2.6.6 Swap issue

Peter Horton wrote this patch up several weeks ago for Cobalt, but it's applicable for all MIPS machines I've seen thus far (atleast SGI and Cobalt). It fixes the kernel panic resulting from trying to activate swap on a system running 2.6.5 and up. It's been in Gentoo's mips-sources for quite some time, and I've had no problems with it on my O2 or Cobalt.

--Kumba

Signature · 1 line
"Such is oft the course of deeds that move the wheels of the world: small hands do them because they must, while the eyes of the great are elsewhere."  --Elrond
asm-mips/pgtable-32.h +10 -6
diff -urN include/asm-mips/pgtable-32.h include/asm-mips/pgtable-32.h
@@ -203,14 +203,18 @@
 /* Swap entries must have VALID and GLOBAL bits cleared. */
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
 
-#define __swp_type(x)		(((x).val >> 1) & 0x7f)
-#define __swp_offset(x)		((x).val >> 10)
-#define __swp_entry(type,offset)	((swp_entry_t) { ((type) << 1) | ((offset) << 10) })
+/* offset is limited to 17 bits (512MB @ 4K page) */
+/* VALID & GLOBAL are bits 9 & 8 */
+#define __swp_type(x)		(((x).val >> 10) & 0x1f)
+#define __swp_offset(x)		((x).val >> 15)
+#define __swp_entry(type,offset)	((swp_entry_t) { ((type) << 10) | ((offset) << 15) })
 #else
 
-#define __swp_type(x)		(((x).val >> 1) & 0x1f)
-#define __swp_offset(x)		((x).val >> 8)
-#define __swp_entry(type,offset)	((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
+/* offset is limited to 19 bits (2GB @ 4K page) */
+/* VALID & GLOBAL are bits 7 & 6 */
+#define __swp_type(x)		(((x).val >> 8) & 0x1f)
+#define __swp_offset(x)		((x).val >> 13)
+#define __swp_entry(type,offset)	((swp_entry_t) { ((type) << 8) | ((offset) << 13) })
 #endif
 
 #define __pte_to_swp_entry(pte)	((swp_entry_t) { pte_val(pte) })