hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/alpha/kernel/traps.c
....@@ -121,10 +121,10 @@
121121 }
122122
123123 static void
124
-dik_show_trace(unsigned long *sp)
124
+dik_show_trace(unsigned long *sp, const char *loglvl)
125125 {
126126 long i = 0;
127
- printk("Trace:\n");
127
+ printk("%sTrace:\n", loglvl);
128128 while (0x1ff8 & (unsigned long) sp) {
129129 extern char _stext[], _etext[];
130130 unsigned long tmp = *sp;
....@@ -133,24 +133,24 @@
133133 continue;
134134 if (tmp >= (unsigned long) &_etext)
135135 continue;
136
- printk("[<%lx>] %pSR\n", tmp, (void *)tmp);
136
+ printk("%s[<%lx>] %pSR\n", loglvl, tmp, (void *)tmp);
137137 if (i > 40) {
138
- printk(" ...");
138
+ printk("%s ...", loglvl);
139139 break;
140140 }
141141 }
142
- printk("\n");
142
+ printk("%s\n", loglvl);
143143 }
144144
145145 static int kstack_depth_to_print = 24;
146146
147
-void show_stack(struct task_struct *task, unsigned long *sp)
147
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
148148 {
149149 unsigned long *stack;
150150 int i;
151151
152152 /*
153
- * debugging aid: "show_stack(NULL);" prints the
153
+ * debugging aid: "show_stack(NULL, NULL, KERN_EMERG);" prints the
154154 * back trace for this cpu.
155155 */
156156 if(sp==NULL)
....@@ -163,14 +163,14 @@
163163 if ((i % 4) == 0) {
164164 if (i)
165165 pr_cont("\n");
166
- printk(" ");
166
+ printk("%s ", loglvl);
167167 } else {
168168 pr_cont(" ");
169169 }
170170 pr_cont("%016lx", *stack++);
171171 }
172172 pr_cont("\n");
173
- dik_show_trace(sp);
173
+ dik_show_trace(sp, loglvl);
174174 }
175175
176176 void
....@@ -184,7 +184,7 @@
184184 printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
185185 dik_show_regs(regs, r9_15);
186186 add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
187
- dik_show_trace((unsigned long *)(regs+1));
187
+ dik_show_trace((unsigned long *)(regs+1), KERN_DEFAULT);
188188 dik_show_code((unsigned int *)regs->pc);
189189
190190 if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
....@@ -192,7 +192,7 @@
192192 local_irq_enable();
193193 while (1);
194194 }
195
- do_exit(SIGSEGV);
195
+ make_task_dead(SIGSEGV);
196196 }
197197
198198 #ifndef CONFIG_MATHEMU
....@@ -235,7 +235,21 @@
235235 {
236236 int signo, code;
237237
238
- if ((regs->ps & ~IPL_MAX) == 0) {
238
+ if (type == 3) { /* FEN fault */
239
+ /* Irritating users can call PAL_clrfen to disable the
240
+ FPU for the process. The kernel will then trap in
241
+ do_switch_stack and undo_switch_stack when we try
242
+ to save and restore the FP registers.
243
+
244
+ Given that GCC by default generates code that uses the
245
+ FP registers, PAL_clrfen is not useful except for DoS
246
+ attacks. So turn the bleeding FPU back on and be done
247
+ with it. */
248
+ current_thread_info()->pcb.flags |= 1;
249
+ __reload_thread(&current_thread_info()->pcb);
250
+ return;
251
+ }
252
+ if (!user_mode(regs)) {
239253 if (type == 1) {
240254 const unsigned int *data
241255 = (const unsigned int *) regs->pc;
....@@ -368,20 +382,6 @@
368382 }
369383 break;
370384
371
- case 3: /* FEN fault */
372
- /* Irritating users can call PAL_clrfen to disable the
373
- FPU for the process. The kernel will then trap in
374
- do_switch_stack and undo_switch_stack when we try
375
- to save and restore the FP registers.
376
-
377
- Given that GCC by default generates code that uses the
378
- FP registers, PAL_clrfen is not useful except for DoS
379
- attacks. So turn the bleeding FPU back on and be done
380
- with it. */
381
- current_thread_info()->pcb.flags |= 1;
382
- __reload_thread(&current_thread_info()->pcb);
383
- return;
384
-
385385 case 5: /* illoc */
386386 default: /* unexpected instruction-fault type */
387387 ;
....@@ -402,7 +402,7 @@
402402 {
403403 die_if_kernel("Instruction fault", regs, 0, NULL);
404404
405
- force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current);
405
+ force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0);
406406 }
407407
408408
....@@ -577,7 +577,7 @@
577577
578578 printk("Bad unaligned kernel access at %016lx: %p %lx %lu\n",
579579 pc, va, opcode, reg);
580
- do_exit(SIGSEGV);
580
+ make_task_dead(SIGSEGV);
581581
582582 got_exception:
583583 /* Ok, we caught the exception, but we don't want it. Is there
....@@ -625,14 +625,14 @@
625625 printk("gp = %016lx sp = %p\n", regs->gp, regs+1);
626626
627627 dik_show_code((unsigned int *)pc);
628
- dik_show_trace((unsigned long *)(regs+1));
628
+ dik_show_trace((unsigned long *)(regs+1), KERN_DEFAULT);
629629
630630 if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
631631 printk("die_if_kernel recursion detected.\n");
632632 local_irq_enable();
633633 while (1);
634634 }
635
- do_exit(SIGSEGV);
635
+ make_task_dead(SIGSEGV);
636636 }
637637
638638 /*
....@@ -883,7 +883,7 @@
883883
884884 case 0x26: /* sts */
885885 fake_reg = s_reg_to_mem(alpha_read_fp_reg(reg));
886
- /* FALLTHRU */
886
+ fallthrough;
887887
888888 case 0x2c: /* stl */
889889 __asm__ __volatile__(
....@@ -911,7 +911,7 @@
911911
912912 case 0x27: /* stt */
913913 fake_reg = alpha_read_fp_reg(reg);
914
- /* FALLTHRU */
914
+ fallthrough;
915915
916916 case 0x2d: /* stq */
917917 __asm__ __volatile__(
....@@ -957,12 +957,12 @@
957957 si_code = SEGV_ACCERR;
958958 else {
959959 struct mm_struct *mm = current->mm;
960
- down_read(&mm->mmap_sem);
960
+ mmap_read_lock(mm);
961961 if (find_vma(mm, (unsigned long)va))
962962 si_code = SEGV_ACCERR;
963963 else
964964 si_code = SEGV_MAPERR;
965
- up_read(&mm->mmap_sem);
965
+ mmap_read_unlock(mm);
966966 }
967967 send_sig_fault(SIGSEGV, si_code, va, 0, current);
968968 return;