From 4245475514544c8d017883f42aac2df6c7bfa3c6 Mon Sep 17 00:00:00 2001 From: lazymio Date: Tue, 13 Feb 2024 16:21:53 +0800 Subject: [PATCH] Detect if we have valid pthread_jit_write_protect_np --- qemu/configure | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/qemu/configure b/qemu/configure index 80080d0d..c17c2cf0 100755 --- a/qemu/configure +++ b/qemu/configure @@ -2139,13 +2139,40 @@ fi if [ "$darwin" = "yes" ] ; then cat > $TMPC << EOF #include -int main() { pthread_jit_write_protect_np(0); return 0; } +int main() { pthread_jit_write_protect_np(0); return 0;} EOF if ! compile_prog ""; then have_pthread_jit_protect='no' else have_pthread_jit_protect='yes' fi + + if test "$have_pthread_jit_protect" = "yes" ; then + cat > $TMPC << EOF +#include "stdint.h" +int main() { + uint64_t commpage_sprr = (*(uint64_t*)0xFFFFFC10C); + + // In Apple Hypervisor, this value is not accessbile and + // pthread_jit_write_protect_np essentially is a no-op + if (!commpage_sprr) { + return 1; + } else { + return 0; + } +} +EOF + if ! compile_prog ""; then + have_pthread_jit_protect='no' + else + $TMPE + if [ $? -eq 0 ]; then + have_pthread_jit_protect='yes' + else + have_pthread_jit_protect='no' + fi + fi + fi fi ##########################################