Jump to user mode.

This instantly creates a page fault as we always map pages with ring 0
permissions.
This commit is contained in:
Drew Galbraith 2023-05-29 12:44:26 -07:00
parent aefb4f082b
commit 7184f527a0
7 changed files with 37 additions and 7 deletions

View file

@ -56,7 +56,7 @@ void badmemcpy(uint64_t base, uint64_t offset, uint64_t dest) {
} // namespace
void LoadElfProgram(uint64_t base, uint64_t offset) {
uint64_t LoadElfProgram(uint64_t base, uint64_t offset) {
Elf64Header* header = reinterpret_cast<Elf64Header*>(base);
dbgln("phoff: %u phnum: %u", header->phoff, header->phnum);
Elf64ProgramHeader* programs =
@ -71,4 +71,5 @@ void LoadElfProgram(uint64_t base, uint64_t offset) {
EnsureResident(program.vaddr, program.memsz);
badmemcpy(base + program.offset, program.filesz, program.vaddr);
}
return header->entry;
}

View file

@ -2,4 +2,5 @@
#include <stdint.h>
void LoadElfProgram(uint64_t base, uint64_t length);
// Loads the elf program and returns its entry point.
uint64_t LoadElfProgram(uint64_t base, uint64_t length);