Files
slimbootloader/BootloaderCorePkg/Library/CpuExceptionLib
Lennert Buytenhek 0a90065ac9 Print code bytes around eip/rip when taking a fatal exception
When we die due to a fatal exception, we get a debug message that
looks like this:

	Exception #6 from 0x0010:0x000728E9 !!!

This message by itself is not incredibly useful for figuring out
which code caused the exception.

This patch borrows an idea from the Linux kernel, and extends the
exception information with a dump of the opcode bytes around the
instruction pointer, which means that the exception debug message
will now look like this:

	Exception #6 from 0x0010:0x000728E9 !!!
	000728C9: 07 00 6A 40 E8 E0 E8 FF-FF 83 C4 0C 68 00 00 07  [...]
	000728D9: 00 68 DA 3A 07 00 6A 40-E8 CC E8 FF FF 83 C4 10  [...]
	000728E9: 0F 0B E8 8E F2 FF FF 8D-55 98 80 78 0E 01 8D 45  [...]
	000728F9: 94 75 06 52 50 6A 01 EB-04 52 50 6A 00 68 53 47  [...]

Tested by inserting a UD2 instruction into Stage1A and verifying on
qemu ia32 and on qemu x64 that the right information is printed.

Signed-off-by: Lennert Buytenhek <buytenh@arista.com>
2021-11-19 12:20:46 -08:00
..