Skip to content

Commit e4dc601

Browse files
committed
m68k: Disable/restore interrupts in hwreg_present()/hwreg_write()
hwreg_present() and hwreg_write() temporarily change the VBR register to another vector table. This table contains a valid bus error handler only, all other entries point to arbitrary addresses. If an interrupt comes in while the temporary table is active, the processor will start executing at such an arbitrary address, and the kernel will crash. While most callers run early, before interrupts are enabled, or explicitly disable interrupts, Finn Thain pointed out that macsonic has one callsite that doesn't, causing intermittent boot crashes. There's another unsafe callsite in hilkbd. Fix this for good by disabling and restoring interrupts inside hwreg_present() and hwreg_write(). Explicitly disabling interrupts can be removed from the callsites later. Reported-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Cc: stable@vger.kernel.org
1 parent fd4d453 commit e4dc601

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎arch/m68k/mm/hwtest.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
int hwreg_present( volatile void *regp )
2929
{
3030
int ret = 0;
31+
unsigned long flags;
3132
long save_sp, save_vbr;
3233
long tmp_vectors[3];
3334

35+
local_irq_save(flags);
3436
__asm__ __volatile__
3537
( "movec %/vbr,%2\n\t"
3638
"movel #Lberr1,%4@(8)\n\t"
@@ -46,6 +48,7 @@ int hwreg_present( volatile void *regp )
4648
: "=&d" (ret), "=&r" (save_sp), "=&r" (save_vbr)
4749
: "a" (regp), "a" (tmp_vectors)
4850
);
51+
local_irq_restore(flags);
4952

5053
return( ret );
5154
}
@@ -58,9 +61,11 @@ EXPORT_SYMBOL(hwreg_present);
5861
int hwreg_write( volatile void *regp, unsigned short val )
5962
{
6063
int ret;
64+
unsigned long flags;
6165
long save_sp, save_vbr;
6266
long tmp_vectors[3];
6367

68+
local_irq_save(flags);
6469
__asm__ __volatile__
6570
( "movec %/vbr,%2\n\t"
6671
"movel #Lberr2,%4@(8)\n\t"
@@ -78,6 +83,7 @@ int hwreg_write( volatile void *regp, unsigned short val )
7883
: "=&d" (ret), "=&r" (save_sp), "=&r" (save_vbr)
7984
: "a" (regp), "a" (tmp_vectors), "g" (val)
8085
);
86+
local_irq_restore(flags);
8187

8288
return( ret );
8389
}

0 commit comments

Comments
 (0)