ROCm / ROCm/amdgpu

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

Open Beginner friendly
#228 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
460
Forks
143
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with m4/drm_mode_create_hdmi_colorspace_property.m4 and inspect existing uses of AC_KERNEL_DO_BACKGROUND alongside the two colorspace probes. Reproduce or verify the configure checks against Linux 5.17, then confirm both probes run in isolated directories and no stale conftest.o produces a false positive.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.