如何解决qemu-system-mipsel运行5.4内核时内存区域重叠错误?
问题描述
想要在qemu-system-mipsel上运行通过firmadyne从固件提取的MIPSEL架构Linux根文件系统,使用firmadyne自带的2.6.39.4+版本vmlinux.elf启动正常,但换成OpenWrt ImageBuilder提供或自行编译的5.4版本vmlinux.elf时,出现内存地址空间重叠错误:
The following two regions overlap (in the memory address space):
vmlinux-5.4.111.mipsel ELF program header segment 0 (addresses 0x0000000000001000 - 0x000000000084b910)
prom (addresses 0x0000000000002000 - 0x0000000000003040)
当前使用的启动脚本:
qemu-system-mipsel -M malta -kernel vmlinuz.elf \ -drive if=ide,format=raw,file=squashfs-factory.raw \ -append "root=/dev/sda1 console=ttyS0 nandsim.parts=64,64,64,64,64,64,64,64,64,64 \ rdinit=/firmadyne/preInit.sh rw debug ignore_loglevel print-fatal-signals=1 user_debug=31 firmadyn" \ -nographic
解决方法
1. 调整内核编译的物理加载地址
MIPS 5.4内核默认加载地址0x00001000会和QEMU Malta平台的PROM区域冲突,修改内核编译配置避开该区域:
- 打开内核配置界面,找到
CONFIG_PHYSICAL_START选项,将值改为0x00010000或更高(比如0x00200000) - 重新编译内核,用新生成的
vmlinux.elf启动
2. 修改QEMU的PROM加载地址
通过QEMU参数强制调整PROM的内存区域,避免与内核重叠:
在启动脚本中添加-prom-env "resetvec=0x00010000"参数,示例:
qemu-system-mipsel -M malta -kernel vmlinux-5.4.111.mipsel \ -drive if=ide,format=raw,file=squashfs-factory.raw \ -append "root=/dev/sda1 console=ttyS0 nandsim.parts=64,64,64,64,64,64,64,64,64,64 \ rdinit=/firmadyne/preInit.sh rw debug ignore_loglevel print-fatal-signals=1 user_debug=31 firmadyn" \ -prom-env "resetvec=0x00010000" \ -nographic
3. 将内核转换为uImage格式
uImage会自动处理加载地址,规避PROM冲突,用mkimage工具转换:
mkimage -A mips -O linux -T kernel -C none -a 0x00200000 -e 0x00200000 -n "Linux 5.4.111" -d vmlinux-5.4.111.mipsel uImage
修改启动脚本,替换-kernel vmlinuz.elf为-kernel uImage
4. 检查内核配置的相关选项
确保内核配置中没有触发冲突的设置:
- 关闭
CONFIG_SYS_SUPPORTS_ZBOOT选项(如果启用的话) - 确认
CONFIG_BOOT_LOAD地址未与PROM区域(0x00002000-0x00003040)重叠
内容的提问来源于stack exchange,提问作者Dario B.
相关产品推荐
相关产品推荐

