History

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.

Hans de Goede committed 6 years ago

Commit f794db61 parent bcf003b4 files · +22 −4Browse files

Unified · Split

4 files
  1. drivers/virt/vboxguest/vboxguest_core.c +3 −1
  2. drivers/virt/vboxguest/vboxguest_core.h +15 −0
  3. drivers/virt/vboxguest/vboxguest_linux.c +2 −1
  4. include/uapi/linux/vboxguest.h +2 −2
drivers/virt/vboxguest/vboxguest_core.c+3−1
@@ -1520,7 +1520,8 @@ int vbg_core_ioctl(struct vbg_session *session, unsigned int req, void *data) · 1519 unmodified lines
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) · 31 unmodified lines
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+15−0
@@ -15,6 +15,21 @@ · 14 unmodified lines
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+2−1
@@ -131,7 +131,8 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req, · 130 unmodified lines
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+2−2
@@ -103,7 +103,7 @@ VMMDEV_ASSERT_SIZE(vbg_ioctl_driver_version_info, 24 + 20); · 102 unmodified lines
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 { · 88 unmodified lines
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. */