hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/mips/kernel/signal.c
....@@ -52,7 +52,7 @@
5252 /* Matches struct ucontext from its uc_mcontext field onwards */
5353 struct sigcontext sf_sc;
5454 sigset_t sf_mask;
55
- unsigned long long sf_extcontext[0];
55
+ unsigned long long sf_extcontext[];
5656 };
5757
5858 struct rt_sigframe {
....@@ -61,6 +61,8 @@
6161 struct siginfo rs_info;
6262 struct ucontext rs_uc;
6363 };
64
+
65
+#ifdef CONFIG_MIPS_FP_SUPPORT
6466
6567 /*
6668 * Thread saved context copy to/from a signal context presumed to be on the
....@@ -104,6 +106,20 @@
104106 return err;
105107 }
106108
109
+#else /* !CONFIG_MIPS_FP_SUPPORT */
110
+
111
+static int copy_fp_to_sigcontext(void __user *sc)
112
+{
113
+ return 0;
114
+}
115
+
116
+static int copy_fp_from_sigcontext(void __user *sc)
117
+{
118
+ return 0;
119
+}
120
+
121
+#endif /* !CONFIG_MIPS_FP_SUPPORT */
122
+
107123 /*
108124 * Wrappers for the assembly _{save,restore}_fp_context functions.
109125 */
....@@ -141,6 +157,8 @@
141157 uc = container_of(sc, struct ucontext, uc_mcontext);
142158 return &uc->uc_extcontext;
143159 }
160
+
161
+#ifdef CONFIG_CPU_HAS_MSA
144162
145163 static int save_msa_extcontext(void __user *buf)
146164 {
....@@ -195,9 +213,6 @@
195213 unsigned int csr;
196214 int i, err;
197215
198
- if (!IS_ENABLED(CONFIG_CPU_HAS_MSA))
199
- return SIGSYS;
200
-
201216 if (size != sizeof(*msa))
202217 return -EINVAL;
203218
....@@ -233,6 +248,20 @@
233248
234249 return err;
235250 }
251
+
252
+#else /* !CONFIG_CPU_HAS_MSA */
253
+
254
+static int save_msa_extcontext(void __user *buf)
255
+{
256
+ return 0;
257
+}
258
+
259
+static int restore_msa_extcontext(void __user *buf, unsigned int size)
260
+{
261
+ return SIGSYS;
262
+}
263
+
264
+#endif /* !CONFIG_CPU_HAS_MSA */
236265
237266 static int save_extcontext(void __user *buf)
238267 {
....@@ -516,6 +545,12 @@
516545 return err ?: protected_restore_fp_context(sc);
517546 }
518547
548
+#ifdef CONFIG_WAR_ICACHE_REFILLS
549
+#define SIGMASK ~(cpu_icache_line_size()-1)
550
+#else
551
+#define SIGMASK ALMASK
552
+#endif
553
+
519554 void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
520555 size_t frame_size)
521556 {
....@@ -536,7 +571,7 @@
536571
537572 sp = sigsp(sp, ksig);
538573
539
- return (void __user *)((sp - frame_size) & (ICACHE_REFILLS_WORKAROUND_WAR ? ~(cpu_icache_line_size()-1) : ALMASK));
574
+ return (void __user *)((sp - frame_size) & SIGMASK);
540575 }
541576
542577 /*
....@@ -561,7 +596,7 @@
561596 if (act) {
562597 old_sigset_t mask;
563598
564
- if (!access_ok(VERIFY_READ, act, sizeof(*act)))
599
+ if (!access_ok(act, sizeof(*act)))
565600 return -EFAULT;
566601 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
567602 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
....@@ -575,7 +610,7 @@
575610 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
576611
577612 if (!ret && oact) {
578
- if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
613
+ if (!access_ok(oact, sizeof(*oact)))
579614 return -EFAULT;
580615 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
581616 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
....@@ -601,7 +636,7 @@
601636
602637 regs = current_pt_regs();
603638 frame = (struct sigframe __user *)regs->regs[29];
604
- if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
639
+ if (!access_ok(frame, sizeof(*frame)))
605640 goto badframe;
606641 if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
607642 goto badframe;
....@@ -612,7 +647,7 @@
612647 if (sig < 0)
613648 goto badframe;
614649 else if (sig)
615
- force_sig(sig, current);
650
+ force_sig(sig);
616651
617652 /*
618653 * Don't let your children do this ...
....@@ -625,7 +660,7 @@
625660 /* Unreached */
626661
627662 badframe:
628
- force_sig(SIGSEGV, current);
663
+ force_sig(SIGSEGV);
629664 }
630665 #endif /* CONFIG_TRAD_SIGNALS */
631666
....@@ -638,7 +673,7 @@
638673
639674 regs = current_pt_regs();
640675 frame = (struct rt_sigframe __user *)regs->regs[29];
641
- if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
676
+ if (!access_ok(frame, sizeof(*frame)))
642677 goto badframe;
643678 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
644679 goto badframe;
....@@ -649,7 +684,7 @@
649684 if (sig < 0)
650685 goto badframe;
651686 else if (sig)
652
- force_sig(sig, current);
687
+ force_sig(sig);
653688
654689 if (restore_altstack(&frame->rs_uc.uc_stack))
655690 goto badframe;
....@@ -665,7 +700,7 @@
665700 /* Unreached */
666701
667702 badframe:
668
- force_sig(SIGSEGV, current);
703
+ force_sig(SIGSEGV);
669704 }
670705
671706 #ifdef CONFIG_TRAD_SIGNALS
....@@ -676,7 +711,7 @@
676711 int err = 0;
677712
678713 frame = get_sigframe(ksig, regs, sizeof(*frame));
679
- if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
714
+ if (!access_ok(frame, sizeof (*frame)))
680715 return -EFAULT;
681716
682717 err |= setup_sigcontext(regs, &frame->sf_sc);
....@@ -715,7 +750,7 @@
715750 int err = 0;
716751
717752 frame = get_sigframe(ksig, regs, sizeof(*frame));
718
- if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
753
+ if (!access_ok(frame, sizeof (*frame)))
719754 return -EFAULT;
720755
721756 /* Create siginfo. */
....@@ -795,7 +830,7 @@
795830 regs->regs[2] = EINTR;
796831 break;
797832 }
798
- /* fallthrough */
833
+ fallthrough;
799834 case ERESTARTNOINTR:
800835 regs->regs[7] = regs->regs[26];
801836 regs->regs[2] = regs->regs[0];
....@@ -868,11 +903,10 @@
868903 uprobe_notify_resume(regs);
869904
870905 /* deal with pending signal delivery */
871
- if (thread_info_flags & _TIF_SIGPENDING)
906
+ if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
872907 do_signal(regs);
873908
874909 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
875
- clear_thread_flag(TIF_NOTIFY_RESUME);
876910 tracehook_notify_resume(regs);
877911 rseq_handle_notify_resume(NULL, regs);
878912 }
....@@ -880,7 +914,7 @@
880914 user_enter();
881915 }
882916
883
-#ifdef CONFIG_SMP
917
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS_FP_SUPPORT)
884918 static int smp_save_fp_context(void __user *sc)
885919 {
886920 return raw_cpu_has_fpu
....@@ -908,7 +942,7 @@
908942 (offsetof(struct rt_sigframe, rs_uc.uc_extcontext) -
909943 offsetof(struct rt_sigframe, rs_uc.uc_mcontext)));
910944
911
-#ifdef CONFIG_SMP
945
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS_FP_SUPPORT)
912946 /* For now just do the cpu_has_fpu check when the functions are invoked */
913947 save_fp_context = smp_save_fp_context;
914948 restore_fp_context = smp_restore_fp_context;