OSDN Git Service

powerpc/64s: system call scv tabort fix for corrupt irq soft-mask state
authorNicholas Piggin <npiggin@gmail.com>
Fri, 3 Sep 2021 12:57:06 +0000 (22:57 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 13 Sep 2021 12:34:11 +0000 (22:34 +1000)
commitb871895b148256f1721bc565d803860242755a0b
tree0f3ba0c3f3db15f3649c927ce5f6394026125b57
parent6880fa6c56601bb8ed59df6c30fd390cc5f6dd8f
powerpc/64s: system call scv tabort fix for corrupt irq soft-mask state

If a system call is made with a transaction active, the kernel
immediately aborts it and returns. scv system calls disable irqs even
earlier in their interrupt handler, and tabort_syscall does not fix this
up.

This can result in irq soft-mask state being messed up on the next
kernel entry, and crashing at BUG_ON(arch_irq_disabled_regs(regs)) in
the kernel exit handlers, or possibly worse.

This can't easily be fixed in asm because at this point an async irq may
have hit, which is soft-masked and marked pending. The pending interrupt
has to be replayed before returning to userspace. The fix is to move the
tabort_syscall code to C in the main syscall handler, and just skip the
system call but otherwise return as usual, which will take care of the
pending irqs. This also does a bunch of other things including possible
signal delivery to the process, but the doomed transaction should still
be aborted when it is eventually returned to.

The sc system call path is changed to use the new C function as well to
reduce code and path differences. This slows down how quickly system
calls are aborted when called while a transaction is active, which could
potentially impact TM performance. But making any system call is already
bad for performance, and TM is on the way out, so go with simpler over
faster.

Fixes: 7fa95f9adaee7 ("powerpc/64s: system call support for scv/rfscv instructions")
Reported-by: Eirik Fuller <efuller@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Use #ifdef rather than IS_ENABLED() to fix build error on 32-bit]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210903125707.1601269-1-npiggin@gmail.com
arch/powerpc/kernel/interrupt.c
arch/powerpc/kernel/interrupt_64.S