Search code examples
debuggingx86qemuosdev

How do I catch the cause of my x86 CPU reset?


I'm running Linux on QEMU emulating an x86_64 CPU. I'm attempting to Kexec into an elf32-format kernel, but after executing the the kernel, the system reboots and I'm not sure how to figure out why.

I attach GDB and can confirm that the new kernel is loaded properly and begins executing. I set a HW breakpoint after the new kernel sets up a new IDT and I put breakpoints on all the vectors to try and catch whatever exception might be getting raised (triple-fault reset) but nothing seems to hit.

Apart from deliberate reboot techniques (FAR JMP 0xFFFF:0000 ...etc), is there anything else that could be causing the CPU to reset that I'm missing?

Thanks.


Solution

  • The main way to do this would be to at the following flags to your QEMU call

    • -d int causes QEMU to display interrupts on error
    • -no-reboot will make it so that your machine won’t reboot
    • -no-shutdown same as -no-reboot

    Also, the reason that your QEMU is rebooting is probably a Segmentation Fault.