Wrong PMP output and compatibility with rCore-Tutorial-v3 of rustsbi-qemu version 0.1.1
wyfcyx opened this issue · 6 comments
The Rustsbi binary was downloaded from https://github.com/rustsbi/rustsbi-qemu/releases/download/v0.1.1/rustsbi-qemu-release.zip.
$ qemu-system-riscv64 --version
QEMU emulator version 6.2.0
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
$ qemu-system-riscv64 -machine virt -nographic -bios ../bootloader/rustsbi-qemu.bin -smp 1
[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0
[logo]
[rustsbi] Implementation: RustSBI-QEMU Version 0.1.1
[rustsbi-dtb] Hart count: cluster0 with 1 cores
[rustsbi] misa: RV64ACDFIMSU
[rustsbi] mideleg: ssoft, stimer, sext (0x222)
[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab)
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-)
[rustsbi] pmp6: 0x2000000 ..= 0x200ffff (rw-)
[rustsbi] pmp12: 0xc000000 ..= 0xc3fffff (rw-)
[rustsbi] enter supervisor 0x80200000
$ qemu-system-riscv64 -machine virt -nographic -bios ../bootloader/rustsbi-qemu.bin -smp 8
[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0
[logo]
[rustsbi] Implementation: RustSBI-QEMU Version 0.1.1
[rustsbi-dtb] Hart count: cluster0 with 8 cores
[rustsbi] misa: RV64ACDFIMSU
[rustsbi] mideleg: ssoft, stimer, sext (0x222)
[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab)
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-)
[rustsbi] pmp6: 0x2000000 ..= 0x200ffff (rw-)
[rustsbi] pmp12: 0xc000000 ..= 0xc3fffff (rw-)
[rustsbi] enter supervisor 0x80200000
The PMP output was not correct. Actually, the expected output is:
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-)
[rustsbi] pmp1: 0x2000000 ..= 0x200ffff (rw-)
[rustsbi] pmp2: 0xc000000 ..= 0xc3fffff (rw-)
[rustsbi] pmp3: 0x80000000 ..= 0x8fffffff (rwx)
It was very weird that when I tested using cargo qemu
under the rustsbi-qemu
root directory, the output was correct. I did not know what happened.
Another question is that rCore-Tutorial-v3 cannot work normally using rustsbi-qemu version 0.1.1 if the tutorial is built in debug mode. However, it works under release mode. Therefore, I decide not to upgrade rustsbi for a while...
Very weird, I can't reproduce locally. My QEMU version:
PS D:\RustSBI\rustsbi-qemu> qemu-system-riscv64 --version
QEMU emulator version 6.2.0 (v6.2.0-11889-g5b72bf03f5-dirty)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
Output:
PS D:\RustSBI\rustsbi-qemu> cargo qemu
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target\debug\xtask.exe qemu`
xtask: mode: Debug
Compiling bit_field v0.10.1
Compiling spin v0.7.1
Compiling spin v0.5.2
Compiling lazy_static v1.4.0
Compiling riscv v0.7.0
Compiling riscv v0.7.0 (https://github.com/rust-embedded/riscv?rev=dc0bc37e#dc0bc37e)
Compiling buddy_system_allocator v0.8.0
Compiling rustsbi v0.2.2
Compiling rustsbi-qemu v0.1.1 (D:\RustSBI\rustsbi-qemu\rustsbi-qemu)
Finished dev [unoptimized + debuginfo] target(s) in 1.64s
Compiling spin v0.7.1
Compiling bit_field v0.10.1
Compiling spin v0.5.2
Compiling lazy_static v1.4.0
Compiling riscv v0.6.0
Compiling buddy_system_allocator v0.8.0
Compiling test-kernel v0.1.0 (D:\RustSBI\rustsbi-qemu\test-kernel)
Finished dev [unoptimized + debuginfo] target(s) in 0.95s
[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0
.______ __ __ _______.___________. _______..______ __
| _ \ | | | | / | | / || _ \ | |
| |_) | | | | | | (----`---| |----`| (----`| |_) || |
| / | | | | \ \ | | \ \ | _ < | |
| |\ \----.| `--' |.----) | | | .----) | | |_) || |
| _| `._____| \______/ |_______/ |__| |_______/ |______/ |__|
[rustsbi] Implementation: RustSBI-QEMU Version 0.1.1
[rustsbi-dtb] Hart count: cluster0 with 8 cores
[rustsbi] misa: RV64ACDFIMSU
[rustsbi] mideleg: ssoft, stimer, sext (0x222)
[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab)
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-)
[rustsbi] pmp1: 0x2000000 ..= 0x200ffff (rw-)
[rustsbi] pmp2: 0xc000000 ..= 0xc3fffff (rw-)
[rustsbi] pmp3: 0x80000000 ..= 0x8fffffff (rwx)
[rustsbi] enter supervisor 0x80200000
<< Test-kernel: Hart id = 0, DTB physical address = 0x87000000
>> Test-kernel: Testing base extension
<< Test-kernel: Base extension version: 1
<< Test-kernel: SBI specification version: 1.0
<< Test-kernel: SBI implementation Id: 4
<< Test-kernel: SBI implementation version: 202
<< Test-kernel: Device mvendorid: 0
<< Test-kernel: Device marchid: 0
<< Test-kernel: Device mimpid: 0
>> Test-kernel: Testing SBI instruction emulation
<< Test-kernel: Current time: ca09f
<< Test-kernel: Time after operation: cc69b
>> Test-kernel: Trigger illegal exception
<< Test-kernel: Value of scause: Exception(IllegalInstruction)
<< Test-kernel: Illegal exception delegate success
>> Stop hart 3, return value 0
>> Hart 0 state return value: 0
>> Hart 1 state return value: 4
>> Hart 2 state return value: 4
>> Hart 3 state return value: 1
>> Hart 4 state return value: 0
<< Test-kernel: test for hart 0 success, wake another hart
>> Wake hart 1, sbi return value 0
>> Start test for hart 1, retentive suspend return value 0
>> Wake hart 2, sbi return value 0
<< The parameter passed to hart 2 resume is: 0x4567890a
>> Start hart 3 with parameter 0x12345678
>> SBI return value: 0
<< The parameter passed to hart 3 start is: 0x12345678
<< Test-kernel: All hart SBI test SUCCESS, shutdown
The Rustsbi binary was downloaded from https://github.com/rustsbi/rustsbi-qemu/releases/download/v0.1.1/rustsbi-qemu-release.zip.
$ qemu-system-riscv64 --version QEMU emulator version 6.2.0 Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers $ qemu-system-riscv64 -machine virt -nographic -bios ../bootloader/rustsbi-qemu.bin -smp 1 [rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0 [logo] [rustsbi] Implementation: RustSBI-QEMU Version 0.1.1 [rustsbi-dtb] Hart count: cluster0 with 1 cores [rustsbi] misa: RV64ACDFIMSU [rustsbi] mideleg: ssoft, stimer, sext (0x222) [rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab) [rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-) [rustsbi] pmp6: 0x2000000 ..= 0x200ffff (rw-) [rustsbi] pmp12: 0xc000000 ..= 0xc3fffff (rw-) [rustsbi] enter supervisor 0x80200000 $ qemu-system-riscv64 -machine virt -nographic -bios ../bootloader/rustsbi-qemu.bin -smp 8 [rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0 [logo] [rustsbi] Implementation: RustSBI-QEMU Version 0.1.1 [rustsbi-dtb] Hart count: cluster0 with 8 cores [rustsbi] misa: RV64ACDFIMSU [rustsbi] mideleg: ssoft, stimer, sext (0x222) [rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab) [rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-) [rustsbi] pmp6: 0x2000000 ..= 0x200ffff (rw-) [rustsbi] pmp12: 0xc000000 ..= 0xc3fffff (rw-) [rustsbi] enter supervisor 0x80200000The PMP output was not correct. Actually, the expected output is:
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-) [rustsbi] pmp1: 0x2000000 ..= 0x200ffff (rw-) [rustsbi] pmp2: 0xc000000 ..= 0xc3fffff (rw-) [rustsbi] pmp3: 0x80000000 ..= 0x8fffffff (rwx)
It was very weird that when I tested using
cargo qemu
under therustsbi-qemu
root directory, the output was correct. I did not know what happened.Another question is that rCore-Tutorial-v3 cannot work normally using rustsbi-qemu version 0.1.1 if the tutorial is built in debug mode. However, it works under release mode. Therefore, I decide not to upgrade rustsbi for a while...
试图引导 zCore,现象一样
我可能试着发一个新版本,先编译main分支的代码试试看
我可能试着发一个新版本,先编译main分支的代码试试看
main
和 release 现象也一样。
cargo qemu
偶尔也不正常,会不会和 qemu 版本有关,我用的 7.0.0:
[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0
.______ __ __ _______.___________. _______..______ __
| _ \ | | | | / | | / || _ \ | |
| |_) | | | | | | (----`---| |----`| (----`| |_) || |
| / | | | | \ \ | | \ \ | _ < | |
| |\ \----.| `--' |.----) | | | .----) | | |_) || |
| _| `._____| \______/ |_______/ |__| |_______/ |______/ |__|
[rustsbi] Implementation: RustSBI-QEMU Version 0.1.1
[rustsbi-dtb] Hart count: cluster0 with 8 cores
[rustsbi] misa: RV64ACDFHIMSU
[rustsbi] mideleg: ssoft, stimer, sext (0x1666)
[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab)
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-)
[rustsbi] pmp6: 0x2000000 ..= 0x200ffff (rw-)
[rustsbi] pmp12: 0xc000000 ..= 0xc3fffff (rw-)
[rustsbi] enter supervisor 0x80200000
opqaue: 0x87000000
<< Test-kernel: Hart id = 0, DTB physical address = 0x87000000
>> Test-kernel: Testing base extension
<< Test-kernel: Base extension version: 1
<< Test-kernel: SBI specification version: 1.0
<< Test-kernel: SBI implementation Id: 4
<< Test-kernel: SBI implementation version: 202
<< Test-kernel: Device mvendorid: 0
<< Test-kernel: Device marchid: 0
<< Test-kernel: Device mimpid: 0
>> Test-kernel: Testing SBI instruction emulation
<< Test-kernel: Current time: a164f
<< Test-kernel: Time after operation: a2149
>> Test-kernel: Trigger illegal exception
<< Test-kernel: Value of scause: Exception(IllegalInstruction)
<< Test-kernel: Illegal exception delegate success
>> Stop hart 3, return value 0
>> Hart 0 state return value: 0
>> Hart 1 state return value: 4
>> Hart 2 state return value: 4
>> Hart 3 state return value: 3
>> Hart 4 state return value: 0
<< Test-kernel: test for hart 0 success, wake another hart
>> Wake hart 1, sbi return value 0
>> Start test for hart 1, retentive suspend return value 0
>> Wake hart 2, sbi return value 0
<< The parameter passed to hart 2 resume is: 0x4567890a
>> Start hart 3 with parameter 0x12345678
>> SBI return value: <SBI invalid parameter>
竟然是偶发性问题吗
解决了