* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
2021-02-06 7:04 [Bug 1914849] [NEW] mprotect fails after MacOS 11.2 on arm mac Toshifumi NISHINAGA
@ 2021-02-06 23:44 ` Roman Bolshakov
2021-02-07 2:17 ` hikalium
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Roman Bolshakov @ 2021-02-06 23:44 UTC (permalink / raw)
To: qemu-devel
Thanks for submitting the ticket.
I've just stumbled upon it after updating to 11.2.
The question was already asked on apple developer forums:
https://developer.apple.com/forums/thread/672804
And there's a thread going on with regard to broken nodejs on 11.2:
https://github.com/nodejs/node/issues/37061#issuecomment-774175983
** Bug watch added: github.com/nodejs/node/issues #37061
https://github.com/nodejs/node/issues/37061
** Tags added: macos tcg
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
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
2021-02-08 18:08 ` Roman Bolshakov
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: hikalium @ 2021-02-07 2:17 UTC (permalink / raw)
To: qemu-devel
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
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
@ 2021-02-08 18:08 ` Roman Bolshakov
2021-02-08 22:36 ` no-reply
2021-02-21 18:54 ` Stefan Weil
` (3 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Roman Bolshakov @ 2021-02-08 18:08 UTC (permalink / raw)
To: qemu-devel
The patch can be used as a workaround for now:
diff --git a/util/osdep.c b/util/osdep.c
index 66d01b9160..76be8c295b 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -110,6 +110,9 @@ int qemu_mprotect_none(void *addr, size_t size)
{
#ifdef _WIN32
return qemu_mprotect__osdep(addr, size, PAGE_NOACCESS);
+#elif defined(__APPLE__) && defined(__arm64__)
+ /* Workaround mprotect (RWX->NONE) issue on Big Sur 11.2 */
+ return 0;
#else
return qemu_mprotect__osdep(addr, size, PROT_NONE);
#endif
--
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
2021-02-08 18:08 ` Roman Bolshakov
@ 2021-02-08 22:36 ` no-reply
0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2021-02-08 22:36 UTC (permalink / raw)
To: 1914849; +Cc: qemu-devel
Patchew URL: https://patchew.org/QEMU/161280769492.2878.8851519112088854609.malone@chaenomeles.canonical.com/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 161280769492.2878.8851519112088854609.malone@chaenomeles.canonical.com
Subject: [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/161280769492.2878.8851519112088854609.malone@chaenomeles.canonical.com -> patchew/161280769492.2878.8851519112088854609.malone@chaenomeles.canonical.com
- [tag update] patchew/20210129005845.416272-1-wuhaotsh@google.com -> patchew/20210129005845.416272-1-wuhaotsh@google.com
- [tag update] patchew/20210208024625.271018-1-richard.henderson@linaro.org -> patchew/20210208024625.271018-1-richard.henderson@linaro.org
- [tag update] patchew/20210208163339.1159514-1-berrange@redhat.com -> patchew/20210208163339.1159514-1-berrange@redhat.com
Switched to a new branch 'test'
f2c73d0 mprotect fails after MacOS 11.2 on arm mac
=== OUTPUT BEGIN ===
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 9 lines checked
Commit f2c73d03916c (mprotect fails after MacOS 11.2 on arm mac) has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/161280769492.2878.8851519112088854609.malone@chaenomeles.canonical.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
2021-02-06 7:04 [Bug 1914849] [NEW] mprotect fails after MacOS 11.2 on arm mac Toshifumi NISHINAGA
` (2 preceding siblings ...)
2021-02-08 18:08 ` Roman Bolshakov
@ 2021-02-21 18:54 ` Stefan Weil
2021-02-21 19:30 ` Stefan Weil
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2021-02-21 18:54 UTC (permalink / raw)
To: qemu-devel
** Changed in: qemu
Status: New => Confirmed
--
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:
Confirmed
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
2021-02-06 7:04 [Bug 1914849] [NEW] mprotect fails after MacOS 11.2 on arm mac Toshifumi NISHINAGA
` (3 preceding siblings ...)
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
6 siblings, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2021-02-21 19:30 UTC (permalink / raw)
To: qemu-devel
It works for me when I use "./configure --enable-debug-tcg --extra-
cflags=-I/opt/homebrew/include".
--
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:
Confirmed
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
2021-02-06 7:04 [Bug 1914849] [NEW] mprotect fails after MacOS 11.2 on arm mac Toshifumi NISHINAGA
` (4 preceding siblings ...)
2021-02-21 19:30 ` Stefan Weil
@ 2021-04-14 14:07 ` Roman Bolshakov
2021-04-30 8:14 ` Thomas Huth
6 siblings, 0 replies; 9+ messages in thread
From: Roman Bolshakov @ 2021-04-14 14:07 UTC (permalink / raw)
To: qemu-devel
** Changed in: qemu
Status: Confirmed => Fix Committed
--
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:
Fix Committed
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug 1914849] Re: mprotect fails after MacOS 11.2 on arm mac
2021-02-06 7:04 [Bug 1914849] [NEW] mprotect fails after MacOS 11.2 on arm mac Toshifumi NISHINAGA
` (5 preceding siblings ...)
2021-04-14 14:07 ` Roman Bolshakov
@ 2021-04-30 8:14 ` Thomas Huth
6 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2021-04-30 8:14 UTC (permalink / raw)
To: qemu-devel
Fixed here:
https://gitlab.com/qemu-project/qemu/-/commit/c118881ee607dcac
** Changed in: qemu
Status: Fix Committed => Fix Released
--
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:
Fix Released
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
^ permalink raw reply [flat|nested] 9+ messages in thread