[boot][kernel] Split programs into sections

To enable setting sections as NX or read-only, the boot program loader
now loads programs as lists of sections, and the kernel args are updated
accordingly. The kernel's loader now just takes a program pointer to
iterate the sections. Also enable NX in IA32_EFER in the bootloader.
This commit is contained in:
Justin C. Miller
2021-01-20 01:25:47 -08:00
parent 14aad62e02
commit cb612c36ea
13 changed files with 140 additions and 61 deletions

View File

@@ -192,16 +192,20 @@ efi_main(uefi::handle image, uefi::system_table *st)
status_bar status {con.fb()}; // Switch to fb status display
args::program &kernel = args->programs[0];
paging::map_pages(args, kernel.phys_addr, kernel.virt_addr, kernel.size);
for (auto &section : kernel.sections)
if (section.size)
paging::map_section(args, section);
kernel::entrypoint kentry =
reinterpret_cast<kernel::entrypoint>(kernel.entrypoint);
status.next();
hw::setup_control_regs();
memory::virtualize(args->pml4, map, st->runtime_services);
status.next();
change_pointer(args->pml4);
hw::setup_cr4();
status.next();
kentry(args);