]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Enable interrupts while handling traps
authormhorne <mhorne@FreeBSD.org>
Thu, 13 Aug 2020 14:21:05 +0000 (14:21 +0000)
committermhorne <mhorne@FreeBSD.org>
Thu, 13 Aug 2020 14:21:05 +0000 (14:21 +0000)
commitdbfd259b0954d15da78a0da52fa0fd8378e707a5
treeb65e1948fcab589b78f9d7a13450bdd574356a8e
parent94ef8551112529178da3b53eb5e20c8efd3987a6
Enable interrupts while handling traps

I observed hangs post-r362977 in QEMU with -smp 2, in which one thread
would acquire write access to an rm_lock (sysctllock) and get stuck
waiting in smp_rendezvous_cpus while the other CPU was servicing a trap.
The other thread was waiting for read access to the same lock, thus
causing deadlock.

It's clear that this is just one symptom of a larger problem. The
general expectation of MI kernel code is that interrupts are enabled.
Violating this assumption will at best create some additional latency,
but otherwise might cause locking or other unforeseen issues. All other
architectures do so for some subset of trap values, but this somehow got
missed in the RISC-V port. Enable interrupts now during kernel page
faults and for all user trap types.

The code in exception.S already knows to disable interrupts while
handling the return from exception, so there are no changes required
there.

Reviewed by: jhb, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26017
sys/riscv/riscv/trap.c