Skip to contentSkip to conversation

linux-user: Guard local FUTEX_CMD_MASK definition

PATCH In review Cédric Le Goater 4 participants 5 messages Jul 22 – Jul 26

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user: Guard local FUTEX_CMD_MASK definition

Building linux-user on a host with Linux 7.2 kernel headers fails with a macro redefinition error for FUTEX_CMD_MASK. The kernel commit 3ca9595d9fb6 ("futex: Add support for unlocking robust futexes") expanded the mask to include the new FUTEX_ROBUST_UNLOCK and FUTEX_ROBUST_LIST32 flags, which conflicts with QEMU's local definition.

Add a #ifndef guard so the host definition takes precedence when available. The local fallback is kept for older kernel headers (pre-2.6.29) that lack FUTEX_CMD_MASK or define a mask without FUTEX_CLOCK_REALTIME.

---
 linux-user/syscall_defs.h | 2 ++
 1 file changed, 2 insertions(+)
linux-user/syscall_defs.h +2 -0
index 5799769f832fd953fe731a33ad7746113dff9957..e033c7db341622e825da6457b1539dd2682b711f 100644
@@ -2593,7 +2593,9 @@ struct target_drm_i915_getparam {
 
 #define FUTEX_PRIVATE_FLAG      128
 #define FUTEX_CLOCK_REALTIME    256
+#ifndef FUTEX_CMD_MASK
 #define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
+#endif
 
 #if defined(TARGET_X86_64)
 #define TARGET_EPOLL_PACKED QEMU_PACKED
Signature · 1 line
2.55.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 12 lines · Cédric Le Goater

Building linux-user on a host with Linux 7.2 kernel headers fails with a macro redefinition error for FUTEX_CMD_MASK. The kernel commit 3ca9595d9fb6 ("futex: Add support for unlocking robust futexes") expanded the mask to include the new FUTEX_ROBUST_UNLOCK and FUTEX_ROBUST_LIST32 flags, which conflicts with QEMU's local definition.

Add a #ifndef guard so the host definition takes precedence when available. The local fallback is kept for older kernel headers (pre-2.6.29) that lack FUTEX_CMD_MASK or define a mask without FUTEX_CLOCK_REALTIME.

Quoted 4 lines
---
  linux-user/syscall_defs.h | 2 ++
  1 file changed, 2 insertions(+)
Reviewed-by on v2 1/1
#2 lore raw
In reply to Cédric Le Goater
Quoted 12 lines · Cédric Le Goater

Building linux-user on a host with Linux 7.2 kernel headers fails with a macro redefinition error for FUTEX_CMD_MASK. The kernel commit 3ca9595d9fb6 ("futex: Add support for unlocking robust futexes") expanded the mask to include the new FUTEX_ROBUST_UNLOCK and FUTEX_ROBUST_LIST32 flags, which conflicts with QEMU's local definition.

Add a #ifndef guard so the host definition takes precedence when available. The local fallback is kept for older kernel headers (pre-2.6.29) that lack FUTEX_CMD_MASK or define a mask without FUTEX_CLOCK_REALTIME.

Quoted 5 lines
---
 linux-user/syscall_defs.h | 2 ++
 1 file changed, 2 insertions(+)
#3 lore raw
In reply to Cédric Le Goater
Quoted 22 lines · Cédric Le Goater

Building linux-user on a host with Linux 7.2 kernel headers fails with a macro redefinition error for FUTEX_CMD_MASK. The kernel commit 3ca9595d9fb6 ("futex: Add support for unlocking robust futexes") expanded the mask to include the new FUTEX_ROBUST_UNLOCK and FUTEX_ROBUST_LIST32 flags, which conflicts with QEMU's local definition.

Add a #ifndef guard so the host definition takes precedence when available. The local fallback is kept for older kernel headers (pre-2.6.29) that lack FUTEX_CMD_MASK or define a mask without FUTEX_CLOCK_REALTIME.

---
  linux-user/syscall_defs.h | 2 ++
  1 file changed, 2 insertions(+)
linux-user/syscall_defs.h +0 -0
index 5799769f832fd953fe731a33ad7746113dff9957..e033c7db341622e825da6457b1539dd2682b711f 100644

linux-user/syscall_defs.h struct target_drm_i915_getparam { · line 2596

Quoted 4 lines
linux-user/syscall_defs.h +1 -0
@@ -2593,7 +2593,9 @@ struct target_drm_i915_getparam {
 
  #define FUTEX_PRIVATE_FLAG      128
  #define FUTEX_CLOCK_REALTIME    256
+#ifndef FUTEX_CMD_MASK

It would be nice to have /* since linux 2.6.29 */ here.

But I wonder - if we really should care about such old kernels? Quite a few qemu-user internals require more recent host kernel. I guess it wont even compile with 3.x kernel headers :) (this is why a comment like this is useful).

Thanks,

/mjt

#4 lore raw
Quoted 4 lines · Michael Tokarev
Quoted 2 lines

  #define FUTEX_CLOCK_REALTIME    256
+#ifndef FUTEX_CMD_MASK

It would be nice to have /* since linux 2.6.29 */ here.

(I can follow-up with such comment later, fwiw).

/mjt