Centos 9 Stream with Kernel 5.14.0-681.el9.x86_64 Modulebuild vboxdrv for 7.2.6 fails during install

Discussions related to using VirtualBox on Linux hosts.
Post Reply
Virtebra
Posts: 30
Joined: 7. Oct 2024, 14:27
Primary OS: Linux other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian, Ubuntu, Fedora, RHEL, Oracle Linux, Centos stream, Windows, macOS

Centos 9 Stream with Kernel 5.14.0-681.el9.x86_64 Modulebuild vboxdrv for 7.2.6 fails during install

Post by Virtebra »

Hi,

I am experiencing issues while trying to install VirtualBox 7.2.6 on a freshly setup CentOS 9 Stream x86_64 environment.

The installation fails due to build compilation errors (see below and in detail attached).
I attempted to recompile as root by running /sbin/vboxconfig, but the errors persisted.
I suspect that the current kernel version (5.14.0-681.el9.x86_64) of Centos 9 stream might not be compatible with this version of VirtualBox.

Please note that I am not using UEFI nor Secure Boot, and SELinux is disabled. This setup is running purely for testing purposes in a virtual machine itself.

Could you please advise on how to resolve this issue?

Thank you for your assistance.

--

============================
Linux Distribution
============================

Code: Select all

CentOS Stream 9
============================
Running Kernel Version
============================

Code: Select all

5.14.0-681.el9.x86_64
============================
Architecture
============================

Code: Select all

x86-64
============================
Installed Essential Packages
============================

Code: Select all

kernel-devel-5.14.0-681.el9.x86_64
kernel-headers-5.14.0-681.el9.x86_64
== Build/tool packages (versions) ==

Code: Select all

gcc-11.5.0-14.el9.x86_64
make-4.3-8.el9.x86_64
perl-5.32.1-483.el9.x86_64
binutils-2.35.2-69.el9.x86_64
glibc-devel-2.34-245.el9.x86_64
elfutils-libelf-devel-0.194-1.el9.x86_64
qt6-qtbase-6.6.2-1.el9.x86_64
== DKMS ==

Code: Select all

dkms-3.3.0-1.el9
============================
Repository List
============================

Code: Select all

repo id                                      repo name
appstream                                    CentOS Stream 9 - AppStream
baseos                                       CentOS Stream 9 - BaseOS
crb                                          CentOS Stream 9 - CRB
epel                                         Extra Packages for Enterprise Linux 9 - x86_64
epel-cisco-openh264                          Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64
epel-next                                    Extra Packages for Enterprise Linux 9 - Next - x86_64
extras-common                                CentOS Stream 9 - Extras packages
virtualbox                                   Oracle Linux / RHEL / CentOS-9 / x86_64 - VirtualBox
errors messages from vbox-setup.log
============================================================

Code: Select all

Building the main VirtualBox module.
Error building the module:
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/5.14.0-681.el9.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j4 modules
make[1]: warning: -j4 forced in submake: resetting jobserver mode.
make -f ./scripts/Makefile.build obj=/tmp/vbox.0 \
---

Code: Select all

In file included from /tmp/vbox.0/combined-os-specific.c:66:
/tmp/vbox.0/r0drv/linux/timer-r0drv-linux.c: In function ‘rtTimerLinuxStdCallback’:
/tmp/vbox.0/r0drv/linux/timer-r0drv-linux.c:754:37: error: implicit declaration of function ‘from_timer’; did you mean ‘mod_timer’? [-Werror=implicit-function-declaration]
  754 |     PRTTIMERLNXSUBTIMER pSubTimer = from_timer(pSubTimer, pLnxTimer, u.Std.LnxTimer);
      |                                     ^~~~~~~~~~
      |                                     mod_timer
/tmp/vbox.0/r0drv/linux/timer-r0drv-linux.c:754:70: error: ‘u’ undeclared (first use in this function); did you mean ‘up’?
  754 |     PRTTIMERLNXSUBTIMER pSubTimer = from_timer(pSubTimer, pLnxTimer, u.Std.LnxTimer);
      |                                                                      ^
      |                                                                      up
/tmp/vbox.0/r0drv/linux/timer-r0drv-linux.c:754:70: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:250: /tmp/vbox.0/combined-os-specific.o] Error 1
make[2]: *** Waiting for unfinished jobs....
---

Code: Select all

/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_HOST_VMX -DLOG_ENABLED -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -DMODULE  -DKBUILD_BASENAME='"combined_agnostic1"' -DKBUILD_MODNAME='"vboxdrv"' -D__KBUILD_MODNAME=kmod_vboxdrv /tmp/vbox.0/combined-agnostic1.c | scripts/genksyms/genksyms   -r /dev/null >> /tmp/vbox.0/.combined-agnostic1.o.cmd; fi
make[1]: *** [Makefile:1968: /tmp/vbox.0] Error 2
make: *** [/tmp/vbox.0/Makefile-footer.gmk:146: vboxdrv] Error 2
---

see the whole vbox-setup.log attached
Attachments
vbox-setup.log
(62.55 KiB) Downloaded 15 times
tkalfaoglu
Posts: 11
Joined: 12. Mar 2008, 09:53

Re: Centos 9 Stream with Kernel 5.14.0-681.el9.x86_64 Modulebuild vboxdrv for 7.2.6 fails during install

Post by tkalfaoglu »

Same boat. did you eventually have any luck?
I can't get VirtualBox to run at all now.
Boxy
Posts: 50
Joined: 31. Jan 2010, 14:58
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7,SUSE,MS-DOS
Location: wild south of germany

Re: Centos 9 Stream with Kernel 5.14.0-681.el9.x86_64 Modulebuild vboxdrv for 7.2.6 fails during install

Post by Boxy »

After some hours of investigation, I got it to work in my fresh CentOS Stream 9 with Kernel 5.14.0.694.el9.x86_64.

1. [VBOX GA "CD" inserted, then executed the installer, resulted in msg
error: implicit declaration of function 'from_timer'; did you mean 'mod_timer'?
754 PRTTIMERLNXSUBTIMER pSubTimer = from_timer(pSubTimer, pLnxTimer, u.Std.LnxTimer);

Found the reason was a function from_timer renamed in Kernel 6.x to timer_container_of
and backported to CentOS 9 Kernel 5.y (I assume in Fedora too and may come to RHEL 9 in some future).

2. Removed the "CD" from its drive so it cannot influence my further investigation, then:
# cd /opt/VBoxGuestAdditions-7.2.8/src/vboxguest-7.2.8/vboxguest/r0drv/linux/
# vi timer-r0drv-linux.c

Changed line 751 # if RTLNX_VER_MIN(6,16,0) || RTLNX_RHEL_RANGE(10,2, 10,99)
to # if RTLNX_VER_MIN(5,14,0) || RTLNX_RHEL_RANGE(10,2, 10,99)
leading to compile

3. # /sbin/rcvboxadd quicksetup
Now the from_timer error wasn't shown again, but a new error:
/tmp/vbox.0/vbox_main.c: In function 'vbox_dumb_mmap_offset':
/tmp/vbox.0/vbox_main.c:693:28: error: 'struct drm_device' has no member named 'struct mutex'
693 mutex_lock(struct_mutex);

4. # cd /opt/VBoxGuestAdditions-7.2.8/src/vboxguest-7.2.8/vboxvideo
# vi vbox_main.c
The reason resulted from this block in function vbox_dumb_mmap_offset :
686 #if RTLNX_VER_MIN(6,18,0) || RTLNX_RHEL_RANGE(10,2, 10,99)
687 struct vbox_private *vbox = dev->dev_private;
688 struct mutex = &vbox->struct_mutex
689 #else
690 struct mutex = &dev->struct_mutex
691 #endif
So I changed these two lines:
line 686 from #if RTLNX_VER_MIN(6,18,0) || RTLNX_RHEL_RANGE(10,2, 10,99)
to #if RTLNX_VER_MIN(5,14,0) || RTLNX_RHEL_RANGE(10,2, 10,99)
line 688 from struct mutex = &vbox->struct_mutex;
to struct_mutex = &vbox->hw_mutex;

I don't know the functional background or difference of struct_mutex vs. hw_mutex
but as I found a similar code block in funct vbox_driver_load - using &vbox->hw_mutex for all Kernels and &vbox->struct_mutex only for Kernel ge 6.18, it should at least not lead to memory corruption.

5. # /sbin/rcvboxadd quicksetup
Run without errors. After reboot, shared clipboard and video resize worked.

6. I found hints about CentOS without minor release number, /etc/redhat-release states "CentOS 9" and not "9.8" or so.
So I didn't find out how to restrict the above lines to Kernel 5.14.0 Patchlevel 694
(although I could see "EXTRAVERSION = -694.el9.x68_64" in the Kernel source directory /usr/src/kernels/5.14.0-694.el9.x86_64/Makefile). As I spent a lot of time to get the sh*t running, I don't want to spend even more in finding out how Virtualbox gets informations about Linux Kernel, but I think, regardings CentOS it would be advisable to compile Guest Additions even with Kernel patch level.

7. BTW, rcvboxadd always showed a weird error message about Kernel not configured (autoconf.h/auto.conf missing, make oldconfig),
I found hints about this not being the real problem, in my case maybe resulting from a fresh CentOS installation. Maybe someone could shed some light on this (ignoring like I did? make oldconfig - but lead to errors?)
Post Reply