Index: arch/ia32/include/context.h
===================================================================
--- arch/ia32/include/context.h	(revision 7f1bfceb9210d208482652a9028d8dc7c11acd79)
+++ arch/ia32/include/context.h	(revision 6b96ab4449e063165c6c13fdee997fa057cb4975)
@@ -32,4 +32,8 @@
 #include <arch/types.h>
 
+/*
+ * Both context_save() and context_restore() eat two doublewords from the stack.
+ * First for pop of the saved register, second during ret instruction.
+ */
 #define SP_DELTA	8
 
Index: arch/ia64/include/context.h
===================================================================
--- arch/ia64/include/context.h	(revision 7f1bfceb9210d208482652a9028d8dc7c11acd79)
+++ arch/ia64/include/context.h	(revision 6b96ab4449e063165c6c13fdee997fa057cb4975)
@@ -32,7 +32,14 @@
 #include <arch/types.h>
 
-#define SP_DELTA	16
+/*
+ * context_save() and context_restore() are both leaf procedures.
+ * No need to allocate scratch area.
+ */
+#define SP_DELTA	0
 
 struct context {
+	/*
+	 * General registers
+	 */
 	__u64 r1;
 	__u64 r2;
@@ -66,5 +73,22 @@
 	__u64 r30;
 	__u64 r31;
+	
+	/*
+	 * Branch registers
+	 */
 	__u64 pc;		/* b0 */
+	__u64 b1;
+	__u64 b2;
+	__u64 b3;
+	__u64 b4;
+	__u64 b5;
+	__u64 b6;
+	__u64 b7;
+
+	/*
+	 * Predicate registers
+	 */
+	__u64 pr;
+	
 	pri_t pri;
 } __attribute__ ((packed));
Index: arch/ia64/include/types.h
===================================================================
--- arch/ia64/include/types.h	(revision 7f1bfceb9210d208482652a9028d8dc7c11acd79)
+++ arch/ia64/include/types.h	(revision 6b96ab4449e063165c6c13fdee997fa057cb4975)
@@ -41,5 +41,5 @@
 typedef __u64 __address;
 
-typedef __u32 pri_t;
+typedef __u64 pri_t;
 
 typedef __u64 __native;
Index: arch/ia64/src/context.S
===================================================================
--- arch/ia64/src/context.S	(revision 7f1bfceb9210d208482652a9028d8dc7c11acd79)
+++ arch/ia64/src/context.S	(revision 6b96ab4449e063165c6c13fdee997fa057cb4975)
@@ -33,5 +33,5 @@
 
 context_save:
-	alloc loc0 = ar.pfs, 1, 2, 0, 0
+	alloc loc0 = ar.pfs, 1, 9, 0, 0
 	
 	/*
@@ -39,4 +39,7 @@
 	 */
 
+	/*
+	 * Save general registers
+	 */
 	st8 [in0] = r1, 8	;;
 	st8 [in0] = r2, 8	;;
@@ -71,6 +74,28 @@
 	st8 [in0] = r31, 8	;;
 
-	/* save pc */
+	/*
+	 * Save branch registers
+	 */
 	mov loc1 = b0		;;
+	st8 [in0] = loc1, 8		/* save pc */
+	mov loc2 = b1		;;
+	st8 [in0] = loc2, 8
+	mov loc3 = b2		;;
+	st8 [in0] = loc3, 8
+	mov loc4 = b3		;;
+	st8 [in0] = loc4, 8
+	mov loc5 = b4		;;
+	st8 [in0] = loc5, 8
+	mov loc6 = b5		;;
+	st8 [in0] = loc6, 8
+	mov loc7 = b6		;;
+	st8 [in0] = loc7, 8
+	mov loc8 = b7		;;
+	st8 [in0] = loc8, 8
+
+	/*
+	 * Save predicate registers
+	 */
+	mov loc1 = pr		;;
 	st8 [in0] = loc1, 8
 	
@@ -81,5 +106,5 @@
 
 context_restore:
-	alloc loc0 = ar.pfs, 1, 2, 0, 0
+	alloc loc0 = ar.pfs, 1, 9, 0, 0
 
 	/*
@@ -87,4 +112,7 @@
 	 */
 	
+	/*
+	 * Restore general registers
+	 */
 	ld8 r1 = [in0], 8	;;
 	ld8 r2 = [in0], 8	;;
@@ -119,7 +147,26 @@
 	ld8 r31 = [in0], 8	;;
 
-	/* restore pc */
+	/* 
+	 * Restore branch registers
+	 */
+	ld8 loc1 = [in0], 8	;;	/* restore pc */
+	mov b0 = loc1
+	ld8 loc2 = [in0], 8	;;
+	mov b1 = loc2
+	ld8 loc3 = [in0], 8	;;
+	mov b2 = loc3
+	ld8 loc4 = [in0], 8	;;
+	mov b3 = loc4
+	ld8 loc5 = [in0], 8	;;
+	mov b4 = loc5
+	ld8 loc6 = [in0], 8	;;
+	mov b5 = loc6
+	ld8 loc7 = [in0], 8	;;
+	mov b6 = loc7
+	ld8 loc8 = [in0], 8	;;
+	mov b7 = loc8
+
 	ld8 loc1 = [in0], 8	;;
-	mov b0 = loc1
+	mov pr = loc1, ~0
 	
 	mov ar.pfs = loc0
