Skip to content

Commit 9c39198

Browse files
committed
Merge tag 'mips-fixes_5.12_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull MIPS fixes from Thomas Bogendoerfer: - fixes for boot breakage because of misaligned FDTs - fix for overwritten exception handlers - enable MIPS optimized crypto for all MIPS CPUs to improve wireguard performance * tag 'mips-fixes_5.12_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: MIPS: kernel: Reserve exception base early to prevent corruption MIPS: vmlinux.lds.S: align raw appended dtb to 8 bytes crypto: mips/poly1305 - enable for all MIPS processors MIPS: boot/compressed: Copy DTB to aligned address
2 parents 987a087 + bd67b71 commit 9c39198

File tree

9 files changed

+35
-9
lines changed

9 files changed

+35
-9
lines changed

arch/mips/boot/compressed/decompress.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <asm/addrspace.h>
1616
#include <asm/unaligned.h>
17+
#include <asm-generic/vmlinux.lds.h>
1718

1819
/*
1920
* These two variables specify the free mem region
@@ -120,6 +121,13 @@ void decompress_kernel(unsigned long boot_heap_start)
120121
/* last four bytes is always image size in little endian */
121122
image_size = get_unaligned_le32((void *)&__image_end - 4);
122123

124+
/* The device tree's address must be properly aligned */
125+
image_size = ALIGN(image_size, STRUCT_ALIGNMENT);
126+
127+
puts("Copy device tree to address ");
128+
puthex(VMLINUX_LOAD_ADDRESS_ULL + image_size);
129+
puts("\n");
130+
123131
/* copy dtb to where the booted kernel will expect it */
124132
memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size,
125133
__appended_dtb, dtb_size);

arch/mips/crypto/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ AFLAGS_chacha-core.o += -O2 # needed to fill branch delay slots
1212
obj-$(CONFIG_CRYPTO_POLY1305_MIPS) += poly1305-mips.o
1313
poly1305-mips-y := poly1305-core.o poly1305-glue.o
1414

15-
perlasm-flavour-$(CONFIG_CPU_MIPS32) := o32
16-
perlasm-flavour-$(CONFIG_CPU_MIPS64) := 64
15+
perlasm-flavour-$(CONFIG_32BIT) := o32
16+
perlasm-flavour-$(CONFIG_64BIT) := 64
1717

1818
quiet_cmd_perlasm = PERLASM $@
1919
cmd_perlasm = $(PERL) $(<) $(perlasm-flavour-y) $(@)

arch/mips/include/asm/traps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ extern void (*board_ebase_setup)(void);
2424
extern void (*board_cache_error_setup)(void);
2525

2626
extern int register_nmi_notifier(struct notifier_block *nb);
27+
extern void reserve_exception_space(phys_addr_t addr, unsigned long size);
2728
extern char except_vec_nmi[];
2829

30+
#define VECTORSPACING 0x100 /* for EI/VI mode */
31+
2932
#define nmi_notifier(fn, pri) \
3033
({ \
3134
static struct notifier_block fn##_nb = { \

arch/mips/kernel/cpu-probe.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <asm/elf.h>
2727
#include <asm/pgtable-bits.h>
2828
#include <asm/spram.h>
29+
#include <asm/traps.h>
2930
#include <linux/uaccess.h>
3031

3132
#include "fpu-probe.h"
@@ -1628,6 +1629,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
16281629
c->cputype = CPU_BMIPS3300;
16291630
__cpu_name[cpu] = "Broadcom BMIPS3300";
16301631
set_elf_platform(cpu, "bmips3300");
1632+
reserve_exception_space(0x400, VECTORSPACING * 64);
16311633
break;
16321634
case PRID_IMP_BMIPS43XX: {
16331635
int rev = c->processor_id & PRID_REV_MASK;
@@ -1638,6 +1640,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
16381640
__cpu_name[cpu] = "Broadcom BMIPS4380";
16391641
set_elf_platform(cpu, "bmips4380");
16401642
c->options |= MIPS_CPU_RIXI;
1643+
reserve_exception_space(0x400, VECTORSPACING * 64);
16411644
} else {
16421645
c->cputype = CPU_BMIPS4350;
16431646
__cpu_name[cpu] = "Broadcom BMIPS4350";
@@ -1654,6 +1657,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
16541657
__cpu_name[cpu] = "Broadcom BMIPS5000";
16551658
set_elf_platform(cpu, "bmips5000");
16561659
c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI;
1660+
reserve_exception_space(0x1000, VECTORSPACING * 64);
16571661
break;
16581662
}
16591663
}
@@ -2133,6 +2137,8 @@ void cpu_probe(void)
21332137
if (cpu == 0)
21342138
__ua_limit = ~((1ull << cpu_vmbits) - 1);
21352139
#endif
2140+
2141+
reserve_exception_space(0, 0x1000);
21362142
}
21372143

21382144
void cpu_report(void)

arch/mips/kernel/cpu-r3k-probe.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <asm/fpu.h>
2222
#include <asm/mipsregs.h>
2323
#include <asm/elf.h>
24+
#include <asm/traps.h>
2425

2526
#include "fpu-probe.h"
2627

@@ -158,6 +159,8 @@ void cpu_probe(void)
158159
cpu_set_fpu_opts(c);
159160
else
160161
cpu_set_nofpu_opts(c);
162+
163+
reserve_exception_space(0, 0x400);
161164
}
162165

163166
void cpu_report(void)

arch/mips/kernel/traps.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,13 +2009,16 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs)
20092009
nmi_exit();
20102010
}
20112011

2012-
#define VECTORSPACING 0x100 /* for EI/VI mode */
2013-
20142012
unsigned long ebase;
20152013
EXPORT_SYMBOL_GPL(ebase);
20162014
unsigned long exception_handlers[32];
20172015
unsigned long vi_handlers[64];
20182016

2017+
void reserve_exception_space(phys_addr_t addr, unsigned long size)
2018+
{
2019+
memblock_reserve(addr, size);
2020+
}
2021+
20192022
void __init *set_except_vector(int n, void *addr)
20202023
{
20212024
unsigned long handler = (unsigned long) addr;
@@ -2367,10 +2370,7 @@ void __init trap_init(void)
23672370

23682371
if (!cpu_has_mips_r2_r6) {
23692372
ebase = CAC_BASE;
2370-
ebase_pa = virt_to_phys((void *)ebase);
23712373
vec_size = 0x400;
2372-
2373-
memblock_reserve(ebase_pa, vec_size);
23742374
} else {
23752375
if (cpu_has_veic || cpu_has_vint)
23762376
vec_size = 0x200 + VECTORSPACING*64;

arch/mips/kernel/vmlinux.lds.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ SECTIONS
145145
}
146146

147147
#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
148+
STRUCT_ALIGN();
148149
.appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
149150
*(.appended_dtb)
150151
KEEP(*(.appended_dtb))
@@ -172,6 +173,11 @@ SECTIONS
172173
#endif
173174

174175
#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
176+
.fill : {
177+
FILL(0);
178+
BYTE(0);
179+
. = ALIGN(8);
180+
}
175181
__appended_dtb = .;
176182
/* leave space for appended DTB */
177183
. += 0x100000;

crypto/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ config CRYPTO_POLY1305_X86_64
767767

768768
config CRYPTO_POLY1305_MIPS
769769
tristate "Poly1305 authenticator algorithm (MIPS optimized)"
770-
depends on CPU_MIPS32 || (CPU_MIPS64 && 64BIT)
770+
depends on MIPS
771771
select CRYPTO_ARCH_HAVE_LIB_POLY1305
772772

773773
config CRYPTO_MD4

drivers/net/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ config WIREGUARD
9494
select CRYPTO_BLAKE2S_ARM if ARM
9595
select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON
9696
select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2
97-
select CRYPTO_POLY1305_MIPS if CPU_MIPS32 || (CPU_MIPS64 && 64BIT)
97+
select CRYPTO_POLY1305_MIPS if MIPS
9898
help
9999
WireGuard is a secure, fast, and easy to use replacement for IPSec
100100
that uses modern cryptography and clever networking tricks. It's

0 commit comments

Comments
 (0)