Skip to content

Commit 0643271

Browse files
FireFox317linusg
authored andcommitted
Kernel: Set up initial exception stack when going into EL1 on aarch64
When an exception is triggered on aarch64, the processor always switches to the exception stack which is defined by the SP_EL1 register.
1 parent 9f730fa commit 0643271

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Kernel/Arch/aarch64/ASM_wrapper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ inline void set_ttbr0_el1(FlatPtr ttbr0_el1)
2323
asm("msr ttbr0_el1, %[value]" ::[value] "r"(ttbr0_el1));
2424
}
2525

26+
inline void set_sp_el1(FlatPtr sp_el1)
27+
{
28+
asm("msr sp_el1, %[value]" ::[value] "r"(sp_el1));
29+
}
30+
2631
inline void flush()
2732
{
2833
asm("dsb ish");

Kernel/Arch/aarch64/Exceptions.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ static void drop_to_el1()
4646
hypervisor_configuration_register_el2.RW = 1; // EL1 to use 64-bit mode
4747
Aarch64::HCR_EL2::write(hypervisor_configuration_register_el2);
4848

49+
// Set up initial exception stack
50+
// FIXME: Define in linker script
51+
Aarch64::Asm::set_sp_el1(0x40000);
52+
4953
Aarch64::SPSR_EL2 saved_program_status_register_el2 = {};
5054

5155
// Mask (disable) all interrupts

0 commit comments

Comments
 (0)