Skip to content

[Issue]: dkms: false positive in HDMI/DP colorspace property checks due to missing AC_KERNEL_DO_BACKGROUND #228

Description

@theSprog

Problem Description

Issue Description
The DKMS configure script produces false positives for drm_mode_create_hdmi_colorspace_property and drm_mode_create_dp_colorspace_property on older kernels (e.g., v5.17) that only support the 1-argument version of these functions.

Latent Bug Nature & Reproduction
This bug is currently masked in the vanilla AMDGPU tree purely due to macro execution order (preceding foreground tests happen to fail or not leave a valid conftest.o). However, it reliably breaks downstream forks or custom backports that introduce a successful foreground macro just before these colorspace checks.

Time-oriented Execution Flow & Root Cause
The issue stems from a missing sandbox isolation wrapper, which causes a sequential state contamination when combined with the Kbuild toolchain.

  1. State Contamination: A prior synchronous test in the configuration sequence succeeds, leaving a valid conftest.o in the top-level build directory.
  2. Missing Sandbox: AC_AMDGPU_DRM_MODE_CREATE_HDMI_COLORSPACE_PROPERTY is executed. Because it lacks the AC_KERNEL_DO_BACKGROUND wrapper, it runs synchronously in the same polluted top-level directory instead of a clean, isolated temporary directory (mktemp -d).
  3. Compiler Failure: gcc fails to compile the 2-argument test code due to argument mismatch and exits. It does not overwrite or generate a new conftest.o.
  4. Pipeline Deception: In x86 Kbuild environments, the compilation pipeline captured in $CFLAGS chains objtool execution with a semicolon (e.g., gcc ... -c -o conftest.o conftest.c ; objtool check ... conftest.o). The shell ignores gcc's exit code.
  5. False Positive: objtool runs, validates the stale conftest.o left by step 1, and returns 0. AC_KERNEL_COMPILE_IFELSE catches this 0 and incorrectly defines HAVE_DRM_MODE_CREATE_HDMI_COLORSPACE_PROPERTY_2ARGS.

Suggested Fix
Wrap the affected macros in AC_KERNEL_DO_BACKGROUND to align with the existing concurrent probing architecture. This ensures they execute in ephemeral, isolated directories, completely avoiding stale object files.

--- a/m4/drm_mode_create_hdmi_colorspace_property.m4
+++ b/m4/drm_mode_create_hdmi_colorspace_property.m4
@@ -1,13 +1,15 @@
 AC_DEFUN([AC_AMDGPU_DRM_MODE_CREATE_HDMI_COLORSPACE_PROPERTY], [
-    AC_KERNEL_TRY_COMPILE_SYMBOL([
-            #include <drm/drm_connector.h>
-        ], [
-            drm_mode_create_hdmi_colorspace_property(NULL, 0);
-        ], [drm_mode_create_hdmi_colorspace_property], [drivers/gpu/drm/drm_connector.c], [
-                AC_DEFINE(HAVE_DRM_MODE_CREATE_HDMI_COLORSPACE_PROPERTY_2ARGS, 1,
-                        [drm_mode_create_hdmi_colorspace_property() has 2 args])
-        ])
+    AC_KERNEL_DO_BACKGROUND([
+        AC_KERNEL_TRY_COMPILE_SYMBOL([
+                #include <drm/drm_connector.h>
+            ], [
+                drm_mode_create_hdmi_colorspace_property(NULL, 0);
+            ], [drm_mode_create_hdmi_colorspace_property], [drivers/gpu/drm/drm_connector.c], [
+                    AC_DEFINE(HAVE_DRM_MODE_CREATE_HDMI_COLORSPACE_PROPERTY_2ARGS, 1,
+                            [drm_mode_create_hdmi_colorspace_property() has 2 args])
+            ])
+    ])
 ]) 
 
 dnl #
@@ -15,12 +17,14 @@
 dnl # drm/connector: Allow drivers to pass list of supported colorspaces
 dnl #
 AC_DEFUN([AC_AMDGPU_DRM_MODE_CREATE_DP_COLORSPACE_PROPERTY], [
-    AC_KERNEL_TRY_COMPILE_SYMBOL([
-            #include <drm/drm_connector.h>
-        ], [
-            drm_mode_create_dp_colorspace_property(NULL, 0);
-        ], [drm_mode_create_dp_colorspace_property], [drivers/gpu/drm/drm_connector.c], [
-                AC_DEFINE(HAVE_DRM_MODE_CREATE_DP_COLORSPACE_PROPERTY_2ARGS, 1,
-                        [drm_mode_create_dp_colorspace_property() has 2 args])
-        ])
+    AC_KERNEL_DO_BACKGROUND([
+        AC_KERNEL_TRY_COMPILE_SYMBOL([
+                #include <drm/drm_connector.h>
+            ], [
+                drm_mode_create_dp_colorspace_property(NULL, 0);
+            ], [drm_mode_create_dp_colorspace_property], [drivers/gpu/drm/drm_connector.c], [
+                    AC_DEFINE(HAVE_DRM_MODE_CREATE_DP_COLORSPACE_PROPERTY_2ARGS, 1,
+                            [drm_mode_create_dp_colorspace_property() has 2 args])
+            ])
+    ])
 ])

Operating System

Linux 5.17

CPU

Hygon C86-3G

GPU

None

ROCm Version

ROCm 6.0.0

ROCm Component

No response

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

rocminfo --support output
Paste output here

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions