diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index 4158c0459..0777d4280 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -20,7 +20,6 @@ #include #include -static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, }; static spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, }; uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE]; @@ -214,8 +213,8 @@ int32_t request_irq(uint32_t req_irq, irq_action_t action_fn, void *priv_data, ret = -EINVAL; } else { desc = &irq_desc_array[irq]; - spinlock_irqsave_obtain(&desc->lock, &rflags); if (desc->action == NULL) { + spinlock_irqsave_obtain(&desc->lock, &rflags); desc->flags = flags; desc->priv_data = priv_data; desc->action = action_fn; @@ -224,8 +223,6 @@ int32_t request_irq(uint32_t req_irq, irq_action_t action_fn, void *priv_data, ret = (int32_t)irq; dev_dbg(DBG_LEVEL_IRQ, "[%s] irq%d vr:0x%x", __func__, irq, desc->vector); } else { - spinlock_irqrestore_release(&desc->lock, rflags); - ret = -EBUSY; pr_err("%s: request irq(%u) vr(%u) failed, already requested", __func__, irq, irq_to_vector(irq)); @@ -372,15 +369,9 @@ void dispatch_exception(struct intr_excp_ctx *ctx) { uint16_t pcpu_id = get_pcpu_id(); - /* Obtain lock to ensure exception dump doesn't get corrupted */ - spinlock_obtain(&exception_spinlock); - /* Dump exception context */ dump_exception(ctx, pcpu_id); - /* Release lock to let other CPUs handle exception */ - spinlock_release(&exception_spinlock); - /* Halt the CPU */ cpu_dead(); } diff --git a/hypervisor/debug/dump.c b/hypervisor/debug/dump.c index 6def74653..de4f9bd37 100644 --- a/hypervisor/debug/dump.c +++ b/hypervisor/debug/dump.c @@ -18,6 +18,7 @@ #define CALL_TRACE_HIERARCHY_MAX 20U #define DUMP_STACK_SIZE 0x200U +static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, }; /* * readable exception descriptors. */ @@ -242,6 +243,9 @@ void dump_intr_excp_frame(const struct intr_excp_ctx *ctx) void dump_exception(struct intr_excp_ctx *ctx, uint16_t pcpu_id) { + /* Obtain lock to ensure exception dump doesn't get corrupted */ + spinlock_obtain(&exception_spinlock); + /* Dump host context */ dump_intr_excp_frame(ctx); /* Show host stack */ @@ -252,4 +256,7 @@ void dump_exception(struct intr_excp_ctx *ctx, uint16_t pcpu_id) /* Save registers*/ crash_ctx = ctx; cache_flush_invalidate_all(); + + /* Release lock to let other CPUs handle exception */ + spinlock_release(&exception_spinlock); }