Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/build-wheels-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ jobs:
python2 -m pip install capstone==4.0.2 wheelhouse/*py2*.whl
python2 -m unittest discover tests/regress "*.py"

# https://github.com/unicorn-engine/unicorn/issues/2033
# Skip macos arm64 wheels during release stage
- uses: actions/upload-artifact@v4
if: ${{!( startsWith(github.ref, 'refs/tags') && !startsWith(github.ref, 'refs/tags/v') && contains(matrix.os, 'macos') && contains(matrix.arch, 'arm64') )}}
with:
name: ${{ env.ARTIFACT_NAME }}
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -281,7 +278,6 @@ jobs:
output-dir: wheelhouse

- uses: actions/upload-artifact@v4
if: ${{!( startsWith(github.ref, 'refs/tags') && !startsWith(github.ref, 'refs/tags/v') && contains(matrix.os, 'macos') && contains(matrix.arch, 'arm64') )}}
with:
name: ${{ env.ARTIFACT_NAME }}
path: ./wheelhouse/*.whl
Expand Down
32 changes: 1 addition & 31 deletions qemu/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2152,39 +2152,13 @@ fi
if [ "$darwin" = "yes" ] ; then
cat > $TMPC << EOF
#include <pthread.h>
int main() { pthread_jit_write_protect_np(0); return 0;}
int main() { pthread_jit_write_protect_supported_np(); 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 v;

__asm__ __volatile__("isb sy\n"
"mrs %0, S3_6_c15_c1_5\n"
: "=r"(v)::"memory");
// In Apple Hypervisor virtualized environment (EL1), this value is not accessbile
// but pthread_jit_write_protect_np essentially is a no-op.
return 0;
}
EOF
if ! compile_prog ""; then
have_sprr_mrs='no'
else
$TMPE
if [ $? -eq 0 ]; then
have_sprr_mrs='yes'
else
have_sprr_mrs='no'
fi
fi
fi
fi

##########################################
Expand Down Expand Up @@ -2565,10 +2539,6 @@ if test "$have_pthread_jit_protect" = "yes" ; then
echo "HAVE_PTHREAD_JIT_PROTECT=y" >> $config_host_mak
fi

if test "$have_sprr_mrs" = "yes" ; then
echo "HAVE_SPRR_MRS=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
Expand Down
19 changes: 9 additions & 10 deletions qemu/include/tcg/tcg-apple-jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
#include "stdbool.h"
#include "qemu/compiler.h"

#if defined(__APPLE__) && defined(HAVE_PTHREAD_JIT_PROTECT) && (defined(__arm__) || defined(__aarch64__))

// Returns the S3_6_c15_c1_5 register's value
// Taken from
// Taken from
// https://stackoverflow.com/questions/70019553/lldb-how-to-read-the-permissions-of-a-memory-region-for-a-thread
// https://blog.svenpeter.dev/posts/m1_sprr_gxf/
// On Github Action (Virtualized environment), this shall always returns 0
#if defined(HAVE_SPRR_MRS)
static inline uint64_t read_sprr_perm(void)
{
uint64_t v;
Expand All @@ -44,17 +45,12 @@ static inline uint64_t read_sprr_perm(void)
: "=r"(v)::"memory");
return v;
}
#else
static inline uint64_t read_sprr_perm(void)
{
return 0;
}
#endif

#if defined(__APPLE__) && defined(HAVE_SPRR_MRS) && defined(HAVE_PTHREAD_JIT_PROTECT) && (defined(__arm__) || defined(__aarch64__))

QEMU_UNUSED_FUNC static inline uint8_t thread_mask()
{
if (!pthread_jit_write_protect_supported_np()) {
return 0;
}
uint64_t v = read_sprr_perm();

if (v == 0) {
Expand All @@ -75,6 +71,9 @@ QEMU_UNUSED_FUNC static inline bool thread_executable()
}

static inline void assert_executable(bool executable) {
if (!pthread_jit_write_protect_supported_np()) {
return;
}
uint64_t v = read_sprr_perm();

if (!v) {
Expand Down
Loading