summaryrefslogtreecommitdiffstats
path: root/sys/pc98/pc98
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2010-11-05 13:42:58 +0000
committerjhb <jhb@FreeBSD.org>2010-11-05 13:42:58 +0000
commit45c075992033864639eca604d1f27bcc4d87ba30 (patch)
tree9c9e2a373ad3546db39524c212798203a0a20f10 /sys/pc98/pc98
parentd9503acaf4d38eb42677c9030fe7cd7d15af3802 (diff)
downloadFreeBSD-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/pc98/pc98')
-rw-r--r--sys/pc98/pc98/machdep.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index e01ef68..942aa45 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -2340,11 +2340,15 @@ void
spinlock_enter(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
- if (td->td_md.md_spinlock_count == 0)
- td->td_md.md_saved_flags = intr_disable();
- td->td_md.md_spinlock_count++;
+ if (td->td_md.md_spinlock_count == 0) {
+ flags = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_flags = flags;
+ } else
+ td->td_md.md_spinlock_count++;
critical_enter();
}
@@ -2352,12 +2356,14 @@ void
spinlock_exit(void)
{
struct thread *td;
+ register_t flags;
td = curthread;
critical_exit();
+ flags = td->td_md.md_saved_flags;
td->td_md.md_spinlock_count--;
if (td->td_md.md_spinlock_count == 0)
- intr_restore(td->td_md.md_saved_flags);
+ intr_restore(flags);
}
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
OpenPOWER on IntegriCloud