Skip to content

Commit 98420fd

Browse files
committed
Support booting the kernel in EL1 with a PSCI proxy
1 parent 30e3bd9 commit 98420fd

File tree

9 files changed

+664
-62
lines changed

9 files changed

+664
-62
lines changed

Cargo.lock

Lines changed: 69 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ categories = ["embedded", "no-std"]
1111

1212
[dependencies]
1313
aarch64-paging = { version = "0.11", default-features = false }
14-
aarch64-rt = { version = "0.3", features = ["el2", "exceptions", "initial-pagetable", "psci"], default-features = false }
14+
aarch64-rt = { version = "0.4.3", features = ["el2", "exceptions", "initial-pagetable", "psci"], default-features = false }
1515
arm-pl011-uart = "0.4"
16+
arm-psci = "0.2"
1617
arm-sysregs = { version = "0.2", features = ["el1", "el2"] }
1718
buddy_system_allocator = { version = "0.12", default-features = false, features = ["alloc", "use_spin"] }
19+
dtoolkit = { version = "0.1", features = ["write"] }
1820
embedded-io = "0.7"
1921
log = "0.4"
2022
percore = "0.2"

linker/qemu.ld

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
MEMORY
22
{
3-
image : ORIGIN = 0x40080000, LENGTH = 64M
3+
image : ORIGIN = 0x40080000, LENGTH = 4M
4+
payload (rwx) : ORIGIN = 0x40400000, LENGTH = 64M
45
}
6+
7+
SECTIONS {
8+
.payload :
9+
{
10+
*(.payload);
11+
. = ALIGN(4);
12+
} > payload
13+
} INSERT AFTER .text;

src/exceptions.rs

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,13 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
#[unsafe(no_mangle)]
10-
extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
11-
panic!("Unexpected sync_exception_current");
12-
}
13-
14-
#[unsafe(no_mangle)]
15-
extern "C" fn irq_current(_elr: u64, _spsr: u64) {
16-
panic!("Unexpected irq_current");
17-
}
18-
19-
#[unsafe(no_mangle)]
20-
extern "C" fn fiq_current(_elr: u64, _spsr: u64) {
21-
panic!("Unexpected fiq_current");
22-
}
23-
24-
#[unsafe(no_mangle)]
25-
extern "C" fn serr_current(_elr: u64, _spsr: u64) {
26-
panic!("Unexpected serr_current");
27-
}
28-
29-
#[unsafe(no_mangle)]
30-
extern "C" fn sync_lower(_elr: u64, _spsr: u64) {
31-
panic!("Unexpected sync_lower");
32-
}
33-
34-
#[unsafe(no_mangle)]
35-
extern "C" fn irq_lower(_elr: u64, _spsr: u64) {
36-
panic!("Unexpected irq_lower");
37-
}
38-
39-
#[unsafe(no_mangle)]
40-
extern "C" fn fiq_lower(_elr: u64, _spsr: u64) {
41-
panic!("Unexpected fiq_lower");
42-
}
43-
44-
#[unsafe(no_mangle)]
45-
extern "C" fn serr_lower(_elr: u64, _spsr: u64) {
46-
panic!("Unexpected serr_lower");
9+
use aarch64_rt::{ExceptionHandlers, RegisterStateRef};
10+
11+
pub struct Exceptions;
12+
impl ExceptionHandlers for Exceptions {
13+
extern "C" fn sync_lower(register_state: RegisterStateRef) {
14+
// sync_lower exception is most likely a HVC/SMC call, which we should
15+
// handle in the hypervisor.
16+
crate::hypervisor::handle_sync_lower(register_state);
17+
}
4718
}

0 commit comments

Comments
 (0)