From: Dale Farnsworth <[EMAIL PROTECTED]>

    When implemented in inline assembly, kgdb_fault_setjmp() and
    kgdb_fault_longjmp() fail when compiled with -fno-omit-frame-pointer.
    This patch avoids that problem by moving them to separate assembly
    files, arch/ppc/kernel/kgdb_misc.S and arch/powerpc/kernel/kgdb_misc.S.

    Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---

I tested this patch on 8555_cds and Maple (970FX).  Not exhaustive, but
it's a start.

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index d017037..6a3b543 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -60,7 +60,7 @@ obj-$(CONFIG_BOOTX_TEXT)      += btext.o
 obj-$(CONFIG_SMP)              += smp.o
 obj-$(CONFIG_KPROBES)          += kprobes.o
 obj-$(CONFIG_PPC_UDBG_16550)   += legacy_serial.o udbg_16550.o
-obj-$(CONFIG_KGDB)             += kgdb.o
+obj-$(CONFIG_KGDB)             += kgdb.o kgdb_misc.o
 module-$(CONFIG_PPC64)         += module_64.o
 obj-$(CONFIG_MODULES)          += $(module-y)
 
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 9d5aaf8..f061c65 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -7,7 +7,6 @@
  *
  * Copied from arch/ppc/kernel/kgdb.c, updated for ppc64
  *
- * Copyright (C) 1996 Paul Mackerras (setjmp/longjmp)
  * 1998 (c) Michael AK Tesch ([EMAIL PROTECTED])
  * Copyright (C) 2003 Timesys Corporation.
  * Copyright (C) 2004-2006 MontaVista Software, Inc.
@@ -469,78 +468,6 @@ #endif
        return -1;
 }
 
-int kgdb_fault_setjmp(unsigned long *curr_context)
-{
-#ifdef CONFIG_PPC32
-        __asm__ __volatile__("mflr 0; stw 0,0(%0);\n\
-                              stw 1,4(%0); stw 2,8(%0);\n\
-                              mfcr 0; stw 0,12(%0);\n\
-                              stmw 13,16(%0)\n" : : "r" (curr_context));
-#else
-       __asm__ __volatile__("mflr 0; std 0,0(%0)\n\
-                             std       1,8(%0)\n\
-                             std       2,16(%0)\n\
-                             mfcr 0; std 0,24(%0)\n\
-                             std       13,32(%0)\n\
-                             std       14,40(%0)\n\
-                             std       15,48(%0)\n\
-                             std       16,56(%0)\n\
-                             std       17,64(%0)\n\
-                             std       18,72(%0)\n\
-                             std       19,80(%0)\n\
-                             std       20,88(%0)\n\
-                             std       21,96(%0)\n\
-                             std       22,104(%0)\n\
-                             std       23,112(%0)\n\
-                             std       24,120(%0)\n\
-                             std       25,128(%0)\n\
-                             std       26,136(%0)\n\
-                             std       27,144(%0)\n\
-                             std       28,152(%0)\n\
-                             std       29,160(%0)\n\
-                             std       30,168(%0)\n\
-                             std       31,176(%0)\n" : : "r" (curr_context));
-#endif
-       return 0;
-}
-
-void kgdb_fault_longjmp(unsigned long *curr_context)
-{
-#ifdef CONFIG_PPC32
-       __asm__ __volatile__("lmw 13,16(%0);\n\
-                             lwz 0,12(%0); mtcrf 0x38,0;\n\
-                             lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);\n\
-                             mtlr 0; mr 3,1\n" : : "r" (curr_context));
-#else
-       __asm__ __volatile__("ld        13,32(%0)\n\
-                             ld        14,40(%0)\n\
-                             ld        15,48(%0)\n\
-                             ld        16,56(%0)\n\
-                             ld        17,64(%0)\n\
-                             ld        18,72(%0)\n\
-                             ld        19,80(%0)\n\
-                             ld        20,88(%0)\n\
-                             ld        21,96(%0)\n\
-                             ld        22,104(%0)\n\
-                             ld        23,112(%0)\n\
-                             ld        24,120(%0)\n\
-                             ld        25,128(%0)\n\
-                             ld        26,136(%0)\n\
-                             ld        27,144(%0)\n\
-                             ld        28,152(%0)\n\
-                             ld        29,160(%0)\n\
-                             ld        30,168(%0)\n\
-                             ld        31,176(%0)\n\
-                             ld        0,24(%0)\n\
-                             mtcrf     0x38,0\n\
-                             ld        0,0(%0)\n\
-                             ld        1,8(%0)\n\
-                             ld        2,16(%0)\n\
-                             mtlr      0\n\
-                             mr        3,1\n" : : "r" (curr_context));
-#endif
-}
-
 /*
  * Global data
  */
diff --git a/arch/powerpc/kernel/kgdb_misc.S b/arch/powerpc/kernel/kgdb_misc.S
index e69de29..190da72 100644
--- a/arch/powerpc/kernel/kgdb_misc.S
+++ b/arch/powerpc/kernel/kgdb_misc.S
@@ -0,0 +1,111 @@
+/*
+ * arch/ppc/kernel/kgdb_setjmp.S
+ *
+ * Copyright (C) 1996 Paul Mackerras
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program as licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <asm/ppc_asm.h>
+
+       .text
+
+/*
+ * kgdb_fault_setjmp() and kgdb_fault_longjmp() were moved from inline
+ * assembly in arch/powerpc/kernel/kgdb.c so they won't be mangled by
+ * -no-omit-frame-pointer
+ *
+ * Save/restore state in case a memory access causes a fault.
+ *
+ * int kgdb_fault_setjmp(unsigned long *curr_context);
+ * void kgdb_fault_longjmp(unsigned long *curr_context);
+ */
+
+#ifdef CONFIG_PPC32
+
+_GLOBAL(kgdb_fault_setjmp)
+       mflr    r0
+       stw     r0,0(r3)
+       stw     r1,4(r3)
+       stw     r2,8(r3)
+       mfcr    r0
+       stw     r0,12(r3)
+       stmw    r13,16(r3)
+       li      r3,0
+       blr
+
+_GLOBAL(kgdb_fault_longjmp)
+       lmw     r13,16(r3)
+       lwz     r0,12(r3)
+       mtcrf   0x38,r0
+       lwz     r0,0(r3)
+       lwz     r1,4(r3)
+       lwz     r2,8(r3)
+       mtlr    r0
+       mr      r3,r1
+       blr
+
+#else
+
+_GLOBAL(kgdb_fault_setjmp)
+       mflr    r0
+       std     r0,0(r3)
+       std     r1,8(r3)
+       std     r2,16(r3)
+       mfcr    r0
+       std     r0,24(r3)
+       std     r13,32(r3)
+       std     r14,40(r3)
+       std     r15,48(r3)
+       std     r16,56(r3)
+       std     r17,64(r3)
+       std     r18,72(r3)
+       std     r19,80(r3)
+       std     r20,88(r3)
+       std     r21,96(r3)
+       std     r22,104(r3)
+       std     r23,112(r3)
+       std     r24,120(r3)
+       std     r25,128(r3)
+       std     r26,136(r3)
+       std     r27,144(r3)
+       std     r28,152(r3)
+       std     r29,160(r3)
+       std     r30,168(r3)
+       std     r31,176(r3)
+       li      r3,0
+       blr
+
+_GLOBAL(kgdb_fault_longjmp)
+       ld      r13,32(r3)
+       ld      r14,40(r3)
+       ld      r15,48(r3)
+       ld      r16,56(r3)
+       ld      r17,64(r3)
+       ld      r18,72(r3)
+       ld      r19,80(r3)
+       ld      r20,88(r3)
+       ld      r21,96(r3)
+       ld      r22,104(r3)
+       ld      r23,112(r3)
+       ld      r24,120(r3)
+       ld      r25,128(r3)
+       ld      r26,136(r3)
+       ld      r27,144(r3)
+       ld      r28,152(r3)
+       ld      r29,160(r3)
+       ld      r30,168(r3)
+       ld      r31,176(r3)
+       ld      r0,24(r3)
+       mtcrf   0x38,r0
+       ld      r0,0(r3)
+       ld      r1,8(r3)
+       ld      r2,16(r3)
+       mtlr    r0
+       mr      r3,r1
+       blr
+#endif
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
index 466437f..b8a10cd 100644
--- a/arch/ppc/kernel/Makefile
+++ b/arch/ppc/kernel/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_MODULES)         += ppc_ksyms.o
 obj-$(CONFIG_NOT_COHERENT_CACHE)       += dma-mapping.o
 obj-$(CONFIG_PCI)              += pci.o
 obj-$(CONFIG_RAPIDIO)          += rio.o
-obj-$(CONFIG_KGDB)             += ppc-stub.o
+obj-$(CONFIG_KGDB)             += kgdb.o kgdb_misc.o
 obj-$(CONFIG_SMP)              += smp.o smp-tbsync.o
 obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o
 
diff --git a/arch/ppc/kernel/kgdb.c b/arch/ppc/kernel/kgdb.c
index d1cfda5..51c2a28 100644
--- a/arch/ppc/kernel/kgdb.c
+++ b/arch/ppc/kernel/kgdb.c
@@ -246,26 +246,6 @@ #endif
 }
 
 /*
- * Save/restore state in case a memory access causes a fault.
- */
-int kgdb_fault_setjmp(unsigned long *curr_context)
-{
-       __asm__ __volatile__("mflr 0; stw 0,0(%0);"
-                            "stw 1,4(%0); stw 2,8(%0);"
-                            "mfcr 0; stw 0,12(%0);"
-                            "stmw 13,16(%0)"::"r"(curr_context));
-       return 0;
-}
-
-void kgdb_fault_longjmp(unsigned long *curr_context)
-{
-       __asm__ __volatile__("lmw 13,16(%0);"
-                            "lwz 0,12(%0); mtcrf 0x38,0;"
-                            "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);"
-                            "mtlr 0; mr 3,1"::"r"(curr_context));
-}
-
-/*
  * This function does PoerPC specific procesing for interfacing to gdb.
  */
 int kgdb_arch_handle_exception(int vector, int signo, int err_code,
diff --git a/arch/ppc/kernel/kgdb_misc.S b/arch/ppc/kernel/kgdb_misc.S
index e69de29..4cec5a8 100644
--- a/arch/ppc/kernel/kgdb_misc.S
+++ b/arch/ppc/kernel/kgdb_misc.S
@@ -0,0 +1,49 @@
+/*
+ * arch/ppc/kernel/kgdb_setjmp.S
+ *
+ *
+ * Copyright (C) 1996 Paul Mackerras
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program as licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <asm/ppc_asm.h>
+
+       .text
+
+/*
+ * kgdb_fault_setjmp() and kgdb_fault_longjmp() were moved from inline
+ * assembly in arch/powerpc/kernel/kgdb.c so they won't be mangled by
+ * -no-omit-frame-pointer
+ *
+ * Save/restore state in case a memory access causes a fault.
+ *
+ * int kgdb_fault_setjmp(unsigned long *curr_context);
+ * void kgdb_fault_longjmp(unsigned long *curr_context);
+ */
+
+_GLOBAL(kgdb_fault_setjmp)
+       mflr    r0
+       stw     r0,0(r3)
+       stw     r1,4(r3)
+       stw     r2,8(r3)
+       mfcr    r0
+       stw     r0,12(r3)
+       stmw    r13,16(r3)
+       li      r3,0
+       blr
+
+_GLOBAL(kgdb_fault_longjmp)
+       lmw     r13,16(r3)
+       lwz     r0,12(r3)
+       mtcrf   0x38,r0
+       lwz     r0,0(r3)
+       lwz     r1,4(r3)
+       lwz     r2,8(r3)
+       mtlr    r0
+       mr      r3,r1
+       blr

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to