tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel goes dark on boot



On Thu, Apr 06, 2023 at 05:08:34PM +0200, Martin Husemann wrote:
> I wonder if tuning EFI_ALLOCATE_MAX_ADDRESS in
> src/sys/arch/i386/stand/efiboot/Makefile.efiboot would be enough.

No success. Here is my conclusions so far:

At kernel start time, the kernel assumes it is loaded at 0x200000,
but unfortuately, this UEFI implementation allocate memory at
0x1000000, and the kernel is bigger than 0x1000000 - 0x200000.

This allocation happens before bootx64.efi has the opportunity to
do anything about it: it is already there after calling InitializeLib(IH,
systemTable); in efi_main().

Writing to this region causes a crash. I am not sure whether it is
write protected, or it is used somehow.

I see two solutions. The first is to build a custom kernel
that loads at a higher address (I tried 0x2200000 with success).
That works, but not out of the box.

The other solution is to make the kernel self-relocatable: if at
start in locore.S, we detect we are not loaded at 0x200000, then
first relocate the kernel.  This can be done by reusing bootx64.efi's
startprog64(). There was code for that in sys/arch/amd64/amd64/locore.S
1.197, for multiboot2 suppot.

-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index