virtualbox/fixes_for_6.5.patch
Larry Finger 124dddfd6b Accepting request 1104707 from home:lwfinger:branches:Virtualization
- An additional fix was needed to handle flexible arrays in kernel 6.5+.
  A fix was made for breakage of kernels 6.4.10+ boo#1212761 and boo#1214391.
  Note that the change in 6.4 missed an internal include that is present
  in kernel 6.5.

OBS-URL: https://build.opensuse.org/request/show/1104707
OBS-URL: https://build.opensuse.org/package/show/Virtualization/virtualbox?expand=0&rev=707
2023-08-18 18:25:00 +00:00

119 lines
3.9 KiB
Diff

Index: VirtualBox-7.0.10/src/VBox/Additions/linux/drm/vbox_fb.c
===================================================================
--- VirtualBox-7.0.10.orig/src/VBox/Additions/linux/drm/vbox_fb.c
+++ VirtualBox-7.0.10/src/VBox/Additions/linux/drm/vbox_fb.c
@@ -197,9 +197,13 @@ static struct fb_ops vboxfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
+#if RTLNX_VER_MIN(6, 5, 0)
+ FB_DEFAULT_SYS_OPS,
+#else
.fb_fillrect = drm_fb_helper_sys_fillrect,
.fb_copyarea = drm_fb_helper_sys_copyarea,
.fb_imageblit = drm_fb_helper_sys_imageblit,
+#endif
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
Index: VirtualBox-7.0.10/include/iprt/cdefs.h
===================================================================
--- VirtualBox-7.0.10.orig/include/iprt/cdefs.h
+++ VirtualBox-7.0.10/include/iprt/cdefs.h
@@ -38,8 +38,9 @@
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
-
-
+#if defined(DECLARE_FLEX_ARRAY)
+# include <linux/version.h>
+#endif
/** @defgroup grp_rt_cdefs IPRT Common Definitions and Macros
* @{
*/
@@ -2961,6 +2962,12 @@
* @note GCC does not permit using this in nested structures, where as MSC
* does. So, use RT_FLEXIBLE_ARRAY_NESTED for that.
*
+ * @note Linux kernels 6.5+ enforce field-spanning write operations
+ * and require flexible arrays to end with 'array[]' rather than array[1].
+ * This construct fails with unions, but VB does not have any such unions.
+ * This header is used with both kernel- and user-mode code. In user-mode,
+ * the old method works. If DECLARE_FLEX_ARRAY is defined, we are
+ * building kernel-mode code and RT_FLEXIBLE_ARRAY is set to blank.
* @sa RT_FLEXIBLE_ARRAY_NESTED, RT_FLEXIBLE_ARRAY_IN_UNION
*/
#if RT_MSC_PREREQ(RT_MSC_VER_VS2005) /** @todo Probably much much earlier. */ \
@@ -2976,10 +2983,18 @@
# if __STDC_VERSION__ >= 1999901L
# define RT_FLEXIBLE_ARRAY
# else
-# define RT_FLEXIBLE_ARRAY 1
+# if defined(DECLARE_FLEX_ARRAY)
+# define RT_FLEXIBLE_ARRAY
+# else
+# define RT_FLEXIBLE_ARRAY 1
+# endif
# endif
#else
+# if defined(DECLARE_FLEX_ARRAY)
+# define RT_FLEXIBLE_ARRAY
+# else
# define RT_FLEXIBLE_ARRAY 1
+# endif
#endif
/** @def RT_FLEXIBLE_ARRAY_EXTENSION
@@ -3008,7 +3023,9 @@
#ifdef _MSC_VER
# define RT_FLEXIBLE_ARRAY_NESTED RT_FLEXIBLE_ARRAY
#else
+# if !defined(DECLARE_FLEX_ARRAY)
# define RT_FLEXIBLE_ARRAY_NESTED 1
+# endif
#endif
/** @def RT_FLEXIBLE_ARRAY_IN_UNION
@@ -3024,7 +3041,9 @@
#ifdef _MSC_VER
# define RT_FLEXIBLE_ARRAY_IN_UNION RT_FLEXIBLE_ARRAY
#else
-# define RT_FLEXIBLE_ARRAY_IN_UNION 1
+# if !defined(DECLARE_FLEX_ARRAY)
+# define RT_FLEXIBLE_ARRAY_IN_UNION 1
+# endif
#endif
/** @def RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
@@ -3037,7 +3056,9 @@
#ifdef _MSC_VER
# define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION RT_FLEXIBLE_ARRAY_NESTED
#else
-# define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION 1
+# if !defined(DECLARE_FLEX_ARRAY)
+# define RT_FLEXIBLE_ARRAY_IN_NESTED_UNION 1
+# endif
#endif
/** @def RT_UNION_NM
Index: VirtualBox-7.0.10/include/VBox/VBoxGuest.h
===================================================================
--- VirtualBox-7.0.10.orig/include/VBox/VBoxGuest.h
+++ VirtualBox-7.0.10/include/VBox/VBoxGuest.h
@@ -458,8 +458,12 @@ typedef struct VBGLIOCLOG
{
/** The log message.
* The length is determined from the input size and zero termination. */
- char szMsg[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
- } In;
+#if defined(DECLARE_FLEX_ARRAY)
+ DECLARE_FLEX_ARRAY(char, szMsg);
+#else
+ char szMsg[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
+#endif
+ } In;
} u;
} VBGLIOCLOG, RT_FAR *PVBGLIOCLOG;
/** @} */