Use SP_EL1 as EL1 stack instead of SP_EL0

pull/9/head
Andre Richter 6 years ago
parent b1786d5110
commit b6fafa6191
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -8,7 +8,7 @@ Cortex-A53 processor: `Exception levels`.
TODO: Write rest of tutorial.
```text
raspi3_boot::setup_and_enter_el1_from_el2::h0641a5a5302db706:
raspi3_boot::setup_and_enter_el1_from_el2::hb2c2ac4f6a7ddb7e:
80954: e8 03 1f aa mov x8, xzr
80958: e9 07 00 32 orr w9, wzr, #0x3
8095c: 4a 00 80 52 mov w10, #0x2
@ -16,12 +16,12 @@ raspi3_boot::setup_and_enter_el1_from_el2::h0641a5a5302db706:
80964: 09 e1 1c d5 msr CNTHCTL_EL2, x9
80968: 68 e0 1c d5 msr CNTVOFF_EL2, x8
8096c: 08 00 00 90 adrp x8, #0x0
80970: 8b 78 80 52 mov w11, #0x3c4
80970: ab 78 80 52 mov w11, #0x3c5
80974: 0a 11 1c d5 msr HCR_EL2, x10
80978: ec 03 0d 32 orr w12, wzr, #0x80000
8097c: 08 81 24 91 add x8, x8, #0x920
80980: 0b 40 1c d5 msr SPSR_EL2, x11
80984: 28 40 1c d5 msr ELR_EL2, x8
80988: 0c 41 18 d5 msr SP_EL0, x12
80988: 0c 41 1c d5 msr SP_EL1, x12
8098c: e0 03 9f d6 eret
```

Binary file not shown.

Binary file not shown.

@ -84,21 +84,21 @@ fn setup_and_enter_el1_from_el2() -> ! {
// Set up a simulated exception return.
//
// First, fake a saved program status, where all interrupts were
// masked and SP_EL0 was used as a stack pointer.
// masked and SP_EL1 was used as a stack pointer.
SPSR_EL2.write(
SPSR_EL2::D::Masked
+ SPSR_EL2::A::Masked
+ SPSR_EL2::I::Masked
+ SPSR_EL2::F::Masked
+ SPSR_EL2::M::EL1t,
+ SPSR_EL2::M::EL1h,
);
// Second, let the link register point to reset().
ELR_EL2.set(reset as *const () as u64);
// Set up SP_EL0 (stack pointer), which will be used by EL1 once
// Set up SP_EL1 (stack pointer), which will be used by EL1 once
// we "return" to it.
SP_EL0.set(0x80_000);
SP_EL1.set(0x80_000);
// Use `eret` to "return" to EL1. This will result in execution of
// `reset()` in EL1.

Binary file not shown.

Binary file not shown.

@ -84,21 +84,21 @@ fn setup_and_enter_el1_from_el2() -> ! {
// Set up a simulated exception return.
//
// First, fake a saved program status, where all interrupts were
// masked and SP_EL0 was used as a stack pointer.
// masked and SP_EL1 was used as a stack pointer.
SPSR_EL2.write(
SPSR_EL2::D::Masked
+ SPSR_EL2::A::Masked
+ SPSR_EL2::I::Masked
+ SPSR_EL2::F::Masked
+ SPSR_EL2::M::EL1t,
+ SPSR_EL2::M::EL1h,
);
// Second, let the link register point to reset().
ELR_EL2.set(reset as *const () as u64);
// Set up SP_EL0 (stack pointer), which will be used by EL1 once
// Set up SP_EL1 (stack pointer), which will be used by EL1 once
// we "return" to it.
SP_EL0.set(0x80_000);
SP_EL1.set(0x80_000);
// Use `eret` to "return" to EL1. This will result in execution of
// `reset()` in EL1.

Binary file not shown.

Binary file not shown.

@ -84,21 +84,21 @@ fn setup_and_enter_el1_from_el2() -> ! {
// Set up a simulated exception return.
//
// First, fake a saved program status, where all interrupts were
// masked and SP_EL0 was used as a stack pointer.
// masked and SP_EL1 was used as a stack pointer.
SPSR_EL2.write(
SPSR_EL2::D::Masked
+ SPSR_EL2::A::Masked
+ SPSR_EL2::I::Masked
+ SPSR_EL2::F::Masked
+ SPSR_EL2::M::EL1t,
+ SPSR_EL2::M::EL1h,
);
// Second, let the link register point to reset().
ELR_EL2.set(reset as *const () as u64);
// Set up SP_EL0 (stack pointer), which will be used by EL1 once
// Set up SP_EL1 (stack pointer), which will be used by EL1 once
// we "return" to it.
SP_EL0.set(0x80_000);
SP_EL1.set(0x80_000);
// Use `eret` to "return" to EL1. This will result in execution of
// `reset()` in EL1.

Loading…
Cancel
Save