mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:27:45 +00:00
Kernel/aarch64: Execute kernel with SP_EL1 instead of SP_EL0
Until now the kernel was always executing with SP_EL0, as this made the initial dropping to EL1 a bit easier. This commit changes this behaviour to use the corresponding SP_ELx for each exception level. To make sure that the execution of the C++ code can continue, the current stack pointer is copied into the corresponding SP_ELx just before dropping an exception level.
This commit is contained in:
parent
05659debd1
commit
247109cee6
5 changed files with 23 additions and 20 deletions
|
@ -75,7 +75,11 @@ inline void load_el1_vector_table(void* vector_table)
|
|||
|
||||
inline void enter_el2_from_el3()
|
||||
{
|
||||
asm volatile(" adr x0, entered_el2\n"
|
||||
// NOTE: This also copies the current stack pointer into SP_EL2, as
|
||||
// the processor is set up to use SP_EL2 when jumping into EL2.
|
||||
asm volatile(" mov x0, sp\n"
|
||||
" msr sp_el2, x0\n"
|
||||
" adr x0, entered_el2\n"
|
||||
" msr elr_el3, x0\n"
|
||||
" eret\n"
|
||||
"entered_el2:" ::
|
||||
|
@ -84,7 +88,11 @@ inline void enter_el2_from_el3()
|
|||
|
||||
inline void enter_el1_from_el2()
|
||||
{
|
||||
asm volatile(" adr x0, entered_el1\n"
|
||||
// NOTE: This also copies the current stack pointer into SP_EL1, as
|
||||
// the processor is set up to use SP_EL1 when jumping into EL1.
|
||||
asm volatile(" mov x0, sp\n"
|
||||
" msr sp_el1, x0\n"
|
||||
" adr x0, entered_el1\n"
|
||||
" msr elr_el2, x0\n"
|
||||
" eret\n"
|
||||
"entered_el1:" ::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue