Skip to content

Commit 1186e4e

Browse files
committed
MIPS: Avoid overoptimization by GCC.
Without this, it's possible that LTO will discard the calls to set_except_vector() in the probe for the DADDI overflow bug resulting in a kernel crash like this: [...] Mount-cache hash table entries: 256 Checking for the daddi bug... Integer overflow[#1]: Cpu 0 $ 0 : 0000000000000000 0000000010008ce1 0000000000000001 0000000000000000 $ 4 : 7fffffffffffedcd ffffffff81410000 0000000000000030 000000000000003f [...] There are other similar places in the kernel so we've just been lucky that GCC's been tolerant. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 02b849f commit 1186e4e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

arch/mips/kernel/traps.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,9 +1390,8 @@ unsigned long vi_handlers[64];
13901390
void __init *set_except_vector(int n, void *addr)
13911391
{
13921392
unsigned long handler = (unsigned long) addr;
1393-
unsigned long old_handler = exception_handlers[n];
1393+
unsigned long old_handler = xchg(&exception_handlers[n], handler);
13941394

1395-
exception_handlers[n] = handler;
13961395
if (n == 0 && cpu_has_divec) {
13971396
unsigned long jump_mask = ~((1 << 28) - 1);
13981397
u32 *buf = (u32 *)(ebase + 0x200);

0 commit comments

Comments
 (0)