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 diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
17 index 7619ad319400..813ba94d87bb 100644
18 --- a/arch/mips/include/asm/processor.h
19 +++ b/arch/mips/include/asm/processor.h
20 @@ -253,13 +253,13 @@ struct thread_struct {
21 #ifdef CONFIG_MIPS_FP_SUPPORT
22 /* Saved fpu/fpu emulator stuff. */
23 struct mips_fpu_struct fpu FPU_ALIGN;
25 /* Assigned branch delay slot 'emulation' frame */
26 atomic_t bd_emu_frame;
27 /* PC of the branch from a branch delay slot 'emulation' */
28 unsigned long bd_emu_branch_pc;
29 /* PC to continue from following a branch delay slot 'emulation' */
30 unsigned long bd_emu_cont_pc;
32 #ifdef CONFIG_MIPS_MT_FPAFF
33 /* Emulated instruction count */
34 unsigned long emulated_fp;
35 @@ -302,7 +302,11 @@ struct thread_struct {
41 + /* Delay slot emulation */ \
42 + .bd_emu_frame = ATOMIC_INIT(BD_EMUFRAME_NONE), \
43 + .bd_emu_branch_pc = 0, \
44 + .bd_emu_cont_pc = 0,
48 @@ -334,10 +338,6 @@ struct thread_struct {
49 * FPU affinity state (null if not FPAFF) \
52 - /* Delay slot emulation */ \
53 - .bd_emu_frame = ATOMIC_INIT(BD_EMUFRAME_NONE), \
54 - .bd_emu_branch_pc = 0, \
55 - .bd_emu_cont_pc = 0, \
59 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
60 index 339870ed92f7..b2a797557825 100644
61 --- a/arch/mips/kernel/process.c
62 +++ b/arch/mips/kernel/process.c
63 @@ -75,7 +75,9 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
65 clear_thread_flag(TIF_MSA_CTX_LIVE);
67 +#ifdef CONFIG_MIPS_FP_SUPPORT
68 atomic_set(¤t->thread.bd_emu_frame, BD_EMUFRAME_NONE);
73 @@ -176,7 +178,9 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
74 clear_tsk_thread_flag(p, TIF_FPUBOUND);
75 #endif /* CONFIG_MIPS_MT_FPAFF */
77 +#ifdef CONFIG_MIPS_FP_SUPPORT
78 atomic_set(&p->thread.bd_emu_frame, BD_EMUFRAME_NONE);
81 if (clone_flags & CLONE_SETTLS)
83 @@ -650,8 +654,10 @@ unsigned long mips_stack_top(void)
85 unsigned long top = TASK_SIZE & PAGE_MASK;
87 - /* One page for branch delay slot "emulation" */
89 + if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
90 + /* One page for branch delay slot "emulation" */
94 /* Space for the VDSO, data page & GIC user page */
95 top -= PAGE_ALIGN(current->thread.abi->vdso->size);
96 diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
97 index bc35f8499111..3adb7354bc01 100644
98 --- a/arch/mips/kernel/vdso.c
99 +++ b/arch/mips/kernel/vdso.c
100 @@ -71,10 +71,12 @@ subsys_initcall(init_vdso);
102 static unsigned long vdso_base(void)
104 - unsigned long base;
105 + unsigned long base = STACK_TOP;
107 - /* Skip the delay slot emulation page */
108 - base = STACK_TOP + PAGE_SIZE;
109 + if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
110 + /* Skip the delay slot emulation page */
114 if (current->flags & PF_RANDOMIZE) {
115 base += get_random_int() & (VDSO_RANDOMIZE_SIZE - 1);
116 @@ -95,14 +97,16 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
117 if (down_write_killable(&mm->mmap_sem))
120 - /* Map delay slot emulation page */
121 - base = mmap_region(NULL, STACK_TOP, PAGE_SIZE,
122 - VM_READ | VM_EXEC |
123 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
125 - if (IS_ERR_VALUE(base)) {
128 + if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
129 + /* Map delay slot emulation page */
130 + base = mmap_region(NULL, STACK_TOP, PAGE_SIZE,
131 + VM_READ | VM_EXEC |
132 + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
134 + if (IS_ERR_VALUE(base)) {