diff options
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r-- | arch/sparc/kernel/helpers.S | 75 | ||||
-rw-r--r-- | arch/sparc/kernel/ptrace_32.c | 4 | ||||
-rw-r--r-- | arch/sparc/kernel/ptrace_64.c | 4 |
3 files changed, 83 insertions, 0 deletions
diff --git a/arch/sparc/kernel/helpers.S b/arch/sparc/kernel/helpers.S index 314dd0c9fc5b..92090cc9e829 100644 --- a/arch/sparc/kernel/helpers.S +++ b/arch/sparc/kernel/helpers.S | |||
@@ -46,6 +46,81 @@ stack_trace_flush: | |||
46 | nop | 46 | nop |
47 | .size stack_trace_flush,.-stack_trace_flush | 47 | .size stack_trace_flush,.-stack_trace_flush |
48 | 48 | ||
49 | #ifdef CONFIG_PERF_EVENTS | ||
50 | .globl perf_arch_fetch_caller_regs | ||
51 | .type perf_arch_fetch_caller_regs,#function | ||
52 | perf_arch_fetch_caller_regs: | ||
53 | /* We always read the %pstate into %o5 since we will use | ||
54 | * that to construct a fake %tstate to store into the regs. | ||
55 | */ | ||
56 | rdpr %pstate, %o5 | ||
57 | brz,pn %o2, 50f | ||
58 | mov %o2, %g7 | ||
59 | |||
60 | /* Turn off interrupts while we walk around the register | ||
61 | * window by hand. | ||
62 | */ | ||
63 | wrpr %o5, PSTATE_IE, %pstate | ||
64 | |||
65 | /* The %canrestore tells us how many register windows are | ||
66 | * still live in the chip above us, past that we have to | ||
67 | * walk the frame as saved on the stack. We stash away | ||
68 | * the %cwp in %g1 so we can return back to the original | ||
69 | * register window. | ||
70 | */ | ||
71 | rdpr %cwp, %g1 | ||
72 | rdpr %canrestore, %g2 | ||
73 | sub %g1, 1, %g3 | ||
74 | |||
75 | /* We have the skip count in %g7, if it hits zero then | ||
76 | * %fp/%i7 are the registers we need. Otherwise if our | ||
77 | * %canrestore count maintained in %g2 hits zero we have | ||
78 | * to start traversing the stack. | ||
79 | */ | ||
80 | 10: brz,pn %g2, 4f | ||
81 | sub %g2, 1, %g2 | ||
82 | wrpr %g3, %cwp | ||
83 | subcc %g7, 1, %g7 | ||
84 | bne,pt %xcc, 10b | ||
85 | sub %g3, 1, %g3 | ||
86 | |||
87 | /* We found the values we need in the cpu's register | ||
88 | * windows. | ||
89 | */ | ||
90 | mov %fp, %g3 | ||
91 | ba,pt %xcc, 3f | ||
92 | mov %i7, %g2 | ||
93 | |||
94 | 50: mov %fp, %g3 | ||
95 | ba,pt %xcc, 2f | ||
96 | mov %i7, %g2 | ||
97 | |||
98 | /* We hit the end of the valid register windows in the | ||
99 | * cpu, start traversing the stack frame. | ||
100 | */ | ||
101 | 4: mov %fp, %g3 | ||
102 | |||
103 | 20: ldx [%g3 + STACK_BIAS + RW_V9_I7], %g2 | ||
104 | subcc %g7, 1, %g7 | ||
105 | bne,pn %xcc, 20b | ||
106 | ldx [%g3 + STACK_BIAS + RW_V9_I6], %g3 | ||
107 | |||
108 | /* Restore the current register window position and | ||
109 | * re-enable interrupts. | ||
110 | */ | ||
111 | 3: wrpr %g1, %cwp | ||
112 | wrpr %o5, %pstate | ||
113 | |||
114 | 2: stx %g3, [%o0 + PT_V9_FP] | ||
115 | sllx %o5, 8, %o5 | ||
116 | stx %o5, [%o0 + PT_V9_TSTATE] | ||
117 | stx %g2, [%o0 + PT_V9_TPC] | ||
118 | add %g2, 4, %g2 | ||
119 | retl | ||
120 | stx %g2, [%o0 + PT_V9_TNPC] | ||
121 | .size perf_arch_fetch_caller_regs,.-perf_arch_fetch_caller_regs | ||
122 | #endif /* CONFIG_PERF_EVENTS */ | ||
123 | |||
49 | #ifdef CONFIG_SMP | 124 | #ifdef CONFIG_SMP |
50 | .globl hard_smp_processor_id | 125 | .globl hard_smp_processor_id |
51 | .type hard_smp_processor_id,#function | 126 | .type hard_smp_processor_id,#function |
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c index 7e3dfd9bb97e..e608f397e11f 100644 --- a/arch/sparc/kernel/ptrace_32.c +++ b/arch/sparc/kernel/ptrace_32.c | |||
@@ -65,6 +65,7 @@ static int genregs32_get(struct task_struct *target, | |||
65 | *k++ = regs->u_regs[pos++]; | 65 | *k++ = regs->u_regs[pos++]; |
66 | 66 | ||
67 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; | 67 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; |
68 | reg_window -= 16; | ||
68 | for (; count > 0 && pos < 32; count--) { | 69 | for (; count > 0 && pos < 32; count--) { |
69 | if (get_user(*k++, ®_window[pos++])) | 70 | if (get_user(*k++, ®_window[pos++])) |
70 | return -EFAULT; | 71 | return -EFAULT; |
@@ -76,6 +77,7 @@ static int genregs32_get(struct task_struct *target, | |||
76 | } | 77 | } |
77 | 78 | ||
78 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; | 79 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; |
80 | reg_window -= 16; | ||
79 | for (; count > 0 && pos < 32; count--) { | 81 | for (; count > 0 && pos < 32; count--) { |
80 | if (get_user(reg, ®_window[pos++]) || | 82 | if (get_user(reg, ®_window[pos++]) || |
81 | put_user(reg, u++)) | 83 | put_user(reg, u++)) |
@@ -141,6 +143,7 @@ static int genregs32_set(struct task_struct *target, | |||
141 | regs->u_regs[pos++] = *k++; | 143 | regs->u_regs[pos++] = *k++; |
142 | 144 | ||
143 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; | 145 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; |
146 | reg_window -= 16; | ||
144 | for (; count > 0 && pos < 32; count--) { | 147 | for (; count > 0 && pos < 32; count--) { |
145 | if (put_user(*k++, ®_window[pos++])) | 148 | if (put_user(*k++, ®_window[pos++])) |
146 | return -EFAULT; | 149 | return -EFAULT; |
@@ -153,6 +156,7 @@ static int genregs32_set(struct task_struct *target, | |||
153 | } | 156 | } |
154 | 157 | ||
155 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; | 158 | reg_window = (unsigned long __user *) regs->u_regs[UREG_I6]; |
159 | reg_window -= 16; | ||
156 | for (; count > 0 && pos < 32; count--) { | 160 | for (; count > 0 && pos < 32; count--) { |
157 | if (get_user(reg, u++) || | 161 | if (get_user(reg, u++) || |
158 | put_user(reg, ®_window[pos++])) | 162 | put_user(reg, ®_window[pos++])) |
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c index 2f6524d1a817..aa90da08bf61 100644 --- a/arch/sparc/kernel/ptrace_64.c +++ b/arch/sparc/kernel/ptrace_64.c | |||
@@ -492,6 +492,7 @@ static int genregs32_get(struct task_struct *target, | |||
492 | *k++ = regs->u_regs[pos++]; | 492 | *k++ = regs->u_regs[pos++]; |
493 | 493 | ||
494 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; | 494 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
495 | reg_window -= 16; | ||
495 | if (target == current) { | 496 | if (target == current) { |
496 | for (; count > 0 && pos < 32; count--) { | 497 | for (; count > 0 && pos < 32; count--) { |
497 | if (get_user(*k++, ®_window[pos++])) | 498 | if (get_user(*k++, ®_window[pos++])) |
@@ -516,6 +517,7 @@ static int genregs32_get(struct task_struct *target, | |||
516 | } | 517 | } |
517 | 518 | ||
518 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; | 519 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
520 | reg_window -= 16; | ||
519 | if (target == current) { | 521 | if (target == current) { |
520 | for (; count > 0 && pos < 32; count--) { | 522 | for (; count > 0 && pos < 32; count--) { |
521 | if (get_user(reg, ®_window[pos++]) || | 523 | if (get_user(reg, ®_window[pos++]) || |
@@ -599,6 +601,7 @@ static int genregs32_set(struct task_struct *target, | |||
599 | regs->u_regs[pos++] = *k++; | 601 | regs->u_regs[pos++] = *k++; |
600 | 602 | ||
601 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; | 603 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
604 | reg_window -= 16; | ||
602 | if (target == current) { | 605 | if (target == current) { |
603 | for (; count > 0 && pos < 32; count--) { | 606 | for (; count > 0 && pos < 32; count--) { |
604 | if (put_user(*k++, ®_window[pos++])) | 607 | if (put_user(*k++, ®_window[pos++])) |
@@ -625,6 +628,7 @@ static int genregs32_set(struct task_struct *target, | |||
625 | } | 628 | } |
626 | 629 | ||
627 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; | 630 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
631 | reg_window -= 16; | ||
628 | if (target == current) { | 632 | if (target == current) { |
629 | for (; count > 0 && pos < 32; count--) { | 633 | for (; count > 0 && pos < 32; count--) { |
630 | if (get_user(reg, u++) || | 634 | if (get_user(reg, u++) || |