Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEMU做profiling时出现错误,Failed to execute /init (error -2) #252

Closed
DimanChauncey opened this issue Jan 17, 2024 · 16 comments
Closed
Assignees
Labels
Not NEMU issue This is not an NEMU related issue

Comments

@DimanChauncey
Copy link

DimanChauncey commented Jan 17, 2024

自行编译了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. ]---

@cebarobot
Copy link
Member

这是您 linux kernel 的 initramfs 的配置问题而非 NEMU 的问题。请检查是否在 initramfs 中配置了 /init 文件或软链接。

@DimanChauncey
Copy link
Author

我设置了,file /init ${RISCV_ROOTFS_HOME}/rootfsimg/coremark 755 0 0

@cebarobot
Copy link
Member

那请您检查 coremark 是否正确编译,文件是否完整,环境变量 ${RISCV_ROOTFS_HOME} 有没有正确设置。

@DimanChauncey
Copy link
Author

官方的coremark需要做什么修改,才能在nemu上进行profiling然后打checkpoint么?

@shinezyy
Copy link
Contributor

shinezyy commented Jan 23, 2024

这个问题分为两部分:

  1. 官方的coremark需要做什么修改,才能在nemu上运行?
  2. 官方的coremark需要做什么修改,才能在nemu上进行profiling然后打checkpoint?

这里的报错和profiling没关系。

建议提问者先不考虑profiling的事情,先把coremark跑起来。

@DimanChauncey
Copy link
Author

感谢回答,是这样的,我用qemu运行了同样的coremark程序,是可以run起来的。以下是这个编译好的程序的链接:https://drive.google.com/file/d/1RmAHQePZSP9OCWp_uJZNRO551Vu8JLxD/view?usp=sharing

按照教程制作成bbl.bin以后,NEMU profiling报错是/init返回-2,同样的制作bbl流程,hello程序和用的另一个benchmark可以正常运行。bbl.bin文件是以下链接:https://drive.google.com/file/d/1RbbMMifxAnIoeN9RyjzjCNagPCb-SjF4/view?usp=sharing

riscv-linux/riscv-pk的使用都和教程一样,coremark使用的工具链是riscv64-unknown-linux-gnu,pk使用的工具链是riscv64-unknown-elf,打包之前也执行了make clean.

riscv-rootfs的initramfs-emu.txt文件如下所示:
dir /dev 755 0 0
nod /dev/console 644 0 0 c 5 1
nod /dev/null 644 0 0 c 1 3
file /init ${RISCV_ROOTFS_HOME}/rootfsimg/coremark 755 0 0

其中coremark软链接了以上提到的google drive链接中程序coremark.riscv。

@shinezyy
Copy link
Contributor

请提供一下NEMU的分支、commit hash id和编译时用的config文件

@DimanChauncey
Copy link
Author

NEMU: tracing分支 5429318

NEMU: 编译时的命令是:make riscv64-xs-simpoint_defconfig,这个文件我没有更改,是该hash id的源文件

NEMU profiling命令:$NEMU_HOME/build/riscv64-nemu-interpreter $RISCV_PK_HOME/build/bbl.bin -D /home/test -w coremark -C profiling -b --simpoint-profile --cpt-interval 100000-r $NEMU_HOME/resource/gcpt_restore/build/gcpt.bin

@shinezyy
Copy link
Contributor

NEMU: tracing分支 5429318

NEMU: 编译时的命令是:make riscv64-xs-simpoint_defconfig,这个文件我没有更改,是该hash id的源文件

NEMU profiling命令:$NEMU_HOME/build/riscv64-nemu-interpreter $RISCV_PK_HOME/build/bbl.bin -D /home/test -w coremark -C profiling -b --simpoint-profile --cpt-interval 100000-r $NEMU_HOME/resource/gcpt_restore/build/gcpt.bin

可以用master分支试一试

@DimanChauncey
Copy link
Author

还是同样的问题,运行如下:

[src/monitor/monitor.c:181,parse_args] Doing Simpoint Profiling
[src/checkpoint/path_manager.cpp:54,init] Cpt id: -1
[src/checkpoint/path_manager.cpp:72,setSimpointProfilingOutputDir] Created /home/zxk/nemu_result/profiling/coremark/

[src/checkpoint/simpoint.cpp:83,init] Doing simpoint profiling with interval 100000
[src/checkpoint/serializer.cpp:300,next_index] set next index 0
[src/checkpoint/path_manager.cpp:91,setCheckpointingOutputDir] donot set checkpoint path without Checkpoint mode
[src/isa/riscv64/init.c:135,init_isa] NEMU will start from pc 0x80000000
[src/monitor/monitor.c:337,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:74,load_img] Loading Gcpt restorer form cmdline: /root/NEMU/resource/gcpt_restore/build/gcpt.bin

[src/monitor/image_loader.c:99,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:119,load_img] Read 3840 bytes from file /root/NEMU/resource/gcpt_restore/build/gcpt.bin to 0x80000000
[src/monitor/image_loader.c:74,load_img] Loading image (bbl/bare metal app) from cmdline: /root/riscv-pk/build/bbl.bin

[src/monitor/image_loader.c:119,load_img] Read 2580068 bytes from file /root/riscv-pk/build/bbl.bin to 0x800a0000
[src/device/io/port-io.c:30,add_pio_map] Add port-io map 'uartlite' at [0x00000000000003f8, 0x0000000000000404]
[src/device/io/port-io.c:30,add_pio_map] Add port-io map 'rtc' at [0x0000000000000048, 0x000000000000004f]
[src/device/io/port-io.c:30,add_pio_map] Add port-io map 'screen' at [0x0000000000000100, 0x0000000000000107]
[src/device/io/port-io.c:30,add_pio_map] Add port-io map 'keyboard' at [0x0000000000000060, 0x0000000000000063]
[src/device/sdcard.c:137,init_sdcard] Can not find sdcard image:
[src/monitor/monitor.c:52,welcome] Debug: OFF
[src/monitor/monitor.c:57,welcome] Build time: 21:11:32, Jan 24 2024
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)) #56 Wed Jan 24 20:10:06 CST 2024
[ 0.000000] bootconsole [early0] enabled
[ 0.000000] Initial ramdisk at: 0x(ptrval) (54784 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: 29068K/30720K available (713K kernel code, 76K rwdata, 102K rodata, 116K init, 98K bss, 1652K 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.000000] pid_max: default: 4096 minimum: 301
[ 0.000000] Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
[ 0.000000] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)
[ 0.020000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.020000] futex hash table entries: 16 (order: -4, 384 bytes)
[ 0.040000] clocksource: Switched to clocksource riscv_clocksource
[ 0.040000] Unpacking initramfs...
[ 0.140000] workingset: timestamp_bits=62 max_order=13 bucket_order=0
[ 0.170000] random: get_random_bytes called from 0xffffffff80020cd0 with crng_init=0
[ 0.170000] Freeing unused kernel memory: 116K
[ 0.170000] This architecture does not have kernel memory protection.
[ 0.170000] Failed to execute /init (error -2)
[ 0.170000] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[ 0.170000] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---

@xyyy1420
Copy link
Contributor

xyyy1420 commented Jan 25, 2024

riscv-software-src/riscv-pk@4ae5a88 可以给pk添加这个commit之后再发一份bbl.bin嘛?
此外还需要pk,kernel还有coremark的反汇编文件

@DimanChauncey
Copy link
Author

DimanChauncey commented Jan 25, 2024

按照您提供的commit,加了代码以后,做成的bbl.bin、pk、vmlinux、coremark.riscv以及对应的反汇编文件(.txt后缀)放在这个链接了:https://drive.google.com/file/d/1vXnUemh-DyXHXtpKULmTudsBeGaFKpta/view?usp=sharing

其中coremark和vmlinux采用riscv64-linux-gnu-编译而成,pk采用riscv64-unknown-elf-编译而成。
非常感谢各位!

@xyyy1420
Copy link
Contributor

xyyy1420 commented Jan 25, 2024

在qemu中使用参数qemu-system-riscv64 -machine nemu -nographic -m 8G -smp1 -bios bbl.bin -cpu rv64,v=false,h=false运行得到了一样和NEMU一样的结果,基本可以排除NEMU实现上的问题;

后续建议参考rootfsimg目录下的文件,链接init为busybox,这样就可以在启动后执行脚本来检查自己打包的rootfs是否有问题,而且由于打包完的bbl.bin是个黑盒,我们很难确定打包的内容是否存在问题,这个只能您来确认;

如果成功执行了,但是还有profiling或者checkpoint的问题,可以在这个issue中继续沟通。

截图参考下文,另外运行的是gcptl.bin是我打包了gcpt.bin和bbl.bin,和NEMU的实际执行是一致的。

image

@xiaokamikami
Copy link
Contributor

Dingtalk_20240125154951

使用nemu(master分支)与spike做difftest,运行到Kernel panic后内部程序卡死,没有触发difftest报错,应该不是nemu的问题,建议检查一下Kernel 编译选项是否设置正确了嘛

@DimanChauncey
Copy link
Author

Dingtalk_20240125154951

使用nemu(master分支)与spike做difftest,运行到Kernel panic后内部程序卡死,没有触发difftest报错,应该不是nemu的问题,建议检查一下Kernel 编译选项是否设置正确了嘛

我怀疑是linux kernel或者pk的问题,但是kernel编译使用的是默认的方式,如下所示,文件没有改动过,按同样的方式,另外一个负载是成功运行的。
image

@shinezyy
Copy link
Contributor

Dingtalk_20240125154951
使用nemu(master分支)与spike做difftest,运行到Kernel panic后内部程序卡死,没有触发difftest报错,应该不是nemu的问题,建议检查一下Kernel 编译选项是否设置正确了嘛

我怀疑是linux kernel或者pk的问题,但是kernel编译使用的是默认的方式,如下所示,文件没有改动过,按同样的方式,另外一个负载是成功运行的。 image

Not NEMU issue

@shinezyy shinezyy added the Not NEMU issue This is not an NEMU related issue label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not NEMU issue This is not an NEMU related issue
Projects
None yet
Development

No branches or pull requests

5 participants