about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-11-10 15:05:39 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-11-10 15:05:39 +0100
commitc2680fd0a73cb46aadad438d3377738d257ddaa2 (patch)
treeaa782109d49a3de5a375feee213183b9d5b8b697
parent85c74c6bf8e361108423da996ee62a53ffeb01d1 (diff)
downloadbox64-c2680fd0a73cb46aadad438d3377738d257ddaa2.tar.gz
box64-c2680fd0a73cb46aadad438d3377738d257ddaa2.zip
Added BOX64_FUTEX_WAITV, on by default expect for BAD_SIGNAL build
-rw-r--r--docs/USAGE.md5
-rw-r--r--docs/box64.pod7
-rw-r--r--src/emu/x64syscall.c25
-rw-r--r--src/include/debug.h1
-rw-r--r--src/main.c19
-rw-r--r--src/tools/rcfile.c1
6 files changed, 54 insertions, 4 deletions
diff --git a/docs/USAGE.md b/docs/USAGE.md
index 6a75aada..6f7a53c2 100644
--- a/docs/USAGE.md
+++ b/docs/USAGE.md
@@ -301,6 +301,11 @@ Disables the load of vulkan libraries.
  * 0 : Load vulkan libraries if found.

  * 1 : Disables the load of vulkan libraries, both the native and the i386 version (can be useful on Pi4, where the vulkan driver is not quite there yet.)

 

+#### BOX64_FUTEX_WAITV *

+Use of the new fuext_waitc syscall

+ * 0 : Do not try to use it, return unsupported (Default for BAD_SIGNAL build)

+ * 1 : let program use the syscall if the host system support it (Default for other build)

+

 #### BOX64_BASH *

 Define x86_64 bash to launch script

  * yyyy

diff --git a/docs/box64.pod b/docs/box64.pod
index 8be2e328..a14f9b73 100644
--- a/docs/box64.pod
+++ b/docs/box64.pod
@@ -463,6 +463,13 @@ Disables the load of vulkan libraries.
     * 0 : Load vulkan libraries if found.
     * 1 : Disables the load of vulkan libraries, both the native and the i386 version (can be useful on Pi4, where the vulkan driver is not quite there yet.)
 
+=item B<BOX64_FUTEX_WAITV>=I<0|1>
+
+Use of the new fuext_waitc syscall
+
+     * 0 : Do not try to use it, return unsupported (default for BAD_SIGNAL build)
+    * 1 : let program use the syscall if the host system support it (Default for other build)
+
 =item B<BOX64_BASH>=I<yyyy>
 
 Define x86_64 bash to launch script. Will use yyyy as x86_64 bash to launch
diff --git a/src/emu/x64syscall.c b/src/emu/x64syscall.c
index 51a05fb1..28ee2771 100644
--- a/src/emu/x64syscall.c
+++ b/src/emu/x64syscall.c
@@ -275,9 +275,7 @@ static const scwrap_t syscallwrap[] = {
     #ifdef __NR_fchmodat4
     { 434, __NR_fchmodat4, 4},
     #endif
-    #ifdef __NR_futex_waitv
-    { 449, __NR_futex_waitv, 5},
-    #endif
+    //{ 449, __NR_futex_waitv, 5},
 };
 
 struct mmap_arg_struct {
@@ -761,11 +759,19 @@ void EXPORT x64Syscall(x64emu_t *emu)
             break;
         #ifndef __NR_fchmodat4
         case 434:
-            *(int64_t*)R_RAX = fchmodat((int)R_EDI, (void*)R_RSI, (mode_t)R_RDX, (int)R_R10d);
+            *(int64_t*)&R_RAX = fchmodat((int)R_EDI, (void*)R_RSI, (mode_t)R_RDX, (int)R_R10d);
             if(R_EAX==0xffffffff)
                 R_RAX = (uint64_t)-errno;
             break;
         #endif
+        case 449:
+            #ifdef __NR_futex_waitv
+            if(box64_futex_waitv)
+                R_RAX = syscall(__NR_futex_waitv, R_RDI, R_RSI, R_RDX, R_R10, R_R8);
+            else
+            #endif
+                R_RAX = (uint64_t)-ENOSYS;
+            break;
         default:
             printf_log(LOG_INFO, "Error: Unsupported Syscall 0x%02Xh (%d)\n", s, s);
             emu->quit = 1;
@@ -1023,6 +1029,17 @@ uintptr_t EXPORT my_syscall(x64emu_t *emu)
         case 434:
             return (int)fchmodat((int)R_ESI, (void*)R_RDX, (mode_t)R_RCX, (int)R_R8d);
         #endif
+        case 449:
+            #ifdef __NR_futex_waitv
+            if(box64_futex_waitv)
+                return syscall(__NR_futex_waitv, R_RSI, R_RDX, R_RCX, R_R8, R_R9);
+            else
+            #endif
+                {
+                    errno = ENOSYS;
+                    return -1;
+                }
+            break;
         default:
             if(!(warned&(1<<s))) {
                 printf_log(LOG_INFO, "Warning: Unsupported libc Syscall 0x%02X (%d)\n", s, s);
diff --git a/src/include/debug.h b/src/include/debug.h
index 53afd3f6..ee4d7700 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -89,6 +89,7 @@ extern int box64_novulkan;  // disabling the use of wrapped vulkan
 extern int box64_showsegv;  // show sigv, even if a signal handler is present
 extern int box64_showbt;    // show a backtrace if a signal is caught
 extern int box64_isglibc234; // is the program linked with glibc 2.34+
+extern int box64_futex_waitv;
 extern int box64_x11threads;
 extern int box64_x11glx;
 extern char* box64_libGL;
diff --git a/src/main.c b/src/main.c
index a44f5940..022b92df 100644
--- a/src/main.c
+++ b/src/main.c
@@ -138,6 +138,11 @@ int box64_novulkan = 0;
 int box64_showsegv = 0;
 int box64_showbt = 0;
 int box64_isglibc234 = 0;
+#ifdef BAD_SIGNAL
+int box64_futex_waitv = 0;
+#else
+int box64_futex_waitv = 1;
+#endif
 char* box64_libGL = NULL;
 char* box64_custom_gstreamer = NULL;
 uintptr_t fmod_smc_start = 0;
@@ -899,6 +904,20 @@ void LoadLogEnv()
         if(box64_novulkan)
             printf_log(LOG_INFO, "Disable the use of wrapped vulkan libs\n");
     }
+    p = getenv("BOX64_FUTEX_WAITV");
+    if(p) {
+        if(strlen(p)==1) {
+            if(p[0]>='0' && p[0]<='0'+1)
+                box64_futex_waitv = p[0]-'0';
+        }
+        #ifdef BAD_SIGNAL
+        if(box64_futex_waitv)
+            printf_log(LOG_INFO, "Enable the use of futex waitv syscall (if available on the system\n");
+        #else
+        if(!box64_futex_waitv)
+            printf_log(LOG_INFO, "Disable the use of futex waitv syscall\n");
+        #endif
+    }
     p = getenv("BOX64_FIX_64BIT_INODES");
     if(p) {
         if(strlen(p)==1) {
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c
index 4217bf8d..ee8a2337 100644
--- a/src/tools/rcfile.c
+++ b/src/tools/rcfile.c
@@ -100,6 +100,7 @@ ENTRYBOOL(BOX64_CRASHHANDLER, box64_dummy_crashhandler) \
 ENTRYBOOL(BOX64_NOPULSE, box64_nopulse)                 \
 ENTRYBOOL(BOX64_NOGTK, box64_nogtk)                     \
 ENTRYBOOL(BOX64_NOVULKAN, box64_novulkan)               \
+ENTRYBOOL(BOX64_FUTEX_WAITV, box64_futex_waitv)         \
 ENTRYSTRING_(BOX64_BASH, bash)                          \
 ENTRYINT(BOX64_JITGDB, jit_gdb, 0, 2, 2)                \
 ENTRYBOOL(BOX64_NOSANDBOX, box64_nosandbox)             \