From 9705d5e38bdf4ec72daf480de0830dfde6e33a70 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 18 Feb 2023 15:06:40 +0100 Subject: Preliminary work to get steamwebhelper working --- src/libtools/signals.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/libtools') diff --git a/src/libtools/signals.c b/src/libtools/signals.c index a3f0b796..9ab18a75 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_DYN)) { mutex_lock(&mutex_dynarec_prot); // check if SMC inside block db = FindDynablockFromNativeAddress(pc); @@ -981,7 +981,7 @@ dynarec_log(/*LOG_DEBUG*/LOG_INFO, "Repeated SIGSEGV with Access error on %p for printf_log(log_minimum, "%04d|Double %s (code=%d, pc=%p, addr=%p)!\n", GetTID(), signame, old_code, old_pc, old_addr); exit(-1); } else { - if(sig==SIGSEGV && info->si_code==2 && ((prot&~PROT_CUSTOM)==5 || (prot&~PROT_CUSTOM)==7)) { + if(sig==SIGSEGV && info->si_code==2 && ((prot&~PROT_DYN)==5 || (prot&~PROT_DYN)==7)) { static uintptr_t old_addr = 0; printf_log(/*LOG_DEBUG*/LOG_INFO, "Strange SIGSEGV with Access error on %p for %p, db=%p, prot=0x%x (old_addr=%p)\n", pc, addr, db, prot, (void*)old_addr); if(old_addr!=(uintptr_t)addr) { @@ -1105,7 +1105,6 @@ exit(-1); free(strings); } else printf_log(log_minimum, "EmulatedBT: none\n"); -printf_log(log_minimum, "RDI = %p, Prot=0x%02x, ElfName(RDI)=%s\n",(void*)R_RDI, getProtection(R_RDI), ElfName(FindElfAddress(my_context, R_RDI))); #define GO(A) R_##A = old_##A GO(RAX); GO(RBX); -- cgit 1.4.1 From ad332494d01897f876ab6b326cf895c9c9389ca9 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 25 Feb 2023 15:21:27 +0100 Subject: [STEAM] Added a workaround for issue with steamwebhelper running on Armbian (for #528 and other tickets) --- src/libtools/signals.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libtools') diff --git a/src/libtools/signals.c b/src/libtools/signals.c index 92ab59ef..f72f6121 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_DYNAREC)) { + 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); -- cgit 1.4.1 From 5a7761c294f2ac0b703027bede709025e90b13e2 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 25 Feb 2023 16:11:00 +0100 Subject: Try to improved the Workaround, to make it more generic --- src/libtools/signals.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libtools') diff --git a/src/libtools/signals.c b/src/libtools/signals.c index f72f6121..98062054 100755 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -853,9 +853,14 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx) CancelBlock64(0); cancelFillBlock(); // Segfault inside a Fillblock, cancel it's creation... } + // try to see if the si_code makes sense + if((sig==SIGSEGV) && (addr) && (info->si_code == 1) && prot&(PROT_READ|PROT_WRITE|PROT_EXEC)) { + printf_log(LOG_DEBUG, "Workaround for suspicious si_code for %p / prot=0x%x\n", addr, prot); + info->si_code = 2; + } dynablock_t* db = NULL; int db_searched = 0; - if ((sig==SIGSEGV) && (addr) && /*(info->si_code == SEGV_ACCERR) &&*/ (prot&PROT_DYNAREC)) { + 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); -- cgit 1.4.1 From b65e02420f5ef1da5a6bb34b4d3020f4e38d6f91 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 26 Feb 2023 09:38:01 +0100 Subject: Made the Signal workaround specific to RK3588 --- src/libtools/signals.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libtools') diff --git a/src/libtools/signals.c b/src/libtools/signals.c index 98062054..cb237f7e 100755 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -853,11 +853,14 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx) CancelBlock64(0); cancelFillBlock(); // Segfault inside a Fillblock, cancel it's creation... } + #ifdef RK3588 // try to see if the si_code makes sense + // the RK3588 tend to need a special Kernel that seems to have a weird behaviour sometimes if((sig==SIGSEGV) && (addr) && (info->si_code == 1) && prot&(PROT_READ|PROT_WRITE|PROT_EXEC)) { printf_log(LOG_DEBUG, "Workaround for suspicious si_code for %p / prot=0x%x\n", addr, prot); info->si_code = 2; } + #endif dynablock_t* db = NULL; int db_searched = 0; if ((sig==SIGSEGV) && (addr) && (info->si_code == SEGV_ACCERR) && (prot&PROT_DYNAREC)) { -- cgit 1.4.1 From cc3237a77d21a13ce29d5768702704f84e3ee59b Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 26 Feb 2023 09:47:15 +0100 Subject: [RK3588] Made Workaround also working on non-dynarec build (just in case...) --- src/libtools/signals.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libtools') diff --git a/src/libtools/signals.c b/src/libtools/signals.c index cb237f7e..f8aa6cb8 100755 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -847,12 +847,6 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx) #endif int Locks = unlockMutex(); uint32_t prot = getProtection((uintptr_t)addr); -#ifdef DYNAREC - if((Locks & is_dyndump_locked) && (sig==SIGSEGV) && current_helper) { - relockMutex(Locks); - CancelBlock64(0); - cancelFillBlock(); // Segfault inside a Fillblock, cancel it's creation... - } #ifdef RK3588 // try to see if the si_code makes sense // the RK3588 tend to need a special Kernel that seems to have a weird behaviour sometimes @@ -861,6 +855,12 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx) info->si_code = 2; } #endif +#ifdef DYNAREC + if((Locks & is_dyndump_locked) && (sig==SIGSEGV) && current_helper) { + relockMutex(Locks); + CancelBlock64(0); + cancelFillBlock(); // Segfault inside a Fillblock, cancel it's creation... + } dynablock_t* db = NULL; int db_searched = 0; if ((sig==SIGSEGV) && (addr) && (info->si_code == SEGV_ACCERR) && (prot&PROT_DYNAREC)) { -- cgit 1.4.1