首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行` mprotect‘got错误:`qemu_mprotect__osdep: mprotect:许可拒绝

运行` mprotect‘got错误:`qemu_mprotect__osdep: mprotect:许可拒绝
EN

Stack Overflow用户
提问于 2021-04-11 02:16:47
回答 3查看 845关注 0票数 2

我正在尝试在mac m1上做mit6.828实验室。安装riscv-tool-chain后,我尝试运行make qemu,这似乎是用来启动内核的,但一开始我得到了以下错误:

代码语言:javascript
复制
mkfs/mkfs fs.img README user/xargstest.sh user/_cat user/_echo user/_forktest user/_grep user/_init user/_kill user/_ln user/_ls user/_mkdir user/_rm user/_sh user/_stressfs user/_usertests user/_wc user/_zombie user/_cowtest user/_uthread user/_call user/_testsh user/_kalloctest user/_bcachetest user/_alloctest user/_bigfile
nmeta 46 (boot, super, log blocks 30 inode blocks 13, bitmap blocks 1) blocks 1954 total 2000
balloc: first 766 blocks have been allocated
balloc: write bitmap block at sector 45
qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 1 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
Could not allocate dynamic translator buffer
make: *** [qemu] Error 1

因此,我从github克隆qemu reposiroty以获得源代码,并检查版本到v5.1.0,然后从这个链接路径应用链接中提到的修补程序

配置run如下所示:

代码语言:javascript
复制
 ./configure --disable-kvm --disable-werror --prefix=/usr/local --target-list="riscv64-softmmu"`

makemake install似乎运行良好,但是当我再次在实验室执行make qemu时,出现了另一个错误,我仍然没有找到解决这个问题的方法:

代码语言:javascript
复制
qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 3 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied
**
ERROR:/Users/rezero/Desktop/6.828-note/qemus/qemu-5.1.0/tcg/tcg.c:733:tcg_region_init: assertion failed: (!rc)
Bail out! ERROR:/Users/rezero/Desktop/6.828-note/qemus/qemu-5.1.0/tcg/tcg.c:733:tcg_region_init: assertion failed: (!rc)
make: *** [qemu] Abort trap: 6
EN

回答 3

Stack Overflow用户

发布于 2021-04-11 16:13:31

我试了很多次,因为我不熟悉qemu和macos。现在我得到了:

代码语言:javascript
复制
# modify /etc/paths 
/usr/bin
/bin
/usr/local/bin
/usr/sbin
/sbin

# modify .zshrc
export PATH="/opt/homebrew/bin:$PATH"
export PATH="$HOME/bin:/usr/local/bin:$PATH"
export PATH="$PATH:/usr/local/opt/riscv-gnu-toolchain/bin"

仍然不知道发生了什么,但事情似乎工作后,我应用了以下两个补丁。(确保在迭代时关闭Rosetta模式,仍然使用qemu 5.1.0)

patch1,您只需将cd下载到qemu目录中,然后命令如下:patch -p1 < ../patch/v2-tcg-Fix-execution-on-Apple-Silicon.patch

patch2只需两行,只需打开osdep.c文件并修改它。

应用上述修补程序之后,运行configure:

./configure --disable-kvm --disable-werror --prefix=/usr/local --target-list="riscv64-softmmu"

make & make install

然后它起作用了,内核可以开始了。

票数 1
EN

Stack Overflow用户

发布于 2021-05-03 16:34:29

@Rezero遵循您的步骤,您在编译时是否遇到过这样的错误:

代码语言:javascript
复制
 CC      hw/display/virtio-gpu-3d.o
hw/display/virtio-gpu-3d.c:149:41: error: variable has incomplete type 'struct virgl_renderer_resource_info'
    struct virgl_renderer_resource_info info;
                                        ^
hw/display/virtio-gpu-3d.c:149:12: note: forward declaration of 'struct virgl_renderer_resource_info'
    struct virgl_renderer_resource_info info;
           ^
hw/display/virtio-gpu-3d.c:167:15: error: implicit declaration of function 'virgl_renderer_resource_get_info' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
票数 0
EN

Stack Overflow用户

发布于 2022-09-11 05:16:03

它是macOS 11.2 mprotect bug,您可以修改qemu/tcg/tcg.c修复它,查看https://gitlab.com/qemu-project/qemu/-/commit/c118881ee607dcac

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67040879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档