Bug 4842 - dkms-vboxadditions fails to build on startup for 3.3 kernel
Summary: dkms-vboxadditions fails to build on startup for 3.3 kernel
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: i586 Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Thomas Backlund
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-07 15:25 CET by William Murphy
Modified: 2012-03-12 22:48 CET (History)
4 users (show)

See Also:
Source RPM: dkms-vboxadditions and kernel-desktop-3.3.0-0.rc6.1
CVE:
Status comment:


Attachments

Description William Murphy 2012-03-07 15:25:25 CET
Description of problem:
The dkms-vboxadditions modules fail to build during startup for the 3.3.0-0.rc6 kernel. After booting, with any kernel, issuing the command as root: 

  dkms build -m vboxadditions -m 4.1.8-3.mga2 -k 3.3.0-desktop-0.rc6.1.mga2

Fails with this error:
...
Error! Bad return status for module build on kernel: 3.3.0-desktop-0.rc6.1.mga2 (i586)
Consult the make.log in the build directory
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/ for more information.
...

Here is the make.log:
DKMS make.log for vboxadditions-4.1.8-3.mga2 for kernel 3.3.0-desktop-0.rc6.1.mga2 (i586)
Wed Mar  7 02:52:07 PST 2012
make: Entering directory `/usr/src/linux-3.3.0-desktop-0.rc6.1.mga2'
  LD      /var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/built-in.o
  CC [M]  /var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.o
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:100:5: warning: braces around scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:100:5: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:101:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:101:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:101:9: warning: initialization from incompatible pointer type [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:101:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:102:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:102:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:102:9: warning: excess elements in scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:102:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:103:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:103:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:103:9: warning: excess elements in scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:103:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:107:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:107:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:107:9: warning: excess elements in scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:107:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:111:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:111:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:111:9: warning: excess elements in scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:111:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:112:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:112:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:112:9: warning: excess elements in scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:112:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:113:9: error: field name not in record or union initializer
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:113:9: error: (near initialization for âdriver.fopsâ)
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:113:9: warning: excess elements in scalar initializer [enabled by default]
/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.c:113:9: warning: (near initialization for âdriver.fopsâ) [enabled by default]
make[1]: *** [/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo/vboxvideo_drm.o] Error 1
make: *** [_module_/var/lib/dkms/vboxadditions/4.1.8-3.mga2/build/vboxvideo] Error 2
make: Leaving directory `/usr/src/linux-3.3.0-desktop-0.rc6.1.mga2'

How reproducible:
Install the 3.3 kernel and dkms-vboxadditions and reboot.

Steps to Reproduce:
1. Install kernel-desktop-devel-3.3.0-0.rc6.1-mga2
2. Install dkms-vboxadditions
3. Run: dkms build -m vboxadditions -m 4.1.8-3.mga2 -k 3.3.0-desktop-0.rc6.1.mga2
Comment 1 Malo Deniélou 2012-03-07 15:37:41 CET
I confirm the bug within my vbox as well.

CC: (none) => malo

Comment 2 Bit Twister 2012-03-08 01:05:00 CET
FYI: vboxadditions will not compile on x86_64 install using vendor vbox package instead of Mageia packages for host and guest.

I am using VirtualBox-4.1-4.1.8_75467_mdv2011.0-1.x86_64.rpm on a Cauldron host.
Anne Nicolas 2012-03-08 11:43:37 CET

CC: (none) => ennael1

Manuel Hiebel 2012-03-08 12:22:49 CET

Assignee: bugsquad => tmb

Comment 3 Angelo Naselli 2012-03-10 16:08:16 CET
If that is the problem can we have an update of virtual box in mga1?
I seem i had this problem and now a kernel panic after updating.
I can boot with 3.2.6-desktop-0.rc1.1.mga2 kernel instead.

CC: (none) => anaselli

Comment 4 Angelo Naselli 2012-03-10 16:26:33 CET
Forget my comment. i booted with an old kernel and installed again new one and old guest addition, now boots.
Comment 5 luca pedrielli 2012-03-11 09:00:46 CET
Same problem with kernel-desktop-devel-3.3.0-0.rc7

CC: (none) => luca.pedrielli

Comment 6 William Murphy 2012-03-12 14:01:11 CET
It seems the drm_driver structure (used by vboxvideo) has been redefined in the 3.3 kernel.

the diff between the drmP.h (/include/drm) from kernel 3.2.9 (<) and 3.3.0.0.rc7 (>) is:

...
921c921
< 	struct file_operations fops;
---
> 	const struct file_operations *fops;
...

Apply this patch to vboxvideo_drm.c to fix it:

89,100d88
< #if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 3, 0)
< static struct file_operations hack_fops =
< {
<         .owner = THIS_MODULE,
<         .open = drm_open,
<         .release = drm_release,
<         .mmap = drm_mmap,
<         .poll = drm_poll,
<         .fasync = drm_fasync,
< };
< #endif
< 
112,114d99
< #if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 3, 0)
<     (const struct file_operations*) &hack_fops,
< #else
130d114
< #endif

Naming the structure 'hack_fops' might be a poor choice. :)
Comment 7 William Murphy 2012-03-12 15:19:24 CET
For clarity, the .fops structure has to refer a structure by constant pointer. The original code in vboxvideo_drm.c looks like:

...
static struct drm_driver driver =
{
    /* .driver_features = DRIVER_USE_MTRR, */
    .load = vboxvideo_driver_load,
    .reclaim_buffers = drm_core_reclaim_buffers,
    /* As of Linux 2.6.37, always the internal functions are used. */
#if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 37) && !defined(DRM_RHEL61)
    .get_map_ofs = drm_core_get_map_ofs,
    .get_reg_ofs = drm_core_get_reg_ofs,
#endif
    .fops =
    {
        .owner = THIS_MODULE,
        .open = drm_open,
        .release = drm_release,
        /* This was changed with Linux 2.6.33 but Fedora backported this
         * change to their 2.6.32 kernel. */
#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 33)
        .unlocked_ioctl = drm_ioctl,
#else
        .ioctl = drm_ioctl,
#endif
        .mmap = drm_mmap,
        .poll = drm_poll,
        .fasync = drm_fasync,
    },
...

I altered it to look like this:

...
#if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 3, 0)
static struct file_operations hack_fops =
{
        .owner = THIS_MODULE,
        .open = drm_open,
        .release = drm_release,
        .mmap = drm_mmap,
        .poll = drm_poll,
        .fasync = drm_fasync,
};
#endif

static struct drm_driver driver =
{
    /* .driver_features = DRIVER_USE_MTRR, */
    .load = vboxvideo_driver_load,
    .reclaim_buffers = drm_core_reclaim_buffers,
    /* As of Linux 2.6.37, always the internal functions are used. */
#if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 37) && !defined(DRM_RHEL61)
    .get_map_ofs = drm_core_get_map_ofs,
    .get_reg_ofs = drm_core_get_reg_ofs,
#endif
    .fops =
#if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 3, 0)
    (const struct file_operations*) &hack_fops,
#else
    {
        .owner = THIS_MODULE,
        .open = drm_open,
        .release = drm_release,
        /* This was changed with Linux 2.6.33 but Fedora backported this
         * change to their 2.6.32 kernel. */
#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 33)
        .unlocked_ioctl = drm_ioctl,
#else
        .ioctl = drm_ioctl,
#endif
        .mmap = drm_mmap,
        .poll = drm_poll,
        .fasync = drm_fasync,
    },
#endif
...

I hope that helps. It might need some cleaning up, but the modules compile.
Comment 8 William Murphy 2012-03-12 18:41:17 CET
I downloaded the src rpm and created a proper patch (finally) for virtualbox-4.1.8-3.mga2 The file_operations structure has been corrected. 

My vbox isn't set up for packaging (yet), so this hasn't been fully tested from build, but I manually build, installed and tested the modules before posting this patch:

From 1830e1c8a67fe345838fadc9f4744f972914a38a Mon Sep 17 00:00:00 2001
From: diogenese <fcs@velotech.net>
Date: Mon, 12 Mar 2012 08:23:59 -0700
Subject: [PATCH] * added kernel 3.3 support to drm_driver

---
 src/VBox/Additions/linux/drm/vboxvideo_drm.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vboxvideo_drm.c b/src/VBox/Additions/linux/drm/vboxvideo_drm.c
index b335f76..91bde06 100644
--- a/src/VBox/Additions/linux/drm/vboxvideo_drm.c
+++ b/src/VBox/Additions/linux/drm/vboxvideo_drm.c
@@ -86,6 +86,18 @@ int vboxvideo_driver_load(struct drm_device * dev, unsigned long flags)
 #endif
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 3, 0)
+static const struct file_operations hack_fops =
+{
+    .owner = THIS_MODULE,
+    .open = drm_open,
+    .release = drm_release,
+    .mmap = drm_mmap,
+    .poll = drm_poll,
+    .fasync = drm_fasync,
+};
+#endif
+
 static struct drm_driver driver =
 {
     /* .driver_features = DRIVER_USE_MTRR, */
@@ -97,6 +109,9 @@ static struct drm_driver driver =
     .get_reg_ofs = drm_core_get_reg_ofs,
 #endif
     .fops =
+#if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 3, 0)
+    &hack_fops,
+#else
     {
         .owner = THIS_MODULE,
         .open = drm_open,
@@ -112,6 +127,7 @@ static struct drm_driver driver =
         .poll = drm_poll,
         .fasync = drm_fasync,
     },
+#endif
 #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 39)
     .pci_driver =
     {
-- 
1.7.4.4
Comment 9 Thomas Backlund 2012-03-12 22:48:20 CET
a fixed virtualbox-4.1.8-4.mga2 is now available

Status: NEW => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.