Skip to content

Commit 2676f1b

Browse files
committed
Detect current EL for setting exception vector too.
1 parent 9534767 commit 2676f1b

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
### Improvements
66

7-
- If the `initial-pagetable` feature is specified without any of the `elX` features, then the
8-
exception level will be checked at runtime and the appropriate registers for the current EL will
9-
be used.
7+
- If the `initial-pagetable` or `exceptions` features are specified without any of the `elX`
8+
features, then the exception level will be checked at runtime and the appropriate registers for
9+
the current EL will be used. The `el1` feature is no longer enabled by default, as this runtime
10+
detection should work instead.
1011

1112
### Bugfixes
1213

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ arm-pl011-uart = "0.4.0"
1919
smccc = "0.2.2"
2020

2121
[features]
22-
default = ["el1", "exceptions", "initial-pagetable", "psci"]
22+
default = ["exceptions", "initial-pagetable", "psci"]
2323
el1 = []
2424
el2 = []
2525
el3 = []

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() {
4646

4747
## Features
4848

49-
`el1`, `exceptions`, `initial-pagetable` and `psci` are enabled by default.
49+
`exceptions`, `initial-pagetable` and `psci` are enabled by default.
5050

5151
### `el1`
5252

src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,35 @@ extern "C" fn set_exception_vector() {
7676
out("x9") _,
7777
);
7878
}
79+
#[cfg(all(
80+
feature = "exceptions",
81+
not(any(feature = "el1", feature = "el2", feature = "el3"))
82+
))]
83+
unsafe {
84+
asm!(
85+
"mrs x9, CurrentEL",
86+
"cmp x9, #3",
87+
"b.ne 1f",
88+
"adr x9, vector_table_el3",
89+
"msr vbar_el3, x9",
90+
"b 3f",
91+
92+
"1:",
93+
"cmp x9, #2",
94+
"b.ne 2f",
95+
"adr x9, vector_table_el2",
96+
"msr vbar_el2, x9",
97+
"b 3f",
98+
99+
"2:",
100+
"adr x9, vector_table_el1",
101+
"msr vbar_el1, x9",
102+
103+
"3:",
104+
options(nomem, nostack),
105+
out("x9") _,
106+
);
107+
}
79108
}
80109

81110
extern "C" fn rust_entry(arg0: u64, arg1: u64, arg2: u64, arg3: u64) -> ! {

0 commit comments

Comments
 (0)