r2410 - in trunk: kernel/source/kernel-source-2.6.10-2.6.10/debian kernel/source/kernel-source-2.6.10-2.6.10/debian/patches kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/series kernel/source/kernel-source-2.6.8-2.6.8/debian kernel/source/kernel-source-2.6.8-2.6.8/debian/patches kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/series kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27 kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian

Dann Frazier dannf@costa.debian.org
Wed, 26 Jan 2005 08:22:09 +0100


Author: dannf
Date: 2005-01-26 08:22:06 +0100 (Wed, 26 Jan 2005)
New Revision: 2410

Added:
   trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/ia64-unwind-fix.patch
   trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-ptrace-fixes.dpatch
   trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-unwind-fix.dpatch
   trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-fixes.dpatch
   trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-speedup.dpatch
   trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-unwind-fix.dpatch
Modified:
   trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/changelog
   trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/rules
   trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/changelog
   trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/series/2.6.10-5
   trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/changelog
   trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/series/2.6.8-14
Log:
some ia64 ptrace & unwind fixes

Modified: trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/changelog
===================================================================
--- trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/changelog	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/changelog	2005-01-26 07:22:06 UTC (rev 2410)
@@ -5,6 +5,12 @@
 
   * scsi_ioctl: only warn about really unknown opcodes. (Maximilian Attems)
 
+  * ia64-ptrace-fixes.dpatch
+    Fix some corner cases in ia64 ptrace code (dann frazier).
+
+  * ia64-unwind-fix.dpatch
+    unw_unwind_to_user sanity check
+
  -- Simon Horman <horms@debian.org>  Fri, 21 Jan 2005 12:43:05 +0900
 
 kernel-source-2.6.10 (2.6.10-4) unstable; urgency=low

Added: trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-ptrace-fixes.dpatch
===================================================================
--- trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-ptrace-fixes.dpatch	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-ptrace-fixes.dpatch	2005-01-26 07:22:06 UTC (rev 2410)
@@ -0,0 +1,252 @@
+#! /bin/sh -e
+## <PATCHNAME>.dpatch by <PATCH_AUTHOR@EMAI>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: [IA64] clean up ptrace corner cases
+## DP: Patch author: tony.luck@intel.com
+## DP: Upstream status: backported
+
+. $(dirname $0)/DPATCH
+
+@DPATCH@
+# This is a BitKeeper generated diff -Nru style patch.
+#
+# ChangeSet
+#   2005/01/22 14:21:34-08:00 tony.luck@intel.com 
+#   [IA64] clean up ptrace corner cases
+#   
+#   Patch from yanmin.zhang@intel.com to fix up some corner cases
+#   in ptrace.  Many thanks to davidm for reviewing and improving.
+#   
+#   Signed-off-by: Tony Luck <tony.luck@intel.com>
+# 
+# arch/ia64/kernel/entry.S
+#   2005/01/22 14:18:28-08:00 tony.luck@intel.com +19 -7
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/fsys.S
+#   2005/01/22 14:19:11-08:00 tony.luck@intel.com +3 -2
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/gate.S
+#   2005/01/22 14:19:18-08:00 tony.luck@intel.com +3 -1
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/ivt.S
+#   2005/01/22 14:19:19-08:00 tony.luck@intel.com +20 -5
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/process.c
+#   2005/01/22 14:19:21-08:00 tony.luck@intel.com +1 -1
+#   clean up ptrace corner cases
+# 
+# include/asm-ia64/unistd.h
+#   2005/01/22 14:19:22-08:00 tony.luck@intel.com +1 -1
+#   clean up ptrace corner cases
+# 
+diff -Nru a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
+--- a/arch/ia64/kernel/entry.S	2005-01-25 21:43:25 -08:00
++++ b/arch/ia64/kernel/entry.S	2005-01-25 21:43:25 -08:00
+@@ -51,8 +51,11 @@
+ 	 * setup a null register window frame.
+ 	 */
+ ENTRY(ia64_execve)
+-	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(3)
+-	alloc loc1=ar.pfs,3,2,4,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
++	alloc loc1=ar.pfs,8,2,4,0
+ 	mov loc0=rp
+ 	.body
+ 	mov out0=in0			// filename
+@@ -113,8 +116,11 @@
+  *	      u64 tls)
+  */
+ GLOBAL_ENTRY(sys_clone2)
+-	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(6)
+-	alloc r16=ar.pfs,6,2,6,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
++	alloc r16=ar.pfs,8,2,6,0
+ 	DO_SAVE_SWITCH_STACK
+ 	adds r2=PT(R16)+IA64_SWITCH_STACK_SIZE+16,sp
+ 	mov loc0=rp
+@@ -142,8 +148,11 @@
+  *	Deprecated.  Use sys_clone2() instead.
+  */
+ GLOBAL_ENTRY(sys_clone)
+-	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5)
+-	alloc r16=ar.pfs,5,2,6,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
++	alloc r16=ar.pfs,8,2,6,0
+ 	DO_SAVE_SWITCH_STACK
+ 	adds r2=PT(R16)+IA64_SWITCH_STACK_SIZE+16,sp
+ 	mov loc0=rp
+@@ -1212,7 +1221,10 @@
+ 
+ ENTRY(sys_rt_sigreturn)
+ 	PT_REGS_UNWIND_INFO(0)
+-	alloc r2=ar.pfs,0,0,1,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	alloc r2=ar.pfs,8,0,1,0
+ 	.prologue
+ 	PT_REGS_SAVES(16)
+ 	adds sp=-16,sp
+diff -Nru a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
+--- a/arch/ia64/kernel/fsys.S	2005-01-25 21:43:25 -08:00
++++ b/arch/ia64/kernel/fsys.S	2005-01-25 21:43:25 -08:00
+@@ -612,8 +612,9 @@
+ 	;;
+ 	mov rp=r2				// set the real return addr
+ 	tbit.z p8,p0=r3,TIF_SYSCALL_TRACE
+-
+-(p8)	br.call.sptk.many b6=b6			// ignore this return addr
++	;;
++(p10)	br.cond.spnt.many ia64_ret_from_syscall	// p10==true means out registers are more than 8
++(p8)	br.call.sptk.many b6=b6		// ignore this return addr
+ 	br.cond.sptk ia64_trace_syscall
+ END(fsys_bubble_down)
+ 
+diff -Nru a/arch/ia64/kernel/gate.S b/arch/ia64/kernel/gate.S
+--- a/arch/ia64/kernel/gate.S	2005-01-25 21:43:25 -08:00
++++ b/arch/ia64/kernel/gate.S	2005-01-25 21:43:25 -08:00
+@@ -81,6 +81,7 @@
+ 	LOAD_FSYSCALL_TABLE(r14)
+ 
+ 	mov r16=IA64_KR(CURRENT)		// 12 cycle read latency
++	tnat.nz p10,p9=r15
+ 	mov r19=NR_syscalls-1
+ 	;;
+ 	shladd r18=r17,3,r14
+@@ -119,7 +120,8 @@
+ #endif
+ 
+ 	mov r10=-1
+-	mov r8=ENOSYS
++(p10)	mov r8=EINVAL
++(p9)	mov r8=ENOSYS
+ 	FSYS_RETURN
+ END(__kernel_syscall_via_epc)
+ 
+diff -Nru a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
+--- a/arch/ia64/kernel/ivt.S	2005-01-25 21:43:25 -08:00
++++ b/arch/ia64/kernel/ivt.S	2005-01-25 21:43:25 -08:00
+@@ -51,6 +51,7 @@
+ #include <asm/system.h>
+ #include <asm/thread_info.h>
+ #include <asm/unistd.h>
++#include <asm/errno.h>
+ 
+ #if 1
+ # define PSR_DEFAULT_BITS	psr.ac
+@@ -732,10 +733,12 @@
+ 	ssm psr.ic | PSR_DEFAULT_BITS
+ 	;;
+ 	srlz.i					// guarantee that interruption collection is on
++	mov r3=NR_syscalls - 1
+ 	;;
+ (p15)	ssm psr.i				// restore psr.i
++	// p10==true means out registers are more than 8 or r15's Nat is true
++(p10)	br.cond.spnt.many ia64_ret_from_syscall
+ 	;;
+-	mov r3=NR_syscalls - 1
+ 	movl r16=sys_call_table
+ 
+ 	adds r15=-1024,r15			// r15 contains the syscall number---subtract 1024
+@@ -836,8 +839,11 @@
+ 	 * On exit:
+ 	 *	- executing on bank 1 registers
+ 	 *	- psr.ic enabled, interrupts restored
++	 *	-  p10: TRUE if syscall is invoked with more than 8 out
++	 *		registers or r15's Nat is true
+ 	 *	-  r1: kernel's gp
+ 	 *	-  r3: preserved (same as on entry)
++	 *	-  r8: -EINVAL if p10 is true
+ 	 *	- r12: points to kernel stack
+ 	 *	- r13: points to current task
+ 	 *	- p15: TRUE if interrupts need to be re-enabled
+@@ -871,12 +877,17 @@
+ 	;;
+ 
+ 	st8 [r16]=r19,PT(AR_RNAT)-PT(CR_IFS)	// store ar.pfs.pfm in cr.ifs
++	extr.u r11=r19,7,7	// I0		// get sol of ar.pfs
++	and r8=0x7f,r19		// A		// get sof of ar.pfs
++
+ 	st8 [r17]=r27,PT(AR_BSPSTORE)-PT(AR_RSC)// save ar.rsc
++	tbit.nz p15,p0=r29,IA64_PSR_I_BIT // I0
+ (p9)	mov in1=-1
++	;;
+ 
+ (pUStk) sub r18=r18,r22				// r18=RSE.ndirty*8
+-	tbit.nz p15,p0=r29,IA64_PSR_I_BIT
+ 	tnat.nz p10,p0=in2
++	add r11=8,r11
+ 	;;
+ (pKStk) adds r16=PT(PR)-PT(AR_RNAT),r16		// skip over ar_rnat field
+ (pKStk) adds r17=PT(B0)-PT(AR_BSPSTORE),r17	// skip over ar_bspstore field
+@@ -904,25 +915,29 @@
+ (p13)	mov in5=-1
+ 	;;
+ 	st8 [r16]=r21,PT(R8)-PT(AR_FPSR)	// save ar.fpsr
+-	st8.spill [r17]=r15			// save r15
+ 	tnat.nz p14,p0=in6
++	cmp.lt p10,p9=r11,r8	// frame size can't be more than local+8
+ 	;;
+ 	stf8 [r16]=f1		// ensure pt_regs.r8 != 0 (see handle_syscall_error)
++(p9)	tnat.nz p10,p0=r15
+ 	adds r12=-16,r1		// switch to kernel memory stack (with 16 bytes of scratch)
++
++	st8.spill [r17]=r15			// save r15
+ 	tnat.nz p8,p0=in7
++	nop.i 0
+ 
+ 	mov r13=r2				// establish `current'
+ 	movl r1=__gp				// establish kernel global pointer
+ 	;;
+ (p14)	mov in6=-1
+ (p8)	mov in7=-1
+-	tnat.nz p9,p0=r15
++	nop.i 0
+ 
+ 	cmp.eq pSys,pNonSys=r0,r0		// set pSys=1, pNonSys=0
+ 	movl r17=FPSR_DEFAULT
+ 	;;
+ 	mov.m ar.fpsr=r17			// set ar.fpsr to kernel default value
+-(p9)	mov r15=-1
++(p10)	mov r8=-EINVAL
+ 	br.ret.sptk.many b7
+ END(ia64_syscall_setup)
+ 
+diff -Nru a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
+--- a/arch/ia64/kernel/process.c	2005-01-25 21:43:25 -08:00
++++ b/arch/ia64/kernel/process.c	2005-01-25 21:43:25 -08:00
+@@ -632,7 +632,7 @@
+ 	return 1;	/* f0-f31 are always valid so we always return 1 */
+ }
+ 
+-asmlinkage long
++long
+ sys_execve (char __user *filename, char __user * __user *argv, char __user * __user *envp,
+ 	    struct pt_regs *regs)
+ {
+diff -Nru a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
+--- a/include/asm-ia64/unistd.h	2005-01-25 21:43:25 -08:00
++++ b/include/asm-ia64/unistd.h	2005-01-25 21:43:25 -08:00
+@@ -374,7 +374,7 @@
+ 				int fd, long pgoff);
+ struct pt_regs;
+ struct sigaction;
+-asmlinkage long sys_execve(char __user *filename, char __user * __user *argv,
++long sys_execve(char __user *filename, char __user * __user *argv,
+ 			   char __user * __user *envp, struct pt_regs *regs);
+ asmlinkage long sys_pipe(long arg0, long arg1, long arg2, long arg3,
+ 			long arg4, long arg5, long arg6, long arg7, long stack);

Added: trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-unwind-fix.dpatch
===================================================================
--- trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-unwind-fix.dpatch	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/ia64-unwind-fix.dpatch	2005-01-26 07:22:06 UTC (rev 2410)
@@ -0,0 +1,46 @@
+#! /bin/sh -e
+## <PATCHNAME>.dpatch by <PATCH_AUTHOR@EMAI>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: [IA64] Sanity check unw_unwind_to_user
+## DP: Patch author: kaos@sgi.com
+## DP: Upstream status: backported
+
+. $(dirname $0)/DPATCH
+
+@DPATCH@
+# This is a BitKeeper generated diff -Nru style patch.
+#
+# ChangeSet
+#   2005/01/22 12:59:23-08:00 kaos@sgi.com 
+#   [IA64] Sanity check unw_unwind_to_user
+#   
+#   Signed-off-by: Keith Owens <kaos@sgi.com>
+#   Signed-off-by: Tony Luck <tony.luck@intel.com>
+# 
+# arch/ia64/kernel/unwind.c
+#   2005/01/22 12:57:36-08:00 kaos@sgi.com +4 -1
+#   Sanity check unw_unwind_to_user
+# 
+diff -Nru a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
+--- a/arch/ia64/kernel/unwind.c	2005-01-25 22:08:49 -08:00
++++ b/arch/ia64/kernel/unwind.c	2005-01-25 22:08:49 -08:00
+@@ -1945,7 +1945,7 @@
+ int
+ unw_unwind_to_user (struct unw_frame_info *info)
+ {
+-	unsigned long ip;
++	unsigned long ip, sp;
+ 
+ 	while (unw_unwind(info) >= 0) {
+ 		if (unw_get_rp(info, &ip) < 0) {
+@@ -1954,6 +1954,9 @@
+ 				   __FUNCTION__, ip);
+ 			return -1;
+ 		}
++		unw_get_sp(info, &sp);
++		if (sp >= (unsigned long)info->task + IA64_STK_OFFSET)
++			break;
+ 		if (ip < FIXADDR_USER_END)
+ 			return 0;
+ 	}

Modified: trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/series/2.6.10-5
===================================================================
--- trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/series/2.6.10-5	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.10-2.6.10/debian/patches/series/2.6.10-5	2005-01-26 07:22:06 UTC (rev 2410)
@@ -1 +1,4 @@
 + scsi-ioctl.dpatch
++ ia64-ptrace-fixes.dpatch
++ ia64-unwind-fix.dpatch
+

Modified: trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/changelog
===================================================================
--- trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/changelog	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/changelog	2005-01-26 07:22:06 UTC (rev 2410)
@@ -5,8 +5,18 @@
     LOG_SELECT as write-ok, quieten scsi ioctl when asking for 
     a lot of memory and failing. (Maximilian Attems)
 
- -- 
+  * ia64-ptrace-speedup.dpatch
+    Backport needed to form a base on top of which ia64-ptrace-fixes will
+    apply. (dann frazier)
 
+  * ia64-ptrace-fixes.dpatch
+    Fix some corner cases in ia64 ptrace code (dann frazier).
+
+  * ia64-unwind-fix.dpatch
+    unw_unwind_to_user sanity check
+
+ -- dann frazier <dannf@debian.org>  Tue, 25 Jan 2005 22:32:15 -0700
+
 kernel-source-2.6.8 (2.6.8-13) unstable; urgency=high
 
   * add more USB card reader blacklist entries.  Patch from Fedora via

Added: trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-fixes.dpatch
===================================================================
--- trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-fixes.dpatch	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-fixes.dpatch	2005-01-26 07:22:06 UTC (rev 2410)
@@ -0,0 +1,255 @@
+#! /bin/sh -e
+## <PATCHNAME>.dpatch by <PATCH_AUTHOR@EMAI>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: [IA64] clean up ptrace corner cases
+## DP: Patch author: tony.luck@intel.com
+## DP: Upstream status: backported
+
+. $(dirname $0)/DPATCH
+
+@DPATCH@
+# This is a BitKeeper generated diff -Nru style patch.
+#
+# ChangeSet
+#   2005/01/22 14:21:34-08:00 tony.luck@intel.com 
+#   [IA64] clean up ptrace corner cases
+#   
+#   Patch from yanmin.zhang@intel.com to fix up some corner cases
+#   in ptrace.  Many thanks to davidm for reviewing and improving.
+#   
+#   Signed-off-by: Tony Luck <tony.luck@intel.com>
+# 
+# arch/ia64/kernel/entry.S
+#   2005/01/22 14:18:28-08:00 tony.luck@intel.com +19 -7
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/fsys.S
+#   2005/01/22 14:19:11-08:00 tony.luck@intel.com +3 -2
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/gate.S
+#   2005/01/22 14:19:18-08:00 tony.luck@intel.com +3 -1
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/ivt.S
+#   2005/01/22 14:19:19-08:00 tony.luck@intel.com +20 -5
+#   clean up ptrace corner cases
+# 
+# arch/ia64/kernel/process.c
+#   2005/01/22 14:19:21-08:00 tony.luck@intel.com +1 -1
+#   clean up ptrace corner cases
+# 
+# include/asm-ia64/unistd.h
+#   2005/01/22 14:19:22-08:00 tony.luck@intel.com +1 -1
+#   clean up ptrace corner cases
+# 
+
+# backported to Debian's 2.6.8 by dann frazier <dannf@debian.org>
+
+diff -urN kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/entry.S kernel-source-2.6.8-2.6.8/arch/ia64/kernel/entry.S
+--- kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/entry.S	2004-08-13 23:36:32.000000000 -0600
++++ kernel-source-2.6.8-2.6.8/arch/ia64/kernel/entry.S	2005-01-25 22:26:17.000000000 -0700
+@@ -51,8 +51,11 @@
+ 	 * setup a null register window frame.
+ 	 */
+ ENTRY(ia64_execve)
+-	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(3)
+-	alloc loc1=ar.pfs,3,2,4,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
++	alloc loc1=ar.pfs,8,2,4,0
+ 	mov loc0=rp
+ 	.body
+ 	mov out0=in0			// filename
+@@ -113,8 +116,11 @@
+  *	      u64 tls)
+  */
+ GLOBAL_ENTRY(sys_clone2)
+-	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(6)
+-	alloc r16=ar.pfs,6,2,6,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
++	alloc r16=ar.pfs,8,2,6,0
+ 	DO_SAVE_SWITCH_STACK
+ 	adds r2=PT(R16)+IA64_SWITCH_STACK_SIZE+16,sp
+ 	mov loc0=rp
+@@ -142,8 +148,11 @@
+  *	Deprecated.  Use sys_clone2() instead.
+  */
+ GLOBAL_ENTRY(sys_clone)
+-	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5)
+-	alloc r16=ar.pfs,5,2,6,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
++	alloc r16=ar.pfs,8,2,6,0
+ 	DO_SAVE_SWITCH_STACK
+ 	adds r2=PT(R16)+IA64_SWITCH_STACK_SIZE+16,sp
+ 	mov loc0=rp
+@@ -1183,7 +1192,10 @@
+ 
+ ENTRY(sys_rt_sigreturn)
+ 	PT_REGS_UNWIND_INFO(0)
+-	alloc r2=ar.pfs,0,0,1,0
++	/*
++	 * Allocate 8 input registers since ptrace() may clobber them
++	 */
++	alloc r2=ar.pfs,8,0,1,0
+ 	.prologue
+ 	PT_REGS_SAVES(16)
+ 	adds sp=-16,sp
+diff -urN kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/fsys.S kernel-source-2.6.8-2.6.8/arch/ia64/kernel/fsys.S
+--- kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/fsys.S	2004-08-13 23:38:11.000000000 -0600
++++ kernel-source-2.6.8-2.6.8/arch/ia64/kernel/fsys.S	2005-01-25 22:26:17.000000000 -0700
+@@ -597,8 +597,9 @@
+ 	;;
+ 	mov rp=r2				// set the real return addr
+ 	tbit.z p8,p0=r3,TIF_SYSCALL_TRACE
+-
+-(p8)	br.call.sptk.many b6=b6			// ignore this return addr
++	;;
++(p10)	br.cond.spnt.many ia64_ret_from_syscall	// p10==true means out registers are more than 8
++(p8)	br.call.sptk.many b6=b6		// ignore this return addr
+ 	br.cond.sptk ia64_trace_syscall
+ END(fsys_bubble_down)
+ 
+diff -urN kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/gate.S kernel-source-2.6.8-2.6.8/arch/ia64/kernel/gate.S
+--- kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/gate.S	2004-08-13 23:37:38.000000000 -0600
++++ kernel-source-2.6.8-2.6.8/arch/ia64/kernel/gate.S	2005-01-25 22:26:17.000000000 -0700
+@@ -81,6 +81,7 @@
+ 	LOAD_FSYSCALL_TABLE(r14)
+ 
+ 	mov r16=IA64_KR(CURRENT)		// 12 cycle read latency
++	tnat.nz p10,p9=r15
+ 	mov r19=NR_syscalls-1
+ 	;;
+ 	shladd r18=r17,3,r14
+@@ -119,7 +120,8 @@
+ #endif
+ 
+ 	mov r10=-1
+-	mov r8=ENOSYS
++(p10)	mov r8=EINVAL
++(p9)	mov r8=ENOSYS
+ 	FSYS_RETURN
+ END(__kernel_syscall_via_epc)
+ 
+diff -urN kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/ivt.S kernel-source-2.6.8-2.6.8/arch/ia64/kernel/ivt.S
+--- kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/ivt.S	2005-01-25 22:25:23.000000000 -0700
++++ kernel-source-2.6.8-2.6.8/arch/ia64/kernel/ivt.S	2005-01-25 22:26:17.000000000 -0700
+@@ -51,6 +51,7 @@
+ #include <asm/system.h>
+ #include <asm/thread_info.h>
+ #include <asm/unistd.h>
++#include <asm/errno.h>
+ 
+ #if 1
+ # define PSR_DEFAULT_BITS	psr.ac
+@@ -732,10 +733,12 @@
+ 	ssm psr.ic | PSR_DEFAULT_BITS
+ 	;;
+ 	srlz.i					// guarantee that interruption collection is on
++	mov r3=NR_syscalls - 1
+ 	;;
+ (p15)	ssm psr.i				// restore psr.i
++	// p10==true means out registers are more than 8 or r15's Nat is true
++(p10)	br.cond.spnt.many ia64_ret_from_syscall
+ 	;;
+-	mov r3=NR_syscalls - 1
+ 	movl r16=sys_call_table
+ 
+ 	adds r15=-1024,r15			// r15 contains the syscall number---subtract 1024
+@@ -836,8 +839,11 @@
+ 	 * On exit:
+ 	 *	- executing on bank 1 registers
+ 	 *	- psr.ic enabled, interrupts restored
++	 *	-  p10: TRUE if syscall is invoked with more than 8 out
++	 *		registers or r15's Nat is true
+ 	 *	-  r1: kernel's gp
+ 	 *	-  r3: preserved (same as on entry)
++	 *	-  r8: -EINVAL if p10 is true
+ 	 *	- r12: points to kernel stack
+ 	 *	- r13: points to current task
+ 	 *	- p15: TRUE if interrupts need to be re-enabled
+@@ -871,12 +877,17 @@
+ 	;;
+ 
+ 	st8 [r16]=r19,PT(AR_RNAT)-PT(CR_IFS)	// store ar.pfs.pfm in cr.ifs
++	extr.u r11=r19,7,7	// I0		// get sol of ar.pfs
++	and r8=0x7f,r19		// A		// get sof of ar.pfs
++
+ 	st8 [r17]=r27,PT(AR_BSPSTORE)-PT(AR_RSC)// save ar.rsc
++	tbit.nz p15,p0=r29,IA64_PSR_I_BIT // I0
+ (p9)	mov in1=-1
++	;;
+ 
+ (pUStk) sub r18=r18,r22				// r18=RSE.ndirty*8
+-	tbit.nz p15,p0=r29,IA64_PSR_I_BIT
+ 	tnat.nz p10,p0=in2
++	add r11=8,r11
+ 	;;
+ (pKStk) adds r16=PT(PR)-PT(AR_RNAT),r16		// skip over ar_rnat field
+ (pKStk) adds r17=PT(B0)-PT(AR_BSPSTORE),r17	// skip over ar_bspstore field
+@@ -904,25 +915,29 @@
+ (p13)	mov in5=-1
+ 	;;
+ 	st8 [r16]=r21,PT(R8)-PT(AR_FPSR)	// save ar.fpsr
+-	st8.spill [r17]=r15			// save r15
+ 	tnat.nz p14,p0=in6
++	cmp.lt p10,p9=r11,r8	// frame size can't be more than local+8
+ 	;;
+ 	stf8 [r16]=f1		// ensure pt_regs.r8 != 0 (see handle_syscall_error)
++(p9)	tnat.nz p10,p0=r15
+ 	adds r12=-16,r1		// switch to kernel memory stack (with 16 bytes of scratch)
++
++	st8.spill [r17]=r15			// save r15
+ 	tnat.nz p8,p0=in7
++	nop.i 0
+ 
+ 	mov r13=r2				// establish `current'
+ 	movl r1=__gp				// establish kernel global pointer
+ 	;;
+ (p14)	mov in6=-1
+ (p8)	mov in7=-1
+-	tnat.nz p9,p0=r15
++	nop.i 0
+ 
+ 	cmp.eq pSys,pNonSys=r0,r0		// set pSys=1, pNonSys=0
+ 	movl r17=FPSR_DEFAULT
+ 	;;
+ 	mov.m ar.fpsr=r17			// set ar.fpsr to kernel default value
+-(p9)	mov r15=-1
++(p10)	mov r8=-EINVAL
+ 	br.ret.sptk.many b7
+ END(ia64_syscall_setup)
+ 
+diff -urN kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/process.c kernel-source-2.6.8-2.6.8/arch/ia64/kernel/process.c
+--- kernel-source-2.6.8-2.6.8.orig/arch/ia64/kernel/process.c	2004-08-13 23:36:57.000000000 -0600
++++ kernel-source-2.6.8-2.6.8/arch/ia64/kernel/process.c	2005-01-25 22:26:42.000000000 -0700
+@@ -601,7 +601,7 @@
+ 	return 1;	/* f0-f31 are always valid so we always return 1 */
+ }
+ 
+-asmlinkage long
++long
+ sys_execve (char *filename, char **argv, char **envp, struct pt_regs *regs)
+ {
+ 	int error;
+diff -urN kernel-source-2.6.8-2.6.8.orig/include/asm-ia64/unistd.h kernel-source-2.6.8-2.6.8/include/asm-ia64/unistd.h
+--- kernel-source-2.6.8-2.6.8.orig/include/asm-ia64/unistd.h	2004-08-13 23:36:16.000000000 -0600
++++ kernel-source-2.6.8-2.6.8/include/asm-ia64/unistd.h	2005-01-25 22:27:14.000000000 -0700
+@@ -369,7 +369,7 @@
+ 				int fd, long pgoff);
+ struct pt_regs;
+ struct sigaction;
+-asmlinkage long sys_execve(char *filename, char **argv, char **envp,
++long sys_execve(char *filename, char **argv, char **envp,
+ 				struct pt_regs *regs);
+ asmlinkage long sys_pipe(long arg0, long arg1, long arg2, long arg3,
+ 			long arg4, long arg5, long arg6, long arg7, long stack);

Added: trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-speedup.dpatch
===================================================================
--- trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-speedup.dpatch	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-ptrace-speedup.dpatch	2005-01-26 07:22:06 UTC (rev 2410)
@@ -0,0 +1,253 @@
+#! /bin/sh -e
+## <PATCHNAME>.dpatch by <PATCH_AUTHOR@EMAI>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: [IA64] speedup ptrace by avoiding kernel-stack walk
+## DP: Patch author: davidm@hpl.hp.com
+## DP: Upstream status: backported
+
+. $(dirname $0)/DPATCH
+
+@DPATCH@
+# This is a BitKeeper generated diff -Nru style patch.
+#
+# ChangeSet
+#   2004/11/10 15:55:07-08:00 davidm@hpl.hp.com 
+#   [IA64] speedup ptrace by avoiding kernel-stack walk
+#   
+#   This patch changes the syscall entry path to store the
+#   current-frame-mask (CFM) in pt_regs->cr_ifs.  This just takes one
+#   extra instruction (a "dep" to clear the bits other than 0-37) and is
+#   free in terms of cycles.
+#   
+#   The advantage of doing this is that it lets ptrace() avoid having to
+#   walk the stack to determine the end of the user-level backing-store of
+#   a process which is in the middle of a system-call.  Since this is what
+#   strace does all the time, this speeds up strace quite a bit (by ~50%).
+#   More importantly, it makes the syscall vs. non-syscall case much more
+#   symmetric, which is always something I wanted.
+#   
+#   Note that the change to ivt.S looks big but this is just a rippling
+#   effect of instruction-scheduling to keep syscall latency the same.
+#   All that's really going on there is that instead of storing 0 into
+#   cr_ifs member we store the low 38 bits of ar.pfs.
+#   
+#   Signed-off-by: David Mosberger <davidm@hpl.hp.com>
+#   Signed-off-by: Tony Luck <tony.luck@intel.com>
+# 
+# arch/ia64/kernel/ivt.S
+#   2004/11/10 15:48:43-08:00 davidm@hpl.hp.com +16 -15
+#   speedup ptrace by avoiding kernel-stack walk
+# 
+# arch/ia64/kernel/ptrace.c
+#   2004/11/10 15:48:43-08:00 davidm@hpl.hp.com +9 -22
+#   speedup ptrace by avoiding kernel-stack walk
+# 
+# arch/ia64/kernel/signal.c
+#   2004/11/10 15:48:43-08:00 davidm@hpl.hp.com +3 -5
+#   speedup ptrace by avoiding kernel-stack walk
+# 
+# include/asm-ia64/ptrace.h
+#   2004/11/10 15:48:43-08:00 davidm@hpl.hp.com +6 -2
+#   speedup ptrace by avoiding kernel-stack walk
+# 
+diff -Nru a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
+--- a/arch/ia64/kernel/ivt.S	2005-01-25 21:17:44 -08:00
++++ b/arch/ia64/kernel/ivt.S	2005-01-25 21:17:44 -08:00
+@@ -852,7 +852,7 @@
+ 	add r17=PT(R11),r1			// initialize second base pointer
+ 	;;
+ 	alloc r19=ar.pfs,8,0,0,0		// ensure in0-in7 are writable
+-	st8 [r16]=r29,PT(CR_IFS)-PT(CR_IPSR)	// save cr.ipsr
++	st8 [r16]=r29,PT(AR_PFS)-PT(CR_IPSR)	// save cr.ipsr
+ 	tnat.nz p8,p0=in0
+ 
+ 	st8.spill [r17]=r11,PT(CR_IIP)-PT(R11)	// save r11
+@@ -860,31 +860,31 @@
+ (pKStk)	mov r18=r0				// make sure r18 isn't NaT
+ 	;;
+ 
++	st8 [r16]=r26,PT(CR_IFS)-PT(AR_PFS)	// save ar.pfs
+ 	st8 [r17]=r28,PT(AR_UNAT)-PT(CR_IIP)	// save cr.iip
+ 	mov r28=b0				// save b0 (2 cyc)
+-(p8)	mov in0=-1
+ 	;;
+ 
+-	st8 [r16]=r0,PT(AR_PFS)-PT(CR_IFS)	// clear cr.ifs
+ 	st8 [r17]=r25,PT(AR_RSC)-PT(AR_UNAT)	// save ar.unat
+-(p9)	mov in1=-1
++	dep r19=0,r19,38,26			// clear all bits but 0..37 [I0]
++(p8)	mov in0=-1
+ 	;;
+ 
+-	st8 [r16]=r26,PT(AR_RNAT)-PT(AR_PFS)	// save ar.pfs
++	st8 [r16]=r19,PT(AR_RNAT)-PT(CR_IFS)	// store ar.pfs.pfm in cr.ifs
+ 	st8 [r17]=r27,PT(AR_BSPSTORE)-PT(AR_RSC)// save ar.rsc
+-	tnat.nz p10,p0=in2
++(p9)	mov in1=-1
+ 
+ (pUStk) sub r18=r18,r22				// r18=RSE.ndirty*8
+ 	tbit.nz p15,p0=r29,IA64_PSR_I_BIT
+-	tnat.nz p11,p0=in3
++	tnat.nz p10,p0=in2
+ 	;;
+ (pKStk) adds r16=PT(PR)-PT(AR_RNAT),r16		// skip over ar_rnat field
+ (pKStk) adds r17=PT(B0)-PT(AR_BSPSTORE),r17	// skip over ar_bspstore field
++	tnat.nz p11,p0=in3
++	;;
+ (p10)	mov in2=-1
+-
++	tnat.nz p12,p0=in4				// [I0]
+ (p11)	mov in3=-1
+-	tnat.nz p12,p0=in4
+-	tnat.nz p13,p0=in5
+ 	;;
+ (pUStk) st8 [r16]=r24,PT(PR)-PT(AR_RNAT)	// save ar.rnat
+ (pUStk) st8 [r17]=r23,PT(B0)-PT(AR_BSPSTORE)	// save ar.bspstore
+@@ -892,28 +892,29 @@
+ 	;;
+ 	st8 [r16]=r31,PT(LOADRS)-PT(PR)		// save predicates
+ 	st8 [r17]=r28,PT(R1)-PT(B0)		// save b0
+-(p12)	mov in4=-1
++	tnat.nz p13,p0=in5				// [I0]
+ 	;;
+ 	st8 [r16]=r18,PT(R12)-PT(LOADRS)	// save ar.rsc value for "loadrs"
+ 	st8.spill [r17]=r20,PT(R13)-PT(R1)	// save original r1
+-(p13)	mov in5=-1
++(p12)	mov in4=-1
+ 	;;
+ 
+ .mem.offset 0,0; st8.spill [r16]=r12,PT(AR_FPSR)-PT(R12)	// save r12
+ .mem.offset 8,0; st8.spill [r17]=r13,PT(R15)-PT(R13)		// save r13
+-	tnat.nz p14,p0=in6
++(p13)	mov in5=-1
+ 	;;
+ 	st8 [r16]=r21,PT(R8)-PT(AR_FPSR)	// save ar.fpsr
+ 	st8.spill [r17]=r15			// save r15
+-	tnat.nz p8,p0=in7
++	tnat.nz p14,p0=in6
+ 	;;
+ 	stf8 [r16]=f1		// ensure pt_regs.r8 != 0 (see handle_syscall_error)
+ 	adds r12=-16,r1		// switch to kernel memory stack (with 16 bytes of scratch)
+-(p14)	mov in6=-1
++	tnat.nz p8,p0=in7
+ 
+ 	mov r13=r2				// establish `current'
+ 	movl r1=__gp				// establish kernel global pointer
+ 	;;
++(p14)	mov in6=-1
+ (p8)	mov in7=-1
+ 	tnat.nz p9,p0=r15
+ 
+diff -Nru a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
+--- a/arch/ia64/kernel/ptrace.c	2005-01-25 21:17:44 -08:00
++++ b/arch/ia64/kernel/ptrace.c	2005-01-25 21:17:44 -08:00
+@@ -1,7 +1,7 @@
+ /*
+  * Kernel support for the ptrace() and syscall tracing interfaces.
+  *
+- * Copyright (C) 1999-2003 Hewlett-Packard Co
++ * Copyright (C) 1999-2004 Hewlett-Packard Co
+  *	David Mosberger-Tang <davidm@hpl.hp.com>
+  *
+  * Derived from the x86 and Alpha versions.  Most of the code in here
+@@ -304,7 +304,6 @@
+ 	long num_regs, nbits;
+ 	struct pt_regs *pt;
+ 	unsigned long cfm, *urbs_kargs;
+-	struct unw_frame_info info;
+ 
+ 	pt = ia64_task_regs(task);
+ 	kbsp = (unsigned long *) sw->ar_bspstore;
+@@ -316,11 +315,8 @@
+ 		 * If entered via syscall, don't allow user to set rnat bits
+ 		 * for syscall args.
+ 		 */
+-		unw_init_from_blocked_task(&info,task);
+-		if (unw_unwind_to_user(&info) == 0) {
+-			unw_get_cfm(&info,&cfm);
+-			urbs_kargs = ia64_rse_skip_regs(urbs_end,-(cfm & 0x7f));
+-		}
++		cfm = pt->cr_ifs;
++		urbs_kargs = ia64_rse_skip_regs(urbs_end, -(cfm & 0x7f));
+ 	}
+ 
+ 	if (urbs_kargs >= urnat_addr)
+@@ -480,27 +476,18 @@
+ unsigned long
+ ia64_get_user_rbs_end (struct task_struct *child, struct pt_regs *pt, unsigned long *cfmp)
+ {
+-	unsigned long *krbs, *bspstore, cfm;
+-	struct unw_frame_info info;
++	unsigned long *krbs, *bspstore, cfm = pt->cr_ifs;
+ 	long ndirty;
+ 
+ 	krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
+ 	bspstore = (unsigned long *) pt->ar_bspstore;
+ 	ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
+-	cfm = pt->cr_ifs & ~(1UL << 63);
+ 
+-	if (in_syscall(pt)) {
+-		/*
+-		 * If bit 63 of cr.ifs is cleared, the kernel was entered via a system
+-		 * call and we need to recover the CFM that existed on entry to the
+-		 * kernel by unwinding the kernel stack.
+-		 */
+-		unw_init_from_blocked_task(&info, child);
+-		if (unw_unwind_to_user(&info) == 0) {
+-			unw_get_cfm(&info, &cfm);
+-			ndirty += (cfm & 0x7f);
+-		}
+-	}
++	if (in_syscall(pt))
++		ndirty += (cfm & 0x7f);
++	else
++		cfm &= ~(1UL << 63);	/* clear valid bit */
++
+ 	if (cfmp)
+ 		*cfmp = cfm;
+ 	return (unsigned long) ia64_rse_skip_regs(bspstore, ndirty);
+diff -Nru a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
+--- a/arch/ia64/kernel/signal.c	2005-01-25 21:17:44 -08:00
++++ b/arch/ia64/kernel/signal.c	2005-01-25 21:17:44 -08:00
+@@ -290,12 +290,10 @@
+ 
+ 	if (on_sig_stack((unsigned long) sc))
+ 		flags |= IA64_SC_FLAG_ONSTACK;
+-	if ((ifs & (1UL << 63)) == 0) {
+-		/* if cr_ifs isn't valid, we got here through a syscall */
++	if ((ifs & (1UL << 63)) == 0)
++		/* if cr_ifs doesn't have the valid bit set, we got here through a syscall */
+ 		flags |= IA64_SC_FLAG_IN_SYSCALL;
+-		cfm = scr->ar_pfs & ((1UL << 38) - 1);
+-	} else
+-		cfm = ifs & ((1UL << 38) - 1);
++	cfm = ifs & ((1UL << 38) - 1);
+ 	ia64_flush_fph(current);
+ 	if ((current->thread.flags & IA64_THREAD_FPH_VALID)) {
+ 		flags |= IA64_SC_FLAG_FPH_VALID;
+diff -Nru a/include/asm-ia64/ptrace.h b/include/asm-ia64/ptrace.h
+--- a/include/asm-ia64/ptrace.h	2005-01-25 21:17:44 -08:00
++++ b/include/asm-ia64/ptrace.h	2005-01-25 21:17:44 -08:00
+@@ -2,7 +2,7 @@
+ #define _ASM_IA64_PTRACE_H
+ 
+ /*
+- * Copyright (C) 1998-2003 Hewlett-Packard Co
++ * Copyright (C) 1998-2004 Hewlett-Packard Co
+  *	David Mosberger-Tang <davidm@hpl.hp.com>
+  *	Stephane Eranian <eranian@hpl.hp.com>
+  * Copyright (C) 2003 Intel Co
+@@ -110,7 +110,11 @@
+ 
+ 	unsigned long cr_ipsr;		/* interrupted task's psr */
+ 	unsigned long cr_iip;		/* interrupted task's instruction pointer */
+-	unsigned long cr_ifs;		/* interrupted task's function state */
++	/*
++	 * interrupted task's function state; if bit 63 is cleared, it
++	 * contains syscall's ar.pfs.pfm:
++	 */
++	unsigned long cr_ifs;
+ 
+ 	unsigned long ar_unat;		/* interrupted task's NaT register (preserved) */
+ 	unsigned long ar_pfs;		/* prev function state  */

Added: trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-unwind-fix.dpatch
===================================================================
--- trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-unwind-fix.dpatch	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ia64-unwind-fix.dpatch	2005-01-26 07:22:06 UTC (rev 2410)
@@ -0,0 +1,46 @@
+#! /bin/sh -e
+## <PATCHNAME>.dpatch by <PATCH_AUTHOR@EMAI>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: [IA64] Sanity check unw_unwind_to_user
+## DP: Patch author: kaos@sgi.com
+## DP: Upstream status: backported
+
+. $(dirname $0)/DPATCH
+
+@DPATCH@
+# This is a BitKeeper generated diff -Nru style patch.
+#
+# ChangeSet
+#   2005/01/22 12:59:23-08:00 kaos@sgi.com 
+#   [IA64] Sanity check unw_unwind_to_user
+#   
+#   Signed-off-by: Keith Owens <kaos@sgi.com>
+#   Signed-off-by: Tony Luck <tony.luck@intel.com>
+# 
+# arch/ia64/kernel/unwind.c
+#   2005/01/22 12:57:36-08:00 kaos@sgi.com +4 -1
+#   Sanity check unw_unwind_to_user
+# 
+diff -Nru a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
+--- a/arch/ia64/kernel/unwind.c	2005-01-25 22:08:49 -08:00
++++ b/arch/ia64/kernel/unwind.c	2005-01-25 22:08:49 -08:00
+@@ -1945,7 +1945,7 @@
+ int
+ unw_unwind_to_user (struct unw_frame_info *info)
+ {
+-	unsigned long ip;
++	unsigned long ip, sp;
+ 
+ 	while (unw_unwind(info) >= 0) {
+ 		if (unw_get_rp(info, &ip) < 0) {
+@@ -1954,6 +1954,9 @@
+ 				   __FUNCTION__, ip);
+ 			return -1;
+ 		}
++		unw_get_sp(info, &sp);
++		if (sp >= (unsigned long)info->task + IA64_STK_OFFSET)
++			break;
+ 		if (ip < FIXADDR_USER_END)
+ 			return 0;
+ 	}

Modified: trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/series/2.6.8-14
===================================================================
--- trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/series/2.6.8-14	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/series/2.6.8-14	2005-01-26 07:22:06 UTC (rev 2410)
@@ -2,3 +2,7 @@
 + scsi-ioctl-remove-dup.dpatch
 + scsi-ioctl-permit.dpatch
 + scsi-ioctl-quiet.dpatch
++ ia64-ptrace-speedup.dpatch
++ ia64-ptrace-fixes.dpatch
++ ia64-unwind-fix.dpatch
+

Modified: trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/changelog
===================================================================
--- trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/changelog	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/changelog	2005-01-26 07:22:06 UTC (rev 2410)
@@ -1,3 +1,9 @@
+kernel-patch-2.4.27-ia64 (2.4.27-2) UNRELEASED; urgency=high
+
+  * Add ia64-unwind-fix.patch - unw_unwind_to_user sanity check
+
+ -- dann frazier <dannf@debian.org>  Wed, 26 Jan 2005 00:11:23 -0700
+
 kernel-patch-2.4.27-ia64 (2.4.27-1) unstable; urgency=high
 
   * Remove fph_context_check.patch (now upstream in kernel-source)

Modified: trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/rules
===================================================================
--- trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/rules	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/debian/rules	2005-01-26 07:22:06 UTC (rev 2410)
@@ -14,7 +14,7 @@
 topdir=$(shell pwd)
 destdir=${topdir}/debian/tmp
 docdir=${destdir}/usr/share/doc/${PACKAGE}
-patches=lia64-bksnapshot-20040815.diff nodebug.patch
+patches=lia64-bksnapshot-20040815.diff nodebug.patch ia64-unwind-fix.patch
 
 build:	build-stamp
 

Added: trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/ia64-unwind-fix.patch
===================================================================
--- trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/ia64-unwind-fix.patch	2005-01-26 04:36:39 UTC (rev 2409)
+++ trunk/kernel-2.4/ia64/kernel-patch-2.4.27-ia64-2.4.27/ia64-unwind-fix.patch	2005-01-26 07:22:06 UTC (rev 2410)
@@ -0,0 +1,22 @@
+diff -urN kernel-source-2.4.27.orig/arch/ia64/kernel/unwind.c kernel-source-2.4.27/arch/ia64/kernel/unwind.c
+--- kernel-source-2.4.27.orig/arch/ia64/kernel/unwind.c	2004-08-07 17:26:04.000000000 -0600
++++ kernel-source-2.4.27/arch/ia64/kernel/unwind.c	2005-01-26 00:09:22.000000000 -0700
+@@ -1916,7 +1916,7 @@
+ int
+ unw_unwind_to_user (struct unw_frame_info *info)
+ {
+-	unsigned long ip;
++	unsigned long ip, sp;
+ 
+ 	while (unw_unwind(info) >= 0) {
+ 		if (unw_get_rp(info, &ip) < 0) {
+@@ -1925,6 +1925,9 @@
+ 				   __FUNCTION__, ip);
+ 			return -1;
+ 		}
++		unw_get_sp(info, &sp);
++		if (sp >= (unsigned long)info->task + IA64_STK_OFFSET)
++			break;
+ 		/*
+ 		 * We don't have unwind info for the gate page, so we consider that part
+ 		 * of user-space for the purpose of unwinding.