<div dir="ltr"><div>Hi!</div><div>Recently, I encountered a seabios hanging problem. When I try to inject an MSI-X interrupt along with SMI in qemu like below:</div><div>*************** patch below*********************</div><div>diff --git a/target-i386/kvm.c b/target-i386/kvm.c- a/target-i386/kvm.c</div><div><br></div><div><br></div><div>---   a/target-i386/kvm.c</div><div>+++   b/target-i386/kvm.c</div><div><br></div><div>@@ -104,6 +104,7 @@ static uint32_t num_architectural_pmu_counters;</div><div> static int has_xsave;</div><div> static int has_xcrs;</div><div> static int has_pit_state2;</div><div>+static int msi_count;</div><div><br></div><div>static bool has_msr_mcg_ext_ctl;</div><div><br></div><div>@@ -2870,12 +2871, 26 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)</div><div><span style="white-space:pre">       </span>DPRINTF("inject SMI\n");</div><div>+<span style="white-space:pre">   </span>MSIMessage msg = {.address = 0x0, .data = 0x4062};</div><div>+<span style="white-space:pre">   </span>if (msi_count == 1) {</div><div>+<span style="white-space:pre">                </span>ret = kvm_irqchip_send_msi(kvm_state, msg);</div><div>+<span style="white-space:pre">          </span>if (ret <0) {</div><div>+<span style="white-space:pre">                     </span>QEMU_LOG(LOG_ALERT, "MSI lost %s\n", strerror(-ret));</div><div>+<span style="white-space:pre">              </span>}</div><div>+<span style="white-space:pre">    </span>}</div><div>+<span style="white-space:pre">    </span>msi_count++;</div><div><br></div><div><span style="white-space:pre"> </span>ret = kvm_vcpu_ioctl(cpu, KVM_SMI);</div><div><span style="white-space:pre">   </span>if (ret < 0)</div><div>**************patch above*************************</div><div><br></div><div>Then, when the vm will hang when booting.</div><div>There will be only one line in the vnc displayer:</div><div><span style="white-space:pre">     </span>"Guest has not initialized the display(yet)"</div><div><br></div><div>I went through the codes(kvm qemu seabios), and I found the check_irqs function in seabios will allow interrupt for a while.</div><div>When the interrupt triggered, the vcpu will lookup the seabios IDT table and jump to the interrupt handler.</div><div><br></div><div>However, in ivt_init(void), the entries from 0x60 to 0x66 will be cleared, which is configured by the patch below.</div><div><br></div><div><a href="https://github.com/coreboot/seabios/commit/b164d2c1b8ff2dd764dcf064e2624dd4aa78c112">https://github.com/coreboot/seabios/commit/b164d2c1b8ff2dd764dcf064e2624dd4aa78c112</a></div><div><br></div><div>So the vcpu will jump to an undefined entry instead of the default entry.</div><div><br></div><div>=========================================================================</div><div>I removed the patch, and the bug seems to disappear. I wonder if this is an approprite solution. </div><div>=========================================================================</div><div><br></div><div>There is an another strange thing: </div><div><span style="white-space:pre">      </span>I opened kvm trace, and it showed like below:</div><div>************************</div><div><span style="white-space:pre">  </span>kvm_inj_exception: #UD(0x0)</div><div><span style="white-space:pre">   </span>kvm_entry: vcpu0</div><div><span style="white-space:pre">      </span>kvm_run: vcpu 0 to guest mode</div><div><span style="white-space:pre"> </span>kvm_run: vcpu 0 out guest mode</div><div><span style="white-space:pre">        </span>kvm_exit: reason EXCEPTION_NMI rip 0x3 info 0 80000306</div><div><span style="white-space:pre">        </span>kvm_emulate_insn: 0:3:f0 53 (real)</div><div><span style="white-space:pre">    </span>kvm_inj_exception: #UD(0x0)</div><div><span style="white-space:pre">   </span>kvm_entry: vcpu0</div><div><span style="white-space:pre">      </span>kvm_run: vcpu 0 to guest mode</div><div><span style="white-space:pre"> </span>kvm_run: vcpu 0 out guest mode</div><div><span style="white-space:pre">        </span>kvm_exit: reason EXCEPTION_NMI rip 0x3 info 0 80000306</div><div><span style="white-space:pre">        </span>kvm_emulate_insn: 0:3:f0 53 (real)</div><div>************************</div><div>It seems the emulation got wrong at cs:eip = 0:0x3, but the entry is set to 0 in ivt_init(void).</div><div><br></div><div>thanks!</div><div><br></div></div>