Skip to content

Commit 418c105

Browse files
Merge #88
88: Bug fix: sfence.vma - incorrect operand order r=Disasm a=DeathWish5 There is a bug about the operand order of `riscv::asm::sfence_vma(asid: usize, addr: usize)`. According to [riscv-isa-manual](https://github.com/riscv/riscv-isa-manual/blob/master/src/supervisor.tex#L1198), the first operand should be `vaddr`, and the second be `asid`. But `riscv::asm::sfence_vma` generates assembly code in the reverse order. In fact, our rust-OS which using this instruction to flush TLB have been running into an error until we reverse the parameter order. I propose a simple solution which leave the function parameter order unchanged. Maybe you guys will change it to be more consistent with the specification. Anyway, let's fix this bug. Co-authored-by: DeathWish5 <[email protected]>
2 parents be2927e + 508a4d0 commit 418c105

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/asm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ instruction!(
5858
pub unsafe fn sfence_vma(asid: usize, addr: usize) {
5959
match () {
6060
#[cfg(all(riscv, feature = "inline-asm"))]
61-
() => asm!("sfence.vma {0}, {1}", in(reg) asid, in(reg) addr),
61+
() => asm!("sfence.vma {0}, {1}", in(reg) addr, in(reg) asid),
6262

6363
#[cfg(all(riscv, not(feature = "inline-asm")))]
6464
() => {
6565
extern "C" {
66-
fn __sfence_vma(asid: usize, addr: usize);
66+
fn __sfence_vma(addr: usize, asid: usize);
6767
}
6868

69-
__sfence_vma(asid, addr);
69+
__sfence_vma(addr, asid);
7070
}
7171

7272
#[cfg(not(riscv))]

0 commit comments

Comments
 (0)