Building world/kernel on amd64 with WITH_INIT_ALL_ZERO set and booting in QEMU results in this failure to boot: /boot/entropy size=0x1000 Start @ 0xffffffff80377000 ... !!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!! RIP - FFFFFFFF819BCAFA, CS - 0000000000000038, RFLAGS - 0000000000000002 RAX - FFFFFFFF80376020, RCX - 0000000000000000, RDX - 00000000000018AA RBX - 0000000000000000, RSP - FFFFFFFF819BC658, RBP - FFFFFFFF82118000 RSI - 00000000000058B8, RDI - FFFFFFFF819BC428 R8 - 0000000000000000, R9 - FFFFFFFF80C40A50, R10 - 0000000000005A30 R11 - 0000000000000CF0, R12 - 0000000002122000, R13 - 0211800000000000 R14 - 0000000002122000, R15 - 000F000000000000 DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030 GS - 0000000000000030, SS - 0000000000000030 CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 000000000EA4F000 CR4 - 0000000000000668, CR8 - 0000000000000000 DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 GDTR - 000000000FBEEA98 0000000000000047, LDTR - 0000000000000000 IDTR - 000000000F819018 0000000000000FFF, TR - 0000000000000000 FXSAVE_STATE - FFFFFFFF819BC2B0 !!!! Find image based on IP(0x819BCAFA) /wrkdirs/usr/ports/sysutils/uefi-edk2-qemu/work-x86_64/edk2-edk2-stable201911/Build/OvmfX64/RELEASE_GCC5/X64/MdeModulePkg/Core/Pei/PeiMain/DEBUG/PeiCore.dll (ImageBase=FFFFFFFF4FEED000, EntryPoint=FFFFFFFF4FEF29F8) !!!! qemu-system-x86_64: terminating on signal 15 from pid 12144 (timeout)
To be clear, the port sysutils/uefi-edk2-qemu was *not* built with INIT_ALL_ZERO, right?
Oh, I think I get it. It seems like INIT_ALL_ZERO is emitting some instruction qemu doesn't understand?
Can you disassemble your kernel around 0xFFFFFFFF819BCAFA?
Further experiments confirm this is not reproducible with the kernel forcing INIT_ALL_ZERO off, but leaving on for the loader. I will investigate more later - I have not built with INIT_ALL_ZERO locally, only via Cirrus-CI.
(In reply to Conrad Meyer from comment #3) That addr is in: [46] .bss NOBITS ffffffff819bbb00 017bbaa8 0000000000444500 0000000000000000 WA 0 0 128
Using QEMU's `-d exec` option I see last instructions before the exception are in these regions: Chain 0: 0x18a5f40 [0000000000000000/ffffffff8105176a/0x40c2b0] ^M Chain 0: 0x18a60c0 [0000000000000000/ffffffff80c40a50/0x40c2b0] ^M Chain 0: 0x18ae840 [0000000000000000/ffffffff8104dd60/0x40c2b0] ^M Chain 0: 0x18a6900 [0000000000000000/ffffffff80c40a84/0x40c2b0] ^M Chain 0: 0x18a6bc0 [0000000000000000/ffffffff81051779/0x40c2b0] ^M Chain 0: 0x18a74c0 [0000000000000000/ffffffff80c4058a/0x40c2b0] ^M Symbols associated with these addrs: ffffffff80c403f0 T link_elf_ireloc ffffffff80c40a50 t elf_lookup_ifunc ffffffff810516e0 t elf_reloc_internal ffffffff8104dd60 t copyout_resolver the last instructions executed are in link_elf_ireloc()
Andy pointed out https://reviews.freebsd.org/D23499. I forgot about this review :(
A commit references this bug: Author: emaste Date: Fri Nov 13 18:34:13 UTC 2020 New revision: 367646 URL: https://svnweb.freebsd.org/changeset/base/367646 Log: Disable kernel INIT_ALL_ZERO on amd64 It is currently incompatible with kernel ifunc memset. PR: 251083 MFC with: r367577 Sponsored by: The FreeBSD Foundation Changes: head/sys/conf/kern.opts.mk