Fix one dabort and iabort lock bug.

This commit is contained in:
TXuian 2024-03-19 10:22:02 +08:00
parent 08c8f0b952
commit 620965dc2c
2 changed files with 11 additions and 11 deletions

View File

@ -95,7 +95,7 @@ void handle_undefined_instruction(struct trapframe* tf)
extern void context_switch(struct context**, struct context*);
void dabort_handler(struct trapframe* r)
{
if (!is_spinlock_locked(&whole_kernel_lock)) {
if (!is_spinlock_locked(&whole_kernel_lock) || whole_kernel_lock.owner_cpu != cur_cpuid()) {
spinlock_lock(&whole_kernel_lock);
}
uint32_t dfs, dfa;
@ -122,7 +122,7 @@ void dabort_handler(struct trapframe* r)
void iabort_handler(struct trapframe* r)
{
if (!is_spinlock_locked(&whole_kernel_lock)) {
if (!is_spinlock_locked(&whole_kernel_lock) || whole_kernel_lock.owner_cpu != cur_cpuid()) {
spinlock_lock(&whole_kernel_lock);
}
uint32_t ifs, ifa;

View File

@ -68,22 +68,22 @@ void spinlock_lock(struct spinlock* lock)
ERROR("spinlock %s lock double locked by core %d\n", lock->name, lock->owner_cpu);
panic("");
}
// _spinlock_lock(&request_lock, SPINLOCK_LOCK_WAITFOREVER);
// doubleListAddOnBack(&core_lock_request[cur_cpuid()].node, &lock_request_guard);
// _spinlock_unlock(&request_lock);
_spinlock_lock(&request_lock, SPINLOCK_LOCK_WAITFOREVER);
doubleListAddOnBack(&core_lock_request[cur_cpuid()].node, &lock_request_guard);
_spinlock_unlock(&request_lock);
// while (lock_request_guard.next != &core_lock_request[cur_cpuid()].node)
// ;
while (lock_request_guard.next != &core_lock_request[cur_cpuid()].node)
;
_spinlock_lock(lock, SPINLOCK_LOCK_WAITFOREVER);
}
void spinlock_unlock(struct spinlock* lock)
{
// assert(lock_request_guard.next == &core_lock_request[cur_cpuid()].node);
// _spinlock_lock(&request_lock, SPINLOCK_LOCK_WAITFOREVER);
// _double_list_del(core_lock_request[cur_cpuid()].node.prev, core_lock_request[cur_cpuid()].node.next);
// _spinlock_unlock(&request_lock);
assert(lock_request_guard.next == &core_lock_request[cur_cpuid()].node);
_spinlock_lock(&request_lock, SPINLOCK_LOCK_WAITFOREVER);
_double_list_del(core_lock_request[cur_cpuid()].node.prev, core_lock_request[cur_cpuid()].node.next);
_spinlock_unlock(&request_lock);
_spinlock_unlock(lock);
}