qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] util/osdep: Avoid mprotect() RWX->NONE on Big Sur 11.2
@ 2021-02-10 10:55 Roman Bolshakov
  2021-03-08  6:47 ` Joelle van Dyne
  2021-03-09 14:03 ` Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Roman Bolshakov @ 2021-02-10 10:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Roman Bolshakov

There's a change in mprotect() behaviour [1] in the latest macOS on M1
and it's not yet clear if it's going to be fixed by Apple. For now we
can avoid unsupported mprotect() calls. QEMU and qtests work fine
without it.

1. https://gist.github.com/hikalium/75ae822466ee4da13cbbe486498a191f

Buglink: https://bugs.launchpad.net/qemu/+bug/1914849
Apple-Feedback: FB8994773
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
 util/osdep.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/util/osdep.c b/util/osdep.c
index 66d01b9160..1edd7b1caf 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -111,6 +111,12 @@ int qemu_mprotect_none(void *addr, size_t size)
 #ifdef _WIN32
     return qemu_mprotect__osdep(addr, size, PAGE_NOACCESS);
 #else
+# if defined(__APPLE__) && defined(__arm64__)
+    if (__builtin_available(macOS 11.2, *)) {
+        /* mprotect() in macOS 11.2 can't switch RWX to NONE */
+        return 0;
+    }
+# endif
     return qemu_mprotect__osdep(addr, size, PROT_NONE);
 #endif
 }
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-09 19:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 10:55 [PATCH] util/osdep: Avoid mprotect() RWX->NONE on Big Sur 11.2 Roman Bolshakov
2021-03-08  6:47 ` Joelle van Dyne
2021-03-09 13:31   ` Roman Bolshakov
2021-03-09 18:06     ` Joelle van Dyne
2021-03-09 14:03 ` Richard Henderson

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).