Signed-Off-By Milind Dumbare <milind@linsyssoft.com>

 kgdb.c |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Index: linux-2.6.18-rc7/arch/ppc/kernel/kgdb.c
===================================================================
--- linux-2.6.18-rc7.orig/arch/ppc/kernel/kgdb.c	2006-10-13 17:06:25.000000000 +0100
+++ linux-2.6.18-rc7/arch/ppc/kernel/kgdb.c	2006-10-13 17:09:54.000000000 +0100
@@ -105,10 +105,31 @@ static int kgdb_breakpoint(struct pt_reg
 
 static int kgdb_singlestep(struct pt_regs *regs)
 {
+	struct thread_info *thread_info, *exception_thread_info;
+
 	if (user_mode(regs))
 		return 0;
+	/*
+	* On Book E and perhaps other processsors, singlestep is handled on
+	* the critical exception stack.  This causes current_thread_info()
+	* to fail, since it it locates the thread_info by masking off
+	* the low bits of the current stack pointer.  We work around
+	* this issue by copying the thread_info from the kernel stack
+	* before calling kgdb_handle_exception, and copying it back
+	* afterwards.  On most processors the copy is avoided since
+	* exception_thread_info == thread_info.
+	*/
+	thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
+	exception_thread_info = current_thread_info();
+
+	if (thread_info != exception_thread_info)
+		memcpy(exception_thread_info, thread_info, sizeof *thread_info);
 
 	kgdb_handle_exception(0, SIGTRAP, 0, regs);
+
+	if (thread_info != exception_thread_info)
+		memcpy(thread_info, exception_thread_info, sizeof *thread_info);
+
 	return 1;
 }