[ipxe-devel] Tips on how to debug EFI code (iPXE) from within KVM after ipxe.efi has crashed with #GP?

Michael Brown mcb30 at ipxe.org
Thu Sep 28 18:04:43 UTC 2017

On 28/09/17 18:37, Konrad Rzeszutek Wilk wrote:
> !!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID -
> 00000000 !!!!
> ExceptionData - 0000000000000000
> RIP  - 00000000BEC2949C, CS  - 0000000000000038, RFLAGS - 0000000000210216
 > ....
> !!!! Find image 808610ed.efidrv (ImageBase=00000000BEC27000,
> EntryPoint=00000000BEC2E089) !!!!
> And now I am trying to figure out how to troubleshoot this.
> (and yes I am thinking it was related to the Tivoli work-around, but
> disabling that didn't help).

The Tivoli workaround is for legacy BIOS only; it doesn't apply to the 
UEFI build of iPXE.

You have the RIP and ImageBase, so you know that the exception happens 
at offset +0x249c within your iPXE binary.  You can use this in 
conjunction with the corresponding map file from the iPXE build (which 
will probably be named bin-x86_64-efi/808610d3.efidrv.tmp.map, but see 
below) to figure out exactly where the crash is occurring.

> #crash ipxe/src/bin/ipxe.lkrn.tmp ./guest-memory

That's a completely different iPXE binary from the one you are using.

> - The 80810ed.efidrv is built using:
> (cd ipxe/src;make bin-x86_64-efi/808610d3.efi  CONFIG=qemu
> DEBUG=iscsi:4,scsi:4 EMBED=/ipxe.config -j8)
> if [ $? -ne 0 ]; then exit 1; fi
> (cd ipxe/src;EfiRom -f 0x8086 -i 0x1528 --pci23 -ec
> bin-x86_64-efi/808610d3.efidrv -o ../../808610d3.rom)
> if [ $? -ne 0 ]; then exit 1; fi

You can build this much more simply in a single command:

   make bin-x86_64-efi/808610d3.efirom EMBED=/ipxe.config

Also note that:

- debug levels in iPXE are bitmasks, so DEBUG=....:4 generally doesn't 
make much sense.  You probably want DEBUG=iscsi,scsi for minimal debug 
(i.e. detailed error messages for any problems), or DEBUG=iscsi:3,scsi:3 
for much more verbose logging.  That said, you don't seem to be using 
iSCSI anyway, so .....?

- In your build chain (using EfiRom) I think you have a typo: you build 
the EFI _application_ bin-x86_64-efi/808610d3.efi but then use the EFI 
_driver_ bin-x86_64-efi/808610d3.efidrv, which you have not explicitly 
built.  Your final binary may therefore not match what you think you 
have just built.  You should probably not worry about any of this, and 
just use the single-command build given above instead.


More information about the ipxe-devel mailing list