aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2013-11-19 12:30:35 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-03-31 12:17:12 -0400
commit3351047f01fe012abbb585b400d1c51b57ed011d (patch)
tree50e921b62fda46b18a9528f0e5b14a031afa168c /arch/mips
parentd7b12056bc9cbd7f0c0ae5bc52f2b049d48c4314 (diff)
MIPS: Simplify PTRACE_PEEKUSR for FPC_EIR
All architecturally defined bits in the FPU implementation register are read only & unchanging. It contains some implementation-defined bits but the architecture manual states "This bits are explicitly not intended to be used for mode control functions" which seems to provide justification for viewing the register as a whole as unchanging. This being the case we can simply re-use the value we read at boot rather than having to re-read it later, and avoid the complexity which that read entails. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Reviewed-by: Qais Yousef <qais.yousef@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/6144/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/kernel/ptrace.c40
-rw-r--r--arch/mips/kernel/ptrace32.c42
2 files changed, 6 insertions, 76 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 4137a49eae26..94144bad5727 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -501,44 +501,10 @@ long arch_ptrace(struct task_struct *child, long request,
501 case FPC_CSR: 501 case FPC_CSR:
502 tmp = child->thread.fpu.fcr31; 502 tmp = child->thread.fpu.fcr31;
503 break; 503 break;
504 case FPC_EIR: { /* implementation / version register */ 504 case FPC_EIR:
505 unsigned int flags; 505 /* implementation / version register */
506#ifdef CONFIG_MIPS_MT_SMTC 506 tmp = current_cpu_data.fpu_id;
507 unsigned long irqflags;
508 unsigned int mtflags;
509#endif /* CONFIG_MIPS_MT_SMTC */
510
511 preempt_disable();
512 if (!cpu_has_fpu) {
513 preempt_enable();
514 break;
515 }
516
517#ifdef CONFIG_MIPS_MT_SMTC
518 /* Read-modify-write of Status must be atomic */
519 local_irq_save(irqflags);
520 mtflags = dmt();
521#endif /* CONFIG_MIPS_MT_SMTC */
522 if (cpu_has_mipsmt) {
523 unsigned int vpflags = dvpe();
524 flags = read_c0_status();
525 __enable_fpu(FPU_AS_IS);
526 __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
527 write_c0_status(flags);
528 evpe(vpflags);
529 } else {
530 flags = read_c0_status();
531 __enable_fpu(FPU_AS_IS);
532 __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
533 write_c0_status(flags);
534 }
535#ifdef CONFIG_MIPS_MT_SMTC
536 emt(mtflags);
537 local_irq_restore(irqflags);
538#endif /* CONFIG_MIPS_MT_SMTC */
539 preempt_enable();
540 break; 507 break;
541 }
542 case DSP_BASE ... DSP_BASE + 5: { 508 case DSP_BASE ... DSP_BASE + 5: {
543 dspreg_t *dregs; 509 dspreg_t *dregs;
544 510
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index c394d8f74265..b40c3ca60ee5 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -127,46 +127,10 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
127 case FPC_CSR: 127 case FPC_CSR:
128 tmp = child->thread.fpu.fcr31; 128 tmp = child->thread.fpu.fcr31;
129 break; 129 break;
130 case FPC_EIR: { /* implementation / version register */ 130 case FPC_EIR:
131 unsigned int flags; 131 /* implementation / version register */
132#ifdef CONFIG_MIPS_MT_SMTC 132 tmp = current_cpu_data.fpu_id;
133 unsigned int irqflags;
134 unsigned int mtflags;
135#endif /* CONFIG_MIPS_MT_SMTC */
136
137 preempt_disable();
138 if (!cpu_has_fpu) {
139 preempt_enable();
140 tmp = 0;
141 break;
142 }
143
144#ifdef CONFIG_MIPS_MT_SMTC
145 /* Read-modify-write of Status must be atomic */
146 local_irq_save(irqflags);
147 mtflags = dmt();
148#endif /* CONFIG_MIPS_MT_SMTC */
149
150 if (cpu_has_mipsmt) {
151 unsigned int vpflags = dvpe();
152 flags = read_c0_status();
153 __enable_fpu(FPU_AS_IS);
154 __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
155 write_c0_status(flags);
156 evpe(vpflags);
157 } else {
158 flags = read_c0_status();
159 __enable_fpu(FPU_AS_IS);
160 __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
161 write_c0_status(flags);
162 }
163#ifdef CONFIG_MIPS_MT_SMTC
164 emt(mtflags);
165 local_irq_restore(irqflags);
166#endif /* CONFIG_MIPS_MT_SMTC */
167 preempt_enable();
168 break; 133 break;
169 }
170 case DSP_BASE ... DSP_BASE + 5: { 134 case DSP_BASE ... DSP_BASE + 5: {
171 dspreg_t *dregs; 135 dspreg_t *dregs;
172 136