commit f2a38807b48fc93eabe99218e0e82b4dcec13f99
Author: Sérgio M. Basto <sergio(a)serjux.com>
Date: Wed Jun 1 00:51:21 2022 +0100
Initial fix Windows 10 VM crashes with Linux 5.18 kernel
https://www.virtualbox.org/ticket/20914
- added new vbox-python-selection.patch from OpenSuse
- use pkgconfig(sdl) as OpenSuse
VirtualBox.spec | 12 +-
vbox-linux-5.18.patch | 285 ++++++++++++++++++++++++++++++++++++++++++++
vbox-python-detection.diff | 51 --------
vbox-python-selection.patch | 98 +++++++++++++++
4 files changed, 392 insertions(+), 54 deletions(-)
---
diff --git a/VirtualBox.spec b/VirtualBox.spec
index 97974fe..61dcac8 100644
--- a/VirtualBox.spec
+++ b/VirtualBox.spec
@@ -39,7 +39,7 @@
Name: VirtualBox
Version: 6.1.34
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: A general-purpose full virtualizer for PC hardware
License: GPLv2 or (GPLv2 and CDDL)
@@ -68,6 +68,7 @@ Source24: os_mageia_x3.png
Source25: os_mageia_64_x3.png
Source26: os_mageia_x4.png
Source27: os_mageia_64_x4.png
+
Patch1: VirtualBox-6.0.0-noupdate.patch
Patch2: VirtualBox-6.1.0-strings.patch
Patch3: VirtualBox-6.0.0-default-to-Fedora.patch
@@ -86,7 +87,7 @@ Patch52: VirtualBox-6.0.10-convert-map-python3.patch
# a systemd service, this works with both Wayland and Xorg based sessions
Patch60: VirtualBox-5.2.10-xclient.patch
# from OpenSuse
-Patch70: vbox-python-detection.diff
+Patch70: vbox-python-selection.patch
Patch71: fixes_for_Qt5.11to15.patch
Patch72: virtualbox-snpritnf-buffer-overflow.patch
Patch73: vb-6.1.16-modal-dialog-parent.patch
@@ -96,10 +97,11 @@ Patch81: ffreestanding.patch
Patch88: VirtualBox-lzf.patch
Patch90: 0001-libs-xpcom-Added-support-for-running-with-Python-3.1.patch
Patch91: 0002-no_ifndef.patch
+Patch92: vbox-linux-5.18.patch
BuildRequires: gcc-c++
BuildRequires: kBuild >= 0.1.9998.r3093
-BuildRequires: SDL-devel
+BuildRequires: pkgconfig(sdl)
BuildRequires: openssl-devel
BuildRequires: libcurl-devel
BuildRequires: iasl
@@ -347,6 +349,7 @@ rm -r src/libs/zlib-1.2.*/
%patch88 -p1 -b .lzf
%patch90 -p2 -b .python3.10
%patch91 -p1 -b .python3.10
+%patch92 -p0 -b .linux-5.18
%build
@@ -903,6 +906,9 @@ getent passwd vboxadd >/dev/null || \
%{_datadir}/%{name}-kmod-%{version}
%changelog
+* Tue May 31 2022 Sérgio Basto <sergio(a)serjux.com> - 6.1.34-3
+- Initial fix Windows 10 VM crashes with Linux 5.18 kernel
+
* Mon Apr 25 2022 Sérgio Basto <sergio(a)serjux.com> - 6.1.34-2
- Fix for rfbz #6287 (won't launch any VM)
diff --git a/vbox-linux-5.18.patch b/vbox-linux-5.18.patch
new file mode 100644
index 0000000..8e77274
--- /dev/null
+++ b/vbox-linux-5.18.patch
@@ -0,0 +1,285 @@
+Index: include/VBox/sup.h
+===================================================================
+--- include/VBox/sup.h (revision 151556)
++++ include/VBox/sup.h (working copy)
+@@ -2142,6 +2142,26 @@
+ */
+ SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void);
+
++/**
++ * Notification from R0 VMM prior to loading the guest-FPU register state.
++ *
++ * @returns Whether the host-FPU register state has been saved by the host kernel.
++ * @param fCtxHook Whether thread-context hooks are enabled.
++ *
++ * @remarks Called with preemption disabled.
++ */
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook);
++
++/**
++ * Notification from R0 VMM prior to saving the guest-FPU register state (and
++ * potentially restoring the host-FPU register state) in ring-0.
++ *
++ * @param fCtxHook Whether thread-context hooks are enabled.
++ *
++ * @remarks Called with preemption disabled.
++ */
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook);
++
+ /** @copydoc RTLogGetDefaultInstanceEx
+ * @remarks To allow overriding RTLogGetDefaultInstanceEx locally. */
+ SUPR0DECL(struct RTLOGGER *) SUPR0GetDefaultLogInstanceEx(uint32_t fFlagsAndGroup);
+Index: src/VBox/Additions/linux/sharedfolders/regops.c
+===================================================================
+--- src/VBox/Additions/linux/sharedfolders/regops.c (revision 151556)
++++ src/VBox/Additions/linux/sharedfolders/regops.c (working copy)
+@@ -3823,7 +3823,9 @@
+ .readpage = vbsf_readpage,
+ .writepage = vbsf_writepage,
+ /** @todo Need .writepages if we want msync performance... */
+-#if RTLNX_VER_MIN(2,5,12)
++#if RTLNX_VER_MIN(5,18,0)
++ .dirty_folio = filemap_dirty_folio,
++#elif RTLNX_VER_MIN(2,5,12)
+ .set_page_dirty = __set_page_dirty_buffers,
+ #endif
+ #if RTLNX_VER_MIN(5,14,0)
+Index: src/VBox/Additions
+===================================================================
+--- src/VBox/Additions (revision 151556)
++++ src/VBox/Additions (working copy)
+
+Property changes on: src/VBox/Additions
+___________________________________________________________________
+Modified: svn:mergeinfo
+## -0,0 +0,1 ##
+ Merged /trunk/src/VBox/Additions:r150844
+Index: src/VBox/HostDrivers/Support/SUPDrv.cpp
+===================================================================
+--- src/VBox/HostDrivers/Support/SUPDrv.cpp (revision 151556)
++++ src/VBox/HostDrivers/Support/SUPDrv.cpp (working copy)
+@@ -98,6 +98,18 @@
+ # endif
+ #endif
+
++#if defined(RT_OS_LINUX) && !defined(__NO_FORTIFY) &&
defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
++/* In Linux 5.18-rc1, memcpy became a wrapper which does fortify checks
++ * before triggering __underlying_memcpy() call. We do not pass these checks here,
++ * so bypass them for now. */
++# if RTLNX_VER_MIN(5,18,0)
++# define SUPDRV_MEMCPY __underlying_memcpy
++# else
++# define SUPDRV_MEMCPY memcpy
++# endif
++#else
++# define SUPDRV_MEMCPY memcpy
++#endif
+
+ /*
+ * Logging assignments:
+@@ -266,6 +278,8 @@
+ SUPEXP_STK_BACK( 2, SUPR0ContFree),
+ SUPEXP_STK_BACK( 2, SUPR0ChangeCR4),
+ SUPEXP_STK_BACK( 1, SUPR0EnableVTx),
++ SUPEXP_STK_OKAY( 1, SUPR0FpuBegin),
++ SUPEXP_STK_OKAY( 1, SUPR0FpuEnd),
+ SUPEXP_STK_BACK( 0, SUPR0SuspendVTxOnCpu),
+ SUPEXP_STK_BACK( 1, SUPR0ResumeVTxOnCpu),
+ SUPEXP_STK_OKAY( 1, SUPR0GetCurrentGdtRw),
+@@ -1742,7 +1756,7 @@
+
+ /* execute */
+ pReq->u.Out.cFunctions = RT_ELEMENTS(g_aFunctions);
+- memcpy(&pReq->u.Out.aFunctions[0], g_aFunctions,
sizeof(g_aFunctions));
++ SUPDRV_MEMCPY(&pReq->u.Out.aFunctions[0], g_aFunctions,
sizeof(g_aFunctions));
+ pReq->Hdr.rc = VINF_SUCCESS;
+ return 0;
+ }
+Index: src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
+===================================================================
+--- src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp (revision 151556)
++++ src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp (working copy)
+@@ -2002,6 +2002,18 @@
+ }
+
+
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++ return false;
++}
++
++
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++}
++
+ /*
+ *
+ * org_virtualbox_SupDrv
+Index: src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
+===================================================================
+--- src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c (revision 151556)
++++ src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c (working copy)
+@@ -640,3 +640,16 @@
+ return 0;
+ }
+
++
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++ return false;
++}
++
++
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++}
++
+Index: src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
+===================================================================
+--- src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (revision 151556)
++++ src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (working copy)
+@@ -1454,6 +1454,31 @@
+ }
+
+
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++#if RTLNX_VER_MIN(5,18,0)
++ kernel_fpu_begin();
++ /* if (fCtxHook) */
++ preempt_enable(); /* HACK ALERT! undo the implicit preempt_disable() in
kernel_fpu_begin(). */
++ return true;
++#else
++ return false;
++#endif
++}
++
++
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++#if RTLNX_VER_MIN(5,18,0)
++ /* if (fCtxHook) */
++ preempt_disable(); /* HACK ALERT! undo the implicit preempt_enable() in
SUPR0FpuBegin(). */
++ kernel_fpu_end();
++#endif
++}
++
++
+ int VBOXCALL supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw)
+ {
+ #if RTLNX_VER_MIN(4,12,0)
+Index: src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
+===================================================================
+--- src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp (revision 151556)
++++ src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp (working copy)
+@@ -541,3 +541,16 @@
+ return 0;
+ }
+
++
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++ return false;
++}
++
++
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++}
++
+Index: src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
+===================================================================
+--- src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c (revision 151556)
++++ src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c (working copy)
+@@ -1309,3 +1309,16 @@
+ return 0;
+ }
+
++
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++ return false;
++}
++
++
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++}
++
+Index: src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
+===================================================================
+--- src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp (revision 151556)
++++ src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp (working copy)
+@@ -2704,6 +2704,19 @@
+ }
+
+
++SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++ return false;
++}
++
++
++SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
++{
++ RT_NOREF(fCtxHook);
++}
++
++
+ SUPR0DECL(int) SUPR0IoCtlSetupForHandle(PSUPDRVSESSION pSession, intptr_t hHandle,
uint32_t fFlags, PSUPR0IOCTLCTX *ppCtx)
+ {
+ /*
+Index: src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
+===================================================================
+--- src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c (revision 151556)
++++ src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c (working copy)
+@@ -2311,7 +2311,13 @@
+ vboxNetFltDumpPacket(pSG, true, "host", (fDst &
INTNETTRUNKDIR_WIRE) ? 0 : 1);
+ Log6(("vboxNetFltPortOsXmit: pBuf->cb dump:\n%.*Rhxd\n",
sizeof(pBuf->cb), pBuf->cb));
+ Log6(("vboxNetFltPortOsXmit: netif_rx_ni(%p)\n", pBuf));
++#if RTLNX_VER_MIN(5,18,0)
++ local_bh_disable();
++ err = netif_rx(pBuf);
++ local_bh_enable();
++#else
+ err = netif_rx_ni(pBuf);
++#endif
+ if (err)
+ rc = RTErrConvertFromErrno(err);
+ }
+Index: src/VBox/VMM/VMMR0/CPUMR0.cpp
+===================================================================
+--- src/VBox/VMM/VMMR0/CPUMR0.cpp (revision 151556)
++++ src/VBox/VMM/VMMR0/CPUMR0.cpp (working copy)
+@@ -440,6 +440,9 @@
+ Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST));
+ Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_SYNC_FPU_STATE));
+
++ /* Notify the support driver prior to loading the guest-FPU register state. */
++ SUPR0FpuBegin(false /* unused */);
++
+ if (!pVM->cpum.s.HostFeatures.fLeakyFxSR)
+ {
+ Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_USED_MANUAL_XMM_RESTORE));
+@@ -484,6 +487,9 @@
+ Assert(ASMGetCR4() & X86_CR4_OSFXSR);
+ if (pVCpu->cpum.s.fUseFlags & (CPUM_USED_FPU_GUEST | CPUM_USED_FPU_HOST))
+ {
++ /* Notify the support driver prior to loading the host-FPU register state. */
++ SUPR0FpuEnd(false /* unused */);
++
+ fSavedGuest = RT_BOOL(pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST);
+ if (!(pVCpu->cpum.s.fUseFlags & CPUM_USED_MANUAL_XMM_RESTORE))
+ cpumR0SaveGuestRestoreHostFPUState(&pVCpu->cpum.s);
diff --git a/vbox-python-selection.patch b/vbox-python-selection.patch
new file mode 100644
index 0000000..fa187d0
--- /dev/null
+++ b/vbox-python-selection.patch
@@ -0,0 +1,98 @@
+--- VirtualBox-6.1.34.orig/src/bldprogs/scm.cpp
++++ VirtualBox-6.1.34/src/bldprogs/scm.cpp
+@@ -2206,7 +2206,7 @@ static int scmProcessFileInner(PSCMRWSTA
+ pszTreatAs = "shell";
+ else if ( (cchFirst >= 15 && strncmp(pchFirst,
"/usr/bin/python", 15) == 0)
+ || (cchFirst >= 19 && strncmp(pchFirst,
"/usr/bin/env python", 19) == 0) )
+- pszTreatAs = "python";
++ pszTreatAs = "python3";
+ else if ( (cchFirst >= 13 && strncmp(pchFirst,
"/usr/bin/perl", 13) == 0)
+ || (cchFirst >= 17 && strncmp(pchFirst,
"/usr/bin/env perl", 17) == 0) )
+ pszTreatAs = "perl";
+--- VirtualBox-6.1.34.orig/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
++++ VirtualBox-6.1.34/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
+@@ -22,6 +22,9 @@
+ %define VBOXDOCDIR %{_defaultdocdir}/%NAME%
+ %global __requires_exclude_from
^/usr/lib/virtualbox/VBoxPython.*$|^/usr/lib/python.*$|^.*\\.py$
+ %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from
distutils.sysconfig import get_python_lib; print(get_python_lib())")}
++# SUSE defines these in python-rpm-macros, not necessarily available here
++%{!?__python3:%{_bindir}/python3}}
++%{!?python3_sitelib: %define python_sitelib python3 -c "import sysconfig as s;
print(s.get_paths().get('purelib'))"}
+
+ Summary: Oracle VM VirtualBox
+ Name: %NAME%
+--- VirtualBox-6.1.34.orig/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
++++ VirtualBox-6.1.34/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
+@@ -439,6 +439,8 @@ char *PyTraceback_AsString(PyObject *exc
+ { // a temp scope so I can use temp locals.
+ #if PY_MAJOR_VERSION <= 2
+ char *tempResult = PyString_AsString(obResult);
++#elif PY_MINOR_VERSION <= 6
++ char *tempResult = PyUnicode_AsUTF8(obResult);
+ #else
+ /* PyUnicode_AsUTF8() is const char * as of Python 3.7, char * earlier. */
+ const char *tempResult = (const char *)PyUnicode_AsUTF8(obResult);
+--- VirtualBox-6.1.34.orig/src/libs/xpcom18a4/python/src/PyGBase.cpp
++++ VirtualBox-6.1.34/src/libs/xpcom18a4/python/src/PyGBase.cpp
+@@ -183,7 +183,11 @@ PyG_Base::~PyG_Base()
+ // Get the correct interface pointer for this object given the IID.
+ void *PyG_Base::ThisAsIID( const nsIID &iid )
+ {
+- if (this==NULL) return NULL;
++#if PY_MINOR_VERSION <= 6
++ if (!this) return NULL;
++#else
++ if (!this) return NULL;
++#endif
+ if (iid.Equals(NS_GET_IID(nsISupports)))
+ return (nsISupports *)(nsIInternalPython *)this;
+ if (iid.Equals(NS_GET_IID(nsISupportsWeakReference)))
+--- VirtualBox-6.1.34.orig/src/libs/xpcom18a4/python/gen_python_deps.py
++++ VirtualBox-6.1.34/src/libs/xpcom18a4/python/gen_python_deps.py
+@@ -86,7 +86,7 @@ def main(argv):
+ else:
+ multi = 1
+
+- if multi == 0:
++ if not multi:
+ prefixes = ["/usr"]
+ versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1]),
+
str(sys.version_info[0])+'.'+str(sys.version_info[1])+'m']
+@@ -114,24 +114,25 @@ def main(argv):
+ continue
+ for p in prefixes:
+ c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
+- if c is not None:
++ if c:
+ known[v] = c
+ break
+- keys = list(known.keys())
+- # we want default to be the lowest versioned Python
+- keys.sort()
+- d = None
+ # We need separator other than newline, to sneak through $(shell)
+ sep = "|"
+- for k in keys:
+- if d is None:
+- d = k
+- vers = k.replace('.', '').upper()
+- print_vars(vers, known[k], sep, bitness_magic)
+- if d is not None:
+- print_vars("DEF", known[d], sep, bitness_magic)
++
++ if not known:
++ # this type of problem should be detected in configure
++ # print_vars("DEF", defaultpaths, sep, bitness_magic)
++ pass
+ else:
+ print(argv[0] + ": No Python development package found!",
file=sys.stderr)
++ if multi:
++ for ver, paths in known.items():
++ print_vars(ver.replace('.', '').upper(), paths, sep,
bitness_magic)
++ else:
++ ver = versions[0]
++ paths = known[ver]
++ print_vars(ver.replace('.', ''), paths, sep, bitness_magic)
+
+ if __name__ == '__main__':
+ main(sys.argv)