Fix read_sprr_perm for Apple real CPUs and GitHub Actions; enable Apple ARM64 wheel builds on PyPI. Fixes #2033.
          #2227
        
          
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
The
read_sprr_permfunction now correctly works both on real Apple CPUs and in GitHub Actions virtualized environments by relying onpthread_jit_write_protect_supported_np().This ensures proper detection of JIT write protection status without depending on build-time msr register check.
As a result, building wheels for Apple ARM64 should now fully work fine.
Fixes:
More context:
In
libsystem_pthread.dylib, the function_pthread_jit_write_protect_npfirst checks whether JIT write protection is enabled by reading from a special memory location in the commpage:0xfffffc10c.The same memory location is also checked by the
_pthread_jit_write_protect_supported_npfunction.In other words, whenever Apple code wants to access the
S3_6_c15_c1_5system register using themrsinstruction, it first verifies that JIT write protection is supported by calling_pthread_jit_write_protect_supported_np(), which ensures the system is in a valid state for that operation.