Skip to contentSkip to conversation

vboxguestdrivers: fix vboxvideo build on kernels lacking drm_fb_helper_alloc_info

PATCH New Khem Raj 1 participant 1 message Aug 23

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/1 vboxguestdrivers: fix vboxvideo build on kernels lacking drm_fb_helper_alloc_info

Now that KERN_MAJ reflects the target kernel instead of the build host's uname -r, vboxvideo is actually built for kernels older than 7.x -- and it does not compile against 6.18.44:

vbox_fb.c:336:16: error: implicit declaration of function 'drm_fb_helper_alloc_info'; did you mean 'drm_fb_helper_fill_info'? [-Wimplicit-function-declaration] vbox_fb.c:336:14: error: assignment to 'struct fb_info *' from 'int' makes pointer from integer without a cast [-Wint-conversion]

Linux commit 63c971af4036 ("drm/fb-helper: Allocate and release fb_info in a single place") moved the struct fb_info allocation out of the drivers and into the DRM core, and made drm_fb_helper_alloc_info() static; drivers now find the instance ready to use in fb_helper->info by the time their .fbdev_probe callback runs. vbox_fb.c guards its call with RTLNX_VER_MIN(6,19,0), which is where the change landed in mainline.

Bumping that version check is not a fix. The commit was pulled into stable as a Stable-dep-of and therefore appears in the *middle* of several series -- v6.6.151, v6.12.103 and v6.18.44 have all dropped the declaration that v6.6.150, v6.12.102 and v6.18.43 still carry. No LINUX_VERSION_CODE comparison can express that, and guessing wrong the other way is worse than a build failure: on a 6.18.0..6.18.43 kernel fb_helper->info is still NULL when .fbdev_probe runs, so the driver would dereference NULL at runtime.

So add an escape hatch to vbox_fb.c and let the build system decide. do_compile greps the kernel headers we are actually compiling against and passes -DVBOX_NO_DRM_FB_HELPER_ALLOC_INFO through KCFLAGS when the declaration is gone. KCFLAGS rather than EXTRA_CFLAGS/VBOXMOD_CFLAGS because a command-line assignment of the latter two would clobber the include paths they carry, while KCFLAGS is untouched by VirtualBox's makefiles and propagates cleanly into the nested $(MAKE) -C $(KERN_DIR). Leaving the macro undefined keeps the previous behaviour, so nothing changes for kernels that still export the function, and 7.x is unaffected -- VBOX_VIDEO_MODULE is empty there and the in-tree drivers/gpu/drm/vboxvideo driver is used instead.

Verified on qemux86-64 against linux-yocto 6.18.44, from cleansstate:
vboxguest.ko, vboxsf.ko and vboxvideo.ko all build with no modpost warnings, the -D reaches the vbox_fb.o compile line, kernel-module-vboxvideo ships the module, and nm -u vboxvideo.ko no longer references drm_fb_helper_alloc_info -- all 155 remaining undefined symbols are exported by the kernel's Module.symvers.

---
 ...-build-decide-if-drm_fb_helper_alloc.patch | 54 +++++++++++++++++++
 .../vboxguestdrivers_7.2.14.bb                | 45 +++++++++++-----
 2 files changed, 87 insertions(+), 12 deletions(-)
 create mode 100644 meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-vboxvideo-let-the-build-decide-if-drm_fb_helper_alloc.patch
meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-vboxvideo-let-the-build-decide-if-drm_fb_helper_alloc.patch new file +54 -0
new file mode 100644
index 0000000000..cf94ce49b9
@@ -0,0 +1,54 @@
+From: Khem Raj <[email protected]>
+Date: Sat, 23 Aug 2026 00:00:00 -0700
+Subject: [PATCH] vboxvideo: let the build decide if drm_fb_helper_alloc_info()
+ exists
+
+Linux commit 63c971af4036 ("drm/fb-helper: Allocate and release fb_info in
+a single place") moved the struct fb_info allocation out of the drivers and
+into the DRM core, and turned drm_fb_helper_alloc_info() into a static
+function. Drivers now find the instance ready to use in fb_helper->info by
+the time their .fbdev_probe callback runs.
+
+vbox_fb.c guards its drm_fb_helper_alloc_info() call with RTLNX_VER_MIN(6,19,0),
+which is where the change landed in mainline. That is not sufficient: the
+commit was also picked up as a Stable-dep-of and so appeared in the middle of
+several stable series - v6.6.151, v6.12.103 and v6.18.44 all dropped the
+declaration while v6.6.150, v6.12.102 and v6.18.43 still have it. Building
+vboxvideo against any of those kernels fails with
+
+  vbox_fb.c:336:16: error: implicit declaration of function 'drm_fb_helper_alloc_info'; did you mean 'drm_fb_helper_fill_info'? [-Wimplicit-function-declaration]
+  vbox_fb.c:336:14: error: assignment to 'struct fb_info *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
+
+Since LINUX_VERSION_CODE cannot express "somewhere inside 6.6.y/6.12.y/6.18.y",
+add an escape hatch the build system can set once it has looked at the kernel
+headers it is actually compiling against. Leaving
+VBOX_NO_DRM_FB_HELPER_ALLOC_INFO undefined keeps the previous behaviour, so
+this is a no-op for anyone building the way VirtualBox intends.
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ vboxvideo/vbox_fb.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/vboxvideo/vbox_fb.c b/vboxvideo/vbox_fb.c
+index 063be63..7163780 100644
+--- a/vboxvideo/vbox_fb.c
++++ b/vboxvideo/vbox_fb.c
+@@ -330,7 +330,14 @@ int vboxfb_create(struct drm_fb_helper *helper,
+ 		return ret;
+ 	}
+
+-#if RTLNX_VER_MIN(6,19,0) || RTLNX_RHEL_RANGE(9,9, 9,99)
++	/*
++	 * Since Linux 6.19 the DRM core allocates the struct fb_info instance
++	 * before it calls into this callback, and drm_fb_helper_alloc_info() is
++	 * no longer available to drivers. A version check alone cannot express
++	 * that, because the change was backported into the middle of the 6.6,
++	 * 6.12 and 6.18 stable series, so let the build system tell us as well.
++	 */
++#if RTLNX_VER_MIN(6,19,0) || RTLNX_RHEL_RANGE(9,9, 9,99) || defined(VBOX_NO_DRM_FB_HELPER_ALLOC_INFO)
+ 	info = helper->info;
+ #elif RTLNX_VER_MIN(6,2,0) || RTLNX_RHEL_RANGE(8,9, 8,99) || RTLNX_RHEL_RANGE(9,3, 9,99)
+ 	info = drm_fb_helper_alloc_info(helper);
meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_7.2.14.bb +33 -12

76 lines not on this page · raw message