Skip to content

Commit

Permalink
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upst…
Browse files Browse the repository at this point in the history
…ream-linus

Pull MIPS updates from Ralf Baechle:
 "This week's round of MIPS fixes:
   - Fix JZ4740 build
   - Fix fallback to GFP_DMA
   - FP seccomp in case of ENOSYS
   - Fix bootmem panic
   - A number of FP and CPS fixes
   - Wire up new syscalls
   - Make sure BPF assembler objects can properly be disassembled
   - Fix BPF assembler code for MIPS I"

* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus:
  MIPS: scall: Always run the seccomp syscall filters
  MIPS: Octeon: Fix kernel panic on startup from memory corruption
  MIPS: Fix R2300 FP context switch handling
  MIPS: Fix octeon FP context switch handling
  MIPS: BPF: Fix load delay slots.
  MIPS: BPF: Do all exports of symbols with FEXPORT().
  MIPS: Fix the build on jz4740 after removing the custom gpio.h
  MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT
  MIPS: CPS: Don't include MT code in non-MT kernels.
  MIPS: CPS: Stop dangling delay slot from has_mt.
  MIPS: dma-default: Fix 32-bit fall back to GFP_DMA
  MIPS: Wire up userfaultfd and membarrier syscalls.
  • Loading branch information
torvalds committed Oct 4, 2015
2 parents 3e519dd + d218af7 commit 0d87708
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 144 deletions.
2 changes: 1 addition & 1 deletion arch/mips/cavium-octeon/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ void __init plat_mem_setup(void)
while ((boot_mem_map.nr_map < BOOT_MEM_MAP_MAX)
&& (total < MAX_MEMORY)) {
memory = cvmx_bootmem_phy_alloc(mem_alloc_size,
__pa_symbol(&__init_end), -1,
__pa_symbol(&_end), -1,
0x100000,
CVMX_BOOTMEM_FLAG_NO_LOCKING);
if (memory >= 0) {
Expand Down
18 changes: 12 additions & 6 deletions arch/mips/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,18 @@
#define __NR_memfd_create (__NR_Linux + 354)
#define __NR_bpf (__NR_Linux + 355)
#define __NR_execveat (__NR_Linux + 356)
#define __NR_userfaultfd (__NR_Linux + 357)
#define __NR_membarrier (__NR_Linux + 358)

/*
* Offset of the last Linux o32 flavoured syscall
*/
#define __NR_Linux_syscalls 356
#define __NR_Linux_syscalls 358

#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */

#define __NR_O32_Linux 4000
#define __NR_O32_Linux_syscalls 356
#define __NR_O32_Linux_syscalls 358

#if _MIPS_SIM == _MIPS_SIM_ABI64

Expand Down Expand Up @@ -711,16 +713,18 @@
#define __NR_memfd_create (__NR_Linux + 314)
#define __NR_bpf (__NR_Linux + 315)
#define __NR_execveat (__NR_Linux + 316)
#define __NR_userfaultfd (__NR_Linux + 317)
#define __NR_membarrier (__NR_Linux + 318)

/*
* Offset of the last Linux 64-bit flavoured syscall
*/
#define __NR_Linux_syscalls 316
#define __NR_Linux_syscalls 318

#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */

#define __NR_64_Linux 5000
#define __NR_64_Linux_syscalls 316
#define __NR_64_Linux_syscalls 318

#if _MIPS_SIM == _MIPS_SIM_NABI32

Expand Down Expand Up @@ -1049,15 +1053,17 @@
#define __NR_memfd_create (__NR_Linux + 318)
#define __NR_bpf (__NR_Linux + 319)
#define __NR_execveat (__NR_Linux + 320)
#define __NR_userfaultfd (__NR_Linux + 321)
#define __NR_membarrier (__NR_Linux + 322)

/*
* Offset of the last N32 flavoured syscall
*/
#define __NR_Linux_syscalls 320
#define __NR_Linux_syscalls 322

#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */

#define __NR_N32_Linux 6000
#define __NR_N32_Linux_syscalls 320
#define __NR_N32_Linux_syscalls 322

#endif /* _UAPI_ASM_UNISTD_H */
1 change: 1 addition & 0 deletions arch/mips/jz4740/board-qi_lb60.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/power/jz4740-battery.h>
#include <linux/power/gpio-charger.h>

#include <asm/mach-jz4740/gpio.h>
#include <asm/mach-jz4740/jz4740_fb.h>
#include <asm/mach-jz4740/jz4740_mmc.h>
#include <asm/mach-jz4740/jz4740_nand.h>
Expand Down
1 change: 1 addition & 0 deletions arch/mips/jz4740/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/seq_file.h>

#include <asm/mach-jz4740/base.h>
#include <asm/mach-jz4740/gpio.h>

#define JZ4740_GPIO_BASE_A (32*0)
#define JZ4740_GPIO_BASE_B (32*1)
Expand Down
12 changes: 7 additions & 5 deletions arch/mips/kernel/cps-vec.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
mfc0 \dest, CP0_CONFIG, 3
andi \dest, \dest, MIPS_CONF3_MT
beqz \dest, \nomt
nop
.endm

.section .text.cps-vec
Expand Down Expand Up @@ -223,10 +224,9 @@ LEAF(excep_ejtag)
END(excep_ejtag)

LEAF(mips_cps_core_init)
#ifdef CONFIG_MIPS_MT
#ifdef CONFIG_MIPS_MT_SMP
/* Check that the core implements the MT ASE */
has_mt t0, 3f
nop

.set push
.set mips64r2
Expand Down Expand Up @@ -310,8 +310,9 @@ LEAF(mips_cps_boot_vpes)
PTR_ADDU t0, t0, t1

/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
li t9, 0
#ifdef CONFIG_MIPS_MT_SMP
has_mt ta2, 1f
li t9, 0

/* Find the number of VPEs present in the core */
mfc0 t1, CP0_MVPCONF0
Expand All @@ -330,14 +331,15 @@ LEAF(mips_cps_boot_vpes)
/* Retrieve the VPE ID from EBase.CPUNum */
mfc0 t9, $15, 1
and t9, t9, t1
#endif

1: /* Calculate a pointer to this VPEs struct vpe_boot_config */
li t1, VPEBOOTCFG_SIZE
mul v0, t9, t1
PTR_L ta3, COREBOOTCFG_VPECONFIG(t0)
PTR_ADDU v0, v0, ta3

#ifdef CONFIG_MIPS_MT
#ifdef CONFIG_MIPS_MT_SMP

/* If the core doesn't support MT then return */
bnez ta2, 1f
Expand Down Expand Up @@ -451,7 +453,7 @@ LEAF(mips_cps_boot_vpes)

2: .set pop

#endif /* CONFIG_MIPS_MT */
#endif /* CONFIG_MIPS_MT_SMP */

/* Return */
jr ra
Expand Down
26 changes: 1 addition & 25 deletions arch/mips/kernel/octeon_switch.S
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.set pop
/*
* task_struct *resume(task_struct *prev, task_struct *next,
* struct thread_info *next_ti, int usedfpu)
* struct thread_info *next_ti)
*/
.align 7
LEAF(resume)
Expand All @@ -28,30 +28,6 @@
cpu_save_nonscratch a0
LONG_S ra, THREAD_REG31(a0)

/*
* check if we need to save FPU registers
*/
.set push
.set noreorder
beqz a3, 1f
PTR_L t3, TASK_THREAD_INFO(a0)
.set pop

/*
* clear saved user stack CU1 bit
*/
LONG_L t0, ST_OFF(t3)
li t1, ~ST0_CU1
and t0, t0, t1
LONG_S t0, ST_OFF(t3)

.set push
.set arch=mips64r2
fpu_save_double a0 t0 t1 # c0_status passed in t0
# clobbers t1
.set pop
1:

#if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
/* Check if we need to store CVMSEG state */
dmfc0 t0, $11,7 /* CvmMemCtl */
Expand Down
28 changes: 1 addition & 27 deletions arch/mips/kernel/r2300_switch.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,16 @@
*/
#define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS)

/*
* FPU context is saved iff the process has used it's FPU in the current
* time slice as indicated by TIF_USEDFPU. In any case, the CU1 bit for user
* space STATUS register should be 0, so that a process *always* starts its
* userland with FPU disabled after each context switch.
*
* FPU will be enabled as soon as the process accesses FPU again, through
* do_cpu() trap.
*/

/*
* task_struct *resume(task_struct *prev, task_struct *next,
* struct thread_info *next_ti, int usedfpu)
* struct thread_info *next_ti)
*/
LEAF(resume)
mfc0 t1, CP0_STATUS
sw t1, THREAD_STATUS(a0)
cpu_save_nonscratch a0
sw ra, THREAD_REG31(a0)

beqz a3, 1f

PTR_L t3, TASK_THREAD_INFO(a0)

/*
* clear saved user stack CU1 bit
*/
lw t0, ST_OFF(t3)
li t1, ~ST0_CU1
and t0, t0, t1
sw t0, ST_OFF(t3)

fpu_save_single a0, t0 # clobbers t0

1:

#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
PTR_LA t8, __stack_chk_guard
LONG_L t9, TASK_STACK_CANARY(a1)
Expand Down
41 changes: 18 additions & 23 deletions arch/mips/kernel/scall32-o32.S
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,8 @@ NESTED(handle_sys, PT_SIZE, sp)
lw t1, PT_EPC(sp) # skip syscall on return

subu v0, v0, __NR_O32_Linux # check syscall number
sltiu t0, v0, __NR_O32_Linux_syscalls + 1
addiu t1, 4 # skip to next instruction
sw t1, PT_EPC(sp)
beqz t0, illegal_syscall

sll t0, v0, 2
la t1, sys_call_table
addu t1, t0
lw t2, (t1) # syscall routine
beqz t2, illegal_syscall

sw a3, PT_R26(sp) # save a3 for syscall restarting

Expand Down Expand Up @@ -96,6 +88,16 @@ loads_done:
li t1, _TIF_WORK_SYSCALL_ENTRY
and t0, t1
bnez t0, syscall_trace_entry # -> yes
syscall_common:
sltiu t0, v0, __NR_O32_Linux_syscalls + 1
beqz t0, illegal_syscall

sll t0, v0, 2
la t1, sys_call_table
addu t1, t0
lw t2, (t1) # syscall routine

beqz t2, illegal_syscall

jalr t2 # Do The Real Thing (TM)

Expand All @@ -116,7 +118,7 @@ o32_syscall_exit:

syscall_trace_entry:
SAVE_STATIC
move s0, t2
move s0, v0
move a0, sp

/*
Expand All @@ -129,27 +131,18 @@ syscall_trace_entry:

1: jal syscall_trace_enter

bltz v0, 2f # seccomp failed? Skip syscall
bltz v0, 1f # seccomp failed? Skip syscall

move v0, s0 # restore syscall

move t0, s0
RESTORE_STATIC
lw a0, PT_R4(sp) # Restore argument registers
lw a1, PT_R5(sp)
lw a2, PT_R6(sp)
lw a3, PT_R7(sp)
jalr t0

li t0, -EMAXERRNO - 1 # error?
sltu t0, t0, v0
sw t0, PT_R7(sp) # set error flag
beqz t0, 1f

lw t1, PT_R2(sp) # syscall number
negu v0 # error
sw t1, PT_R0(sp) # save it for syscall restarting
1: sw v0, PT_R2(sp) # result
j syscall_common

2: j syscall_exit
1: j syscall_exit

/* ------------------------------------------------------------------------ */

Expand Down Expand Up @@ -599,3 +592,5 @@ EXPORT(sys_call_table)
PTR sys_memfd_create
PTR sys_bpf /* 4355 */
PTR sys_execveat
PTR sys_userfaultfd
PTR sys_membarrier
40 changes: 18 additions & 22 deletions arch/mips/kernel/scall64-64.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ NESTED(handle_sys64, PT_SIZE, sp)
.set at
#endif

dsubu t0, v0, __NR_64_Linux # check syscall number
sltiu t0, t0, __NR_64_Linux_syscalls + 1
#if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
ld t1, PT_EPC(sp) # skip syscall on return
daddiu t1, 4 # skip to next instruction
sd t1, PT_EPC(sp)
#endif
beqz t0, illegal_syscall

dsll t0, v0, 3 # offset into table
ld t2, (sys_call_table - (__NR_64_Linux * 8))(t0)
# syscall routine

sd a3, PT_R26(sp) # save a3 for syscall restarting

Expand All @@ -59,6 +52,17 @@ NESTED(handle_sys64, PT_SIZE, sp)
and t0, t1, t0
bnez t0, syscall_trace_entry

syscall_common:
dsubu t2, v0, __NR_64_Linux
sltiu t0, t2, __NR_64_Linux_syscalls + 1
beqz t0, illegal_syscall

dsll t0, t2, 3 # offset into table
dla t2, sys_call_table
daddu t0, t2, t0
ld t2, (t0) # syscall routine
beqz t2, illegal_syscall

jalr t2 # Do The Real Thing (TM)

li t0, -EMAXERRNO - 1 # error?
Expand All @@ -78,34 +82,24 @@ n64_syscall_exit:

syscall_trace_entry:
SAVE_STATIC
move s0, t2
move s0, v0
move a0, sp
move a1, v0
jal syscall_trace_enter

bltz v0, 2f # seccomp failed? Skip syscall
bltz v0, 1f # seccomp failed? Skip syscall

move t0, s0
move v0, s0
RESTORE_STATIC
ld a0, PT_R4(sp) # Restore argument registers
ld a1, PT_R5(sp)
ld a2, PT_R6(sp)
ld a3, PT_R7(sp)
ld a4, PT_R8(sp)
ld a5, PT_R9(sp)
jalr t0

li t0, -EMAXERRNO - 1 # error?
sltu t0, t0, v0
sd t0, PT_R7(sp) # set error flag
beqz t0, 1f

ld t1, PT_R2(sp) # syscall number
dnegu v0 # error
sd t1, PT_R0(sp) # save it for syscall restarting
1: sd v0, PT_R2(sp) # result
j syscall_common

2: j syscall_exit
1: j syscall_exit

illegal_syscall:
/* This also isn't a 64-bit syscall, throw an error. */
Expand Down Expand Up @@ -436,4 +430,6 @@ EXPORT(sys_call_table)
PTR sys_memfd_create
PTR sys_bpf /* 5315 */
PTR sys_execveat
PTR sys_userfaultfd
PTR sys_membarrier
.size sys_call_table,.-sys_call_table
Loading

0 comments on commit 0d87708

Please sign in to comment.