about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-02-20 19:49:55 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-02-20 19:49:55 +0100
commited4e33d8886a7e8c89318fa41535e9158a3c9893 (patch)
tree7256827cc790d86b0a3411b3392d81f908817e69 /src/libtools
parentc6dd73065db825d7456c00cc3f1127aff195ebe7 (diff)
downloadbox64-ed4e33d8886a7e8c89318fa41535e9158a3c9893.tar.gz
box64-ed4e33d8886a7e8c89318fa41535e9158a3c9893.zip
[DYNAREC] Directly run program Segfault handler for Access Error with PROT_DYNAREC_R, after a quick unprotectDB first
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/signals.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libtools/signals.c b/src/libtools/signals.c
index 40e9a8a7..b2da2723 100755
--- a/src/libtools/signals.c
+++ b/src/libtools/signals.c
@@ -855,7 +855,7 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
     }
     dynablock_t* db = NULL;
     int db_searched = 0;
-    if ((sig==SIGSEGV) && (addr) && (info->si_code == SEGV_ACCERR) && (prot&PROT_CUSTOM)) {
+    if ((sig==SIGSEGV) && (addr) && (info->si_code == SEGV_ACCERR) && (prot&PROT_DYNAREC)) {
         mutex_lock(&mutex_dynarec_prot);
         // check if SMC inside block
         db = FindDynablockFromNativeAddress(pc);
@@ -966,6 +966,9 @@ dynarec_log(/*LOG_DEBUG*/LOG_INFO, "Repeated SIGSEGV with Access error on %p for
             glitch2_prot = 0;
         }
         mutex_unlock(&mutex_dynarec_prot);
+    } else if ((sig==SIGSEGV) && (addr) && (info->si_code == SEGV_ACCERR) && (prot&PROT_DYNAREC_R)) {
+        // unprotect and continue to signal handler, because Write is not there on purpose
+        unprotectDB((uintptr_t)addr, 1, 1);    // unprotect 1 byte... But then, the whole page will be unprotected
     }
     if(!db_searched)
         db = FindDynablockFromNativeAddress(pc);