Commit 0d877081 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-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.
parents 3e519dde d218af78
...@@ -933,7 +933,7 @@ void __init plat_mem_setup(void) ...@@ -933,7 +933,7 @@ void __init plat_mem_setup(void)
while ((boot_mem_map.nr_map < BOOT_MEM_MAP_MAX) while ((boot_mem_map.nr_map < BOOT_MEM_MAP_MAX)
&& (total < MAX_MEMORY)) { && (total < MAX_MEMORY)) {
memory = cvmx_bootmem_phy_alloc(mem_alloc_size, memory = cvmx_bootmem_phy_alloc(mem_alloc_size,
__pa_symbol(&__init_end), -1, __pa_symbol(&_end), -1,
0x100000, 0x100000,
CVMX_BOOTMEM_FLAG_NO_LOCKING); CVMX_BOOTMEM_FLAG_NO_LOCKING);
if (memory >= 0) { if (memory >= 0) {
......
...@@ -377,16 +377,18 @@ ...@@ -377,16 +377,18 @@
#define __NR_memfd_create (__NR_Linux + 354) #define __NR_memfd_create (__NR_Linux + 354)
#define __NR_bpf (__NR_Linux + 355) #define __NR_bpf (__NR_Linux + 355)
#define __NR_execveat (__NR_Linux + 356) #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 * Offset of the last Linux o32 flavoured syscall
*/ */
#define __NR_Linux_syscalls 356 #define __NR_Linux_syscalls 358
#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
#define __NR_O32_Linux 4000 #define __NR_O32_Linux 4000
#define __NR_O32_Linux_syscalls 356 #define __NR_O32_Linux_syscalls 358
#if _MIPS_SIM == _MIPS_SIM_ABI64 #if _MIPS_SIM == _MIPS_SIM_ABI64
...@@ -711,16 +713,18 @@ ...@@ -711,16 +713,18 @@
#define __NR_memfd_create (__NR_Linux + 314) #define __NR_memfd_create (__NR_Linux + 314)
#define __NR_bpf (__NR_Linux + 315) #define __NR_bpf (__NR_Linux + 315)
#define __NR_execveat (__NR_Linux + 316) #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 * 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 */ #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
#define __NR_64_Linux 5000 #define __NR_64_Linux 5000
#define __NR_64_Linux_syscalls 316 #define __NR_64_Linux_syscalls 318
#if _MIPS_SIM == _MIPS_SIM_NABI32 #if _MIPS_SIM == _MIPS_SIM_NABI32
...@@ -1049,15 +1053,17 @@ ...@@ -1049,15 +1053,17 @@
#define __NR_memfd_create (__NR_Linux + 318) #define __NR_memfd_create (__NR_Linux + 318)
#define __NR_bpf (__NR_Linux + 319) #define __NR_bpf (__NR_Linux + 319)
#define __NR_execveat (__NR_Linux + 320) #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 * Offset of the last N32 flavoured syscall
*/ */
#define __NR_Linux_syscalls 320 #define __NR_Linux_syscalls 322
#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
#define __NR_N32_Linux 6000 #define __NR_N32_Linux 6000
#define __NR_N32_Linux_syscalls 320 #define __NR_N32_Linux_syscalls 322
#endif /* _UAPI_ASM_UNISTD_H */ #endif /* _UAPI_ASM_UNISTD_H */
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/power/jz4740-battery.h> #include <linux/power/jz4740-battery.h>
#include <linux/power/gpio-charger.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_fb.h>
#include <asm/mach-jz4740/jz4740_mmc.h> #include <asm/mach-jz4740/jz4740_mmc.h>
#include <asm/mach-jz4740/jz4740_nand.h> #include <asm/mach-jz4740/jz4740_nand.h>
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <asm/mach-jz4740/base.h> #include <asm/mach-jz4740/base.h>
#include <asm/mach-jz4740/gpio.h>
#define JZ4740_GPIO_BASE_A (32*0) #define JZ4740_GPIO_BASE_A (32*0)
#define JZ4740_GPIO_BASE_B (32*1) #define JZ4740_GPIO_BASE_B (32*1)
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
mfc0 \dest, CP0_CONFIG, 3 mfc0 \dest, CP0_CONFIG, 3
andi \dest, \dest, MIPS_CONF3_MT andi \dest, \dest, MIPS_CONF3_MT
beqz \dest, \nomt beqz \dest, \nomt
nop
.endm .endm
.section .text.cps-vec .section .text.cps-vec
...@@ -223,10 +224,9 @@ LEAF(excep_ejtag) ...@@ -223,10 +224,9 @@ LEAF(excep_ejtag)
END(excep_ejtag) END(excep_ejtag)
LEAF(mips_cps_core_init) LEAF(mips_cps_core_init)
#ifdef CONFIG_MIPS_MT #ifdef CONFIG_MIPS_MT_SMP
/* Check that the core implements the MT ASE */ /* Check that the core implements the MT ASE */
has_mt t0, 3f has_mt t0, 3f
nop
.set push .set push
.set mips64r2 .set mips64r2
...@@ -310,8 +310,9 @@ LEAF(mips_cps_boot_vpes) ...@@ -310,8 +310,9 @@ LEAF(mips_cps_boot_vpes)
PTR_ADDU t0, t0, t1 PTR_ADDU t0, t0, t1
/* Calculate this VPEs ID. If the core doesn't support MT use 0 */ /* 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 has_mt ta2, 1f
li t9, 0
/* Find the number of VPEs present in the core */ /* Find the number of VPEs present in the core */
mfc0 t1, CP0_MVPCONF0 mfc0 t1, CP0_MVPCONF0
...@@ -330,6 +331,7 @@ LEAF(mips_cps_boot_vpes) ...@@ -330,6 +331,7 @@ LEAF(mips_cps_boot_vpes)
/* Retrieve the VPE ID from EBase.CPUNum */ /* Retrieve the VPE ID from EBase.CPUNum */
mfc0 t9, $15, 1 mfc0 t9, $15, 1
and t9, t9, t1 and t9, t9, t1
#endif
1: /* Calculate a pointer to this VPEs struct vpe_boot_config */ 1: /* Calculate a pointer to this VPEs struct vpe_boot_config */
li t1, VPEBOOTCFG_SIZE li t1, VPEBOOTCFG_SIZE
...@@ -337,7 +339,7 @@ LEAF(mips_cps_boot_vpes) ...@@ -337,7 +339,7 @@ LEAF(mips_cps_boot_vpes)
PTR_L ta3, COREBOOTCFG_VPECONFIG(t0) PTR_L ta3, COREBOOTCFG_VPECONFIG(t0)
PTR_ADDU v0, v0, ta3 PTR_ADDU v0, v0, ta3
#ifdef CONFIG_MIPS_MT #ifdef CONFIG_MIPS_MT_SMP
/* If the core doesn't support MT then return */ /* If the core doesn't support MT then return */
bnez ta2, 1f bnez ta2, 1f
...@@ -451,7 +453,7 @@ LEAF(mips_cps_boot_vpes) ...@@ -451,7 +453,7 @@ LEAF(mips_cps_boot_vpes)
2: .set pop 2: .set pop
#endif /* CONFIG_MIPS_MT */ #endif /* CONFIG_MIPS_MT_SMP */
/* Return */ /* Return */
jr ra jr ra
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
.set pop .set pop
/* /*
* task_struct *resume(task_struct *prev, task_struct *next, * task_struct *resume(task_struct *prev, task_struct *next,
* struct thread_info *next_ti, int usedfpu) * struct thread_info *next_ti)
*/ */
.align 7 .align 7
LEAF(resume) LEAF(resume)
...@@ -28,30 +28,6 @@ ...@@ -28,30 +28,6 @@
cpu_save_nonscratch a0 cpu_save_nonscratch a0
LONG_S ra, THREAD_REG31(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 #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
/* Check if we need to store CVMSEG state */ /* Check if we need to store CVMSEG state */
dmfc0 t0, $11,7 /* CvmMemCtl */ dmfc0 t0, $11,7 /* CvmMemCtl */
......
...@@ -30,19 +30,9 @@ ...@@ -30,19 +30,9 @@
*/ */
#define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS) #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, * task_struct *resume(task_struct *prev, task_struct *next,
* struct thread_info *next_ti, int usedfpu) * struct thread_info *next_ti)
*/ */
LEAF(resume) LEAF(resume)
mfc0 t1, CP0_STATUS mfc0 t1, CP0_STATUS
...@@ -50,22 +40,6 @@ LEAF(resume) ...@@ -50,22 +40,6 @@ LEAF(resume)
cpu_save_nonscratch a0 cpu_save_nonscratch a0
sw ra, THREAD_REG31(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) #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
PTR_LA t8, __stack_chk_guard PTR_LA t8, __stack_chk_guard
LONG_L t9, TASK_STACK_CANARY(a1) LONG_L t9, TASK_STACK_CANARY(a1)
......
...@@ -36,16 +36,8 @@ NESTED(handle_sys, PT_SIZE, sp) ...@@ -36,16 +36,8 @@ NESTED(handle_sys, PT_SIZE, sp)
lw t1, PT_EPC(sp) # skip syscall on return lw t1, PT_EPC(sp) # skip syscall on return
subu v0, v0, __NR_O32_Linux # check syscall number subu v0, v0, __NR_O32_Linux # check syscall number
sltiu t0, v0, __NR_O32_Linux_syscalls + 1
addiu t1, 4 # skip to next instruction addiu t1, 4 # skip to next instruction
sw t1, PT_EPC(sp) 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 sw a3, PT_R26(sp) # save a3 for syscall restarting
...@@ -96,6 +88,16 @@ loads_done: ...@@ -96,6 +88,16 @@ loads_done:
li t1, _TIF_WORK_SYSCALL_ENTRY li t1, _TIF_WORK_SYSCALL_ENTRY
and t0, t1 and t0, t1
bnez t0, syscall_trace_entry # -> yes 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) jalr t2 # Do The Real Thing (TM)
...@@ -116,7 +118,7 @@ o32_syscall_exit: ...@@ -116,7 +118,7 @@ o32_syscall_exit:
syscall_trace_entry: syscall_trace_entry:
SAVE_STATIC SAVE_STATIC
move s0, t2 move s0, v0
move a0, sp move a0, sp
/* /*
...@@ -129,27 +131,18 @@ syscall_trace_entry: ...@@ -129,27 +131,18 @@ syscall_trace_entry:
1: jal syscall_trace_enter 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 RESTORE_STATIC
lw a0, PT_R4(sp) # Restore argument registers lw a0, PT_R4(sp) # Restore argument registers
lw a1, PT_R5(sp) lw a1, PT_R5(sp)
lw a2, PT_R6(sp) lw a2, PT_R6(sp)
lw a3, PT_R7(sp) lw a3, PT_R7(sp)
jalr t0 j syscall_common
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
2: j syscall_exit 1: j syscall_exit
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
...@@ -599,3 +592,5 @@ EXPORT(sys_call_table) ...@@ -599,3 +592,5 @@ EXPORT(sys_call_table)
PTR sys_memfd_create PTR sys_memfd_create
PTR sys_bpf /* 4355 */ PTR sys_bpf /* 4355 */
PTR sys_execveat PTR sys_execveat
PTR sys_userfaultfd
PTR sys_membarrier
...@@ -39,18 +39,11 @@ NESTED(handle_sys64, PT_SIZE, sp) ...@@ -39,18 +39,11 @@ NESTED(handle_sys64, PT_SIZE, sp)
.set at .set at
#endif #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) #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
ld t1, PT_EPC(sp) # skip syscall on return ld t1, PT_EPC(sp) # skip syscall on return
daddiu t1, 4 # skip to next instruction daddiu t1, 4 # skip to next instruction
sd t1, PT_EPC(sp) sd t1, PT_EPC(sp)
#endif #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 sd a3, PT_R26(sp) # save a3 for syscall restarting
...@@ -59,6 +52,17 @@ NESTED(handle_sys64, PT_SIZE, sp) ...@@ -59,6 +52,17 @@ NESTED(handle_sys64, PT_SIZE, sp)
and t0, t1, t0 and t0, t1, t0
bnez t0, syscall_trace_entry 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) jalr t2 # Do The Real Thing (TM)
li t0, -EMAXERRNO - 1 # error? li t0, -EMAXERRNO - 1 # error?
...@@ -78,14 +82,14 @@ n64_syscall_exit: ...@@ -78,14 +82,14 @@ n64_syscall_exit:
syscall_trace_entry: syscall_trace_entry:
SAVE_STATIC SAVE_STATIC
move s0, t2 move s0, v0
move a0, sp move a0, sp
move a1, v0 move a1, v0
jal syscall_trace_enter 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 RESTORE_STATIC
ld a0, PT_R4(sp) # Restore argument registers ld a0, PT_R4(sp) # Restore argument registers
ld a1, PT_R5(sp) ld a1, PT_R5(sp)
...@@ -93,19 +97,9 @@ syscall_trace_entry: ...@@ -93,19 +97,9 @@ syscall_trace_entry:
ld a3, PT_R7(sp) ld a3, PT_R7(sp)
ld a4, PT_R8(sp) ld a4, PT_R8(sp)
ld a5, PT_R9(sp) ld a5, PT_R9(sp)
jalr t0 j syscall_common
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
2: j syscall_exit 1: j syscall_exit
illegal_syscall: illegal_syscall:
/* This also isn't a 64-bit syscall, throw an error. */ /* This also isn't a 64-bit syscall, throw an error. */
...@@ -436,4 +430,6 @@ EXPORT(sys_call_table) ...@@ -436,4 +430,6 @@ EXPORT(sys_call_table)
PTR sys_memfd_create PTR sys_memfd_create
PTR sys_bpf /* 5315 */ PTR sys_bpf /* 5315 */
PTR sys_execveat PTR sys_execveat
PTR sys_userfaultfd
PTR sys_membarrier
.size sys_call_table,.-sys_call_table .size sys_call_table,.-sys_call_table
...@@ -52,6 +52,7 @@ NESTED(handle_sysn32, PT_SIZE, sp) ...@@ -52,6 +52,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
and t0, t1, t0 and t0, t1, t0
bnez t0, n32_syscall_trace_entry bnez t0, n32_syscall_trace_entry
syscall_common:
jalr t2 # Do The Real Thing (TM) jalr t2 # Do The Real Thing (TM)
li t0, -EMAXERRNO - 1 # error? li t0, -EMAXERRNO - 1 # error?
...@@ -75,9 +76,9 @@ n32_syscall_trace_entry: ...@@ -75,9 +76,9 @@ n32_syscall_trace_entry:
move a1, v0 move a1, v0
jal syscall_trace_enter jal syscall_trace_enter
bltz v0, 2f # seccomp failed? Skip syscall bltz v0, 1f # seccomp failed? Skip syscall
move t0, s0 move t2, s0
RESTORE_STATIC RESTORE_STATIC
ld a0, PT_R4(sp) # Restore argument registers ld a0, PT_R4(sp) # Restore argument registers
ld a1, PT_R5(sp) ld a1, PT_R5(sp)
...@@ -85,19 +86,9 @@ n32_syscall_trace_entry: ...@@ -85,19 +86,9 @@ n32_syscall_trace_entry:
ld a3, PT_R7(sp) ld a3, PT_R7(sp)
ld a4, PT_R8(sp) ld a4, PT_R8(sp)
ld a5, PT_R9(sp) ld a5, PT_R9(sp)
jalr t0 j syscall_common
li t0, -EMAXERRNO - 1 # error? 1: j syscall_exit
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
2: j syscall_exit
not_n32_scall: not_n32_scall:
/* This is not an n32 compatibility syscall, pass it on to /* This is not an n32 compatibility syscall, pass it on to
...@@ -429,4 +420,6 @@ EXPORT(sysn32_call_table) ...@@ -429,4 +420,6 @@ EXPORT(sysn32_call_table)
PTR sys_memfd_create PTR sys_memfd_create
PTR sys_bpf PTR sys_bpf
PTR compat_sys_execveat /* 6320 */ PTR compat_sys_execveat /* 6320 */
PTR sys_userfaultfd
PTR sys_membarrier
.size sysn32_call_table,.-sysn32_call_table .size sysn32_call_table,.-sysn32_call_table
...@@ -87,6 +87,7 @@ loads_done: ...@@ -87,6 +87,7 @@ loads_done:
and t0, t1, t0 and t0, t1, t0