From: Helge Deller <[email protected]>

The FUTEX_WAIT_BITSET and FUTEX_WAKE_BITSET operations use a val3
parameter for comparism. Even if this 32-bit parameter is in most cases
0xffffffff, ensure that we do a required endianess swapping if host and
guest endianess differ.

Signed-off-by: Helge Deller <[email protected]>
---
 linux-user/syscall.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c0a9a86529..7cb9de97e9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8106,7 +8106,10 @@ static int do_futex(CPUState *cpu, bool time64, 
target_ulong uaddr,
 #endif
     switch (base_op) {
     case FUTEX_WAIT:
+        val = tswap32(val);
+        break;
     case FUTEX_WAIT_BITSET:
+        val3 = tswap32(val3);
         val = tswap32(val);
         break;
     case FUTEX_WAIT_REQUEUE_PI:
@@ -8116,8 +8119,11 @@ static int do_futex(CPUState *cpu, bool time64, 
target_ulong uaddr,
     case FUTEX_LOCK_PI:
     case FUTEX_LOCK_PI2:
         break;
-    case FUTEX_WAKE:
     case FUTEX_WAKE_BITSET:
+        val3 = tswap32(val3);
+        timeout = 0;
+        break;
+    case FUTEX_WAKE:
     case FUTEX_TRYLOCK_PI:
     case FUTEX_UNLOCK_PI:
         timeout = 0;
-- 
2.52.0


Reply via email to