Skip to content

Commit 475d592

Browse files
committed
Merge branch '3.16-fixes' into mips-for-linux-next
2 parents c6b7b9f + 1062080 commit 475d592

15 files changed

Lines changed: 116 additions & 28 deletions

File tree

‎arch/mips/jz4740/platform.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct platform_device jz4740_usb_ohci_device = {
5959

6060
/* USB Device Controller */
6161
struct platform_device jz4740_udc_xceiv_device = {
62-
.name = "usb_phy_gen_xceiv",
62+
.name = "usb_phy_generic",
6363
.id = 0,
6464
};
6565

‎arch/mips/kernel/ftrace.c‎

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ static inline int in_kernel_space(unsigned long ip)
6363
((unsigned int)(JAL | (((addr) >> 2) & ADDR_MASK)))
6464

6565
static unsigned int insn_jal_ftrace_caller __read_mostly;
66-
static unsigned int insn_lui_v1_hi16_mcount __read_mostly;
66+
static unsigned int insn_la_mcount[2] __read_mostly;
6767
static unsigned int insn_j_ftrace_graph_caller __maybe_unused __read_mostly;
6868

6969
static inline void ftrace_dyn_arch_init_insns(void)
7070
{
7171
u32 *buf;
7272
unsigned int v1;
7373

74-
/* lui v1, hi16_mcount */
74+
/* la v1, _mcount */
7575
v1 = 3;
76-
buf = (u32 *)&insn_lui_v1_hi16_mcount;
77-
UASM_i_LA_mostly(&buf, v1, MCOUNT_ADDR);
76+
buf = (u32 *)&insn_la_mcount[0];
77+
UASM_i_LA(&buf, v1, MCOUNT_ADDR);
7878

7979
/* jal (ftrace_caller + 8), jump over the first two instruction */
8080
buf = (u32 *)&insn_jal_ftrace_caller;
@@ -111,14 +111,47 @@ static int ftrace_modify_code_2(unsigned long ip, unsigned int new_code1,
111111
unsigned int new_code2)
112112
{
113113
int faulted;
114+
mm_segment_t old_fs;
114115

115116
safe_store_code(new_code1, ip, faulted);
116117
if (unlikely(faulted))
117118
return -EFAULT;
118-
safe_store_code(new_code2, ip + 4, faulted);
119+
120+
ip += 4;
121+
safe_store_code(new_code2, ip, faulted);
119122
if (unlikely(faulted))
120123
return -EFAULT;
124+
125+
ip -= 4;
126+
old_fs = get_fs();
127+
set_fs(get_ds());
121128
flush_icache_range(ip, ip + 8);
129+
set_fs(old_fs);
130+
131+
return 0;
132+
}
133+
134+
static int ftrace_modify_code_2r(unsigned long ip, unsigned int new_code1,
135+
unsigned int new_code2)
136+
{
137+
int faulted;
138+
mm_segment_t old_fs;
139+
140+
ip += 4;
141+
safe_store_code(new_code2, ip, faulted);
142+
if (unlikely(faulted))
143+
return -EFAULT;
144+
145+
ip -= 4;
146+
safe_store_code(new_code1, ip, faulted);
147+
if (unlikely(faulted))
148+
return -EFAULT;
149+
150+
old_fs = get_fs();
151+
set_fs(get_ds());
152+
flush_icache_range(ip, ip + 8);
153+
set_fs(old_fs);
154+
122155
return 0;
123156
}
124157
#endif
@@ -130,13 +163,14 @@ static int ftrace_modify_code_2(unsigned long ip, unsigned int new_code1,
130163
*
131164
* move at, ra
132165
* jal _mcount --> nop
166+
* sub sp, sp, 8 --> nop (CONFIG_32BIT)
133167
*
134168
* 2. For modules:
135169
*
136170
* 2.1 For KBUILD_MCOUNT_RA_ADDRESS and CONFIG_32BIT
137171
*
138172
* lui v1, hi_16bit_of_mcount --> b 1f (0x10000005)
139-
* addiu v1, v1, low_16bit_of_mcount
173+
* addiu v1, v1, low_16bit_of_mcount --> nop (CONFIG_32BIT)
140174
* move at, ra
141175
* move $12, ra_address
142176
* jalr v1
@@ -145,7 +179,7 @@ static int ftrace_modify_code_2(unsigned long ip, unsigned int new_code1,
145179
* 2.2 For the Other situations
146180
*
147181
* lui v1, hi_16bit_of_mcount --> b 1f (0x10000004)
148-
* addiu v1, v1, low_16bit_of_mcount
182+
* addiu v1, v1, low_16bit_of_mcount --> nop (CONFIG_32BIT)
149183
* move at, ra
150184
* jalr v1
151185
* nop | move $12, ra_address | sub sp, sp, 8
@@ -184,10 +218,14 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
184218
unsigned int new;
185219
unsigned long ip = rec->ip;
186220

187-
new = in_kernel_space(ip) ? insn_jal_ftrace_caller :
188-
insn_lui_v1_hi16_mcount;
221+
new = in_kernel_space(ip) ? insn_jal_ftrace_caller : insn_la_mcount[0];
189222

223+
#ifdef CONFIG_64BIT
190224
return ftrace_modify_code(ip, new);
225+
#else
226+
return ftrace_modify_code_2r(ip, new, in_kernel_space(ip) ?
227+
INSN_NOP : insn_la_mcount[1]);
228+
#endif
191229
}
192230

193231
#define FTRACE_CALL_IP ((unsigned long)(&ftrace_call))

‎arch/mips/kernel/mcount.S‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ _mcount:
8484
#endif
8585

8686
PTR_SUBU a0, ra, 8 /* arg1: self address */
87+
PTR_LA t1, _stext
88+
sltu t2, a0, t1 /* t2 = (a0 < _stext) */
89+
PTR_LA t1, _etext
90+
sltu t3, t1, a0 /* t3 = (a0 > _etext) */
91+
or t1, t2, t3
92+
beqz t1, ftrace_call
93+
nop
94+
#if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT)
95+
PTR_SUBU a0, a0, 16 /* arg1: adjust to module's recorded callsite */
96+
#else
97+
PTR_SUBU a0, a0, 12
98+
#endif
99+
87100
.globl ftrace_call
88101
ftrace_call:
89102
nop /* a placeholder for the call to a real tracing function */

‎arch/mips/kernel/ptrace.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
150150
}
151151

152152
__get_user(child->thread.fpu.fcr31, data + 64);
153+
child->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X;
153154

154155
/* FIR may not be written. */
155156

@@ -695,7 +696,7 @@ long arch_ptrace(struct task_struct *child, long request,
695696
break;
696697
#endif
697698
case FPC_CSR:
698-
child->thread.fpu.fcr31 = data;
699+
child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X;
699700
break;
700701
case DSP_BASE ... DSP_BASE + 5: {
701702
dspreg_t *dregs;

‎arch/mips/kernel/rtlx-cmp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ int __init rtlx_module_init(void)
7777
dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
7878
"%s%d", RTLX_MODULE_NAME, i);
7979
if (IS_ERR(dev)) {
80+
while (i--)
81+
device_destroy(mt_class, MKDEV(major, i));
82+
8083
err = PTR_ERR(dev);
8184
goto out_chrdev;
8285
}

‎arch/mips/kernel/rtlx-mt.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ int __init rtlx_module_init(void)
103103
dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
104104
"%s%d", RTLX_MODULE_NAME, i);
105105
if (IS_ERR(dev)) {
106+
while (i--)
107+
device_destroy(mt_class, MKDEV(major, i));
108+
106109
err = PTR_ERR(dev);
107110
goto out_chrdev;
108111
}

‎arch/mips/kernel/scall64-n32.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ EXPORT(sysn32_call_table)
162162
PTR sys_getpeername
163163
PTR sys_socketpair
164164
PTR compat_sys_setsockopt
165-
PTR sys_getsockopt
165+
PTR compat_sys_getsockopt
166166
PTR __sys_clone /* 6055 */
167167
PTR __sys_fork
168168
PTR compat_sys_execve

‎arch/mips/kernel/smp-mt.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ struct plat_smp_ops vsmp_smp_ops = {
288288
.prepare_cpus = vsmp_prepare_cpus,
289289
};
290290

291+
#ifdef CONFIG_PROC_FS
291292
static int proc_cpuinfo_chain_call(struct notifier_block *nfb,
292293
unsigned long action_unused, void *data)
293294
{
@@ -309,3 +310,4 @@ static int __init proc_cpuinfo_notifier_init(void)
309310
}
310311

311312
subsys_initcall(proc_cpuinfo_notifier_init);
313+
#endif

‎arch/mips/kernel/unaligned.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ static void emulate_load_store_insn(struct pt_regs *regs,
690690
case sdc1_op:
691691
die_if_kernel("Unaligned FP access in kernel code", regs);
692692
BUG_ON(!used_math());
693-
BUG_ON(!is_fpu_owner());
694693

695694
lose_fpu(1); /* Save FPU state for the emulator. */
696695
res = fpu_emulator_cop1Handler(regs, &current->thread.fpu, 1,

‎arch/mips/math-emu/cp1emu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
18271827
case -1:
18281828

18291829
if (cpu_has_mips_4_5_r)
1830-
cbit = fpucondbit[MIPSInst_RT(ir) >> 2];
1830+
cbit = fpucondbit[MIPSInst_FD(ir) >> 2];
18311831
else
18321832
cbit = FPU_CSR_COND;
18331833
if (rv.w)

0 commit comments

Comments
 (0)