From: Heinrich Schuchardt Date: Sat, 13 Oct 2018 03:08:31 +0200 Subject: [U-Boot] [PATCH 4/4] WIP: travis: Add qemu-x86_64 target for test.py testing In-Reply-To: <3ed280cb-bc65-e32f-28f9-6e285661ba5f@gmx.de> References: <1539222787-27208-1-git-send-email-bmeng.cn@gmail.com> <1539222787-27208-4-git-send-email-bmeng.cn@gmail.com> <1552f175-dec5-f9bc-054c-568cf4bc8e12@gmx.de> <3ed280cb-bc65-e32f-28f9-6e285661ba5f@gmx.de> Message-ID: <6ed76c9b-5815-313f-c3fe-2b8ecb155d8d@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 10/12/2018 11:02 PM, Heinrich Schuchardt wrote: > On 10/12/2018 03:45 AM, Bin Meng wrote: >> Hi Heinrich, >> >> On Fri, Oct 12, 2018 at 6:10 AM Heinrich Schuchardt wrote: >>> >>> On 10/11/2018 03:57 AM, Bin Meng wrote: >>>> Hi Heinrich, >>>> >>>> On Thu, Oct 11, 2018 at 9:48 AM Bin Meng wrote: >>>>> >>>>> Add qemu-x86_64 to the list of targets we use for test.py runs. >>>>> >>>>> Signed-off-by: Bin Meng >>>>> >>>>> --- >>>>> testp.py testing is currently failing at 'bootefi selftest'. >>>>> >>>> >>>> Can you try this series for the 'bootefi selftest' testing? >>> >>> I am clueless why the EFI subsystems is failing completely on >>> qemu-x86_64_defconfig. >>> >>> Any printf() or puts() statement I put into >>> lib/efi_loader/efi_boottime.c leads to no output at all. >>> >>> I connected gdb with >>> >>> gdb u-boot -ex 'target remote localhost:1234' >>> add-symbol-file u-boot >>> >>> But the debugger did not stop at breakpoints. >> >> I encountered exactly the same issue that breakpoint is not hit when >> debugging this endless loop issue. And I finally figured it out: >> >> The symbol table should not be loaded to , instead it needs >> to be loaded to . >> >> The .text.start was introduced in commit >> 7e21fbca26d18327cf7cabaad08df276a06a07d8 "efi_loader: Rename sections >> to allow for implicit data", and its commit message mentioned: [agraf: >> Fix x86_64 breakage], although I was not sure what x86_64 breakage was >> fixed. >> >> Please have a try. >> >> Regards, >> Bin >> > > Hello Bin, > > thanks for your hint. Now I was able to debug the problem. > > The code is not correctly relocated. > > Function do_elf_reloc_fixups64() only analyzes re_src->r_offset but not > the relocation type. > > I put a print statement into the relocation loop and found the > relocation type of the first relocation to be reported as having an > illegal value of 0x10ff70. All other relocation types were reported as > 0x8 as expected. > > diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c > index ed10755d9c..095374830f 100644 > --- a/arch/x86/lib/relocate.c > +++ b/arch/x86/lib/relocate.c > @@ -55,6 +55,7 @@ static void do_elf_reloc_fixups64(unsigned int > text_base, uintptr_t size, > do { > . /* Get the location from the relocation entry */ > . offset_ptr_rom = (Elf64_Addr *)(uintptr_t)re_src->r_offset; > + printf("Reloc type %llx\n", ELF64_R_TYPE(re_src->r_info)); > . > . /* Check that the location of the relocation is in .text */ > . if (offset_ptr_rom >= (Elf64_Addr *)(uintptr_t)text_base && > > > Reloc type 10ff70 > Reloc type 8 > Reloc type 8 > Reloc type 8 > .. > > > The relocation types in efi_runtime_relocate() are complete garbage: > > efi_runtime_relocate: 8 > efi_runtime_relocate: 30 > efi_runtime_relocate: b0 > efi_runtime_relocate: 8 > efi_runtime_relocate: 50 > efi_runtime_relocate: 20 > efi_runtime_relocate: 8 > efi_runtime_relocate: 60 > efi_runtime_relocate: 20 > efi_runtime_relocate: 8 > efi_runtime_relocate: a0 > efi_runtime_relocate: b5 > efi_runtime_relocate: 8 > efi_runtime_relocate: b0 > efi_runtime_relocate: aa > efi_runtime_relocate: 8 > efi_runtime_relocate: c0 > efi_runtime_relocate: c0 > efi_runtime_relocate: 8 > efi_runtime_relocate: d0 > efi_runtime_relocate: 68 > efi_runtime_relocate: 8 > efi_runtime_relocate: e0 > efi_runtime_relocate: b5 > efi_runtime_relocate: 8 > efi_runtime_relocate: f0 > efi_runtime_relocate: cb > efi_runtime_relocate: 8 > efi_runtime_relocate: 0 > efi_runtime_relocate: e1 > > I will send a patch for efi_runtime_relocate(). > > Bin, can you please, have a look at the first problem. > > Best regards > > Heinrich > > > Using a memory watchpoint pinpoints the culprit overwriting the relocation table with an illegal relocation type: Hardware access (read/write) watchpoint 1: *0x118b188 Old value = 8 New value = 1113968 arch_setup_gd (new_gd=0x10ff70) at arch/x86/cpu/x86_64/cpu.c:32 (gdb) 0x111173e mov %rdi,0x79a43(%rip) # 0x118b188 0x1111745 mov $0x20,%edi 0x111174a jmpq 0x11399fb 0x111174f mov $0x1,%eax The global_data_ptr and the relocation table occupy the same memory location: .bss.global_data_ptr 0x000000000118b188 0x8 arch/x86/cpu/built-in.o 0x000000000118b188 global_data_ptr .rela.got 0x000000000118b180 0x90 arch/x86/cpu/start64.o .rela.bss 0x000000000118b210 0x0 arch/x86/cpu/start64.o Essentially we have to relocate before accessing any global symbols in the data section. I have sent a patch moving global_data_ptr to the .text section. Best regards Heinrich