Skip to content

Commit 2fe8e32

Browse files
committed
[Fix] pass x16 register as parameter for SBI call
The previous approach "li x16,0" may prevent the compiler from recognizing x16 as a function parameter, resulting in the caller saved register saving mechanism not being triggered in release mode.
1 parent 90e16f9 commit 2fe8e32

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

os/src/sbi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
1212
let mut ret;
1313
unsafe {
1414
asm!(
15-
"li x16, 0",
15+
1616
"ecall",
1717
inlateout("x10") arg0 => ret,
1818
in("x11") arg1,
1919
in("x12") arg2,
20+
in("x16") 0,
2021
in("x17") which,
2122
);
2223
}

0 commit comments

Comments
 (0)