[PATCH v2] linux-user: Guard local FUTEX_CMD_MASK definition

Cédric Le Goater posted 1 patch 2 days, 18 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260722123545.743792-1-clg@redhat.com
Maintainers: Laurent Vivier <laurent@vivier.eu>, Helge Deller <deller@gmx.de>, Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
linux-user/syscall_defs.h | 2 ++
1 file changed, 2 insertions(+)
[PATCH v2] linux-user: Guard local FUTEX_CMD_MASK definition
Posted by Cédric Le Goater 2 days, 18 hours ago
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.

Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 linux-user/syscall_defs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 5799769f832fd953fe731a33ad7746113dff9957..e033c7db341622e825da6457b1539dd2682b711f 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -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
-- 
2.55.0


Re: [PATCH v2] linux-user: Guard local FUTEX_CMD_MASK definition
Posted by Pierrick Bouvier 2 days, 15 hours ago
On 7/22/2026 5:35 AM, Cédric Le Goater wrote:
> 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.
> 
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
>  linux-user/syscall_defs.h | 2 ++
>  1 file changed, 2 insertions(+)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>

Re: [PATCH v2] linux-user: Guard local FUTEX_CMD_MASK definition
Posted by Philippe Mathieu-Daudé 2 days, 16 hours ago
On 22/7/26 14:35, Cédric Le Goater wrote:
> 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.
> 
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
>   linux-user/syscall_defs.h | 2 ++
>   1 file changed, 2 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>