[SeaBIOS] seabios hangs when injecting an MSI-X interrupt in early booting.

Zhe Liu liuzhe452769109 at gmail.com
Thu Mar 22 04:40:46 CET 2018


Hi!
Recently, I encountered a seabios hanging problem. When I try to inject an
MSI-X interrupt along with SMI in qemu like below:
*************** patch below*********************
diff --git a/target-i386/kvm.c b/target-i386/kvm.c- a/target-i386/kvm.c


---   a/target-i386/kvm.c
+++   b/target-i386/kvm.c

@@ -104,6 +104,7 @@ static uint32_t num_architectural_pmu_counters;
 static int has_xsave;
 static int has_xcrs;
 static int has_pit_state2;
+static int msi_count;

static bool has_msr_mcg_ext_ctl;

@@ -2870,12 +2871, 26 @@ void kvm_arch_pre_run(CPUState *cpu, struct
kvm_run *run)
DPRINTF("inject SMI\n");
+ MSIMessage msg = {.address = 0x0, .data = 0x4062};
+ if (msi_count == 1) {
+ ret = kvm_irqchip_send_msi(kvm_state, msg);
+ if (ret <0) {
+ QEMU_LOG(LOG_ALERT, "MSI lost %s\n", strerror(-ret));
+ }
+ }
+ msi_count++;

ret = kvm_vcpu_ioctl(cpu, KVM_SMI);
if (ret < 0)
**************patch above*************************

Then, when the vm will hang when booting.
There will be only one line in the vnc displayer:
"Guest has not initialized the display(yet)"

I went through the codes(kvm qemu seabios), and I found the check_irqs
function in seabios will allow interrupt for a while.
When the interrupt triggered, the vcpu will lookup the seabios IDT table
and jump to the interrupt handler.

However, in ivt_init(void), the entries from 0x60 to 0x66 will be cleared,
which is configured by the patch below.

https://github.com/coreboot/seabios/commit/b164d2c1b8ff2dd764dcf064e2624dd4aa78c112

So the vcpu will jump to an undefined entry instead of the default entry.

=========================================================================
I removed the patch, and the bug seems to disappear. I wonder if this is an
approprite solution.
=========================================================================

There is an another strange thing:
I opened kvm trace, and it showed like below:
************************
kvm_inj_exception: #UD(0x0)
kvm_entry: vcpu0
kvm_run: vcpu 0 to guest mode
kvm_run: vcpu 0 out guest mode
kvm_exit: reason EXCEPTION_NMI rip 0x3 info 0 80000306
kvm_emulate_insn: 0:3:f0 53 (real)
kvm_inj_exception: #UD(0x0)
kvm_entry: vcpu0
kvm_run: vcpu 0 to guest mode
kvm_run: vcpu 0 out guest mode
kvm_exit: reason EXCEPTION_NMI rip 0x3 info 0 80000306
kvm_emulate_insn: 0:3:f0 53 (real)
************************
It seems the emulation got wrong at cs:eip = 0:0x3, but the entry is set to
0 in ivt_init(void).

thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/seabios/attachments/20180322/7ecf7186/attachment.html>


More information about the SeaBIOS mailing list