| 65 | |
| 66 | |
| 67 | JitWriteProtection::JitWriteProtection(bool enable) { |
| 68 | #ifdef __aarch64__ |
| 69 | // Mimic pthread_jit_write_protect_np(), but save the previous state |
| 70 | if (*(volatile char*)0xfffffc10c) { |
| 71 | u64 val = enable ? *(volatile u64*)0xfffffc118 : *(volatile u64*)0xfffffc110; |
| 72 | u64 prev; |
| 73 | asm volatile("mrs %0, s3_6_c15_c1_5" : "=r" (prev) : : ); |
| 74 | if (prev != val) { |
| 75 | _prev = prev; |
| 76 | _restore = true; |
| 77 | asm volatile("msr s3_6_c15_c1_5, %0\n" |
| 78 | "isb" |
| 79 | : "+r" (val) : : "memory"); |
| 80 | return; |
| 81 | } |
| 82 | } |
| 83 | // Already in the required mode, or write protection is not supported |
| 84 | _restore = false; |
| 85 | #endif |
| 86 | } |
| 87 | |
| 88 | JitWriteProtection::~JitWriteProtection() { |
| 89 | #ifdef __aarch64__ |
nothing calls this directly
no outgoing calls
no test coverage detected