Skip to content

Commit f794db6

Browse files
jwrdegoedegregkh
authored andcommitted
virt: vbox: Fix VBGL_IOCTL_VMMDEV_REQUEST_BIG and _LOG req numbers to match upstream
Until this commit the mainline kernel version (this version) of the vboxguest module contained a bug where it defined VBGL_IOCTL_VMMDEV_REQUEST_BIG and VBGL_IOCTL_LOG using _IOC(_IOC_READ | _IOC_WRITE, 'V', ...) instead of _IO(V, ...) as the out of tree VirtualBox upstream version does. Since the VirtualBox userspace bits are always built against VirtualBox upstream's headers, this means that so far the mainline kernel version of the vboxguest module has been failing these 2 ioctls with -ENOTTY. I guess that VBGL_IOCTL_VMMDEV_REQUEST_BIG is never used causing us to not hit that one and sofar the vboxguest driver has failed to actually log any log messages passed it through VBGL_IOCTL_LOG. This commit changes the VBGL_IOCTL_VMMDEV_REQUEST_BIG and VBGL_IOCTL_LOG defines to match the out of tree VirtualBox upstream vboxguest version, while keeping compatibility with the old wrong request defines so as to not break the kernel ABI in case someone has been using the old request defines. Fixes: f6ddd09 ("virt: Add vboxguest driver for Virtual Box Guest integration UAPI") Cc: [email protected] Acked-by: Arnd Bergmann <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bcf003b commit f794db6

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

drivers/virt/vboxguest/vboxguest_core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,8 @@ int vbg_core_ioctl(struct vbg_session *session, unsigned int req, void *data)
15201520

15211521
/* For VMMDEV_REQUEST hdr->type != VBG_IOCTL_HDR_TYPE_DEFAULT */
15221522
if (req_no_size == VBG_IOCTL_VMMDEV_REQUEST(0) ||
1523-
req == VBG_IOCTL_VMMDEV_REQUEST_BIG)
1523+
req == VBG_IOCTL_VMMDEV_REQUEST_BIG ||
1524+
req == VBG_IOCTL_VMMDEV_REQUEST_BIG_ALT)
15241525
return vbg_ioctl_vmmrequest(gdev, session, data);
15251526

15261527
if (hdr->type != VBG_IOCTL_HDR_TYPE_DEFAULT)
@@ -1558,6 +1559,7 @@ int vbg_core_ioctl(struct vbg_session *session, unsigned int req, void *data)
15581559
case VBG_IOCTL_HGCM_CALL(0):
15591560
return vbg_ioctl_hgcm_call(gdev, session, f32bit, data);
15601561
case VBG_IOCTL_LOG(0):
1562+
case VBG_IOCTL_LOG_ALT(0):
15611563
return vbg_ioctl_log(data);
15621564
}
15631565

drivers/virt/vboxguest/vboxguest_core.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
#include <linux/vboxguest.h>
1616
#include "vmmdev.h"
1717

18+
/*
19+
* The mainline kernel version (this version) of the vboxguest module
20+
* contained a bug where it defined VBGL_IOCTL_VMMDEV_REQUEST_BIG and
21+
* VBGL_IOCTL_LOG using _IOC(_IOC_READ | _IOC_WRITE, 'V', ...) instead
22+
* of _IO(V, ...) as the out of tree VirtualBox upstream version does.
23+
*
24+
* These _ALT definitions keep compatibility with the wrong defines the
25+
* mainline kernel version used for a while.
26+
* Note the VirtualBox userspace bits have always been built against
27+
* VirtualBox upstream's headers, so this is likely not necessary. But
28+
* we must never break our ABI so we keep these around to be 100% sure.
29+
*/
30+
#define VBG_IOCTL_VMMDEV_REQUEST_BIG_ALT _IOC(_IOC_READ | _IOC_WRITE, 'V', 3, 0)
31+
#define VBG_IOCTL_LOG_ALT(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 9, s)
32+
1833
struct vbg_session;
1934

2035
/** VBox guest memory balloon. */

drivers/virt/vboxguest/vboxguest_linux.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req,
131131
* the need for a bounce-buffer and another copy later on.
132132
*/
133133
is_vmmdev_req = (req & ~IOCSIZE_MASK) == VBG_IOCTL_VMMDEV_REQUEST(0) ||
134-
req == VBG_IOCTL_VMMDEV_REQUEST_BIG;
134+
req == VBG_IOCTL_VMMDEV_REQUEST_BIG ||
135+
req == VBG_IOCTL_VMMDEV_REQUEST_BIG_ALT;
135136

136137
if (is_vmmdev_req)
137138
buf = vbg_req_alloc(size, VBG_IOCTL_HDR_TYPE_DEFAULT,

include/uapi/linux/vboxguest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ VMMDEV_ASSERT_SIZE(vbg_ioctl_driver_version_info, 24 + 20);
103103

104104

105105
/* IOCTL to perform a VMM Device request larger then 1KB. */
106-
#define VBG_IOCTL_VMMDEV_REQUEST_BIG _IOC(_IOC_READ | _IOC_WRITE, 'V', 3, 0)
106+
#define VBG_IOCTL_VMMDEV_REQUEST_BIG _IO('V', 3)
107107

108108

109109
/** VBG_IOCTL_HGCM_CONNECT data structure. */
@@ -198,7 +198,7 @@ struct vbg_ioctl_log {
198198
} u;
199199
};
200200

201-
#define VBG_IOCTL_LOG(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 9, s)
201+
#define VBG_IOCTL_LOG(s) _IO('V', 9)
202202

203203

204204
/** VBG_IOCTL_WAIT_FOR_EVENTS data structure. */

0 commit comments

Comments
 (0)