Page 1 of 1

Load higher half kernel with UEFI application

Posted: Sun Jan 16, 2022 8:58 pm
by 22OsC
Does anyone know how to load a higher half kernel using the bootloader from poncho's UEFI bootloader?
At this moment when I try to load the kernel in the memory, EDK throws this exception:

Code: Select all

!!!! X64 Exception Type - 0E(#PF - Page-Fault)  CPU Apic ID - 00000000 !!!!
ExceptionData - 0000000000000000  I:0 R:0 U:0 W:0 P:0 PK:0 SS:0 SGX:0
RIP  - 0000000000015E40, CS  - 0000000000000038, RFLAGS - 0000000000010006
RAX  - 0000000000000025, RCX - 0000000000000000, RDX - 00000000000003F8
RBX  - 00000000000003FD, RSP - 000000007FE6B658, RBP - 000000007FE6B690
RSI  - FFFFFFFF80032628, RDI - FFFFFFFF80032628
R8   - 0000000000000025, R9  - 0000000000000078, R10 - 000000007FBC4880
R11  - 00000000CB8F5AF3, R12 - 0000000000000000, R13 - FFFFFFFF80032628
R14  - 000000007FE6B750, R15 - 00000000000003F8
DS   - 0000000000000030, ES  - 0000000000000030, FS  - 0000000000000030
GS   - 0000000000000030, SS  - 0000000000000030
CR0  - 0000000080010033, CR2 - FFFFFFFF80032628, CR3 - 000000007FC01000
CR4  - 0000000000000668, CR8 - 0000000000000000
DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 000000007FBEEA98 0000000000000047, LDTR - 0000000000000000
IDTR - 000000007F2D0018 0000000000000FFF,   TR - 0000000000000000
FXSAVE_STATE - 000000007FE6B2B0
!!!! Can't find image information. !!!!


main.c: https://github.com/Absurdponcho/PonchoO ... der/main.c

Any help is welcome

Re: Load higher half kernel with UEFI application

Posted: Mon Jan 17, 2022 2:03 am
by Octocontrabass
There are three problems in this one line of code.
  • Specific addresses are not guaranteed to be free. A bootloader should never use AllocateAddress.
  • The physical addresses in the program headers are usually meaningless to a higher-half kernel. The bootloader should be using the virtual addresses.
  • Memory allocations may fail, but the bootloader assumes they will succeed.
A bootloader for a higher-half kernel should load the kernel into a free area of memory without caring about the physical address (except for alignment), then set up page tables to map that memory at the appropriate virtual address according to the program headers.

You'll have to either find a better bootloader or write one yourself.