diff options
author | Ruslan Bukin <br@FreeBSD.org> | 2019-05-07 14:32:17 +0000 |
---|---|---|
committer | Ruslan Bukin <br@FreeBSD.org> | 2019-05-07 14:32:17 +0000 |
commit | bf03b1f1f95eeb68aaebbdd3fa160c5dfd9d8141 (patch) | |
tree | 62d7d45f2ead4890351dff9af3432e04a4a1ec85 /sys/riscv | |
parent | 75cf8837a97de72a0b56e5a53feea45419280119 (diff) | |
download | src-bf03b1f1f95eeb68aaebbdd3fa160c5dfd9d8141.tar.gz src-bf03b1f1f95eeb68aaebbdd3fa160c5dfd9d8141.zip |
Disable interrupts first and then set spinlock_count to 1.
Otherwise interrupt can be generated just after setting spinlock_count
and before disabling interrupts.
Sponsored by: DARPA, AFRL
Notes
Notes:
svn path=/head/; revision=347226
Diffstat (limited to 'sys/riscv')
-rw-r--r-- | sys/riscv/riscv/machdep.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index ae4c040dc479..417373744aeb 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -457,11 +457,13 @@ void spinlock_enter(void) { struct thread *td; + register_t reg; td = curthread; if (td->td_md.md_spinlock_count == 0) { + reg = intr_disable(); td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_sstatus_ie = intr_disable(); + td->td_md.md_saved_sstatus_ie = reg; } else td->td_md.md_spinlock_count++; critical_enter(); |