| .. | .. |
|---|
| 52 | 52 | /* Matches struct ucontext from its uc_mcontext field onwards */ |
|---|
| 53 | 53 | struct sigcontext sf_sc; |
|---|
| 54 | 54 | sigset_t sf_mask; |
|---|
| 55 | | - unsigned long long sf_extcontext[0]; |
|---|
| 55 | + unsigned long long sf_extcontext[]; |
|---|
| 56 | 56 | }; |
|---|
| 57 | 57 | |
|---|
| 58 | 58 | struct rt_sigframe { |
|---|
| .. | .. |
|---|
| 61 | 61 | struct siginfo rs_info; |
|---|
| 62 | 62 | struct ucontext rs_uc; |
|---|
| 63 | 63 | }; |
|---|
| 64 | + |
|---|
| 65 | +#ifdef CONFIG_MIPS_FP_SUPPORT |
|---|
| 64 | 66 | |
|---|
| 65 | 67 | /* |
|---|
| 66 | 68 | * Thread saved context copy to/from a signal context presumed to be on the |
|---|
| .. | .. |
|---|
| 104 | 106 | return err; |
|---|
| 105 | 107 | } |
|---|
| 106 | 108 | |
|---|
| 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 | + |
|---|
| 107 | 123 | /* |
|---|
| 108 | 124 | * Wrappers for the assembly _{save,restore}_fp_context functions. |
|---|
| 109 | 125 | */ |
|---|
| .. | .. |
|---|
| 141 | 157 | uc = container_of(sc, struct ucontext, uc_mcontext); |
|---|
| 142 | 158 | return &uc->uc_extcontext; |
|---|
| 143 | 159 | } |
|---|
| 160 | + |
|---|
| 161 | +#ifdef CONFIG_CPU_HAS_MSA |
|---|
| 144 | 162 | |
|---|
| 145 | 163 | static int save_msa_extcontext(void __user *buf) |
|---|
| 146 | 164 | { |
|---|
| .. | .. |
|---|
| 195 | 213 | unsigned int csr; |
|---|
| 196 | 214 | int i, err; |
|---|
| 197 | 215 | |
|---|
| 198 | | - if (!IS_ENABLED(CONFIG_CPU_HAS_MSA)) |
|---|
| 199 | | - return SIGSYS; |
|---|
| 200 | | - |
|---|
| 201 | 216 | if (size != sizeof(*msa)) |
|---|
| 202 | 217 | return -EINVAL; |
|---|
| 203 | 218 | |
|---|
| .. | .. |
|---|
| 233 | 248 | |
|---|
| 234 | 249 | return err; |
|---|
| 235 | 250 | } |
|---|
| 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 */ |
|---|
| 236 | 265 | |
|---|
| 237 | 266 | static int save_extcontext(void __user *buf) |
|---|
| 238 | 267 | { |
|---|
| .. | .. |
|---|
| 516 | 545 | return err ?: protected_restore_fp_context(sc); |
|---|
| 517 | 546 | } |
|---|
| 518 | 547 | |
|---|
| 548 | +#ifdef CONFIG_WAR_ICACHE_REFILLS |
|---|
| 549 | +#define SIGMASK ~(cpu_icache_line_size()-1) |
|---|
| 550 | +#else |
|---|
| 551 | +#define SIGMASK ALMASK |
|---|
| 552 | +#endif |
|---|
| 553 | + |
|---|
| 519 | 554 | void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, |
|---|
| 520 | 555 | size_t frame_size) |
|---|
| 521 | 556 | { |
|---|
| .. | .. |
|---|
| 536 | 571 | |
|---|
| 537 | 572 | sp = sigsp(sp, ksig); |
|---|
| 538 | 573 | |
|---|
| 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); |
|---|
| 540 | 575 | } |
|---|
| 541 | 576 | |
|---|
| 542 | 577 | /* |
|---|
| .. | .. |
|---|
| 561 | 596 | if (act) { |
|---|
| 562 | 597 | old_sigset_t mask; |
|---|
| 563 | 598 | |
|---|
| 564 | | - if (!access_ok(VERIFY_READ, act, sizeof(*act))) |
|---|
| 599 | + if (!access_ok(act, sizeof(*act))) |
|---|
| 565 | 600 | return -EFAULT; |
|---|
| 566 | 601 | err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler); |
|---|
| 567 | 602 | err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags); |
|---|
| .. | .. |
|---|
| 575 | 610 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
|---|
| 576 | 611 | |
|---|
| 577 | 612 | if (!ret && oact) { |
|---|
| 578 | | - if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact))) |
|---|
| 613 | + if (!access_ok(oact, sizeof(*oact))) |
|---|
| 579 | 614 | return -EFAULT; |
|---|
| 580 | 615 | err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); |
|---|
| 581 | 616 | err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler); |
|---|
| .. | .. |
|---|
| 601 | 636 | |
|---|
| 602 | 637 | regs = current_pt_regs(); |
|---|
| 603 | 638 | frame = (struct sigframe __user *)regs->regs[29]; |
|---|
| 604 | | - if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
|---|
| 639 | + if (!access_ok(frame, sizeof(*frame))) |
|---|
| 605 | 640 | goto badframe; |
|---|
| 606 | 641 | if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked))) |
|---|
| 607 | 642 | goto badframe; |
|---|
| .. | .. |
|---|
| 612 | 647 | if (sig < 0) |
|---|
| 613 | 648 | goto badframe; |
|---|
| 614 | 649 | else if (sig) |
|---|
| 615 | | - force_sig(sig, current); |
|---|
| 650 | + force_sig(sig); |
|---|
| 616 | 651 | |
|---|
| 617 | 652 | /* |
|---|
| 618 | 653 | * Don't let your children do this ... |
|---|
| .. | .. |
|---|
| 625 | 660 | /* Unreached */ |
|---|
| 626 | 661 | |
|---|
| 627 | 662 | badframe: |
|---|
| 628 | | - force_sig(SIGSEGV, current); |
|---|
| 663 | + force_sig(SIGSEGV); |
|---|
| 629 | 664 | } |
|---|
| 630 | 665 | #endif /* CONFIG_TRAD_SIGNALS */ |
|---|
| 631 | 666 | |
|---|
| .. | .. |
|---|
| 638 | 673 | |
|---|
| 639 | 674 | regs = current_pt_regs(); |
|---|
| 640 | 675 | frame = (struct rt_sigframe __user *)regs->regs[29]; |
|---|
| 641 | | - if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
|---|
| 676 | + if (!access_ok(frame, sizeof(*frame))) |
|---|
| 642 | 677 | goto badframe; |
|---|
| 643 | 678 | if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set))) |
|---|
| 644 | 679 | goto badframe; |
|---|
| .. | .. |
|---|
| 649 | 684 | if (sig < 0) |
|---|
| 650 | 685 | goto badframe; |
|---|
| 651 | 686 | else if (sig) |
|---|
| 652 | | - force_sig(sig, current); |
|---|
| 687 | + force_sig(sig); |
|---|
| 653 | 688 | |
|---|
| 654 | 689 | if (restore_altstack(&frame->rs_uc.uc_stack)) |
|---|
| 655 | 690 | goto badframe; |
|---|
| .. | .. |
|---|
| 665 | 700 | /* Unreached */ |
|---|
| 666 | 701 | |
|---|
| 667 | 702 | badframe: |
|---|
| 668 | | - force_sig(SIGSEGV, current); |
|---|
| 703 | + force_sig(SIGSEGV); |
|---|
| 669 | 704 | } |
|---|
| 670 | 705 | |
|---|
| 671 | 706 | #ifdef CONFIG_TRAD_SIGNALS |
|---|
| .. | .. |
|---|
| 676 | 711 | int err = 0; |
|---|
| 677 | 712 | |
|---|
| 678 | 713 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
|---|
| 679 | | - if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
|---|
| 714 | + if (!access_ok(frame, sizeof (*frame))) |
|---|
| 680 | 715 | return -EFAULT; |
|---|
| 681 | 716 | |
|---|
| 682 | 717 | err |= setup_sigcontext(regs, &frame->sf_sc); |
|---|
| .. | .. |
|---|
| 715 | 750 | int err = 0; |
|---|
| 716 | 751 | |
|---|
| 717 | 752 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
|---|
| 718 | | - if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
|---|
| 753 | + if (!access_ok(frame, sizeof (*frame))) |
|---|
| 719 | 754 | return -EFAULT; |
|---|
| 720 | 755 | |
|---|
| 721 | 756 | /* Create siginfo. */ |
|---|
| .. | .. |
|---|
| 795 | 830 | regs->regs[2] = EINTR; |
|---|
| 796 | 831 | break; |
|---|
| 797 | 832 | } |
|---|
| 798 | | - /* fallthrough */ |
|---|
| 833 | + fallthrough; |
|---|
| 799 | 834 | case ERESTARTNOINTR: |
|---|
| 800 | 835 | regs->regs[7] = regs->regs[26]; |
|---|
| 801 | 836 | regs->regs[2] = regs->regs[0]; |
|---|
| .. | .. |
|---|
| 868 | 903 | uprobe_notify_resume(regs); |
|---|
| 869 | 904 | |
|---|
| 870 | 905 | /* deal with pending signal delivery */ |
|---|
| 871 | | - if (thread_info_flags & _TIF_SIGPENDING) |
|---|
| 906 | + if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) |
|---|
| 872 | 907 | do_signal(regs); |
|---|
| 873 | 908 | |
|---|
| 874 | 909 | if (thread_info_flags & _TIF_NOTIFY_RESUME) { |
|---|
| 875 | | - clear_thread_flag(TIF_NOTIFY_RESUME); |
|---|
| 876 | 910 | tracehook_notify_resume(regs); |
|---|
| 877 | 911 | rseq_handle_notify_resume(NULL, regs); |
|---|
| 878 | 912 | } |
|---|
| .. | .. |
|---|
| 880 | 914 | user_enter(); |
|---|
| 881 | 915 | } |
|---|
| 882 | 916 | |
|---|
| 883 | | -#ifdef CONFIG_SMP |
|---|
| 917 | +#if defined(CONFIG_SMP) && defined(CONFIG_MIPS_FP_SUPPORT) |
|---|
| 884 | 918 | static int smp_save_fp_context(void __user *sc) |
|---|
| 885 | 919 | { |
|---|
| 886 | 920 | return raw_cpu_has_fpu |
|---|
| .. | .. |
|---|
| 908 | 942 | (offsetof(struct rt_sigframe, rs_uc.uc_extcontext) - |
|---|
| 909 | 943 | offsetof(struct rt_sigframe, rs_uc.uc_mcontext))); |
|---|
| 910 | 944 | |
|---|
| 911 | | -#ifdef CONFIG_SMP |
|---|
| 945 | +#if defined(CONFIG_SMP) && defined(CONFIG_MIPS_FP_SUPPORT) |
|---|
| 912 | 946 | /* For now just do the cpu_has_fpu check when the functions are invoked */ |
|---|
| 913 | 947 | save_fp_context = smp_save_fp_context; |
|---|
| 914 | 948 | restore_fp_context = smp_restore_fp_context; |
|---|