In the previous articles of this series, we analyzed how QEMU starts executing the BIOS firmware (see here) and how addresses are translated from the emulated physical space to the host memory (see here). The proposal now is to discuss what these first instructions are doing and how the first I/O interaction with virtual hardware looks like.
After the initial long jump at the entry point, the BIOS firmware has the following i8086 instructions:
1 2 3 4 5 6 7 |
cmpl $0x0,%cs:0x62e8 jne 0x0000d08a xor %dx,%dx mov %dx,%ss mov $0x7000,%esp mov $0xef209,%edx jmp 0x0000cf04 |
The first comparison is to check whether the VM is resuming or rebooting. Assuming the latter, the stack segment selector is set to 0x0 and the stack pointer to 0x7000. According to the Memory Regions map, the stack will be located in ram-below-4g. An address value, which belongs to the pc.bios region, is finally loaded into the EDX register and a jump to a different block occurs. Source code is available here and here.
Continue reading “BIOS execution in QEMU: first I/O interaction”