Kernel/aarch64: Implement set_exec_state in ThreadRegisters

This sets up the correct ThreadRegisters state when a process is
exec'ed, which happens when the first userspace application is executed.
Also changes Processor.cpp to get the stack pointer from the
ThreadRegisters.
This commit is contained in:
Timon Kruiper 2023-01-30 11:19:03 +01:00 committed by Linus Groh
parent 8960662e57
commit 5781d58fe8
2 changed files with 5 additions and 5 deletions

View file

@ -241,7 +241,7 @@ FlatPtr Processor::init_context(Thread& thread, bool leave_crit)
// x30 is the Link Register for the aarch64 ABI, so this will return to exit_kernel_thread when main thread function returns.
eretframe.x[30] = FlatPtr(&exit_kernel_thread);
eretframe.elr_el1 = thread_regs.elr_el1;
eretframe.sp_el0 = kernel_stack_top;
eretframe.sp_el0 = thread_regs.sp_el0;
eretframe.tpidr_el0 = 0; // FIXME: Correctly initialize this when aarch64 has support for thread local storage.
eretframe.spsr_el1 = thread_regs.spsr_el1;

View file

@ -39,10 +39,10 @@ struct ThreadRegisters {
void set_exec_state(FlatPtr entry_ip, FlatPtr userspace_sp, Memory::AddressSpace& space)
{
(void)entry_ip;
(void)userspace_sp;
(void)space;
TODO_AARCH64();
set_ip(entry_ip);
set_sp(userspace_sp);
ttbr0_el1 = space.page_directory().ttbr0();
set_spsr_el1(false);
}
void set_spsr_el1(bool is_kernel_process)