I am trying to implement process. The first problem is how to start a process. After building the page map, loading elf64 file into memory, I tried to use sysret to jump to the entry point of the executable, but a #PF happened. The page fault address was the entry point of the executable.
The sysret was used like this:
A static method System::sysret(entry) was used to start the user process. Here parameter entry was the entry point of the executable. System::sysret() was implemented like this:
Code: Select all
void System::sysret(Address address) {
asm volatile("mov %0, %%rcx\n"
"sysretq\n" : : "m"(address));
}
Code: Select all
asm volatile("jmp *%0" : : "r"(entry));
Thanks in advance
torshie