From: David Woodhouse Date: Wed, 11 Jan 2023 14:53:18 +0000 (+0000) Subject: printf debugging for intack X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fintack;p=users%2Fdwmw2%2Fqemu.git printf debugging for intack --- diff --git a/hw/core/irq.c b/hw/core/irq.c index 552e732835..f5d5eab0b1 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -32,6 +32,7 @@ DECLARE_INSTANCE_CHECKER(struct IRQState, IRQ, struct IRQState { Object parent_obj; + bool printed; qemu_irq_ack_fn ack_cb; void *ack_opaque; @@ -51,16 +52,26 @@ void qemu_set_irq(qemu_irq irq, int level) void qemu_set_irq_ack_callback(qemu_irq irq, qemu_irq_ack_fn cb, void *opaque) { if (irq) { + printf("Set ack callback on %p to %p/%p\n", irq, cb, opaque); irq->ack_cb = cb; irq->ack_opaque = opaque; - } + irq->printed = false; + } else printf("no irq!\n"); } bool qemu_notify_irq_ack(qemu_irq irq) { if (irq && irq->ack_cb) { + if (!irq->printed) { + printf("Calling ack callback on %p\n", irq); + irq->printed = true; + } return irq->ack_cb(irq, irq->ack_opaque); } + if (irq && !irq->printed) { + printf("No ack callback on %p\n", irq); + irq->printed = true; + } return false; } diff --git a/hw/i386/kvm/xen-stubs.c b/hw/i386/kvm/xen-stubs.c index 6f433dc995..523cb5a831 100644 --- a/hw/i386/kvm/xen-stubs.c +++ b/hw/i386/kvm/xen-stubs.c @@ -15,11 +15,11 @@ EvtchnInfoList *qmp_xen_event_list(Error **errp) { - error_setg(errp, "Xen event channel emulation not enabled"); + error_setg(errp, "Xen event channel emulation not enabled\n"); return NULL; } void qmp_xen_event_inject(uint32_t port, Error **errp) { - error_setg(errp, "Xen event channel emulation not enabled"); + error_setg(errp, "Xen event channel emulation not enabled\n"); } diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 5867868549..788e1fe5db 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -237,6 +237,8 @@ void xen_evtchn_connect_gsis(qemu_irq *system_gsis) for (i = 0; i < GSI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(s), i, system_gsis[i]); + printf("Xen connect gsi %p to system gsi %p\n", + s->gsis[i], system_gsis[i]); } } @@ -284,6 +286,7 @@ void xen_evtchn_set_callback_level(int level) XenEvtchnState *s = xen_evtchn_singleton; if (s && s->callback_gsi && s->callback_gsi < GSI_NUM_PINS) { + printf("set level on %p(%d) to %d\n", s->gsis[s->callback_gsi], s->callback_gsi, level); qemu_set_irq(s->gsis[s->callback_gsi], level); } } @@ -293,11 +296,12 @@ static bool resample_evtchn_irq(qemu_irq irq, void *opaques) struct vcpu_info *vi = kvm_xen_get_vcpu_info_hva(0); if (vi && !vi->evtchn_upcall_pending) { + printf("resample turns evtchn irq off\n"); return true; } + printf("no turn off\n"); return false; } - int xen_evtchn_set_callback_param(uint64_t param) { XenEvtchnState *s = xen_evtchn_singleton; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8cfd6ff641..203c13e354 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1369,6 +1369,8 @@ void pc_i8259_create(ISABus *isa_bus, GSIState *gsi_state) for (size_t i = 0; i < ISA_NUM_IRQS; i++) { gsi_state->i8259_irq[i] = i8259[i]; + printf("Set ack on %p (i8259 %zd) to %p\n", + gsi_state->i8259_irq[i], i, gsi_state->gsi_irq[i]); qemu_set_irq_ack_callback(gsi_state->i8259_irq[i], gsi_ack_handler, gsi_state->gsi_irq[i]); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 677e4ec3eb..46e791cdc9 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -624,6 +624,7 @@ bool gsi_ack_handler(qemu_irq irq, void *opaque) * opaque pointer that was registered is the GSI irq. Propagate * the notifiation. */ + printf("Passing on ack from %p to %p\n", irq, opaque); return qemu_notify_irq_ack(opaque); } @@ -647,6 +648,8 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name) for (i = 0; i < IOAPIC_NUM_PINS; i++) { gsi_state->ioapic_irq[i] = qdev_get_gpio_in(dev, i); + printf("Set ack on %p (ioapic %d) to %p\n", + gsi_state->ioapic_irq[i], i, gsi_state->gsi_irq[i]); qemu_set_irq_ack_callback(gsi_state->ioapic_irq[i], gsi_ack_handler, gsi_state->gsi_irq[i]); } @@ -665,6 +668,8 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state) for (i = 0; i < IOAPIC_NUM_PINS; i++) { gsi_state->ioapic2_irq[i] = qdev_get_gpio_in(dev, i); + printf("Set ack on %p (ioapic %d) to %p\n", + gsi_state->ioapic2_irq[i], i, gsi_state->gsi_irq[IO_APIC_SECONDARY_IRQBASE + i]); qemu_set_irq_ack_callback(gsi_state->ioapic2_irq[i], gsi_ack_handler, gsi_state->gsi_irq[IO_APIC_SECONDARY_IRQBASE + i]); } diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index 0bc43f0fc3..f7cf0d7b69 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -173,6 +173,7 @@ static void pic_intack(PICCommonState *s, int irq) if (!(s->elcr & (1 << irq))) { s->irr &= ~(1 << irq); } else if (qemu_notify_irq_ack(qdev_get_gpio_in(DEVICE(s), irq))) { + printf("i8259 ack notify returned true\n"); s->irr &= ~(1 << irq); s->last_irr &= ~(1 << irq); } diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 4d56bbedac..4b303682e8 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -261,6 +261,7 @@ void ioapic_eoi_broadcast(int vector) kvm_resample_fd_notify(n); #endif if (qemu_notify_irq_ack(qdev_get_gpio_in(DEVICE(s), n))) { + printf("clearing pin %d for notifier\n", n); s->irr &= ~(1 << n); } if (!(entry & IOAPIC_LVT_REMOTE_IRR)) { diff --git a/include/hw/irq.h b/include/hw/irq.h index f21110d5f0..ee54dbb6f4 100644 --- a/include/hw/irq.h +++ b/include/hw/irq.h @@ -25,9 +25,7 @@ static inline void qemu_irq_pulse(qemu_irq irq) /* * Allows a callback to be invoked when an IRQ is acked at the irqchip, - * allowing it to be resampled and reasserted as appropriate. If the - * callback function returns true, the interrupt is deasserted at the - * irqchip. + * allowing it to be resampled and reasserted as appropriate. */ typedef bool (*qemu_irq_ack_fn)(qemu_irq irq, void *opaque); void qemu_set_irq_ack_callback(qemu_irq irq, qemu_irq_ack_fn cb, void *opaque); diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index a7d3fc33b3..806c66e914 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -391,7 +391,8 @@ void kvm_xen_maybe_deassert_callback(CPUState *cs) /* If the evtchn_upcall_pending flag is cleared, turn the GSI off. */ if (!vi->evtchn_upcall_pending) { env->xen_callback_asserted = false; - //xen_evtchn_set_callback_level(0); + printf("already off?\n"); +// xen_evtchn_set_callback_level(0); } } @@ -432,7 +433,7 @@ void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type) case HVM_PARAM_CALLBACK_TYPE_PCI_INTX: if (vcpu_id == 0) { xen_evtchn_set_callback_level(1); - //X86_CPU(cs)->env.xen_callback_asserted = true; + X86_CPU(cs)->env.xen_callback_asserted = true; } break; }