diff options
author | Timon Kruiper <timonkruiper@gmail.com> | 2023-02-06 20:26:28 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-08 18:19:48 +0000 |
commit | 8960662e57f367ea6cb649518036ad1c7a042214 (patch) | |
tree | 730a4515b27863847b9c5ab2a2c604f97f3b86e7 /Kernel/Arch | |
parent | 3f05748c0c83665de25244cd61da536d03004155 (diff) | |
download | serenity-8960662e57f367ea6cb649518036ad1c7a042214.zip |
Kernel/aarch64: Set exception origin mode to SP_EL0 for userspace thread
Diffstat (limited to 'Kernel/Arch')
-rw-r--r-- | Kernel/Arch/aarch64/ThreadRegisters.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Kernel/Arch/aarch64/ThreadRegisters.h b/Kernel/Arch/aarch64/ThreadRegisters.h index 64402113c0..1ae9c0c5a7 100644 --- a/Kernel/Arch/aarch64/ThreadRegisters.h +++ b/Kernel/Arch/aarch64/ThreadRegisters.h @@ -24,11 +24,11 @@ struct ThreadRegisters { void set_sp(FlatPtr value) { sp_el0 = value; } - void set_initial_state(bool, Memory::AddressSpace& space, FlatPtr kernel_stack_top) + void set_initial_state(bool is_kernel_process, Memory::AddressSpace& space, FlatPtr kernel_stack_top) { set_sp(kernel_stack_top); ttbr0_el1 = space.page_directory().ttbr0(); - set_spsr_el1(); + set_spsr_el1(is_kernel_process); } void set_entry_function(FlatPtr entry_ip, FlatPtr entry_data) @@ -45,7 +45,7 @@ struct ThreadRegisters { TODO_AARCH64(); } - void set_spsr_el1() + void set_spsr_el1(bool is_kernel_process) { Aarch64::SPSR_EL1 saved_program_status_register_el1 = {}; @@ -55,9 +55,7 @@ struct ThreadRegisters { saved_program_status_register_el1.I = 0; saved_program_status_register_el1.F = 0; - // Set exception origin mode to EL1h, so when the context is restored, we'll be executing in EL1 with SP_EL1 - // FIXME: This must be EL0t when aarch64 supports userspace applications. - saved_program_status_register_el1.M = Aarch64::SPSR_EL1::Mode::EL1h; + saved_program_status_register_el1.M = is_kernel_process ? Aarch64::SPSR_EL1::Mode::EL1h : Aarch64::SPSR_EL1::Mode::EL0t; memcpy(&spsr_el1, &saved_program_status_register_el1, sizeof(u64)); } }; |