From 71c729a9d7059aac6d2bf0e4f21a9cded62af6a3 Mon Sep 17 00:00:00 2001 From: lazymio Date: Tue, 13 Feb 2024 19:09:35 +0800 Subject: [PATCH] Define HAVE_SPRR --- qemu/accel/tcg/translate-all.c | 2 +- qemu/configure | 9 +++++++-- qemu/include/tcg/tcg-apple-jit.h | 2 +- uc.c | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c index 4ec6c0332d..b4977054f3 100644 --- a/qemu/accel/tcg/translate-all.c +++ b/qemu/accel/tcg/translate-all.c @@ -2171,7 +2171,7 @@ void tcg_flush_softmmu_tlb(struct uc_struct *uc) } -#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && (defined(__arm__) || defined(__aarch64__)) +#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && defined(HAVE_SPRR) && (defined(__arm__) || defined(__aarch64__)) static bool tb_exec_is_locked(struct uc_struct *uc) { return uc->current_executable; diff --git a/qemu/configure b/qemu/configure index c17c2cf086..11f8b0f5ae 100755 --- a/qemu/configure +++ b/qemu/configure @@ -2163,13 +2163,14 @@ int main() { } EOF if ! compile_prog ""; then + have_sprr='no' have_pthread_jit_protect='no' else $TMPE if [ $? -eq 0 ]; then - have_pthread_jit_protect='yes' + have_sprr='yes' else - have_pthread_jit_protect='no' + have_sprr='no' fi fi fi @@ -2553,6 +2554,10 @@ if test "$have_pthread_jit_protect" = "yes" ; then echo "HAVE_PTHREAD_JIT_PROTECT=y" >> $config_host_mak fi +if test "$have_sprr" = "yes" ; then + echo "HAVE_SPRR=y" >> $config_host_mak +fi + # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on # a thread we have a handle to diff --git a/qemu/include/tcg/tcg-apple-jit.h b/qemu/include/tcg/tcg-apple-jit.h index f0fc3520dd..9c4d38430b 100644 --- a/qemu/include/tcg/tcg-apple-jit.h +++ b/qemu/include/tcg/tcg-apple-jit.h @@ -25,7 +25,7 @@ #ifndef TCG_APPLE_JIT_H #define TCG_APPLE_JIT_H -#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && (defined(__arm__) || defined(__aarch64__)) +#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && defined(HAVE_SPRR) && (defined(__arm__) || defined(__aarch64__)) /* write protect enable = write disable */ static inline void jit_write_protect(int enabled) diff --git a/uc.c b/uc.c index 21b1037a4f..f4d427716b 100644 --- a/uc.c +++ b/uc.c @@ -35,7 +35,8 @@ static void clear_deleted_hooks(uc_engine *uc); static uc_err uc_snapshot(uc_engine *uc); static uc_err uc_restore_latest_snapshot(uc_engine *uc); -#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && (defined(__arm__) || defined(__aarch64__)) +#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && \ + defined(HAVE_SPRR) && (defined(__arm__) || defined(__aarch64__)) static void save_jit_state(uc_engine *uc) { if (!uc->nested) {