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
6 This furthers what commit 42b10815d559 ("MIPS: Don't compile math-emu
7 when CONFIG_MIPS_FP_SUPPORT=n") has done
9 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
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(-)
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;
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;
30 #ifdef CONFIG_MIPS_MT_FPAFF
31 /* Emulated instruction count */
32 unsigned long emulated_fp;
33 @@ -302,7 +302,11 @@ struct thread_struct {
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,
46 @@ -334,10 +338,6 @@ struct thread_struct {
47 * FPU affinity state (null if not FPAFF) \
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, \
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,
61 clear_thread_flag(TIF_MSA_CTX_LIVE);
63 +#ifdef CONFIG_MIPS_FP_SUPPORT
64 atomic_set(¤t->thread.bd_emu_frame, BD_EMUFRAME_NONE);
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 */
73 +#ifdef CONFIG_MIPS_FP_SUPPORT
74 atomic_set(&p->thread.bd_emu_frame, BD_EMUFRAME_NONE);
77 if (clone_flags & CLONE_SETTLS)
79 @@ -650,8 +654,10 @@ unsigned long mips_stack_top(void)
81 unsigned long top = TASK_SIZE & PAGE_MASK;
83 - /* One page for branch delay slot "emulation" */
85 + if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
86 + /* One page for branch delay slot "emulation" */
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);
96 static unsigned long vdso_base(void)
99 + unsigned long base = STACK_TOP;
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 */
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))
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,
119 - if (IS_ERR_VALUE(base)) {
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,
128 + if (IS_ERR_VALUE(base)) {