Thumb-2: Implementation of the unified start-up and exceptions code
[deliverable/linux.git] / arch / arm / kernel / unwind.c
index 1dedc2c7ff4973974aa00cfde9f887c2936ef629..39baf1128bfa16c82a805ce668cc797e9d82e44e 100644 (file)
@@ -62,7 +62,11 @@ struct unwind_ctrl_block {
 };
 
 enum regs {
+#ifdef CONFIG_THUMB2_KERNEL
+       FP = 7,
+#else
        FP = 11,
+#endif
        SP = 13,
        LR = 14,
        PC = 15
@@ -212,7 +216,8 @@ static int unwind_exec_insn(struct unwind_ctrl_block *ctrl)
                        ctrl->vrs[14] = *vsp++;
                ctrl->vrs[SP] = (unsigned long)vsp;
        } else if (insn == 0xb0) {
-               ctrl->vrs[PC] = ctrl->vrs[LR];
+               if (ctrl->vrs[PC] == 0)
+                       ctrl->vrs[PC] = ctrl->vrs[LR];
                /* no further processing */
                ctrl->entries = 0;
        } else if (insn == 0xb1) {
@@ -309,18 +314,20 @@ int unwind_frame(struct stackframe *frame)
        }
 
        while (ctrl.entries > 0) {
-               int urc;
-
-               if (ctrl.vrs[SP] < low || ctrl.vrs[SP] >= high)
-                       return -URC_FAILURE;
-               urc = unwind_exec_insn(&ctrl);
+               int urc = unwind_exec_insn(&ctrl);
                if (urc < 0)
                        return urc;
+               if (ctrl.vrs[SP] < low || ctrl.vrs[SP] >= high)
+                       return -URC_FAILURE;
        }
 
        if (ctrl.vrs[PC] == 0)
                ctrl.vrs[PC] = ctrl.vrs[LR];
 
+       /* check for infinite loop */
+       if (frame->pc == ctrl.vrs[PC])
+               return -URC_FAILURE;
+
        frame->fp = ctrl.vrs[FP];
        frame->sp = ctrl.vrs[SP];
        frame->lr = ctrl.vrs[LR];
@@ -332,7 +339,6 @@ int unwind_frame(struct stackframe *frame)
 void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 {
        struct stackframe frame;
-       unsigned long high, low;
        register unsigned long current_sp asm ("sp");
 
        pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
@@ -362,9 +368,6 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                frame.pc = thread_saved_pc(tsk);
        }
 
-       low = frame.sp & ~(THREAD_SIZE - 1);
-       high = low + THREAD_SIZE;
-
        while (1) {
                int urc;
                unsigned long where = frame.pc;
This page took 0.026975 seconds and 5 git commands to generate.