diff options
author | jhb <jhb@FreeBSD.org> | 2010-11-05 13:42:58 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2010-11-05 13:42:58 +0000 |
commit | 45c075992033864639eca604d1f27bcc4d87ba30 (patch) | |
tree | 9c9e2a373ad3546db39524c212798203a0a20f10 /sys/powerpc/aim/machdep.c | |
parent | d9503acaf4d38eb42677c9030fe7cd7d15af3802 (diff) | |
download | FreeBSD-src-45c075992033864639eca604d1f27bcc4d87ba30.zip FreeBSD-src-45c075992033864639eca604d1f27bcc4d87ba30.tar.gz |
Adjust the order of operations in spinlock_enter() and spinlock_exit() to
work properly with single-stepping in a kernel debugger. Specifically,
these routines have always disabled interrupts before increasing the nesting
count and restored the prior state of interrupts after decreasing the nesting
count to avoid problems with a nested interrupt not disabling interrupts
when acquiring a spin lock. However, trap interrupts for single-stepping
can still occur even when interrupts are disabled. Now the saved state of
interrupts is not saved in the thread until after interrupts have been
disabled and the nesting count has been increased. Similarly, the saved
state from the thread cannot be read once the nesting count has been
decreased to zero. To fix this, use temporary variables to store interrupt
state and shuffle it between the thread's MD area and the appropriate
registers.
In cooperation with: bde
MFC after: 1 month
Diffstat (limited to 'sys/powerpc/aim/machdep.c')
-rw-r--r-- | sys/powerpc/aim/machdep.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c index 9dec1f7..0331b50 100644 --- a/sys/powerpc/aim/machdep.c +++ b/sys/powerpc/aim/machdep.c @@ -751,11 +751,15 @@ void spinlock_enter(void) { struct thread *td; + register_t msr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_msr = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + msr = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_msr = msr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -763,12 +767,14 @@ void spinlock_exit(void) { struct thread *td; + register_t msr; td = curthread; critical_exit(); + msr = td->td_md.md_saved_msr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_msr); + intr_restore(msr); } /* |