kernel: bump 5.4 to 5.4.34
[oweals/openwrt.git] / target / linux / generic / backport-5.4 / 300-MIPS-Exclude-more-dsemul-code-when-CONFIG_MIPS_FP_SU.patch
1 From d96c3157f9ca177727fbad960fcf6f52f145f471 Mon Sep 17 00:00:00 2001
2 From: Yousong Zhou <yszhou4tech@gmail.com>
3 Date: Thu, 9 Jan 2020 11:33:19 +0800
4 Subject: [PATCH] MIPS: Exclude more dsemul code when CONFIG_MIPS_FP_SUPPORT=n
5
6 This furthers what commit 42b10815d559 ("MIPS: Don't compile math-emu
7 when CONFIG_MIPS_FP_SUPPORT=n") has done
8
9 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 ---
11  arch/mips/include/asm/processor.h | 12 ++++++------
12  arch/mips/kernel/process.c        | 10 ++++++++--
13  arch/mips/kernel/vdso.c           | 26 +++++++++++++++-----------
14  3 files changed, 29 insertions(+), 19 deletions(-)
15
16 --- a/arch/mips/include/asm/processor.h
17 +++ b/arch/mips/include/asm/processor.h
18 @@ -253,13 +253,13 @@ struct thread_struct {
19  #ifdef CONFIG_MIPS_FP_SUPPORT
20         /* Saved fpu/fpu emulator stuff. */
21         struct mips_fpu_struct fpu FPU_ALIGN;
22 -#endif
23         /* Assigned branch delay slot 'emulation' frame */
24         atomic_t bd_emu_frame;
25         /* PC of the branch from a branch delay slot 'emulation' */
26         unsigned long bd_emu_branch_pc;
27         /* PC to continue from following a branch delay slot 'emulation' */
28         unsigned long bd_emu_cont_pc;
29 +#endif
30  #ifdef CONFIG_MIPS_MT_FPAFF
31         /* Emulated instruction count */
32         unsigned long emulated_fp;
33 @@ -302,7 +302,11 @@ struct thread_struct {
34                 .fpr            = {{{0,},},},                   \
35                 .fcr31          = 0,                            \
36                 .msacsr         = 0,                            \
37 -       },
38 +       },                                                      \
39 +       /* Delay slot emulation */                              \
40 +       .bd_emu_frame = ATOMIC_INIT(BD_EMUFRAME_NONE),          \
41 +       .bd_emu_branch_pc = 0,                                  \
42 +       .bd_emu_cont_pc = 0,
43  #else
44  # define FPU_INIT
45  #endif
46 @@ -334,10 +338,6 @@ struct thread_struct {
47          * FPU affinity state (null if not FPAFF)               \
48          */                                                     \
49         FPAFF_INIT                                              \
50 -       /* Delay slot emulation */                              \
51 -       .bd_emu_frame = ATOMIC_INIT(BD_EMUFRAME_NONE),          \
52 -       .bd_emu_branch_pc = 0,                                  \
53 -       .bd_emu_cont_pc = 0,                                    \
54         /*                                                      \
55          * Saved DSP stuff                                      \
56          */                                                     \
57 --- a/arch/mips/kernel/process.c
58 +++ b/arch/mips/kernel/process.c
59 @@ -75,7 +75,9 @@ void start_thread(struct pt_regs * regs,
60         lose_fpu(0);
61         clear_thread_flag(TIF_MSA_CTX_LIVE);
62         clear_used_math();
63 +#ifdef CONFIG_MIPS_FP_SUPPORT
64         atomic_set(&current->thread.bd_emu_frame, BD_EMUFRAME_NONE);
65 +#endif
66         init_dsp();
67         regs->cp0_epc = pc;
68         regs->regs[29] = sp;
69 @@ -176,7 +178,9 @@ int copy_thread_tls(unsigned long clone_
70         clear_tsk_thread_flag(p, TIF_FPUBOUND);
71  #endif /* CONFIG_MIPS_MT_FPAFF */
72  
73 +#ifdef CONFIG_MIPS_FP_SUPPORT
74         atomic_set(&p->thread.bd_emu_frame, BD_EMUFRAME_NONE);
75 +#endif
76  
77         if (clone_flags & CLONE_SETTLS)
78                 ti->tp_value = tls;
79 @@ -650,8 +654,10 @@ unsigned long mips_stack_top(void)
80  {
81         unsigned long top = TASK_SIZE & PAGE_MASK;
82  
83 -       /* One page for branch delay slot "emulation" */
84 -       top -= PAGE_SIZE;
85 +       if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
86 +               /* One page for branch delay slot "emulation" */
87 +               top -= PAGE_SIZE;
88 +       }
89  
90         /* Space for the VDSO, data page & GIC user page */
91         top -= PAGE_ALIGN(current->thread.abi->vdso->size);
92 --- a/arch/mips/kernel/vdso.c
93 +++ b/arch/mips/kernel/vdso.c
94 @@ -71,10 +71,12 @@ subsys_initcall(init_vdso);
95  
96  static unsigned long vdso_base(void)
97  {
98 -       unsigned long base;
99 +       unsigned long base = STACK_TOP;
100  
101 -       /* Skip the delay slot emulation page */
102 -       base = STACK_TOP + PAGE_SIZE;
103 +       if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
104 +               /* Skip the delay slot emulation page */
105 +               base += PAGE_SIZE;
106 +       }
107  
108         if (current->flags & PF_RANDOMIZE) {
109                 base += get_random_int() & (VDSO_RANDOMIZE_SIZE - 1);
110 @@ -95,14 +97,16 @@ int arch_setup_additional_pages(struct l
111         if (down_write_killable(&mm->mmap_sem))
112                 return -EINTR;
113  
114 -       /* Map delay slot emulation page */
115 -       base = mmap_region(NULL, STACK_TOP, PAGE_SIZE,
116 -                          VM_READ | VM_EXEC |
117 -                          VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
118 -                          0, NULL);
119 -       if (IS_ERR_VALUE(base)) {
120 -               ret = base;
121 -               goto out;
122 +       if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
123 +               /* Map delay slot emulation page */
124 +               base = mmap_region(NULL, STACK_TOP, PAGE_SIZE,
125 +                               VM_READ | VM_EXEC |
126 +                               VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
127 +                               0, NULL);
128 +               if (IS_ERR_VALUE(base)) {
129 +                       ret = base;
130 +                       goto out;
131 +               }
132         }
133  
134         /*