forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/sh/kernel/traps_32.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * 'traps.c' handles hardware traps and faults after we have saved some
34 * state in 'entry.S'.
....@@ -6,10 +7,6 @@
67 * Copyright (C) 2000 Philipp Rumpf
78 * Copyright (C) 2000 David Howells
89 * Copyright (C) 2002 - 2010 Paul Mundt
9
- *
10
- * This file is subject to the terms and conditions of the GNU General Public
11
- * License. See the file "COPYING" in the main directory of this archive
12
- * for more details.
1310 */
1411 #include <linux/kernel.h>
1512 #include <linux/ptrace.h>
....@@ -485,8 +482,6 @@
485482 error_code = lookup_exception_vector();
486483 #endif
487484
488
- oldfs = get_fs();
489
-
490485 if (user_mode(regs)) {
491486 int si_code = BUS_ADRERR;
492487 unsigned int user_action;
....@@ -494,13 +489,13 @@
494489 local_irq_enable();
495490 inc_unaligned_user_access();
496491
497
- set_fs(USER_DS);
492
+ oldfs = force_uaccess_begin();
498493 if (copy_from_user(&instruction, (insn_size_t *)(regs->pc & ~1),
499494 sizeof(instruction))) {
500
- set_fs(oldfs);
495
+ force_uaccess_end(oldfs);
501496 goto uspace_segv;
502497 }
503
- set_fs(oldfs);
498
+ force_uaccess_end(oldfs);
504499
505500 /* shout about userspace fixups */
506501 unaligned_fixups_notify(current, instruction, regs);
....@@ -523,11 +518,11 @@
523518 goto uspace_segv;
524519 }
525520
526
- set_fs(USER_DS);
521
+ oldfs = force_uaccess_begin();
527522 tmp = handle_unaligned_access(instruction, regs,
528523 &user_mem_access, 0,
529524 address);
530
- set_fs(oldfs);
525
+ force_uaccess_end(oldfs);
531526
532527 if (tmp == 0)
533528 return; /* sorted */
....@@ -536,7 +531,7 @@
536531 "access (PC %lx PR %lx)\n", current->comm, regs->pc,
537532 regs->pr);
538533
539
- force_sig_fault(SIGBUS, si_code, (void __user *)address, current);
534
+ force_sig_fault(SIGBUS, si_code, (void __user *)address);
540535 } else {
541536 inc_unaligned_kernel_access();
542537
....@@ -606,7 +601,7 @@
606601 /* Let gcc know unhandled cases don't make it past here */
607602 return;
608603 }
609
- force_sig_fault(SIGFPE, code, NULL, current);
604
+ force_sig_fault(SIGFPE, code, NULL);
610605 }
611606 #endif
612607
....@@ -614,7 +609,6 @@
614609 {
615610 struct pt_regs *regs = current_pt_regs();
616611 unsigned long error_code;
617
- struct task_struct *tsk = current;
618612
619613 #ifdef CONFIG_SH_FPU_EMU
620614 unsigned short inst = 0;
....@@ -636,7 +630,7 @@
636630 /* Enable DSP mode, and restart instruction. */
637631 regs->sr |= SR_DSP;
638632 /* Save DSP mode */
639
- tsk->thread.dsp_status.status |= SR_DSP;
633
+ current->thread.dsp_status.status |= SR_DSP;
640634 return;
641635 }
642636 #endif
....@@ -644,7 +638,7 @@
644638 error_code = lookup_exception_vector();
645639
646640 local_irq_enable();
647
- force_sig(SIGILL, tsk);
641
+ force_sig(SIGILL);
648642 die_if_no_fixup("reserved instruction", regs, error_code);
649643 }
650644
....@@ -700,7 +694,6 @@
700694 {
701695 struct pt_regs *regs = current_pt_regs();
702696 unsigned long inst;
703
- struct task_struct *tsk = current;
704697
705698 if (kprobe_handle_illslot(regs->pc) == 0)
706699 return;
....@@ -719,7 +712,7 @@
719712 inst = lookup_exception_vector();
720713
721714 local_irq_enable();
722
- force_sig(SIGILL, tsk);
715
+ force_sig(SIGILL);
723716 die_if_no_fixup("illegal slot instruction", regs, inst);
724717 }
725718