From: hikalium <1914849@bugs.launchpad.net>
To: qemu-devel@nongnu.org
Subject: [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
Date: Sun, 07 Feb 2021 02:17:15 -0000 [thread overview]
Message-ID: <161266423509.2846.13019124961581445864.malone@gac.canonical.com> (raw)
In-Reply-To: 161259505296.24527.7729976640303273029.malonedeb@wampee.canonical.com
I hit the same problem and did some initial investigation with
Toshifumi.
Here is a more exhaustive test program I wrote based on the post on the
Apple Developer Forums and the result shows that very interesting
behavior of mmap and mprotect since macOS 11.2.
https://gist.github.com/hikalium/75ae822466ee4da13cbbe486498a191f
I and my friend confirmed that all mmap & following mprotect calls with
any protection bit combinations are succeeded up to 11.1 on M1 Mac but
starting from 11.2 mprotect starts failing if we call mmap with
PROT_WRITE + PROT_EXEC. (Surprisingly, mmap itself is not failing even
on those patterns.)
It looks like the allocation of code gen buffer in QEMU uses this combination at mmap call:
https://github.com/qemu/qemu/blob/master/accel/tcg/translate-all.c#L1294
So maybe we need to specify PROT_NONE instead on the initial mmap and
change it appropriately afterwards to make it working on M1 Mac after
11.2.
(We tried to fix it but we have no sufficient knowledge about tcg...
Could you take a look into it?)
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914849
Title:
mprotect fails after MacOS 11.2 on arm mac
Status in QEMU:
New
Bug description:
I got the following error when I ran qemu on arm mac(MacOS 11.2).
```
$ ./qemu-system-x86_64
qemu-system-x86_64: qemu_mprotect__osdep: mprotect failed: Permission denied
**
ERROR:../tcg/tcg.c:844:tcg_region_init: assertion failed: (!rc)
Bail out! ERROR:../tcg/tcg.c:844:tcg_region_init: assertion failed: (!rc)
[1] 34898 abort ./qemu-system-x86_64
```
I tested the same version of qemu on intel mac(MacOS 11.2), but it
works fine.
And my friend told me that they did not have this error with MacOS
11.1.
So, I think it is CPU architecture or an OS version dependent error.
Environment:
Qemu commit id: d0dddab40e472ba62b5f43f11cc7dba085dabe71
OS: MacOS 11.2(20D64)
Hardware: MacBook Air (M1, 2020)
How to build:
```
mkdir build/
cd build/
../configure --target-list=aarch64-softmmu,x86_64-softmmu
make
```
How to reproduce:
```
./qemu-system-x86_64
```
Error message:
```
$ ./qemu-system-x86_64
qemu-system-x86_64: qemu_mprotect__osdep: mprotect failed: Permission denied
**
ERROR:../tcg/tcg.c:844:tcg_region_init: assertion failed: (!rc)
Bail out! ERROR:../tcg/tcg.c:844:tcg_region_init: assertion failed: (!rc)
[1] 34898 abort ./qemu-system-x86_64
```
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914849/+subscriptions
next prev parent reply other threads:[~2021-02-07 2:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-06 7:04 [Bug 1914849] [NEW] mprotect fails after MacOS 11.2 on arm mac Toshifumi NISHINAGA
2021-02-06 23:44 ` [Bug 1914849] " Roman Bolshakov
2021-02-07 2:17 ` hikalium [this message]
2021-02-08 18:08 ` Roman Bolshakov
2021-02-08 22:36 ` no-reply
2021-02-21 18:54 ` Stefan Weil
2021-02-21 19:30 ` Stefan Weil
2021-04-14 14:07 ` Roman Bolshakov
2021-04-30 8:14 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=161266423509.2846.13019124961581445864.malone@gac.canonical.com \
--to=1914849@bugs.launchpad.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).