Issue
I'm writing a binary that runs in an early phase of the boot process. To be specific, a multiboot2-compliant kernel, that runs in 64-bit (AMD64/x86_64) mode after GRUBs handoff (GRUB is my bootloader). To debug and test my code, I thought of writing values to registers and execute a hlt
. Afterwards, I can view the register values in QEMU. Surprisingly, my hlt
-instructions are ignored/skipped and register values like in eax
are not what I expect them to be. I don't understand why, because when I use a multiboot2-header that instructs GRUB to do a 32-bit multiboot2 handoff, it works. What's going on here?
Solution
In my project I figured out, that when GRUB does a handoff to the binary in the EFI amd64 machine with boot services enabled-state [section 3.5 of Multiboot2 spec], interrupts are enabled. I don't know what specific interrupt QEMU reports to the CPU in this case, but if you disable them by adding a cli
instruction once before the hlt
, it works as desired. Don't forget to enable interrupts again, when it's the right time for it in your kernel.
Answered By - phip1611
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.