openxiangshan / nemu Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
在S模式下触发异常,例如load access fault,非法指令异常等,NEMU目前是直接报错,希望NEMU能触发异常。
src/isa/riscv64/reg.c 中able_to_take_cpt()进行了模式判断,请问为什么需要这个限制?
bool able_to_take_cpt() {
// return true;
return cpu.mode != MODE_M;
}
您好:请问关于0x5c0-0x5Fd,这几个自定义读写寄存器这边是怎么设置的,我用csrw对这几个寄存器写0x0失败;
如题,请问NEMU的Tracing 分支profiling的算法差异,以及 tracing 的意味是什么,我可以查看哪些文献来了解。
CONFIG_SVINVAL
is defined by default and CONFIG_DEBUG
is not defined by default, however if I define both of them, there will be a compilation error(in standalone mode):
src/cpu/cpu-exec.c: In function ‘execute’:
src/cpu/cpu-exec.c:159:5: error: label ‘exec_sinval_vma’ used but not defined
159 | MAP(INSTR_LIST, FILL_EXEC_TABLE)
| ^~~
src/cpu/cpu-exec.c:159:5: error: label ‘exec_sfence_inval_ir’ used but not defined
src/cpu/cpu-exec.c:159:5: error: label ‘exec_sfence_w_inval’ used but not defined
I think this may be caused by:
NEMU/src/isa/riscv64/instr/priv/decode.h
Lines 7 to 27 in eaa07cd
我的命令是:
$NEMU_HOME/build/riscv64-nemu-interpreter coremark-2-iteration.bin -D /home/zxk/nemu_result -w coremark10000 -C profiling -b --simpoint-profile --cpt-interval 10000 -r $NEMU_HOME/resource/gcpt_restore/build/gcpt.bin
详细输出如下:
[src/monitor/monitor.c:154,parse_args] Doing Simpoint Profiling
[src/checkpoint/path_manager.cpp:40,init] Cpt id: -1
[src/checkpoint/path_manager.cpp:62,setOutputDir] Created /home/zxk/nemu_result/profiling/coremark10000/
[src/checkpoint/simpoint.cpp:81,init] Doing simpoint profiling with interval 10000
[src/memory/paddr.c:81,init_mem] mmap memory to anonymous file
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'clint' at [0x0000000038000000, 0x000000003800ffff]
[src/isa/riscv64/init.c:70,init_isa] NEMU will start from pc 0x80000000
[src/monitor/monitor.c:308,init_monitor] You are providing a gcpt restorer when doing simpoing profiling, If you didn't link the program correctly, this will corrupt your memory/program.
[src/monitor/image_loader.c:56,load_img] Loading Gcpt restorer form cmdline: /root/NEMU/resource/gcpt_restore/build/gcpt.bin
[src/monitor/image_loader.c:83,load_img] Warning: size is larger than img_size(upper limit), please check if code is missing. size:1100 img_size:f00
[src/monitor/image_loader.c:88,load_img] Fread from file because less than 512MB
[src/monitor/image_loader.c:120,load_img] Read 3840 bytes from file /root/NEMU/resource/gcpt_restore/build/gcpt.bin to 0x80000000
[src/monitor/image_loader.c:56,load_img] Loading image (bbl/bare metal app) from cmdline: coremark
[src/monitor/image_loader.c:88,load_img] Fread from file because less than 512MB
[src/monitor/image_loader.c:120,load_img] Read 18984 bytes from file coremark to 0x800a0000
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'uartlite' at [0x00000000000003f8, 0x0000000000000404]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'uartlite' at [0x0000000040600000, 0x000000004060000c]
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'rtc' at [0x0000000000000048, 0x000000000000004f]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'rtc' at [0x00000000a1000048, 0x00000000a100004f]
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'screen' at [0x0000000000000100, 0x0000000000000107]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'screen' at [0x0000000040001000, 0x0000000040001007]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'vmem' at [0x0000000050000000, 0x00000000500752ff]
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'keyboard' at [0x0000000000000060, 0x0000000000000063]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'keyboard' at [0x00000000a1000060, 0x00000000a1000063]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'sdhci' at [0x0000000040002000, 0x000000004000207f]
[src/device/sdcard.c:121,init_sdcard] Can not find sdcard image:
[src/monitor/monitor.c:37,welcome] Debug: OFF
[src/monitor/monitor.c:42,welcome] Build time: 19:06:20, Jan 8 2024
Welcome to riscv64-NEMU!
For help, type "help"
Running CoreMark for 2 iterations
2K performance run parameters for coremark.
[0]ERROR! list crc 0xbd52 - should be 0xe714
[0]ERROR! state crc 0x6f31 - should be 0x8e3a
CoreMark Size : 666
Total time (ms) : 36480
Iterations : 2
Compiler version : GCC10.2.0
seedcrc : 0xe9f5
[0]crclist : 0xbd52
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x6f31
[0]crcfinal : 0x0026
Finised in 36480 ms.
Errors detected
[src/cpu/cpu-exec.c:436,cpu_exec] nemu: HIT GOOD TRAP at pc = 0x00000000800a26ba
[src/cpu/cpu-exec.c:440,cpu_exec] trap code:0
[src/cpu/cpu-exec.c:76,monitor_statistic] host time spent = 5854 us
[src/cpu/cpu-exec.c:78,monitor_statistic] total guest instructions = 466897
[src/cpu/cpu-exec.c:79,monitor_statistic] simulation frequency = 79756918 instr/s
PPM correct: 0, PPM mispred: 0
MPKI: 0.000000
[src/profiling/betapoint_profiling.cpp:338,onExit] numLoad: 0, numStore: 0
[src/profiling/betapoint_profiling.cpp:339,onExit] Footprint: 0 cacheblocks, 0 KiB
[src/profiling/betapoint_profiling.cpp:213,dumpStride] Dump stride histogram
[src/profiling/betapoint_profiling.cpp:251,dumpStride] global stride total: 0
[src/profiling/betapoint_profiling.cpp:251,dumpStride] global stride total: 0
[src/profiling/betapoint_profiling.cpp:288,dumpStride] local stride total: 0, local pc count: 0
[src/profiling/betapoint_profiling.cpp:288,dumpStride] local stride total: 0, local pc count: 0
[src/profiling/betapoint_profiling.cpp:351,dumpDistinctStrideInc] Dump new distinct strides : 0
[src/profiling/betapoint_profiling.cpp:363,dumpFootPrintInc] Dump footprint increments: 0
[src/profiling/betapoint_profiling.cpp:312,calcReuseMatrix] Dump Reuse matrix
[src/profiling/betapoint_profiling.cpp:502,onExit] Dump critical path size: 0
[src/profiling/betapoint_profiling.cpp:509,onExit] Dump ppm miss count: 1
[src/utils/state.c:11,is_exit_status_bad] NEMU exit with good state: 2, halt ret: 0
生成的bbv文件为空。
环境:
docker镜像:ubuntu20/ubuntu19/debian-10 都试了
已安装
问题
执行chroot /mnt /bin/bash
chroot: failed to run command '/bin/bash': Exec format error
已排查:
1)qemu没装好
2)https://stackoverflow.com/questions/68351252/qemu-x86-64-static-exec-format-error-after-chroot
请问是否有遇到过这个问题
我用 Tracing 分支,已经成功完成 profiling 生成 bbv 文件,然后通过 simpoint 程序,输出 simpoints 和 weights 文件,然后在 NEMU上生成切片。可是,那些切片在 emu 上运行不起来。另外,我把在Tracing分支输出的 simpoints 和 weights 拿到 cpt-bk分支的NEMU上,可以成功切片和在emu上运行。所以,我判断问题出现在Tracing分支的切片功能。下面是,Tracing分支切片使用的命令,以及在emu上的报错信息。请问,如何解决呢?
1 #!/usr/bin/sh
2 ../build/riscv64-nemu-interpreter \
3 -b /riscv/xs-env/riscv-pk/build/bbl.bin \
4 -D . \
5 -w bbl \
6 -C take_cpt \
7 -S take_cpt \
8 --cpt-interval 1000000 \
9 -r /riscv/xs-env/NEMU/resource/gcpt_restore/build/gcpt.bin
$> emu -i take_cpt/bbl/20/_536240_0.072592_.gz -I 1000000
Emu compiled at Mar 21 2022, 20:50:05
The image is take_cpt/bbl/20/_536240_0.072592_.gz
Using simulated 16384MB RAM
Gzip file detected and loading image from extracted gz file
--diff is not given, try to use $(NEMU_HOME)/build/riscv64-nemu-interpreter-so by default
NemuProxy using /riscv/xs-env/NEMU/build/riscv64-nemu-interpreter-so
[src/memory/paddr.c:81,init_mem] mmap memory to anonymous file
The first instruction of core 0 has commited. Difftest enabled.
ERROR: invalid mem read from paddr 0x10000000, NEMU raise illegal inst exception
sh: spike-dasm????????????
============== Commit Group Trace (Core 0) ==============
commit group [00]: pc 0010000000 cmtcnt 1 <--
commit group [01]: pc 0000000000 cmtcnt 0
commit group [02]: pc 0000000000 cmtcnt 0
commit group [03]: pc 0000000000 cmtcnt 0
commit group [04]: pc 0000000000 cmtcnt 0
commit group [05]: pc 0000000000 cmtcnt 0
commit group [06]: pc 0000000000 cmtcnt 0
commit group [07]: pc 0000000000 cmtcnt 0
commit group [08]: pc 0000000000 cmtcnt 0
commit group [09]: pc 0000000000 cmtcnt 0
commit group [10]: pc 0000000000 cmtcnt 0
commit group [11]: pc 0000000000 cmtcnt 0
commit group [12]: pc 0000000000 cmtcnt 0
commit group [13]: pc 0000000000 cmtcnt 0
commit group [14]: pc 0000000000 cmtcnt 0
commit group [15]: pc 0000000000 cmtcnt 0
============== Commit Instr Trace ==============
commit inst [00]: pc 0010000000 inst 0010029b wen 1 dst 00000005 data 0000000000000001 <--
commit inst [01]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [02]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [03]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [04]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [05]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [06]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [07]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [08]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [09]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [10]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [11]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [12]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [13]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [14]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [15]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [16]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [17]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [18]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [19]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [20]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [21]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [22]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [23]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [24]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [25]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [26]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [27]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [28]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [29]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [30]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
commit inst [31]: pc 0000000000 inst 00000000 wen 0 dst 00000000 data 0000000000000000
============== REF Regs ==============
$0: 0x0000000000000000 ra: 0x88b0117316fdf463 sp: 0x8f2fde55abec1f2c gp: 0x2b4b239c6259e1a0
tp: 0x96d46bf23bffa86b t0: 0x0000000000000001 t1: 0xc24c1caf1b8e6823 t2: 0x5aa7032eca00dd23
s0: 0x3f626b247aae3353 s1: 0x5ba53723b34756c0 a0: 0x380cdb07a5a58caf a1: 0x377ed3564e95cc4d
a2: 0xd411fef010dade06 a3: 0x1ba6d3fb1cec189a a4: 0x6f018a24fc544269 a5: 0x1bf43813a7fbb7ac
a6: 0xfe77eca18ab07b80 a7: 0xa1b66f5f3f3cd109 s2: 0x545a1831dfe58105 s3: 0x2a325a3ecb635806
s4: 0xedd2db71c4214781 s5: 0x1b98f2cef9c3e7da s6: 0x77462083ed0f71cc s7: 0x84a8e2d1d810ca56
s8: 0x85337553e885ffd8 s9: 0x533998b77e546d91 s10: 0x4b876709ca0f486e s11: 0x406cce6a1327b057
t3: 0x741d9a8403c08905 t4: 0xca81c3af810f34d6 t5: 0x1fc3c62f86cce9b7 t6: 0x4ebf40bcd97af7c0
ft0: 0x865b3aabd7d43852 ft1: 0x4897fb25bb1d7953 ft2: 0x3f660f30658f5273 ft3: 0x092a4a5c1a02f1fb
ft4: 0x22803dca6532c49f ft5: 0xf3dc71c8f2311850 ft6: 0x8e3552dbc8174309 ft7: 0xd3cac1431d6005d0
fs0: 0x3e56a9c5d0725871 fs1: 0x5afd5e76867d5733 fa0: 0x72077dd16195a6c7 fa1: 0x2ee785f650d0a8bd
fa2: 0x9779c5ecf5cf4a00 fa3: 0x5ee50155d0597c45 fa4: 0xfbb8c7a71ecf70ca fa5: 0x6a48b8ccf3393d70
fa6: 0x1613954ae0e66c87 fa7: 0x2f16489d4394d006 fs2: 0x335e038d2fb37a58 fs3: 0x5b8fbd26f0940e89
fs4: 0xa8ce72642fdb0fcb fs5: 0xce2bf90ee812f68c fs6: 0x64380a3a0d36250e fs7: 0x702d1e2d0f1d0dec
fs8: 0xfe19b4edb1c1cae4 fs9: 0xe2951460b4c3737d fs10: 0x8fb12a5de2ed0158 fs11: 0x05b3a50d5fd64c27
ft8: 0x3ffff7aacee2f812 ft9: 0x4a04aa0facff9f79 ft10: 0xa3d49d7740a62609 ft11: 0x970d4b40f4c483cf
pc: 0x0000000000000000 mstatus: 0x0000000a00001800 mcause: 0x0000000000000002 mepc: 0x0000000010000000
sstatus: 0x0000000200000000 scause: 0x0000000000000000 sepc: 0x0000000000000000
satp: 0x0000000000000000
mip: 0x0000000000000000 mie: 0x0000000000000000 mscratch: 0x0000000000000000 sscratch: 0x0000000000000000
mideleg: 0x0000000000000000 medeleg: 0x0000000000000000
mtval: 0x0000000000000000 stval: 0x000000104ee9bfbd mtvec: 0x0000000000000000 stvec: 0x0000000000000000
privilege mode:3 pmp: below
0: cfg:0x00 addr:0x0000000000000000| 1: cfg:0x00 addr:0x0000000000000000
2: cfg:0x00 addr:0x0000000000000000| 3: cfg:0x00 addr:0x0000000000000000
4: cfg:0x00 addr:0x0000000000000000| 5: cfg:0x00 addr:0x0000000000000000
6: cfg:0x00 addr:0x0000000000000000| 7: cfg:0x00 addr:0x0000000000000000
8: cfg:0x00 addr:0x0000000000000000| 9: cfg:0x00 addr:0x0000000000000000
10: cfg:0x00 addr:0x0000000000000000|11: cfg:0x00 addr:0x0000000000000000
12: cfg:0x00 addr:0x0000000000000000|13: cfg:0x00 addr:0x0000000000000000
14: cfg:0x00 addr:0x0000000000000000|15: cfg:0x00 addr:0x0000000000000000
priviledgeMode: 3
mstatus different at pc = 0x0010000000, right= 0x0000000a00001800, wrong = 0x0000000a00000000
mcause different at pc = 0x0010000000, right= 0x0000000000000002, wrong = 0x0000000000000000
mepc different at pc = 0x0010000000, right= 0x0000000010000000, wrong = 0xe636dbfe88cc0ed0
Core 0: ABORT at pc = 0x321db953d7
total guest instructions = 1
instrCnt = 1, cycleCnt = 558, IPC = 0.001792
Saving snapshots to file system. Please wait.
Please remove unused snapshots manually
Seed=0 Guest cycle spent: 559 (this will be different from cycleCnt if emu loads a snapshot)
Host time spent: 3,089ms
我最近基于NutShell做了一些工作,并希望使用NEMU的Difftest功能来辅助调试。但结果却是NutShell的差分测试代码无法与现有的NEMU的so动态链接库兼容。在链接时会出现找不到符号(symbol)的问题,这意味着在新的代码中移除了一些原先存在的接口。而这个问题甚至存在于NutShell仓库的不同分支中(我无法将difftest
分支下的riscv64-nemu-interpreter-so
文件用于master
分支,这同样存在找不到符号的问题)。
考虑到NEMU现在已经被同时应用于OpenXiangShan、NutShell以及一生一芯这三个颇具影响力的项目中,我认为也许是时候将API的向后兼容性这一问题提上议程了。一个稳定的API能够保证我们不用频繁地修改测试代码。而且,如果日后希望能进一步地推广NEMU的话,一个稳定且具有向后兼容性的API也是必不可少的。
src/cpu/cpu-exec.c:12:10: fatal error: roaring/roaring.h: No such file or directory
#include <roaring/roaring.h>
I canot find this file in include library.
想请问下有没有计划将xiangshan的nemu和nju的nemu (https://github.com/NJU-ProjectN/nemu) 合并?看到上游也有些不同的功能比如itrace
我们在gentoo上给两个nemu都打了包,不过如果两个nemu能合并的话就能让包维护者和用户方便不少。
目前NEMU不支持PLIC中断控制器,无法做一下外设相关的实验
你们好,我阅读完了你们有关checkpoint的资料,发现没有说到:如何让香山的emu调用已生成的checkpoint。请问这是如何操作呢?谢谢。
我的负载很简单,是hello world + 累加累减 + 一个卷积计算的简单计算。我使用的interval是10w,分支使用的是tracing分支。
profiling使用命令: ./build/riscv64-nemu-interpreter /root/riscv-pk/build/bbl.bin -D /home/zxk/spec_cpt -w workloadName2 -C profiling -b --simpoint-profile --cpt-interval 100000 -r ./resource
/gcpt_restore/build/gcpt.bin
生成了bbv.gz,但是文件大小只有20B
cluster使用命令:./resource/simpoint/simpoint_repo/bin/simpoint -loadFVFile /home/zxk/spec_cpt/profiling/workloadName2/simpoint_bbv.gz -saveSimpoints $CLUSTER/simpoints0 -saveSimpointWeigh
ts $CLUSTER/weights0 -inputVectorsGzipped -maxK 30 -numInitSeeds 2 -iters 1000 -seedkm 123456 -seedproj 654321
只聚了一个类
checkpointing使用命令:
./build/riscv64-nemu-interpreter $RISCV_PK_HOME/build/bbl.bin \ -D /home/zxk/spec_cpt -w workloadName2 -C take_cpt \ -b -S /home/zxk/spec_cpt/cluster--cpt-interval 100000 \ -r ./resource/gcpt_restore/build/gcpt.bin
未生成文件。
当我在profiling阶段加了--dont-skip-boot以后,bbv文件比较大,聚类聚了7个类,但是checkpointing阶段遇到了crash,信息如下:
[src/checkpoint/serializer.cpp:209,init] Simpoint 0: @ 18, weight: 0.048780
[src/checkpoint/serializer.cpp:209,init] Simpoint 1: @ 5, weight: 0.048780
[src/checkpoint/serializer.cpp:209,init] Simpoint 2: @ 3, weight: 0.048780
[src/checkpoint/serializer.cpp:209,init] Simpoint 3: @ 9, weight: 0.121951
[src/checkpoint/serializer.cpp:209,init] Simpoint 4: @ 0, weight: 0.048780
[src/checkpoint/serializer.cpp:209,init] Simpoint 5: @ 27, weight: 0.024390
[src/checkpoint/serializer.cpp:209,init] Simpoint 6: @ 17, weight: 0.024390
[src/checkpoint/serializer.cpp:209,init] Simpoint 7: @ 12, weight: 0.121951
[src/checkpoint/serializer.cpp:209,init] Simpoint 8: @ 38, weight: 0.195122
[src/checkpoint/serializer.cpp:209,init] Simpoint 9: @ 20, weight: 0.097561
[src/checkpoint/serializer.cpp:209,init] Simpoint 10: @ 26, weight: 0.024390
[src/checkpoint/serializer.cpp:209,init] Simpoint 11: @ 36, weight: 0.097561
[src/checkpoint/serializer.cpp:209,init] Simpoint 12: @ 21, weight: 0.097561
[src/memory/paddr.c:81,init_mem] mmap memory to anonymous file
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'clint' at [0x0000000038000000, 0x000000003800ffff]
[src/isa/riscv64/init.c:70,init_isa] NEMU will start from pc 0x80000000
[src/monitor/image_loader.c:56,load_img] Loading Gcpt restorer form cmdline: /root/NEMU/resource/gcpt_restore/build/gcpt.bin
[src/monitor/image_loader.c:83,load_img] Warning: size is larger than img_size(upper limit), please check if code is missing. size:1100 img_size:f00
[src/monitor/image_loader.c:88,load_img] Fread from file because less than 512MB
[src/monitor/image_loader.c:120,load_img] Read 3840 bytes from file /root/NEMU/resource/gcpt_restore/build/gcpt.bin to 0x80000000
[src/monitor/image_loader.c:56,load_img] Loading image (bbl/bare metal app) from cmdline: ./resource/gcpt_restore/build/gcpt.bin
[src/monitor/image_loader.c:88,load_img] Fread from file because less than 512MB
[src/monitor/image_loader.c:120,load_img] Read 4352 bytes from file ./resource/gcpt_restore/build/gcpt.bin to 0x800a0000
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'uartlite' at [0x00000000000003f8, 0x0000000000000404]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'uartlite' at [0x0000000040600000, 0x000000004060000c]
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'rtc' at [0x0000000000000048, 0x000000000000004f]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'rtc' at [0x00000000a1000048, 0x00000000a100004f]
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'screen' at [0x0000000000000100, 0x0000000000000107]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'screen' at [0x0000000040001000, 0x0000000040001007]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'vmem' at [0x0000000050000000, 0x00000000500752ff]
[src/device/io/port-io.c:15,add_pio_map] Add port-io map 'keyboard' at [0x0000000000000060, 0x0000000000000063]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'keyboard' at [0x00000000a1000060, 0x00000000a1000063]
[src/device/io/mmio.c:18,add_mmio_map] Add mmio map 'sdhci' at [0x0000000040002000, 0x000000004000207f]
[src/device/sdcard.c:121,init_sdcard] Can not find sdcard image:
[src/monitor/monitor.c:37,welcome] Debug: OFF
[src/monitor/monitor.c:42,welcome] Build time: 17:31:30, Jun 24 2023
Welcome to riscv64-NEMU!
For help, type "help"
(nemu) c
Invalid inst 0x0000: pc = 0x0000000080140000
$0: 0x0000000000000000 ra: 0x0000000000000000 sp: 0x0000000000000000 gp: 0x0000000000000000
tp: 0x0000000000000000 t0: 0x0000000000000000 t1: 0x0000000000000000 t2: 0x000000000000beef
s0: 0x0000000080000f00 s1: 0x0000000000000000 a0: 0x0000000000000000 a1: 0x0000000000000000
a2: 0x0000000000000000 a3: 0x0000000000000000 a4: 0x0000000000000000 a5: 0x0000000000000000
a6: 0x0000000000000000 a7: 0x0000000000000000 s2: 0x0000000000000000 s3: 0x0000000000000000
s4: 0x0000000000000000 s5: 0x0000000000000000 s6: 0x0000000000000000 s7: 0x0000000000000000
s8: 0x0000000000000000 s9: 0x0000000000000000 s10: 0x0000000000000000 s11: 0x0000000000000000
t3: 0x0000000000000000 t4: 0x0000000000000000 t5: 0x0000000000000000 t6: 0x0000000000000000
ft0: 0x0000000000000000 ft1: 0x0000000000000000 ft2: 0x0000000000000000 ft3: 0x0000000000000000
ft4: 0x0000000000000000 ft5: 0x0000000000000000 ft6: 0x0000000000000000 ft7: 0x0000000000000000
fs0: 0x0000000000000000 fs1: 0x0000000000000000 fa0: 0x0000000000000000 fa1: 0x0000000000000000
fa2: 0x0000000000000000 fa3: 0x0000000000000000 fa4: 0x0000000000000000 fa5: 0x0000000000000000
fa6: 0x0000000000000000 fa7: 0x0000000000000000 fs2: 0x0000000000000000 fs3: 0x0000000000000000
fs4: 0x0000000000000000 fs5: 0x0000000000000000 fs6: 0x0000000000000000 fs7: 0x0000000000000000
fs8: 0x0000000000000000 fs9: 0x0000000000000000 fs10: 0x0000000000000000 fs11: 0x0000000000000000
ft8: 0x0000000000000000 ft9: 0x0000000000000000 ft10: 0x0000000000000000 ft11: 0x0000000000000000
pc: 0x0000000080000000 mstatus: 0x0000000a00000000 mcause: 0x0000000000000000 mepc: 0x0000000000000000
sstatus: 0x0000000200000000 scause: 0x0000000000000000 sepc: 0x0000000000000000
satp: 0x0000000000000000
mip: 0x0000000000000000 mie: 0x0000000000000000 mscratch: 0x0000000000000000 sscratch: 0x0000000000000000
mideleg: 0x0000000000000000 medeleg: 0x0000000000000000
mtval: 0x0000000000000000 stval: 0x0000000000000000 mtvec: 0x0000000000000000 stvec: 0x0000000000000000
privilege mode:3 pmp: below
0: cfg:0x00 addr:0x0000000000000000| 1: cfg:0x00 addr:0x0000000000000000
2: cfg:0x00 addr:0x0000000000000000| 3: cfg:0x00 addr:0x0000000000000000
4: cfg:0x00 addr:0x0000000000000000| 5: cfg:0x00 addr:0x0000000000000000
6: cfg:0x00 addr:0x0000000000000000| 7: cfg:0x00 addr:0x0000000000000000
8: cfg:0x00 addr:0x0000000000000000| 9: cfg:0x00 addr:0x0000000000000000
10: cfg:0x00 addr:0x0000000000000000|11: cfg:0x00 addr:0x0000000000000000
12: cfg:0x00 addr:0x0000000000000000|13: cfg:0x00 addr:0x0000000000000000
14: cfg:0x00 addr:0x0000000000000000|15: cfg:0x00 addr:0x0000000000000000
pmp csr rw: enable, pmp check: disable
[src/cpu/cpu-exec.c:76,monitor_statistic] host time spent = 0 us
[src/cpu/cpu-exec.c:78,monitor_statistic] total guest instructions = 18
[src/cpu/cpu-exec.c:80,monitor_statistic] Finish running in less than 1 us and can not calculate the simulation frequency
riscv64-nemu-interpreter: src/isa/riscv64/instr/rvc/decode.h:132: decode_C_ADDI4SPN: Assertion `0' failed.
Aborted (core dumped)
使用make menuconfig
命令进入配置界面后,在FPU_Emulation一栏下选择Disable FPU Emulation。此后再进行编译会出现链接错误如下
/usr/bin/ld: /tmp/ccdfIYii.ltrans0.ltrans.o: in function `rtl_fpcall':
<artificial>:(.text+0x8579): undefined reference to `fesetround'
/usr/bin/ld: <artificial>:(.text+0x8595): undefined reference to `llrintf'
/usr/bin/ld: <artificial>:(.text+0x8725): undefined reference to `fmaf'
/usr/bin/ld: <artificial>:(.text+0x8825): undefined reference to `llrintf'
/usr/bin/ld: <artificial>:(.text+0x883d): undefined reference to `llrintf'
/usr/bin/ld: <artificial>:(.text+0x8856): undefined reference to `llrint'
/usr/bin/ld: <artificial>:(.text+0x8868): undefined reference to `llrint'
/usr/bin/ld: <artificial>:(.text+0x887c): undefined reference to `llrint'
/usr/bin/ld: <artificial>:(.text+0x88db): undefined reference to `fma'
/usr/bin/ld: <artificial>:(.text+0x8afc): undefined reference to `sqrt'
/usr/bin/ld: <artificial>:(.text+0x8b06): undefined reference to `sqrtf'
collect2: error: ld returned 1 exit status
而开启FPU Emulation选项时则不会出现这个问题。
我编译时总体的配置文件内容如下
#
# Automatically generated file; DO NOT EDIT.
# NEMU Configuration Menu
#
# CONFIG_ISA_x86 is not set
# CONFIG_ISA_mips32 is not set
# CONFIG_ISA_riscv32 is not set
CONFIG_ISA_riscv64=y
CONFIG_ISA="riscv64"
CONFIG_ILEN_MIN=2
CONFIG_ISA64=y
#
# ISA-dependent Options for riscv64
#
CONFIG_CLINT_MMIO=0xa2000000
# CONFIG_MULTICORE_DIFF is not set
# CONFIG_RVB is not set
# CONFIG_RVV_010 is not set
# end of ISA-dependent Options for riscv64
CONFIG_ENGINE_INTERPRETER=y
CONFIG_ENGINE="interpreter"
CONFIG_MODE_SYSTEM=y
# CONFIG_MODE_USER is not set
#
# Build Options
#
CONFIG_CC_GCC=y
# CONFIG_CC_GPP is not set
# CONFIG_CC_CLANG is not set
CONFIG_CC="gcc"
# CONFIG_CC_O0 is not set
# CONFIG_CC_O1 is not set
CONFIG_CC_O2=y
# CONFIG_CC_O3 is not set
CONFIG_CC_OPT="-O2"
CONFIG_CC_LTO=y
# CONFIG_CC_DEBUG is not set
# CONFIG_CC_ASAN is not set
# end of Build Options
#
# Testing and Debugging
#
CONFIG_DIFFTEST_REF_PATH="none"
CONFIG_DIFFTEST_REF_NAME="none"
# CONFIG_DETERMINISTIC is not set
# CONFIG_IQUEUE is not set
# end of Testing and Debugging
#
# Memory Configuration
#
CONFIG_MBASE=0x80000000
CONFIG_MSIZE=0x8000000
CONFIG_PC_RESET_OFFSET=0x100000
CONFIG_USE_MMAP=y
CONFIG_MEM_RANDOM=y
# CONFIG_MEM_COMPRESS is not set
# end of Memory Configuration
# CONFIG_FPU_HOST is not set
# CONFIG_FPU_SOFT is not set
CONFIG_FPU_NONE=y
CONFIG_AC_HOST=y
# CONFIG_AC_SOFT is not set
# CONFIG_AC_NONE is not set
#
# Processor difftest reference config
#
CONFIG_SHARE=y
CONFIG_DIFFTEST_STORE_COMMIT=y
CONFIG_GUIDED_EXEC=y
CONFIG_PANIC_ON_UNIMP_CSR=y
# end of Processor difftest reference config
#
# Miscellaneous
#
CONFIG_TIMER_GETTIMEOFDAY=y
# CONFIG_TIMER_CLOCK_GETTIME is not set
CONFIG_RT_CHECK=y
CONFIG_ENABLE_INSTR_CNT=y
# end of Miscellaneous
默认是不使能CONFIG_SHARE的,在make riscv64-xs_defconfig之后,会报错
/usr/bin/ld: /tmp/riscv64-nemu-interpreter.h5RMVg.ltrans0.ltrans.o: relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
1.rs1rs2两者结果的解码正好为上溢出时,fnmadd.s的运算结果为rs3的值,正确结果应为0xff800000;
2.rs1rs2两者结果为上溢出(不包括临界条件),则计算正确;
通过计算:
Fs10_4f057641(rs1):0 100 1111 0000 0101 0111 0110 0100 0001
数符:0
阶:阶码:10011110 阶码的值: 158-127=31 移码:阶码表示=真值+阶码常数
尾数部分:1.0000000000000000 0000000000000000 000000000000 00000000
ft0_0x70000000(rs2):
0 11100000 000 0000 0000 0000 0000 0000
数符:0
阶:阶码:11100000 阶码的值:224-127=97
尾数部分:1.00000 0000000000000000000000000 000000000000000000 0000
Fs5_0xff057641(rs3):
1 111 1111 0 000 0101 0111 0110 0100 0001
数符:1
阶:阶码:111 1111 0 阶码的值:254-127=127
尾数部分:1.00000 0000000000000000000000000 000000000000000000 0000
Fs10*ft0=0x7f800000(0 111 1111 1000 0000 0000 0000 0000 0000)
①0异或0=0,所以符号位等于0
②阶码相加
31+97=128 向上溢出:单精度浮点数阶码值范围为-126~127,128+127=255(边界条件)
③尾数:溢出尾数为0
-(Fs10*ft0)+fs5=-0x7f800000(上溢出)+0xff057641=0xff800000 NEMU结果为0xff057641
[ TIME ] Timed out waiting for device dev-hvc0.device - /dev/hvc0.
[DEPEND] Dependency failed for seri…ervice - Serial Getty on hvc0.
[FAILED] Failed to start systemd-lo…rvice - User Login Management.
See 'systemctl status systemd-logind.service' for details.
[ OK ] Started dbus.service - D-Bus System Message Bus.
[ OK ] Stopped haveged.servicemon based on the HAVEGE algorithm.
[ OK ] Started haveged.servicemon based on the HAVEGE algorithm.
Starting networking.service - Raise network interfaces...
[ OK ] Stopped systemd-logind.service - User Login Management.
Starting [email protected] - Load Kernel Module drm...
[ OK ] Finished [email protected] - Load Kernel Module drm.
[ OK ] Stopped haveged.servicemon based on the HAVEGE algorithm.
[ OK ] Started haveged.servicemon based on the HAVEGE algorithm.
Starting systemd-logind.se…ice - User Login Management...
[FAILED] Failed to start systemd-lo…rvice - User Login Management.
请问你们有遇到过这个错误吗
IntervalSize = 1M,共有 283226 个 Interval (在 Profiling时,BBV的行数),即429用例约共执行了 283226 * 1M = 283,226,000,000 (+/-) 1M 条指令。
然后,我用以下公式去推算你们结果,发现IPC只有0.21左右。请指教下,是在计算的过程中,哪里出现了问题吗?
(给定:429测试用例得分为 标准用时除以实际用时,其中如上图,用例得分为14.52,标准用时为 9120s,emu模拟CPU的主频为 2.0GHz,总执行指令数为 283,226,000,000)
429测试用例得分 = 标准用时 / 实际用时 (求得 实际用时 为 9120 / 14.52 = 628.0991735537191)
实际用时 = 总执行时钟数 / CPU主频 (求得 总执行时钟数 为 628.0991735537191 * 2G = 1348832704528.9258 )
总执行时钟数 = 总执行指令数 / 加权平均IPC (求得 加权平均IPC 为 283,226,000,000 / 1348832704528.9258 = 0.21 )
因此,把给定的参数代入,得出的 IPC 约为 0.21。
Hi,
基于文档中的 生成profile, cluster, checkpoint的流程, 在尝试restore checkpoint时, 出现以下错误
[src/monitor/monitor.c:125,parse_args] Restoring from checkpoint
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted (core dumped)
总共生成了6个checkpoint , 都是相同的错误
thx.
riscv64-xs-ref_defconfig
fw_jump.bin
如题,在上述条件下运行 NEMU 时出现了段错误,但关闭性能优化选项(Miscellaneous -> Performance optimization)则可正常运行。段错误截图如下
经过初步调试,发现下述代码中 s->tnext
和 s->ntnext
为空指针,引发段错误。
Lines 175 to 180 in 3da78d2
根据 s
中存储的信息,引发出错的指令是 fw_jump
中地址为 0x8000d4a4
的 EBREAK 指令。
When turning on Testing and Debugging
-> Enable debug features: instruction tracing and watchpoint
(macro CONFIG_DEBUG
), compiling NEMU will get a format-truncation
error:
开启 Testing and Debugging
-> Enable debug features: instruction tracing and watchpoint
(宏 CONFIG_DEBUG
)之后,编译 NEMU 会出现 format-truncation
报错:
include/common.h:34:39: error: ‘%s’ directive output may be truncated writing up to 79 bytes into a region of size 58 [-Werror=format-truncation=]
ln -sf resource/softfloat/repo/build/Linux-x86_64-GCC/softfloat.a resource/softfloat/build/softfloat.a
In file included from include/common.h:26,
from include/cpu/cpu.h:19,
from src/cpu/cpu-exec.c:18:
src/cpu/cpu-exec.c: In function ‘fetch_decode’:
include/common.h:34:39: error: ‘%s’ directive output may be truncated writing up to 79 bytes into a region of size 58 [-Werror=format-truncation=]
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~~~~~
include/macro.h:69:21: note: in definition of macro ‘__KEEP’
69 | #define __KEEP(...) __VA_ARGS__
| ^~~~~~~~~~~
src/cpu/cpu-exec.c:577:3: note: in expansion of macro ‘IFDEF’
577 | IFDEF(CONFIG_DEBUG,
| ^~~~~
include/macro.h:41:45: note: in expansion of macro ‘CHOOSE2nd’
41 | #define MUX_WITH_COMMA(contain_comma, a, b) CHOOSE2nd(contain_comma a, b)
| ^~~~~~~~~
include/macro.h:42:44: note: in expansion of macro ‘MUX_WITH_COMMA’
42 | #define MUX_MACRO_PROPERTY(p, macro, a, b) MUX_WITH_COMMA(concat(p, macro), a, b)
| ^~~~~~~~~~~~~~
include/macro.h:49:30: note: in expansion of macro ‘MUX_MACRO_PROPERTY’
49 | #define MUXDEF(macro, X, Y) MUX_MACRO_PROPERTY(__P_DEF_, macro, X, Y)
| ^~~~~~~~~~~~~~~~~~
include/common.h:34:18: note: in expansion of macro ‘MUXDEF’
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~
src/cpu/cpu-exec.c:578:48: note: in expansion of macro ‘FMT_WORD’
578 | snprintf(s->logbuf, sizeof(s->logbuf), FMT_WORD ": %s%*.s%s", s->pc,
| ^~~~~~~~
src/cpu/cpu-exec.c:578:62: note: format string is defined here
578 | snprintf(s->logbuf, sizeof(s->logbuf), FMT_WORD ": %s%*.s%s", s->pc,
| ^~
In file included from include/common.h:26,
from include/cpu/cpu.h:19,
from src/cpu/cpu-exec.c:18:
include/common.h:34:39: note: assuming directive output of 1 byte
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~~~~~
include/macro.h:69:21: note: in definition of macro ‘__KEEP’
69 | #define __KEEP(...) __VA_ARGS__
| ^~~~~~~~~~~
src/cpu/cpu-exec.c:577:3: note: in expansion of macro ‘IFDEF’
577 | IFDEF(CONFIG_DEBUG,
| ^~~~~
include/macro.h:41:45: note: in expansion of macro ‘CHOOSE2nd’
41 | #define MUX_WITH_COMMA(contain_comma, a, b) CHOOSE2nd(contain_comma a, b)
| ^~~~~~~~~
include/macro.h:42:44: note: in expansion of macro ‘MUX_WITH_COMMA’
42 | #define MUX_MACRO_PROPERTY(p, macro, a, b) MUX_WITH_COMMA(concat(p, macro), a, b)
| ^~~~~~~~~~~~~~
include/macro.h:49:30: note: in expansion of macro ‘MUX_MACRO_PROPERTY’
49 | #define MUXDEF(macro, X, Y) MUX_MACRO_PROPERTY(__P_DEF_, macro, X, Y)
| ^~~~~~~~~~~~~~~~~~
include/common.h:34:18: note: in expansion of macro ‘MUXDEF’
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~
src/cpu/cpu-exec.c:578:48: note: in expansion of macro ‘FMT_WORD’
578 | snprintf(s->logbuf, sizeof(s->logbuf), FMT_WORD ": %s%*.s%s", s->pc,
| ^~~~~~~~
In file included from /usr/include/stdio.h:867,
from include/debug.h:20,
from include/common.h:55,
from include/cpu/cpu.h:19,
from src/cpu/cpu-exec.c:18:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 23 and 2147483828 bytes into a destination of size 80
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
I think this warning is a misreport. This debug output may be truncated in theroy, not not in practice. I think add -Wno-format-truncation
to CFLAGS
and CXXFLAGS
in Makefile will solve this. I can't think of any unexpected results.
我认为这个警告是误报。这个调试输出理论上可能被截断,但实际并不会(实际上就算节段了也完全不影响)。在Makefile中的 CFLAGS
和 CXXFLAGS
中添加 -Wno-format-truncation
可以解决此问题。我想不出有什么出乎意料的结果。
请问NEMU有没有debug模式?怎么进入?
自行编译了riscv的coremark,使用的是https://github.com/riscv-boom/riscv-coremark
加入了nemu_signal,做了bbl.bin,NEMU做profiling时出现错误,Failed to execute /init (error -2),想问下该如何解决
详细输出:
Welcome to riscv64-NEMU!
For help, type "help"
bbl loader
freq-mhz = 500
CLINT: set frequency to 500 MHz
[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[ 0.000000] Linux version 4.18.0-14486-g655055af981b-dirty (root@73c87a4ba4b3) (gcc version 10.5.0 (Ubuntu 10.5.0-1ubuntu1~20.04)) #26 Wed Jan 17 16:26:46 CST 2024
[ 0.000000] bootconsole [early0] enabled
[ 0.000000] Initial ramdisk at: 0x(ptrval) (20480 bytes)
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 empty
[ 0.000000] Normal [mem 0x0000000080200000-0x0000000081ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000080200000-0x0000000081ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x0000000081ffffff]
[ 0.000000] Cannot allocate SWIOTLB buffer
[ 0.000000] elf_hwcap is 0x112d
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 7575
[ 0.000000] Kernel command line: root=/dev/mmcblk0 rootfstype=ext4 ro rootwait earlycon
[ 0.000000] Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.000000] Inode-cache hash table entries: 2048 (order: 2, 16384 bytes)
[ 0.000000] Sorting __ex_table...
[ 0.000000] Memory: 29100K/30720K available (713K kernel code, 76K rwdata, 102K rodata, 84K init, 98K bss, 1620K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
[ 0.000000] console [hvc0] enabled
[ 0.000000] console [hvc0] enabled
[ 0.000000] bootconsole [early0] disabled
[ 0.000000] bootconsole [early0] disabled
[ 0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=10000)
[ 0.010000] pid_max: default: 4096 minimum: 301
[ 0.010000] Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
[ 0.010000] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)
[ 0.030000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.030000] futex hash table entries: 16 (order: -4, 384 bytes)
[src/isa/riscv64/system/mmu.c:216,isa_mmu_check] addr misaligned happened: vaddr:ffffffff800c78b4 len:8 type:1 pc:ffffffff80015810
[ 0.050000] clocksource: Switched to clocksource riscv_clocksource
[ 0.050000] Unpacking initramfs...
[ 0.110000] workingset: timestamp_bits=62 max_order=13 bucket_order=0
[ 0.130000] random: get_random_bytes called from 0xffffffff80018cd0 with crng_init=0
[ 0.130000] Freeing unused kernel memory: 84K
[ 0.130000] This architecture does not have kernel memory protection.
[ 0.130000] Failed to execute /init (error -2)
[ 0.130000] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[ 0.130000] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
CI运行不起来了,没有log,一直卡在start,超时后显示This job failed。
CI can't run, there is no log, it is stuck in start, and This job failed is displayed after timeout.
在NEMU中设置断点,发现 NEMU可以识别到断点,但是没有停在断点上。
例如我在程序里,设置断点“w $pc == 0x80200008”
nemu) w $pc == 0x80200008
Set watchpoint #0
(nemu) c
Hint watchpoint 0 at address 0x0000000080200004, expr = $pc == 0x80200008
old value = 0x0000000000000000
new value = 0x0000000000000001
Hint watchpoint 0 at address 0x0000000080200008, expr = $pc == 0x80200008
old value = 0x0000000000000001
new value = 0x0000000000000000
Welcome RISC-V!
目前NEMU内部已经支持了一个SDB。不过如果支持gdbserver的话,会方便其他更多高校同学使用NEMU来基于香山处理器做一些其他课程的实验,比如OS课程等。
你好,近期编译NEMU simpoint分支时总是报如下错误:
g++ -O2 -MMD -Wall -Werror --std=c++17 -I/home/user/xs/xs-env/NEMU/src/isa/riscv64/include -I/home/user/xs/xs-env/NEMU/src/engine/interpreter -Iresource/softfloat/repo/source/include -Iresource/softfloat/repo/source/RISCV -Iresource/lz4/lib -Iresource/zstd/lib -Iresource/CRoaring/include -I/home/user/xs/xs-env/NEMU/include -I/home/user/xs/xs-env/NEMU/lib-include -I/home/user/xs/xs-env/NEMU/resource -O2 -MMD -Wall -Werror -I/home/user/xs/xs-env/NEMU/src/isa/riscv64/include -I/home/user/xs/xs-env/NEMU/src/engine/interpreter -Iresource/softfloat/repo/source/include -Iresource/softfloat/repo/source/RISCV -Iresource/lz4/lib -Iresource/zstd/lib -Iresource/CRoaring/include -I/home/user/xs/xs-env/NEMU/include -I/home/user/xs/xs-env/NEMU/lib-include -D__ISA__=riscv64 -I/usr/local/include -O2 -flto -D__ISA_riscv64__=1 -c -o /home/user/xs/xs-env/NEMU/build/obj-riscv64-nemu-interpreter/src/inst_trace/protoio.opp src/inst_trace/protoio.cpp
In file included from src/inst_trace/inst_dep_record.pb.cpp:4:
/home/user/xs/xs-env/NEMU/include/inst_trace/inst_dep_record.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^~~~~
/home/user/xs/xs-env/NEMU/include/inst_trace/inst_dep_record.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^~~~~
/home/user/xs/xs-env/NEMU/include/inst_trace/inst_dep_record.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.
^~~~~
In file included from src/inst_trace/packet.pb.cpp:4:
/home/user/xs/xs-env/NEMU/include/inst_trace/packet.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
看错误是protoc自动生成的头文件在做版本校验时报错,既然是protoc自动生成的文件是否将原.proto文件公布出来,然后在编译过程中自动生成更合适些?谢谢
如上图所示,为了修改NEMU支持的PA位宽,对配置做了改动,重新编译后,作为difftest运行coremark测试程序,会报错如下:
1 emu compiled at Dec 15 2023, 14:51:55
2 Using simulated 32768B flash
3 Using simulated 8192MB RAM
4 The image is /root/xs-env/nexus-am/apps/coremark/build-1/coremark-riscv64-xs.bin
5 DRAMsim3 memory system initialized.
6 sh: 1: spike-dasm: not found
7 The reference model is /root/xs-env-40bit/NEMU/build/riscv64-nemu-interpreter-so
8 The first instruction of core 0 has commited. Difftest enabled.
9 ^[[1;34m[src/cpu/cpu-exec.c:524,cpu_exec] Setting NEMU state to RUNNING^[[0m
10 ^[[1;34m[src/cpu/cpu-exec.c:530,cpu_exec] cpu_exec will exec 1 instrunctions^[[0m
11 ahead pc 0 3
12 ^[[1;34m[src/memory/vaddr.c:115,vaddr_read_internal] Checking mmu when MMU_DYN^[[0m
13 ^[[1;34m[src/isa/riscv64/system/mmu.c:448,isa_mmu_check] MMU checking addr 3^[[0m
14 ^[[1;34m[src/memory/vaddr.c:119,vaddr_read_internal] Paddr reading directly^[[0m
15 ^[[1;34m[src/cpu/cpu-exec.c:125,longjmp_exception] longjmp_exec(NEMU_EXEC_EXCEPTION)^[[0m
16 ^[[1;34m[src/cpu/cpu-exec.c:115,longjmp_exec] Longjmp to jbuf_exec with cause: 3^[[0m
17 ^[[1;34m[src/cpu/cpu-exec.c:538,cpu_exec] After update_global, n_remain: 1, n_remain_total: 1^[[0m
18 ^[[1;34m[src/cpu/cpu-exec.c:559,cpu_exec] Handle NEMU_EXEC_EXCEPTION^[[0m
19
20 ============== Commit Group Trace (Core 0) ==============
21 commit group [00]: pc 0010000000 cmtcnt 1 <--
22 commit group [01]: pc 0000000000 cmtcnt 0
23 commit group [02]: pc 0000000000 cmtcnt 0
24 commit group [03]: pc 0000000000 cmtcnt 0
25 commit group [04]: pc 0000000000 cmtcnt 0
26 commit group [05]: pc 0000000000 cmtcnt 0
27 commit group [06]: pc 0000000000 cmtcnt 0
28 commit group [07]: pc 0000000000 cmtcnt 0
29 commit group [08]: pc 0000000000 cmtcnt 0
30 commit group [09]: pc 0000000000 cmtcnt 0
31 commit group [10]: pc 0000000000 cmtcnt 0
32 commit group [11]: pc 0000000000 cmtcnt 0
33 commit group [12]: pc 0000000000 cmtcnt 0
34 commit group [13]: pc 0000000000 cmtcnt 0
35 commit group [14]: pc 0000000000 cmtcnt 0
36 commit group [15]: pc 0000000000 cmtcnt 0
37
38 ============== Commit Instr Trace ==============
39 [00] commit pc 0000000010000000 inst 0010029b wen 1 dst 05 data 0000000000000001 idx 000 <--
40
41 ============== REF Regs ==============
42 $0: 0x0000000000000000 ra: 0x0000000000000000 sp: 0x0000000000000000 gp: 0x0000000000000000
43 tp: 0x0000000000000000 t0: 0x0000000000000001 t1: 0x0000000000000000 t2: 0x0000000000000000
44 s0: 0x0000000000000000 s1: 0x0000000000000000 a0: 0x0000000000000000 a1: 0x0000000000000000
45 a2: 0x0000000000000000 a3: 0x0000000000000000 a4: 0x0000000000000000 a5: 0x0000000000000000
46 a6: 0x0000000000000000 a7: 0x0000000000000000 s2: 0x0000000000000000 s3: 0x0000000000000000
47 s4: 0x0000000000000000 s5: 0x0000000000000000 s6: 0x0000000000000000 s7: 0x0000000000000000
48 s8: 0x0000000000000000 s9: 0x0000000000000000 s10: 0x0000000000000000 s11: 0x0000000000000000
49 t3: 0x0000000000000000 t4: 0x0000000000000000 t5: 0x0000000000000000 t6: 0x0000000000000000
50 ft0: 0xd292d9c1d9f0a85d ft1: 0x71b4da9162860bf9 ft2: 0x705d7bc72fcbf47a ft3: 0xfb5f54db700f63b8
51 ft4: 0x61ffc1faee8fe7b9 ft5: 0xb1f743859942be6d ft6: 0xd1fbf8586773bbe0 ft7: 0x982868853d95d658
52 fs0: 0xbc5429020817345d fs1: 0xbf52d24e8904cb40 fa0: 0x931335f941606e04 fa1: 0x9b4643aee97c395c
53 fa2: 0xf21803e3c75b4761 fa3: 0x843f5f7d57607255 fa4: 0x108d48649281b2c1 fa5: 0x43ee9db117e6de42
54 fa6: 0x537b09b4dc1786f2 fa7: 0x554c539b6b4b3625 fs2: 0xc69353c52d83f9ec fs3: 0x27a84f22b196ba3c
55 fs4: 0xcc5003f646e3ed70 fs5: 0x786b3327a558a25c fs6: 0xe13ad054d430a32c fs7: 0xdfe550d1f0ff4982
56 fs8: 0x29880d5eed39b7b2 fs9: 0x66cd0c915a70ddfd fs10: 0x06968cb4c2bc8baa fs11: 0x2283798941415673
57 ft8: 0xd540e55e8876101f ft9: 0x54a7aba14ed01523 ft10: 0xabfde16b9884ba37 ft11: 0x20d96642aa49d086
58 pc: 0x0000000000000000 mstatus: 0x0000000a00002000 mcause: 0x0000000000000001 mepc: 0x0000000000000003
59 sstatus: 0x0000000200002000 scause: 0x0000000000000000 sepc: 0x45b2f58542bcc7a2
60 satp: 0x0000000000000000
61 mip: 0x0000000000000000 mie: 0x0000000000000000 mscratch: 0x0000000000000000 sscratch: 0x0000000000000000
62 mideleg: 0x0000000000000000 medeleg: 0x0000000000000000
63 mtval: 0x0000000000000003 stval: 0x0000000000000000 mtvec: 0x0000000000000000 stvec: 0x0000000000000000
64 privilege mode:3 pmp: below
65 0: cfg:0x00 addr:0x0000000000000000| 1: cfg:0x00 addr:0x0000000000000000
66 2: cfg:0x00 addr:0x0000000000000000| 3: cfg:0x00 addr:0x0000000000000000
67 4: cfg:0x00 addr:0x0000000000000000| 5: cfg:0x00 addr:0x0000000000000000
68 6: cfg:0x00 addr:0x0000000000000000| 7: cfg:0x00 addr:0x0000000000000000
69 8: cfg:0x00 addr:0x0000000000000000| 9: cfg:0x00 addr:0x0000000000000000
70 10: cfg:0x00 addr:0x0000000000000000|11: cfg:0x00 addr:0x0000000000000000
71 12: cfg:0x00 addr:0x0000000000000000|13: cfg:0x00 addr:0x0000000000000000
72 14: cfg:0x00 addr:0x0000000000000000|15: cfg:0x00 addr:0x0000000000000000
73 pmp csr rw: enable, pmp check: disable
74 priviledgeMode: 3
75 mode different at pc = 0x0010000000, right= 0x0000000000000000, wrong = 0x0000000000000003
76 sstatus different at pc = 0x0010000000, right= 0x0000000000000001, wrong = 0x0000000200002000
77 mepc different at pc = 0x0010000000, right= 0x0000000000000003, wrong = 0x4c097fabe24d5a72
78 sepc different at pc = 0x0010000000, right= 0x0000000200002000, wrong = 0x0000000000000000
79 mscratch different at pc = 0x0010000000, right= 0x0000000000000003, wrong = 0x0000000000000000
80 Core 0: ^[[31mABORT at pc = 0xffffffc1b07fbf13
81 ^[[0m^[[35minstrCnt = 1, cycleCnt = 2096, IPC = 0.000477
82 ^[[0m^[[34mSeed=0 Guest cycle spent: 2099 (this will be different from cycleCnt if emu loads a snapshot)
83 ^[[0m^[[34mHost time spent: 1602ms
84 ^[[0m
请问如何配置(或者改动)NEMU,使得PA位宽40生效?最终目的是为了搭配RTL启动difftest
按照 香山官方文档中,cpt-bk分支运行方法 ,执行了其中的profiling、cluster、checkpointing三条指令。
分别能够得到 simpoint_bbv、simpoints0 & weights0、xxxxx.gz切片文件。
当前问题是:
2.运行cpt-bk分支时,如何选择其中参数?比如指令间隔大小应该怎样选择,以100,000还是1,000,000为区间比较好?或者是依照程序总指令数,按照一定比例划分指令区间?还有maxK的大小应该怎么取?例如我在maxK的值分别取30和100,得到了分类(切片)数量分别为23与29,应该如何选择?
3.还有如下的三个阶段的指令中,除了 maxK和指令间隔,还有什么可以调节的参数?
#profile
riscv64-nemu-interpreter workload.bin -D /home/user/spec_cpt -w workloadName -C profiling -b --simpoint-profile --interval 100000000
#Cluster
simpoint -loadFVFile ../../simpoint_bbv.gz -saveSimpoints simpoints0 -saveSimpointWeights weights0 -inputVectorsGzipped -maxK 30 -numInitSeeds 2 -iters 1000 -seedkm 123456 -seedproj 654321
# Checkpointing
riscv64-nemu-interpreter workload.bin -D /home/user/spec_cpt -w workloadName -C take_cpt -b -S /home/user/spec_cpt/cluster --checkpoint-interval 100000000
4.想问一下香山执行checkpoint执行SPEC INT 2006 的 429.mcf,大概多长时间?想参考一下
以下为我执行的过程中具体切片数据大小:
我在运行的程序是SPEC INT 2006 的 429.mcf,三次不同指令间隔的运行结果如下:
指令间隔 100,000: bbv文件:140.33MB 切片数量:21 .gz切片:大多数是280-330MB,2个20+MB,剩余170-220MB
指令间隔 1,000,000: bbv文件:51.90MB 切片数量:26 .gz切片:大多数是280-330MB,1个29.57MB,
指令间隔 10,000,000: bbv文件:7.1MB 切片数量:14 .gz切片:大多数是280MB以上
*其中.gz切片中295.*MB的文件最多
根据文档https://xiangshan-doc.readthedocs.io/zh-cn/latest/tools/nemu/。
设置执行make riscv64-xs_defconfig后make -j。出现如下报错。请问该如何解决?
[TRANSLATION] According to the documentation at https://xiangshan-doc.readthedocs.io/zh-cn/latest/tools/nemu/.
After executing make riscv64-xs_defconfig
, I encountered the following error when running make -j
. How can this issue be resolved?"
nemu commit:626af2
os:centos linux 7.9
是缺少某些库吗?
[TRANSLATION] Is it due to the absence of certain libraries?
在NEMU上启动debian之后,执行NCNN推理程序时出现下面的问题
root@xiangshan-06:/root# ./squeezenet 000005.png
[src/isa/riscv64/system/mmu.c,209,isa_mmu_check] addr misaligned happened: vaddr:b6f23 len:8 type:1 pc:20000117d4
riscv64-nemu-interpreter: src/isa/riscv64/system/mmu.c:210: isa_mmu_check: Assertion `0' failed.
Aborted
按照指导书走流程,执行 make riscv64-xs-ref_deconfig && make -j
时出错,如下图:
在 softfloat 中编译选项(NEMU/resource/softfloat/repo/build/Linux-x86_64-GCC/Makefile 46:48)中添加 -fPIC
后,才能够正常链接和运行:
COMPILE_C = \
gcc -c -fPIC -Werror-implicit-function-declaration -DSOFTFLOAT_FAST_INT64 \
$(SOFTFLOAT_OPTS) $(C_INCLUDES) -O2 -o $@
此外,执行 make riscv64-xs_deconfig && make -j
是能够正常编译链接执行的
1.问题列表:
①jalr指令错误(地址最低有效位不会被置为0,不符合riscv规范,影响功能)
问题描述:jalr指令理论上运行的结果应为偶数,实际上NEMU无法将最低位的bit置为0。
报错信息:NEMU=0x00000000800015bb(error),理论应为0x00000000800015ba
该指令解析:跳转并寄存器链接(Jumpand LinkRegister).I-type, RV32IandRV64I.把pc设置为x[rs1]+sign-extend(offset),把计算出的地址的 最低有效位设为0 ,并将原pc+4的值写入f[rd]。rd默认为x1。(标粗部分出错)
(t=pc+4;pc=(x[rs1]+sext(offset))&[~1];x[rd]=t)
②ebreak&c.ebreak指令错误(显示为无效指令,影响功能)
问题描述:ebreak&c.ebreak在NEMU上运行输出为无效数:
Welcome to riscv64-NEMU!
For help, type "help"
invalid opcode(PC = 0x00000000800001de):
02 90 17 5c 00 00 13 0c ...
5c179002 0c130000...
③部分原子指令计算结果异常(有符号数比较大小时NEMU不会区分符号位)
问题描述:amomin.w t6,t2,(s6)
M[s6]中取出的值为:0x00000000 0000005b
t2的值为: 0x00000000 f610b92a
二进制补码比较取最小值(M[s6]):NEMU:0x0000005b(错误,正确应为0xf610b92a)
2.目前需要解答:
①请问有没有哪个版本已经修复了这三个bug,目前试运行了2022.03.31和2022.05.01两个版本的master分支,均存在此类问题;
②如果自己修改代码的话,需要看哪部分代码,请指教;
③另外请问您是否有关于NEMU比较详细一些的解读文档,可不可以分享一下;
在(https://xiangshan-doc.readthedocs.io/zh_CN/latest/tools/simpoint/) 文档中,默认流程是构建一个linux内核并在linux中运行benchmark,再打包成bbl.bin让NEMU运行。目前我想要直接让NEMU运行bin文件,例如简单的hello world,请问是可行的吗?
Hi,
可否更新一下NEMU的README.md,罗列一下当前NEMU在RV32和RV64上所支持的指令列表?这样一目了然。
谢谢~
目前NEMU不支持PMP,运行支持PMP的程序,NEMU会crash。
Welcome to riscv64-NEMU!
For help, type "help"
___ ___
// ) ) // ) ) // ) ) / /
//___/ / ___ __ (( //___/ / / /
/ __ ( //___) ) // ) ) \ / __ ( / /
// ) ) // // / / ) ) // ) ) / /
//____/ / ((____ // / / ((___ / / //____/ / __/ /___
sbi_set_pmp: start: 0x0 order 64 prot 0x7
sbi_set_pmp: pmpaddr: 0xffffffffffffffff pmpcfg 0x1f, cfs_csr 0x3a0 addr_csr 0x3b0
sbi_trap_error: trap handler failed (error -5)
mcause: 0000000000000002 mtval: 0000000000000000
mepc: 0000000080000cdc mstatus : 0000000a00001800
gp : 0000000000000000 tp : 0000000080000208 t0 : 0000000000001000
t1 : 0000000000000000 t2 : 0000000000000000 t3 : 0000000080003f60
s1 : 0000000000000000 a0 : 00000000000003b0 a1 : ffffffffffffffff
a2 : ffffffffffffffff a3 : 0000000000000010 a4 : ffffffffffffe9c8
a5 : ffffffffffffffff a6 : 0000000000000000 a7 : 0000000000000000
s2 : 0000000000000000 s3 : 0000000000000000 s4 : 0000000000000000
s5 : 0000000000000000 s6 : 0000000000000000 s7 : 0000000000000000
s8 : 0000000000000000 s9 : 0000000000000000 s10: 0000000000000000
s11: 0000000000000000 t3 : 0000000000000000 t4: 0000000000000000
t5 : 0000000000000000 t6 : 0000000000000000 sp: 0000000080003ef0
ra: 0000000080000218
sbi panic
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.