Commit 42cc77c861e8e850e86252bb5b1e12e006261973

Authored by David S. Miller
1 parent 1c339eb183

sparc64: Reschedule KGDB capture to a software interrupt.

Otherwise it might interrupt switch_to() midstream and use
half-cooked register window state.

Reported-by: Chris Torek <chris.torek@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 4 changed files with 10 additions and 24 deletions Side-by-side Diff

arch/sparc/include/asm/pil.h
... ... @@ -24,6 +24,7 @@
24 24 #define PIL_DEVICE_IRQ 5
25 25 #define PIL_SMP_CALL_FUNC_SNGL 6
26 26 #define PIL_DEFERRED_PCR_WORK 7
  27 +#define PIL_KGDB_CAPTURE 8
27 28 #define PIL_NORMAL_MAX 14
28 29 #define PIL_NMI 15
29 30  
arch/sparc/kernel/kgdb_64.c
... ... @@ -108,7 +108,7 @@
108 108 }
109 109  
110 110 #ifdef CONFIG_SMP
111   -void smp_kgdb_capture_client(struct pt_regs *regs)
  111 +void smp_kgdb_capture_client(int irq, struct pt_regs *regs)
112 112 {
113 113 unsigned long flags;
114 114  
arch/sparc/kernel/ttable.S
... ... @@ -64,7 +64,12 @@
64 64 tl0_irq6: BTRAP(0x46)
65 65 #endif
66 66 tl0_irq7: TRAP_IRQ(deferred_pcr_work_irq, 7)
67   -tl0_irq8: BTRAP(0x48) BTRAP(0x49)
  67 +#ifdef CONFIG_KGDB
  68 +tl0_irq8: TRAP_IRQ(smp_kgdb_capture_client, 8)
  69 +#else
  70 +tl0_irq8: BTRAP(0x48)
  71 +#endif
  72 +tl0_irq9: BTRAP(0x49)
68 73 tl0_irq10: BTRAP(0x4a) BTRAP(0x4b) BTRAP(0x4c) BTRAP(0x4d)
69 74 tl0_irq14: TRAP_IRQ(timer_interrupt, 14)
70 75 tl0_irq15: TRAP_NMI_IRQ(perfctr_irq, 15)
arch/sparc/mm/ultra.S
... ... @@ -679,28 +679,8 @@
679 679 #ifdef CONFIG_KGDB
680 680 .globl xcall_kgdb_capture
681 681 xcall_kgdb_capture:
682   -661: rdpr %pstate, %g2
683   - wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
684   - .section .sun4v_2insn_patch, "ax"
685   - .word 661b
686   - nop
687   - nop
688   - .previous
689   -
690   - rdpr %pil, %g2
691   - wrpr %g0, PIL_NORMAL_MAX, %pil
692   - sethi %hi(109f), %g7
693   - ba,pt %xcc, etrap_irq
694   -109: or %g7, %lo(109b), %g7
695   -#ifdef CONFIG_TRACE_IRQFLAGS
696   - call trace_hardirqs_off
697   - nop
698   -#endif
699   - call smp_kgdb_capture_client
700   - add %sp, PTREGS_OFF, %o0
701   - /* Has to be a non-v9 branch due to the large distance. */
702   - ba rtrap_xcall
703   - ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
  682 + wr %g0, (1 << PIL_KGDB_CAPTURE), %set_softint
  683 + retry
704 684 #endif
705 685  
706 686 #endif /* CONFIG_SMP */