diff options
author | Regia König | 2022-08-09 11:00:00 +0200 |
---|---|---|
committer | Regia König | 2022-08-09 11:00:00 +0200 |
commit | 9814d8cb459f2c9dc3b6d6b131fa7b4461744256 (patch) | |
tree | 9f684a2908770f90fb84c285f9f9e3d528abf1d6 /test_code | |
parent | start documentation (diff) | |
download | memtest86-9814d8cb459f2c9dc3b6d6b131fa7b4461744256.tar.gz memtest86-9814d8cb459f2c9dc3b6d6b131fa7b4461744256.tar.xz memtest86-9814d8cb459f2c9dc3b6d6b131fa7b4461744256.zip |
Move all documentation into directory -documentation-
Diffstat (limited to 'test_code')
-rw-r--r-- | test_code/OVMF_VARS.fd | bin | 540672 -> 540672 bytes | |||
-rw-r--r-- | test_code/README | 17 | ||||
-rw-r--r-- | test_code/debug.log | 93 | ||||
-rw-r--r-- | test_code/gdbscript | 1 | ||||
-rw-r--r-- | test_code/how to run OVMF | 17 | ||||
-rw-r--r-- | test_code/ovmf_with_gdb_16_5_2022.txt | 171 |
6 files changed, 15 insertions, 284 deletions
diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd Binary files differindex 4abd7bb..5227763 100644 --- a/test_code/OVMF_VARS.fd +++ b/test_code/OVMF_VARS.fd diff --git a/test_code/README b/test_code/README deleted file mode 100644 index 048c893..0000000 --- a/test_code/README +++ /dev/null @@ -1,17 +0,0 @@ -https://retrage.github.io/2019/12/05/debugging-ovmf-en.html - -How to debug with gdb: - -1. make run - -2. ./gen_symbol_offets.sh > gdbscript - -3. make debug - -4. open second terminal. Type gdb - -5. In second terminal: - (gdb) source gdbscript - (gdb) b CoreHandleProtocol - (gdb) target remote localhost:1234 - (gdb) c diff --git a/test_code/debug.log b/test_code/debug.log index cda2afa..8f5c139 100644 --- a/test_code/debug.log +++ b/test_code/debug.log @@ -30,7 +30,7 @@ FW CFG Revision: 0x3 QemuFwCfg interface (DMA) is supported.
Platform PEIM Loaded
CMOS:
-00: 19 00 47 00 12 00 02 08 08 22 26 02 10 80 00 00
+00: 38 00 21 00 14 00 02 08 08 22 26 02 00 80 00 00
10: 00 00 F0 00 06 80 02 FF FF 2F 00 00 04 10 FF FF
20: C8 00 04 3F 00 00 00 00 00 00 00 00 00 00 00 00
30: FF FF 20 00 00 07 00 20 30 00 00 00 00 12 00 00
@@ -1399,82 +1399,19 @@ Loading driver at 0x000064F5000 EntryPoint=0x0000654C804 Shell.efi InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 6CF3818
ProtectUefiImageCommon - 0x6CB0440
- 0x00000000064F5000 - 0x00000000000E24C0
-InstallProtocolInterface: 387477C2-69C7-11D2-8E39-00A0C969723B 66B8620
-InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 66B7E18
+InstallProtocolInterface: 387477C2-69C7-11D2-8E39-00A0C969723B 66B84A0
+InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 66B7F18
InstallProtocolInterface: 6302D008-7F9B-4F30-87AC-60C9FEF5DA4E 65710C0
FSOpen: Open '\' Success
-FSOpen: Open '\' Success
-FSOpen: Open '\' Success
-Image Return Status = Success
-[Bds] Booting Boot Manager Menu.
-[Bds]Stop Hotkey Service!
-Memory Previous Current Next
- Type Pages Pages Pages
-====== ======== ======== ========
- 0A 00000080 00000022 00000080
- 09 00000010 00000007 00000010
- 00 00000080 00000022 00000080
- 05 00000100 0000003D 00000100
- 06 00000100 000000B1 00000100
-[Bds]Booting UiApp
-[Bds] Expand Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(462CAA21-7614-4503-836E-8AB6F4662331) -> Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(462CAA21-7614-4503-836E-8AB6F4662331)
-InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 6CB0440
-Loading driver at 0x0000666E000 EntryPoint=0x0000667D3F8 UiApp.efi
-InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 66B8718
-ProtectUefiImageCommon - 0x6CB0440
- - 0x000000000666E000 - 0x0000000000024D00
-InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 66BB818
-InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 6692838
-InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 6690810
-InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 6690898
-ClockRate = 1843200
-Divisor = 1
-BaudRate/Actual (115200/115200) = 100%
-PciSioSerial: Create SIO child serial device - Device Error
-SataControllerStart START
-SataControllerStart error return status = Already started
- BlockSize : 512
- LastBlock : FBFFF
-ClockRate = 1843200
-Divisor = 1
-BaudRate/Actual (115200/115200) = 100%
-PciSioSerial: Create SIO child serial device - Device Error
-SataControllerStart START
-SataControllerStart error return status = Already started
- BlockSize : 512
- LastBlock : FBFFF
-ClockRate = 1843200
-Divisor = 1
-BaudRate/Actual (115200/115200) = 100%
-PciSioSerial: Create SIO child serial device - Device Error
- BlockSize : 512
- LastBlock : FBFFF
-InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 66907F0
-InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 6690938
-InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 66907D0
-InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 6690A18
-ClockRate = 1843200
-Divisor = 1
-BaudRate/Actual (115200/115200) = 100%
-PciSioSerial: Create SIO child serial device - Device Error
-SataControllerStart START
-SataControllerStart error return status = Already started
- BlockSize : 512
- LastBlock : FBFFF
-ClockRate = 1843200
-Divisor = 1
-BaudRate/Actual (115200/115200) = 100%
-PciSioSerial: Create SIO child serial device - Device Error
-SataControllerStart START
-SataControllerStart error return status = Already started
- BlockSize : 512
- LastBlock : FBFFF
-ClockRate = 1843200
-Divisor = 1
-BaudRate/Actual (115200/115200) = 100%
-PciSioSerial: Create SIO child serial device - Device Error
- BlockSize : 512
- LastBlock : FBFFF
-InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 6690760
-InstallProtocolInterface: 330D4706-F2A0-4E4F-A369-B66FA8D54385 66907A0
-InstallProtocolInterface: 348C4D62-BFBD-4882-9ECE-C80BB1C4783B 0
+FSOpen: Open '.' Success
+FSOpen: Open '\MemtestEfi.efi' Success
+FSOpen: Open '\MemtestEfi.efi' Success
+FSOpen: Open '\MemtestEfi.efi' Success
+FSOpen: Open '\MemtestEfi.efi' Success
+[Security] 3rd party image[0] can be loaded after EndOfDxe: PciRoot(0x0)/Pci(0x1,0x1)/Ata(Primary,Master,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/\MemtestEfi.efi.
+InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 667F040
+Loading driver at 0x0000661D000 EntryPoint=0x000066299A5
+InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 6681698
+ProtectUefiImageCommon - 0x667F040
+ - 0x000000000661D000 - 0x0000000000016D40
+InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 7E9B6A8
diff --git a/test_code/gdbscript b/test_code/gdbscript index 57ed30e..8316706 100644 --- a/test_code/gdbscript +++ b/test_code/gdbscript @@ -104,4 +104,3 @@ add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbM add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuVideoDxe.debug 0x6c66240 add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioGpuDxe.debug 0x6c60240 add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Shell.debug 0x64f5240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UiApp.debug 0x666e240 diff --git a/test_code/how to run OVMF b/test_code/how to run OVMF deleted file mode 100644 index 9776c9e..0000000 --- a/test_code/how to run OVMF +++ /dev/null @@ -1,17 +0,0 @@ -- Create a directory for the *.efi applications. The name is "hda-contents" - -1. With qemu-system-x86_64 command: - -- Create OVMF.fd -> rename it to bios.bin - -- Either place it into the same directory from where the command is executed - or specify the path to bios.bin as argument to -L - -run qemu-system-x86_64 -L . -hda fat:hda-contents -net none // TODO not possible to boot into EFI shell - - - -2. With kvm command: - -run sudo kvm -bios OVMF.fd -hda fat:hda-contents -net none // boots into UEFI Shell - diff --git a/test_code/ovmf_with_gdb_16_5_2022.txt b/test_code/ovmf_with_gdb_16_5_2022.txt deleted file mode 100644 index c5b8b7a..0000000 --- a/test_code/ovmf_with_gdb_16_5_2022.txt +++ /dev/null @@ -1,171 +0,0 @@ -https://retrage.github.io/2019/12/05/debugging-ovmf-en.html - - -Building EDK2 -Build EDK2 using gcc as usual. - -$ git clone git@github.com:tianocore/edk2.git -$ cd edk2 -$ git submodule update --init --recursive -$ make -C BaseTools -$ source ./edksetup.sh -$ build -p OvmfPkg/OvmfPkgX64.dsc -b DEBUG -a X64 -t GCC5 -To make debugging easy, create a Makefile as follow. Note that we have to connect debugcon at 0x402 to dump debug information (debug.log) from OVMF[4]. - -#!/usr/bin/env make - -SHELL=/bin/bash - -LOG=debug.log -OVMFBASE=edk2/Build/OvmfX64/DEBUG_GCC5/ -OVMFCODE=$(OVMFBASE)/FV/OVMF_CODE.fd -OVMFVARS=$(OVMFBASE)/FV/OVMF_VARS.fd -QEMU=qemu-system-x86_64 -QEMUFLAGS=-drive format=raw,file=fat:rw:image \ - -drive if=pflash,format=raw,readonly,file=$(OVMFCODE) \ - -drive if=pflash,format=raw,file=$(OVMFVARS) \ - -debugcon file:$(LOG) -global isa-debugcon.iobase=0x402 \ - -serial stdio \ - -nographic \ - -nodefaults - -run: - $(QEMU) $(QEMUFLAGS) - -debug: - $(QEMU) $(QEMUFLAGS) -s -S - -.PHONY: run debug -Before debugging, run the firmware to get debug.log. It may be better to provide startup.nsh script. - -$ make run -Now, we have debug.log. It includes the addresses of loaded UEFI images like this: - -Loading PEIM at 0x00007EA8000 EntryPoint=0x00007EAB0BC DxeCore.efi -Next, extract text section (.text) RVA from *.efi PE binaries. This can be done by readelf if it is ELF, but the images are PE format. Here we use retrage/peinfo[3]. - -$ git clone git@github.com:retrage/peinfo.git -$ cd peinfo -$ make -peinfo extracts section information from a binary. This time we want to know VirtualAddress in RVA. - -Name: .text -VirtualSize: 0x000204c0 -VirtualAddress: 0x00000240 -SizeOfRawData: 0x000204c0 -PointerToRawData: 0x00000240 -PointerToRelocations: 0x00000000 -PointerToLinenumbers: 0x00000000 -NumberOfRelocations: 0x0000 -NumberOfLinenumbers: 0x0000 -Characteristics: 0x60000020 -Run following bash script with debug.log and peinfo. This outputs a snippet of GDB script that adds symbol information (add-symbol-file). It calculates the address of UEFI image text section from base address and VirtualAddress. - -#!/bin/bash - -LOG="debug.log" -BUILD="edk2/Build/OvmfX64/DEBUG_GCC5/X64" -PEINFO="peinfo/peinfo" - -cat ${LOG} | grep Loading | grep -i efi | while read LINE; do - BASE="`echo ${LINE} | cut -d " " -f4`" - NAME="`echo ${LINE} | cut -d " " -f6 | tr -d "[:cntrl:]"`" - ADDR="`${PEINFO} ${BUILD}/${NAME} \ - | grep -A 5 text | grep VirtualAddress | cut -d " " -f2`" - TEXT="`python -c "print(hex(${BASE} + ${ADDR}))"`" - SYMS="`echo ${NAME} | sed -e "s/\.efi/\.debug/g"`" - echo "add-symbol-file ${BUILD}/${SYMS} ${TEXT}" -done -$ bash gen_symbol_offsets.sh > gdbscript -cat gdb -The generated GDB script is like this: - -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug 0x82c380 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/ReportStatusCodeRouterPei.debug 0x831080 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/StatusCodeHandlerPei.debug 0x833100 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/PlatformPei.debug 0x835100 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/PeiCore.debug 0x7ee8240 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeIpl.debug 0x7ee3240 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/S3Resume2Pei.debug 0x7edf240 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuMpPei.debug 0x7ed6240 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeCore.debug 0x7ea8240 -add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/DevicePathDxe.debug 0x7b8f240 -Now we are ready. - -$ less debug.log -... -The 0th FV start address is 0x0000082000 -... -Loading PEIM at 0x0000082BFC0 - Entry Point = 0x0000082F40A PcdPeim.efi -... - -$ make debug - -Let’s place a breakpoint at BootServices->HandleProtocol(). - -(gdb) source gdbscript -. -. -. -add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbBusDxe.debug" at - .text_addr = 0x6c85240 -add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbKbDxe.debug" at - .text_addr = 0x6cb3240 -add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbMassStorageDxe.debug" at - .text_addr = 0x6c6d240 -add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuVideoDxe.debug" at - .text_addr = 0x6c66240 -add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioGpuDxe.debug" at - .text_addr = 0x6c60240 -add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Shell.debug" at - .text_addr = 0x64f5240 - -(gdb) info functions CoreHandleProtocol -All functions matching regular expression "CoreHandleProtocol": -File /.../edk2/MdeModulePkg/Core/Dxe/Hand/Handle.c: -EFI_STATUS CoreHandleProtocol(EFI_HANDLE, EFI_GUID *, void **); - -(gdb) info address CoreHandleProtocol -Symbol "CoreHandleProtocol" is a function at address 0x7ea4aa9. - -(gdb) b CoreHandleProtocol - -(gdb) info symbol 0x82F40A -_ModuleEntryPoint in section .text of /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug - -(gdb) b *0x82F40A -Breakpoint 2 at 0x82f40a: file /home/koenigr/Memtest/git/edk2/MdePkg/Library/PeimEntryPoint/PeimEntryPoint.c, line 33. - -(gdb) target remote localhost:1234 -Remote debugging using localhost:1234 -warning: No executable has been specified and target does not support -determining executable automatically. Try using the "file" command. -0x000000000000fff0 in ?? () - -(gdb) c - -The debugger stops, and we can do source code level debug. - -!!!!!!!!!!!!!!!!!!!!!!!!!!! DOES NOT WORK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - ┌──/home/akira/src/ovmf-debug/edk2/MdeModulePkg/Core/Dxe/Hand/Handle.c──────┐ - │933 CoreHandleProtocol ( │ - │934 IN EFI_HANDLE UserHandle, │ - │935 IN EFI_GUID *Protocol, │ - │936 OUT VOID **Interface │ - │937 ) │ -B+>│938 { │ - │939 return CoreOpenProtocol ( │ - │940 UserHandle, │ - │941 Protocol, │ - │942 Interface, │ - │943 gDxeCoreImageHandle, │ - │944 NULL, │ - │945 EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL │ - └───────────────────────────────────────────────────────────────────────────┘ -remote Thread 1 In: CoreHandleProtocol L938 PC: 0x7eb6ad4 - - - -(gdb) |