diff options
Diffstat (limited to 'arch/mips/kernel')
| -rw-r--r-- | arch/mips/kernel/cevt-ds1287.c | 15 | ||||
| -rw-r--r-- | arch/mips/kernel/cevt-gt641xx.c | 15 | ||||
| -rw-r--r-- | arch/mips/kernel/cpu-bugs64.c | 4 | ||||
| -rw-r--r-- | arch/mips/kernel/cpu-probe.c | 8 | ||||
| -rw-r--r-- | arch/mips/kernel/early_printk_8250.c | 15 | ||||
| -rw-r--r-- | arch/mips/kernel/entry.S | 5 | ||||
| -rw-r--r-- | arch/mips/kernel/irq-gt641xx.c | 15 | ||||
| -rw-r--r-- | arch/mips/kernel/jump_label.c | 30 | ||||
| -rw-r--r-- | arch/mips/kernel/kgdb.c | 3 | ||||
| -rw-r--r-- | arch/mips/kernel/perf_event_mipsxx.c | 21 | ||||
| -rw-r--r-- | arch/mips/kernel/prom.c | 18 | ||||
| -rw-r--r-- | arch/mips/kernel/ptrace.c | 4 | ||||
| -rw-r--r-- | arch/mips/kernel/scall64-o32.S | 2 | ||||
| -rw-r--r-- | arch/mips/kernel/setup.c | 129 | ||||
| -rw-r--r-- | arch/mips/kernel/stacktrace.c | 1 | ||||
| -rw-r--r-- | arch/mips/kernel/syscalls/syscall_n32.tbl | 10 | ||||
| -rw-r--r-- | arch/mips/kernel/syscalls/syscall_n64.tbl | 10 | ||||
| -rw-r--r-- | arch/mips/kernel/syscalls/syscall_o32.tbl | 10 | ||||
| -rw-r--r-- | arch/mips/kernel/traps.c | 63 | 
19 files changed, 153 insertions, 225 deletions
diff --git a/arch/mips/kernel/cevt-ds1287.c b/arch/mips/kernel/cevt-ds1287.c index 61ad9079fa16..1e1edab4a63f 100644 --- a/arch/mips/kernel/cevt-ds1287.c +++ b/arch/mips/kernel/cevt-ds1287.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later  /*   *  DS1287 clockevent driver   *   *  Copyright (C) 2008	Yoichi Yuasa <[email protected]> - * - *  This program is free software; you can redistribute it and/or modify - *  it under the terms of the GNU General Public License as published by - *  the Free Software Foundation; either version 2 of the License, or - *  (at your option) any later version. - * - *  This program is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU General Public License for more details. - * - *  You should have received a copy of the GNU General Public License - *  along with this program; if not, write to the Free Software - *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA   */  #include <linux/clockchips.h>  #include <linux/init.h> diff --git a/arch/mips/kernel/cevt-gt641xx.c b/arch/mips/kernel/cevt-gt641xx.c index fd90c82dc17d..eb53548d2538 100644 --- a/arch/mips/kernel/cevt-gt641xx.c +++ b/arch/mips/kernel/cevt-gt641xx.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later  /*   *  GT641xx clockevent routines.   *   *  Copyright (C) 2007	Yoichi Yuasa <[email protected]> - * - *  This program is free software; you can redistribute it and/or modify - *  it under the terms of the GNU General Public License as published by - *  the Free Software Foundation; either version 2 of the License, or - *  (at your option) any later version. - * - *  This program is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU General Public License for more details. - * - *  You should have received a copy of the GNU General Public License - *  along with this program; if not, write to the Free Software - *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA   */  #include <linux/clockchips.h>  #include <linux/init.h> diff --git a/arch/mips/kernel/cpu-bugs64.c b/arch/mips/kernel/cpu-bugs64.c index bada74af7641..c04b97aace4a 100644 --- a/arch/mips/kernel/cpu-bugs64.c +++ b/arch/mips/kernel/cpu-bugs64.c @@ -42,8 +42,8 @@ static inline void align_mod(const int align, const int mod)  		: "n"(align), "n"(mod));  } -static inline void mult_sh_align_mod(long *v1, long *v2, long *w, -				     const int align, const int mod) +static __always_inline void mult_sh_align_mod(long *v1, long *v2, long *w, +					      const int align, const int mod)  {  	unsigned long flags;  	int m1, m2; diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index d5e335e6846a..6126b77d5a62 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -1973,6 +1973,14 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)  		panic("Unknown Ingenic Processor ID!");  		break;  	} + +	/* +	 * The config0 register in the Xburst CPUs with a processor ID of +	 * PRID_COMP_INGENIC_D0 report themselves as MIPS32r2 compatible, +	 * but they don't actually support this ISA. +	 */ +	if ((c->processor_id & PRID_COMP_MASK) == PRID_COMP_INGENIC_D0) +		c->isa_level &= ~MIPS_CPU_ISA_M32R2;  }  static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu) diff --git a/arch/mips/kernel/early_printk_8250.c b/arch/mips/kernel/early_printk_8250.c index ea26614afac6..567c6ec0cfae 100644 --- a/arch/mips/kernel/early_printk_8250.c +++ b/arch/mips/kernel/early_printk_8250.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later  /*   *  8250/16550-type serial ports prom_putchar()   *   *  Copyright (C) 2010  Yoichi Yuasa <[email protected]> - * - *  This program is free software; you can redistribute it and/or modify - *  it under the terms of the GNU General Public License as published by - *  the Free Software Foundation; either version 2 of the License, or - *  (at your option) any later version. - * - *  This program is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU General Public License for more details. - * - *  You should have received a copy of the GNU General Public License - *  along with this program; if not, write to the Free Software - *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA   */  #include <linux/io.h>  #include <linux/serial_core.h> diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S index d7de8adcfcc8..5469d43b6966 100644 --- a/arch/mips/kernel/entry.S +++ b/arch/mips/kernel/entry.S @@ -58,15 +58,14 @@ resume_kernel:  	local_irq_disable  	lw	t0, TI_PRE_COUNT($28)  	bnez	t0, restore_all -need_resched:  	LONG_L	t0, TI_FLAGS($28)  	andi	t1, t0, _TIF_NEED_RESCHED  	beqz	t1, restore_all  	LONG_L	t0, PT_STATUS(sp)		# Interrupts off?  	andi	t0, 1  	beqz	t0, restore_all -	jal	preempt_schedule_irq -	b	need_resched +	PTR_LA	ra, restore_all +	j	preempt_schedule_irq  #endif  FEXPORT(ret_from_kernel_thread) diff --git a/arch/mips/kernel/irq-gt641xx.c b/arch/mips/kernel/irq-gt641xx.c index 44a1f792e399..93bcf5736a6f 100644 --- a/arch/mips/kernel/irq-gt641xx.c +++ b/arch/mips/kernel/irq-gt641xx.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later  /*   *  GT641xx IRQ routines.   *   *  Copyright (C) 2007	Yoichi Yuasa <[email protected]> - * - *  This program is free software; you can redistribute it and/or modify - *  it under the terms of the GNU General Public License as published by - *  the Free Software Foundation; either version 2 of the License, or - *  (at your option) any later version. - * - *  This program is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU General Public License for more details. - * - *  You should have received a copy of the GNU General Public License - *  along with this program; if not, write to the Free Software - *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA   */  #include <linux/hardirq.h>  #include <linux/init.h> diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c index ab943927f97a..662c8db9f45b 100644 --- a/arch/mips/kernel/jump_label.c +++ b/arch/mips/kernel/jump_label.c @@ -40,18 +40,38 @@ void arch_jump_label_transform(struct jump_entry *e,  {  	union mips_instruction *insn_p;  	union mips_instruction insn; +	long offset;  	insn_p = (union mips_instruction *)msk_isa16_mode(e->code); -	/* Jump only works within an aligned region its delay slot is in. */ -	BUG_ON((e->target & ~J_RANGE_MASK) != ((e->code + 4) & ~J_RANGE_MASK)); -  	/* Target must have the right alignment and ISA must be preserved. */  	BUG_ON((e->target & J_ALIGN_MASK) != J_ISA_BIT);  	if (type == JUMP_LABEL_JMP) { -		insn.j_format.opcode = J_ISA_BIT ? mm_j32_op : j_op; -		insn.j_format.target = e->target >> J_RANGE_SHIFT; +		if (!IS_ENABLED(CONFIG_CPU_MICROMIPS) && MIPS_ISA_REV >= 6) { +			offset = e->target - ((unsigned long)insn_p + 4); +			offset >>= 2; + +			/* +			 * The branch offset must fit in the instruction's 26 +			 * bit field. +			 */ +			WARN_ON((offset >= BIT(25)) || +				(offset < -(long)BIT(25))); + +			insn.j_format.opcode = bc6_op; +			insn.j_format.target = offset; +		} else { +			/* +			 * Jump only works within an aligned region its delay +			 * slot is in. +			 */ +			WARN_ON((e->target & ~J_RANGE_MASK) != +				((e->code + 4) & ~J_RANGE_MASK)); + +			insn.j_format.opcode = J_ISA_BIT ? mm_j32_op : j_op; +			insn.j_format.target = e->target >> J_RANGE_SHIFT; +		}  	} else {  		insn.word = 0; /* nop */  	} diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c index 6e574c02e4c3..ea781b29f7f1 100644 --- a/arch/mips/kernel/kgdb.c +++ b/arch/mips/kernel/kgdb.c @@ -33,6 +33,7 @@  #include <asm/processor.h>  #include <asm/sigcontext.h>  #include <linux/uaccess.h> +#include <asm/irq_regs.h>  static struct hard_trap_info {  	unsigned char tt;	/* Trap type code for MIPS R3xxx and R4xxx */ @@ -214,7 +215,7 @@ void kgdb_call_nmi_hook(void *ignored)  	old_fs = get_fs();  	set_fs(KERNEL_DS); -	kgdb_nmicallback(raw_smp_processor_id(), NULL); +	kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());  	set_fs(old_fs);  } diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index 413863508f6f..d67fb64e908c 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c @@ -64,17 +64,11 @@ struct mips_perf_event {  	#define CNTR_EVEN	0x55555555  	#define CNTR_ODD	0xaaaaaaaa  	#define CNTR_ALL	0xffffffff -#ifdef CONFIG_MIPS_MT_SMP  	enum {  		T  = 0,  		V  = 1,  		P  = 2,  	} range; -#else -	#define T -	#define V -	#define P -#endif  };  static struct mips_perf_event raw_event; @@ -325,9 +319,7 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)  {  	struct perf_event *event = container_of(evt, struct perf_event, hw);  	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); -#ifdef CONFIG_MIPS_MT_SMP  	unsigned int range = evt->event_base >> 24; -#endif /* CONFIG_MIPS_MT_SMP */  	WARN_ON(idx < 0 || idx >= mipspmu.num_counters); @@ -336,21 +328,15 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)  		/* Make sure interrupt enabled. */  		MIPS_PERFCTRL_IE; -#ifdef CONFIG_CPU_BMIPS5000 -	{ +	if (IS_ENABLED(CONFIG_CPU_BMIPS5000)) {  		/* enable the counter for the calling thread */  		cpuc->saved_ctrl[idx] |=  			(1 << (12 + vpe_id())) | BRCM_PERFCTRL_TC; -	} -#else -#ifdef CONFIG_MIPS_MT_SMP -	if (range > V) { +	} else if (IS_ENABLED(CONFIG_MIPS_MT_SMP) && range > V) {  		/* The counter is processor wide. Set it up to count all TCs. */  		pr_debug("Enabling perf counter for all TCs\n");  		cpuc->saved_ctrl[idx] |= M_TC_EN_ALL; -	} else -#endif /* CONFIG_MIPS_MT_SMP */ -	{ +	} else {  		unsigned int cpu, ctrl;  		/* @@ -365,7 +351,6 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)  		cpuc->saved_ctrl[idx] |= ctrl;  		pr_debug("Enabling perf counter for CPU%d\n", cpu);  	} -#endif /* CONFIG_CPU_BMIPS5000 */  	/*  	 * We do not actually let the counter run. Leave it until start().  	 */ diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 93b8e0b4332f..28bf01961bb2 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -41,13 +41,27 @@ char *mips_get_machine_name(void)  #ifdef CONFIG_USE_OF  void __init early_init_dt_add_memory_arch(u64 base, u64 size)  { -	return add_memory_region(base, size, BOOT_MEM_RAM); +	if (base >= PHYS_ADDR_MAX) { +		pr_warn("Trying to add an invalid memory region, skipped\n"); +		return; +	} + +	/* Truncate the passed memory region instead of type casting */ +	if (base + size - 1 >= PHYS_ADDR_MAX || base + size < base) { +		pr_warn("Truncate memory region %llx @ %llx to size %llx\n", +			size, base, PHYS_ADDR_MAX - base); +		size = PHYS_ADDR_MAX - base; +	} + +	add_memory_region(base, size, BOOT_MEM_RAM);  }  int __init early_init_dt_reserve_memory_arch(phys_addr_t base,  					phys_addr_t size, bool nomap)  { -	add_memory_region(base, size, BOOT_MEM_RESERVED); +	add_memory_region(base, size, +			  nomap ? BOOT_MEM_NOMAP : BOOT_MEM_RESERVED); +  	return 0;  } diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 0057c910bc2f..414b6e9c900b 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -1418,8 +1418,8 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)  		unsigned long args[6];  		sd.nr = syscall; -		sd.arch = syscall_get_arch(); -		syscall_get_arguments(current, regs, 0, 6, args); +		sd.arch = syscall_get_arch(current); +		syscall_get_arguments(current, regs, args);  		for (i = 0; i < 6; i++)  			sd.args[i] = args[i];  		sd.instruction_pointer = KSTK_EIP(current); diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S index f158c5894a9a..feb2653490df 100644 --- a/arch/mips/kernel/scall64-o32.S +++ b/arch/mips/kernel/scall64-o32.S @@ -125,7 +125,7 @@ trace_a_syscall:  	subu	t1, v0,  __NR_O32_Linux  	move	a1, v0  	bnez	t1, 1f /* __NR_syscall at offset 0 */ -	lw	a1, PT_R4(sp) /* Arg1 for __NR_syscall case */ +	ld	a1, PT_R4(sp) /* Arg1 for __NR_syscall case */  	.set	pop  1:	jal	syscall_trace_enter diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 8d1dc6c71173..ab349d2381c3 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -27,6 +27,7 @@  #include <linux/dma-contiguous.h>  #include <linux/decompress/generic.h>  #include <linux/of_fdt.h> +#include <linux/of_reserved_mem.h>  #include <asm/addrspace.h>  #include <asm/bootinfo.h> @@ -178,6 +179,7 @@ static bool __init __maybe_unused memory_region_available(phys_addr_t start,  				in_ram = true;  			break;  		case BOOT_MEM_RESERVED: +		case BOOT_MEM_NOMAP:  			if ((start >= start_ && start < end_) ||  			    (start < start_ && start + size >= start_))  				free = false; @@ -213,6 +215,9 @@ static void __init print_memory_map(void)  		case BOOT_MEM_RESERVED:  			printk(KERN_CONT "(reserved)\n");  			break; +		case BOOT_MEM_NOMAP: +			printk(KERN_CONT "(nomap)\n"); +			break;  		default:  			printk(KERN_CONT "type %lu\n", boot_mem_map.map[i].type);  			break; @@ -371,7 +376,6 @@ static void __init bootmem_init(void)  static void __init bootmem_init(void)  { -	unsigned long reserved_end;  	phys_addr_t ramstart = PHYS_ADDR_MAX;  	int i; @@ -382,10 +386,10 @@ static void __init bootmem_init(void)  	 * will reserve the area used for the initrd.  	 */  	init_initrd(); -	reserved_end = (unsigned long) PFN_UP(__pa_symbol(&_end)); -	memblock_reserve(PHYS_OFFSET, -			 (reserved_end << PAGE_SHIFT) - PHYS_OFFSET); +	/* Reserve memory occupied by kernel. */ +	memblock_reserve(__pa_symbol(&_text), +			__pa_symbol(&_end) - __pa_symbol(&_text));  	/*  	 * max_low_pfn is not a number of pages. The number of pages @@ -394,10 +398,7 @@ static void __init bootmem_init(void)  	min_low_pfn = ~0UL;  	max_low_pfn = 0; -	/* -	 * Find the highest page frame number we have available -	 * and the lowest used RAM address -	 */ +	/* Find the highest and lowest page frame numbers we have available. */  	for (i = 0; i < boot_mem_map.nr_map; i++) {  		unsigned long start, end; @@ -427,13 +428,6 @@ static void __init bootmem_init(void)  			max_low_pfn = end;  		if (start < min_low_pfn)  			min_low_pfn = start; -		if (end <= reserved_end) -			continue; -#ifdef CONFIG_BLK_DEV_INITRD -		/* Skip zones before initrd and initrd itself */ -		if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end))) -			continue; -#endif  	}  	if (min_low_pfn >= max_low_pfn) @@ -474,6 +468,7 @@ static void __init bootmem_init(void)  		max_low_pfn = PFN_DOWN(HIGHMEM_START);  	} +	/* Install all valid RAM ranges to the memblock memory region */  	for (i = 0; i < boot_mem_map.nr_map; i++) {  		unsigned long start, end; @@ -481,98 +476,38 @@ static void __init bootmem_init(void)  		end = PFN_DOWN(boot_mem_map.map[i].addr  				+ boot_mem_map.map[i].size); -		if (start <= min_low_pfn) +		if (start < min_low_pfn)  			start = min_low_pfn; -		if (start >= end) -			continue; -  #ifndef CONFIG_HIGHMEM +		/* Ignore highmem regions if highmem is unsupported */  		if (end > max_low_pfn)  			end = max_low_pfn; - -		/* -		 * ... finally, is the area going away? -		 */ +#endif  		if (end <= start)  			continue; -#endif  		memblock_add_node(PFN_PHYS(start), PFN_PHYS(end - start), 0); -	} - -	/* -	 * Register fully available low RAM pages with the bootmem allocator. -	 */ -	for (i = 0; i < boot_mem_map.nr_map; i++) { -		unsigned long start, end, size; -		start = PFN_UP(boot_mem_map.map[i].addr); -		end   = PFN_DOWN(boot_mem_map.map[i].addr -				    + boot_mem_map.map[i].size); - -		/* -		 * Reserve usable memory. -		 */ +		/* Reserve any memory except the ordinary RAM ranges. */  		switch (boot_mem_map.map[i].type) {  		case BOOT_MEM_RAM:  			break; -		case BOOT_MEM_INIT_RAM: -			memory_present(0, start, end); -			continue; -		default: -			/* Not usable memory */ -			if (start > min_low_pfn && end < max_low_pfn) -				memblock_reserve(boot_mem_map.map[i].addr, -						boot_mem_map.map[i].size); - +		case BOOT_MEM_NOMAP: /* Discard the range from the system. */ +			memblock_remove(PFN_PHYS(start), PFN_PHYS(end - start));  			continue; +		default: /* Reserve the rest of the memory types at boot time */ +			memblock_reserve(PFN_PHYS(start), PFN_PHYS(end - start)); +			break;  		}  		/* -		 * We are rounding up the start address of usable memory -		 * and at the end of the usable range downwards. +		 * In any case the added to the memblock memory regions +		 * (highmem/lowmem, available/reserved, etc) are considered +		 * as present, so inform sparsemem about them.  		 */ -		if (start >= max_low_pfn) -			continue; -		if (start < reserved_end) -			start = reserved_end; -		if (end > max_low_pfn) -			end = max_low_pfn; - -		/* -		 * ... finally, is the area going away? -		 */ -		if (end <= start) -			continue; -		size = end - start; - -		/* Register lowmem ranges */  		memory_present(0, start, end);  	} -#ifdef CONFIG_RELOCATABLE -	/* -	 * The kernel reserves all memory below its _end symbol as bootmem, -	 * but the kernel may now be at a much higher address. The memory -	 * between the original and new locations may be returned to the system. -	 */ -	if (__pa_symbol(_text) > __pa_symbol(VMLINUX_LOAD_ADDRESS)) { -		unsigned long offset; -		extern void show_kernel_relocation(const char *level); - -		offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS); -		memblock_free(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset); - -#if defined(CONFIG_DEBUG_KERNEL) && defined(CONFIG_DEBUG_INFO) -		/* -		 * This information is necessary when debugging the kernel -		 * But is a security vulnerability otherwise! -		 */ -		show_kernel_relocation(KERN_INFO); -#endif -	} -#endif -  	/*  	 * Reserve initrd memory if needed.  	 */ @@ -781,7 +716,6 @@ static void __init request_crashkernel(struct resource *res)   */  static void __init arch_mem_init(char **cmdline_p)  { -	struct memblock_region *reg;  	extern void plat_mem_setup(void);  	/* @@ -809,6 +743,9 @@ static void __init arch_mem_init(char **cmdline_p)  	arch_mem_addpart(PFN_UP(__pa_symbol(&__init_begin)) << PAGE_SHIFT,  			 PFN_DOWN(__pa_symbol(&__init_end)) << PAGE_SHIFT,  			 BOOT_MEM_INIT_RAM); +	arch_mem_addpart(PFN_DOWN(__pa_symbol(&__bss_start)) << PAGE_SHIFT, +			 PFN_UP(__pa_symbol(&__bss_stop)) << PAGE_SHIFT, +			 BOOT_MEM_RAM);  	pr_info("Determined physical RAM map:\n");  	print_memory_map(); @@ -884,13 +821,16 @@ static void __init arch_mem_init(char **cmdline_p)  	plat_swiotlb_setup();  	dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); -	/* Tell bootmem about cma reserved memblock section */ -	for_each_memblock(reserved, reg) -		if (reg->size != 0) -			memblock_reserve(reg->base, reg->size); -	reserve_bootmem_region(__pa_symbol(&__nosave_begin), -			__pa_symbol(&__nosave_end)); /* Reserve for hibernation */ +	/* Reserve for hibernation. */ +	memblock_reserve(__pa_symbol(&__nosave_begin), +		__pa_symbol(&__nosave_end) - __pa_symbol(&__nosave_begin)); + +	fdt_init_reserved_mem(); + +	memblock_dump_all(); + +	early_memtest(PFN_PHYS(min_low_pfn), PFN_PHYS(max_low_pfn));  }  static void __init resource_init(void) @@ -935,6 +875,7 @@ static void __init resource_init(void)  			res->flags |= IORESOURCE_SYSRAM;  			break;  		case BOOT_MEM_RESERVED: +		case BOOT_MEM_NOMAP:  		default:  			res->name = "reserved";  		} diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c index 7c7c902249f2..f2e72094051b 100644 --- a/arch/mips/kernel/stacktrace.c +++ b/arch/mips/kernel/stacktrace.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only  /*   * Stack trace management functions   * diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index 15f4117900ee..0e2dd68ade57 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -362,3 +362,13 @@  421	n32	rt_sigtimedwait_time64		compat_sys_rt_sigtimedwait_time64  422	n32	futex_time64			sys_futex  423	n32	sched_rr_get_interval_time64	sys_sched_rr_get_interval +424	n32	pidfd_send_signal		sys_pidfd_send_signal +425	n32	io_uring_setup			sys_io_uring_setup +426	n32	io_uring_enter			sys_io_uring_enter +427	n32	io_uring_register		sys_io_uring_register +428	n32	open_tree			sys_open_tree +429	n32	move_mount			sys_move_mount +430	n32	fsopen				sys_fsopen +431	n32	fsconfig			sys_fsconfig +432	n32	fsmount				sys_fsmount +433	n32	fspick				sys_fspick diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl index c85502e67b44..5eebfa0d155c 100644 --- a/arch/mips/kernel/syscalls/syscall_n64.tbl +++ b/arch/mips/kernel/syscalls/syscall_n64.tbl @@ -338,3 +338,13 @@  327	n64	rseq				sys_rseq  328	n64	io_pgetevents			sys_io_pgetevents  # 329 through 423 are reserved to sync up with other architectures +424	n64	pidfd_send_signal		sys_pidfd_send_signal +425	n64	io_uring_setup			sys_io_uring_setup +426	n64	io_uring_enter			sys_io_uring_enter +427	n64	io_uring_register		sys_io_uring_register +428	n64	open_tree			sys_open_tree +429	n64	move_mount			sys_move_mount +430	n64	fsopen				sys_fsopen +431	n64	fsconfig			sys_fsconfig +432	n64	fsmount				sys_fsmount +433	n64	fspick				sys_fspick diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 2e063d0f837e..3cc1374e02d0 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -411,3 +411,13 @@  421	o32	rt_sigtimedwait_time64		sys_rt_sigtimedwait		compat_sys_rt_sigtimedwait_time64  422	o32	futex_time64			sys_futex			sys_futex  423	o32	sched_rr_get_interval_time64	sys_sched_rr_get_interval	sys_sched_rr_get_interval +424	o32	pidfd_send_signal		sys_pidfd_send_signal +425	o32	io_uring_setup			sys_io_uring_setup +426	o32	io_uring_enter			sys_io_uring_enter +427	o32	io_uring_register		sys_io_uring_register +428	o32	open_tree			sys_open_tree +429	o32	move_mount			sys_move_mount +430	o32	fsopen				sys_fsopen +431	o32	fsconfig			sys_fsconfig +432	o32	fsmount				sys_fsmount +433	o32	fspick				sys_fspick diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 98ca55d62201..c52766a5b85f 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2151,7 +2151,7 @@ static void configure_hwrena(void)  static void configure_exception_vector(void)  { -	if (cpu_has_veic || cpu_has_vint) { +	if (cpu_has_mips_r2_r6) {  		unsigned long sr = set_c0_status(ST0_BEV);  		/* If available, use WG to set top bits of EBASE */  		if (cpu_has_ebase_wg) { @@ -2163,6 +2163,8 @@ static void configure_exception_vector(void)  		}  		write_c0_ebase(ebase);  		write_c0_status(sr); +	} +	if (cpu_has_veic || cpu_has_vint) {  		/* Setting vector spacing enables EI/VI mode  */  		change_c0_intctl(0x3e0, VECTORSPACING);  	} @@ -2193,22 +2195,6 @@ void per_cpu_trap_init(bool is_boot_cpu)  	 *  o read IntCtl.IPFDC to determine the fast debug channel interrupt  	 */  	if (cpu_has_mips_r2_r6) { -		/* -		 * We shouldn't trust a secondary core has a sane EBASE register -		 * so use the one calculated by the boot CPU. -		 */ -		if (!is_boot_cpu) { -			/* If available, use WG to set top bits of EBASE */ -			if (cpu_has_ebase_wg) { -#ifdef CONFIG_64BIT -				write_c0_ebase_64(ebase | MIPS_EBASE_WG); -#else -				write_c0_ebase(ebase | MIPS_EBASE_WG); -#endif -			} -			write_c0_ebase(ebase); -		} -  		cp0_compare_irq_shift = CAUSEB_TI - CAUSEB_IP;  		cp0_compare_irq = (read_c0_intctl() >> INTCTLB_IPTI) & 7;  		cp0_perfcount_irq = (read_c0_intctl() >> INTCTLB_IPPCI) & 7; @@ -2284,19 +2270,27 @@ void __init trap_init(void)  	extern char except_vec3_generic;  	extern char except_vec4;  	extern char except_vec3_r4000; -	unsigned long i; +	unsigned long i, vec_size; +	phys_addr_t ebase_pa;  	check_wait(); -	if (cpu_has_veic || cpu_has_vint) { -		unsigned long size = 0x200 + VECTORSPACING*64; -		phys_addr_t ebase_pa; +	if (!cpu_has_mips_r2_r6) { +		ebase = CAC_BASE; +		ebase_pa = virt_to_phys((void *)ebase); +		vec_size = 0x400; -		ebase = (unsigned long) -			memblock_alloc(size, 1 << fls(size)); -		if (!ebase) +		memblock_reserve(ebase_pa, vec_size); +	} else { +		if (cpu_has_veic || cpu_has_vint) +			vec_size = 0x200 + VECTORSPACING*64; +		else +			vec_size = PAGE_SIZE; + +		ebase_pa = memblock_phys_alloc(vec_size, 1 << fls(vec_size)); +		if (!ebase_pa)  			panic("%s: Failed to allocate %lu bytes align=0x%x\n", -			      __func__, size, 1 << fls(size)); +			      __func__, vec_size, 1 << fls(vec_size));  		/*  		 * Try to ensure ebase resides in KSeg0 if possible. @@ -2309,23 +2303,10 @@ void __init trap_init(void)  		 * EVA is special though as it allows segments to be rearranged  		 * and to become uncached during cache error handling.  		 */ -		ebase_pa = __pa(ebase);  		if (!IS_ENABLED(CONFIG_EVA) && !WARN_ON(ebase_pa >= 0x20000000))  			ebase = CKSEG0ADDR(ebase_pa); -	} else { -		ebase = CAC_BASE; - -		if (cpu_has_mips_r2_r6) { -			if (cpu_has_ebase_wg) { -#ifdef CONFIG_64BIT -				ebase = (read_c0_ebase_64() & ~0xfff); -#else -				ebase = (read_c0_ebase() & ~0xfff); -#endif -			} else { -				ebase += (read_c0_ebase() & 0x3ffff000); -			} -		} +		else +			ebase = (unsigned long)phys_to_virt(ebase_pa);  	}  	if (cpu_has_mmips) { @@ -2459,7 +2440,7 @@ void __init trap_init(void)  	else  		set_handler(0x080, &except_vec3_generic, 0x80); -	local_flush_icache_range(ebase, ebase + 0x400); +	local_flush_icache_range(ebase, ebase + vec_size);  	sort_extable(__start___dbe_table, __stop___dbe_table);  |