Index: arch/ia64/include/context.h
===================================================================
--- arch/ia64/include/context.h	(revision e0cdb7b6525161f0a4e6f31c56baf5e373dfa5ce)
+++ arch/ia64/include/context.h	(revision a016b635e87c4ce35ab625dd3488a94c230c8cae)
@@ -50,6 +50,6 @@
 #define context_set(c, _pc, stack, size) 						\
 	(c)->pc = (__address) _pc;							\
-	(c)->bsp = ((__address) stack) + (ALIGN(sizeof(the_t), STACK_ALIGNMENT));	\
-	(c)->sp = ((__address) stack) + (size) - SP_DELTA;
+	(c)->bsp = ((__address) stack) + ALIGN(sizeof(the_t), STACK_ALIGNMENT);		\
+	(c)->sp = ((__address) stack) + ALIGN((size) - SP_DELTA, STACK_ALIGNMENT);
 
 /*
Index: arch/mips32/include/mm/page.h
===================================================================
--- arch/mips32/include/mm/page.h	(revision e0cdb7b6525161f0a4e6f31c56baf5e373dfa5ce)
+++ arch/mips32/include/mm/page.h	(revision a016b635e87c4ce35ab625dd3488a94c230c8cae)
@@ -63,13 +63,13 @@
 #define SET_PTL0_ADDRESS_ARCH(ptl0)		(PTL0 = (pte_t *)(ptl0))
 
-#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		(((pte_t *)(ptl0))[(i)].pfn<<12)
+#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		(((pte_t *)(ptl0))[(i)].lo.pfn<<12)
 #define GET_PTL2_ADDRESS_ARCH(ptl1, i)		(ptl1)
 #define GET_PTL3_ADDRESS_ARCH(ptl2, i)		(ptl2)
-#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		(((pte_t *)(ptl3))[(i)].pfn<<12)
+#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		(((pte_t *)(ptl3))[(i)].lo.pfn<<12)
 
-#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a)	(((pte_t *)(ptl0))[(i)].pfn = (a)>>12)
+#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a)	(((pte_t *)(ptl0))[(i)].lo.pfn = (a)>>12)
 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
-#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)	(((pte_t *)(ptl3))[(i)].pfn = (a)>>12)
+#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)	(((pte_t *)(ptl3))[(i)].lo.pfn = (a)>>12)
 
 #define GET_PTL1_FLAGS_ARCH(ptl0, i)		get_pt_flags((pte_t *)(ptl0), (index_t)(i))
@@ -95,6 +95,6 @@
 	
 	return (
-		((p->c>PAGE_UNCACHED)<<PAGE_CACHEABLE_SHIFT) |
-		((!p->v)<<PAGE_PRESENT_SHIFT) |
+		((p->lo.c>PAGE_UNCACHED)<<PAGE_CACHEABLE_SHIFT) |
+		((!p->lo.v)<<PAGE_PRESENT_SHIFT) |
 		(1<<PAGE_USER_SHIFT) |
 		(1<<PAGE_READ_SHIFT) |
@@ -109,6 +109,6 @@
 	pte_t *p = &pt[i];
 	
-	p->c = (flags & PAGE_CACHEABLE) != 0 ? PAGE_CACHEABLE_EXC_WRITE : PAGE_UNCACHED;
-	p->v = !(flags & PAGE_NOT_PRESENT);
+	p->lo.c = (flags & PAGE_CACHEABLE) != 0 ? PAGE_CACHEABLE_EXC_WRITE : PAGE_UNCACHED;
+	p->lo.v = !(flags & PAGE_NOT_PRESENT);
 	p->w = (flags & PAGE_WRITE) != 0;
 }
Index: arch/mips32/include/mm/tlb.h
===================================================================
--- arch/mips32/include/mm/tlb.h	(revision e0cdb7b6525161f0a4e6f31c56baf5e373dfa5ce)
+++ arch/mips32/include/mm/tlb.h	(revision a016b635e87c4ce35ab625dd3488a94c230c8cae)
@@ -31,4 +31,5 @@
 
 #include <arch/exception.h>
+#include <typedefs.h>
 
 #define TLB_SIZE	48
@@ -41,4 +42,9 @@
 #define PAGE_UNCACHED			2
 #define PAGE_CACHEABLE_EXC_WRITE	5
+
+typedef union entry_lo entry_lo_t;
+typedef union entry_hi entry_hi_t;
+typedef union page_mask page_mask_t;
+typedef union index tlb_index_t;
 
 union entry_lo {
@@ -54,13 +60,12 @@
 };
 
-struct pte {
-	unsigned g : 1; 	/* global bit */
-	unsigned v : 1; 	/* valid bit */
-	unsigned d : 1; 	/* dirty/write-protect bit */
-	unsigned c : 3; 	/* cache coherency attribute */
-	unsigned pfn : 24;	/* frame number */
-	unsigned w : 1;		/* writable */
-	unsigned a : 1;		/* accessed */
-} __attribute__ ((packed));
+union pte {
+	entry_lo_t lo;
+	struct {
+		unsigned : 30;
+		unsigned w : 1;		/* writable */
+		unsigned a : 1;		/* accessed */
+	} __attribute__ ((packed));
+};
 
 union entry_hi {
@@ -90,9 +95,4 @@
 	__u32 value;
 };
-
-typedef union entry_lo entry_lo_t;
-typedef union entry_hi entry_hi_t;
-typedef union page_mask page_mask_t;
-typedef union index tlb_index_t;
 
 /** Probe TLB for Matching Entry
Index: arch/mips32/include/types.h
===================================================================
--- arch/mips32/include/types.h	(revision e0cdb7b6525161f0a4e6f31c56baf5e373dfa5ce)
+++ arch/mips32/include/types.h	(revision a016b635e87c4ce35ab625dd3488a94c230c8cae)
@@ -50,5 +50,5 @@
 typedef __u32 __native;
 
-typedef struct pte pte_t;
+typedef union pte pte_t;
 
 #endif
Index: arch/mips32/src/mm/tlb.c
===================================================================
--- arch/mips32/src/mm/tlb.c	(revision e0cdb7b6525161f0a4e6f31c56baf5e373dfa5ce)
+++ arch/mips32/src/mm/tlb.c	(revision a016b635e87c4ce35ab625dd3488a94c230c8cae)
@@ -105,5 +105,5 @@
 
 	prepare_entry_hi(&hi, VM->asid, badvaddr);
-	prepare_entry_lo(&lo, pte->g, pte->v, pte->d, pte->c, pte->pfn);
+	prepare_entry_lo(&lo, pte->lo.g, pte->lo.v, pte->lo.d, pte->lo.c, pte->lo.pfn);
 
 	/*
@@ -178,5 +178,5 @@
 	pte->a = 1;
 
-	prepare_entry_lo(&lo, pte->g, pte->v, pte->d, pte->c, pte->pfn);
+	prepare_entry_lo(&lo, pte->lo.g, pte->lo.v, pte->lo.d, pte->lo.c, pte->lo.pfn);
 
 	/*
@@ -251,7 +251,7 @@
 	 */
 	pte->a = 1;
-	pte->d = 1;
-
-	prepare_entry_lo(&lo, pte->g, pte->v, pte->w, pte->c, pte->pfn);
+	pte->lo.d = 1;
+
+	prepare_entry_lo(&lo, pte->lo.g, pte->lo.v, pte->w, pte->lo.c, pte->lo.pfn);
 
 	/*
@@ -376,5 +376,5 @@
 	 * Handler cannot succeed if the mapping is marked as invalid.
 	 */
-	if (!pte->v) {
+	if (!pte->lo.v) {
 		printf("Invalid mapping.\n");
 		return NULL;
