1
0
forked from pool/virtualbox

- Update fixes_for_kernel_5.18.patch to save and restore FPU status during interrupt.

The change fixes boo#1199803.

- A requirement for sysvinit was inadvertently left when VB was converted to a systemd service. This pulls
  in packages that are not needed.

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virtualbox?expand=0&rev=639
This commit is contained in:
Larry Finger 2022-05-27 23:33:15 +00:00 committed by Git OBS Bridge
parent 85da96c788
commit 1d9fb23722
3 changed files with 239 additions and 13 deletions

View File

@ -20,19 +20,41 @@ Index: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/SUPDrv.cpp
=================================================================== ===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/SUPDrv.cpp --- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/SUPDrv.cpp
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/SUPDrv.cpp +++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/SUPDrv.cpp
@@ -1742,7 +1742,15 @@ static int supdrvIOCtlInnerUnrestricted( @@ -98,7 +98,18 @@
# endif
#endif
/* execute */ -
pReq->u.Out.cFunctions = RT_ELEMENTS(g_aFunctions); +#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
+ /* In 5.18.0, memcpy became a wrapper which does fortify checks
+ * before triggering __underlying_memcpy() call. We do not pass these checks here, + * before triggering __underlying_memcpy() call. We do not pass these checks here,
+ * so bypass them for now. */ + * so bypass them for now. */
+# if RTLNX_VER_MIN(5,18,0) +# if RTLNX_VER_MIN(5,18,0)
+ __underlying_memcpy(&pReq->u.Out.aFunctions[0], g_aFunctions, sizeof(g_aFunctions)); +# define SUPDRV_MEMCPY __underlying_memcpy
+# else +# else
memcpy(&pReq->u.Out.aFunctions[0], g_aFunctions, sizeof(g_aFunctions)); +# define SUPDRV_MEMCPY memcpy
+# endif +# endif
+#else
+# define SUPDRV_MEMCPY memcpy
+#endif
/*
* Logging assignments:
* Log - useful stuff, like failures.
@@ -267,6 +278,8 @@ static SUPFUNC g_aFunctions[] =
SUPEXP_STK_BACK( 2, SUPR0ChangeCR4),
SUPEXP_STK_BACK( 1, SUPR0EnableVTx),
SUPEXP_STK_BACK( 0, SUPR0SuspendVTxOnCpu),
+ SUPEXP_STK_OKAY( 1, SUPR0FpuBegin),
+ SUPEXP_STK_OKAY( 1, SUPR0FpuEnd),
SUPEXP_STK_BACK( 1, SUPR0ResumeVTxOnCpu),
SUPEXP_STK_OKAY( 1, SUPR0GetCurrentGdtRw),
SUPEXP_STK_OKAY( 0, SUPR0GetKernelFeatures),
@@ -1742,7 +1755,7 @@ static int supdrvIOCtlInnerUnrestricted(
/* 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; pReq->Hdr.rc = VINF_SUCCESS;
return 0; return 0;
} }
@ -84,4 +106,195 @@ Index: VirtualBox-6.1.34/Config.kmk
TEMPLATE_VBoxR0_CFLAGS.amd64 = -m64 -mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fasynchronous-unwind-tables -ffreestanding TEMPLATE_VBoxR0_CFLAGS.amd64 = -m64 -mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fasynchronous-unwind-tables -ffreestanding
TEMPLATE_VBoxR0_CXXFLAGS.amd64 = -m64 -mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fasynchronous-unwind-tables TEMPLATE_VBoxR0_CXXFLAGS.amd64 = -m64 -mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fasynchronous-unwind-tables
TEMPLATE_VBoxR0_CXXFLAGS.freebsd = -ffreestanding TEMPLATE_VBoxR0_CXXFLAGS.freebsd = -ffreestanding
Index: VirtualBox-6.1.34/include/VBox/sup.h
===================================================================
--- VirtualBox-6.1.34.orig/include/VBox/sup.h
+++ VirtualBox-6.1.34/include/VBox/sup.h
@@ -2142,7 +2142,25 @@ RT_IPRT_FORMAT_ATTR(1, 2) SUPR0Printf(co
*/
SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void);
-/** @copydoc RTLogGetDefaultInstanceEx
+/**
+ * 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);
/** @copydoc RTLogRelGetDefaultInstanceEx
Index: VirtualBox-6.1.34/src/VBox/VMM/VMMR0/CPUMR0.cpp
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/VMM/VMMR0/CPUMR0.cpp
+++ VirtualBox-6.1.34/src/VBox/VMM/VMMR0/CPUMR0.cpp
@@ -440,6 +440,8 @@ VMMR0_INT_DECL(int) CPUMR0LoadGuestFPU(P
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));
@@ -485,6 +487,8 @@ VMMR0_INT_DECL(bool) CPUMR0FpuStateMaybe
if (pVCpu->cpum.s.fUseFlags & (CPUM_USED_FPU_GUEST | CPUM_USED_FPU_HOST))
{
fSavedGuest = RT_BOOL(pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST);
+ /* Notify the support driver prior to loading the host-FPU register state. */
+ SUPR0FpuEnd(false /* unused */);
if (!(pVCpu->cpum.s.fUseFlags & CPUM_USED_MANUAL_XMM_RESTORE))
cpumR0SaveGuestRestoreHostFPUState(&pVCpu->cpum.s);
else
Index: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
@@ -2002,6 +2002,17 @@ SUPR0DECL(uint32_t) SUPR0GetKernelFeatur
}
+SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+ return false;
+}
+
+
+SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+}
/*
*
* org_virtualbox_SupDrv
Index: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
@@ -640,3 +640,15 @@ SUPR0DECL(uint32_t) SUPR0GetKernelFeatur
return 0;
}
+SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+ return false;
+}
+
+
+SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+}
+
Index: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
@@ -541,3 +541,15 @@ SUPR0DECL(uint32_t) SUPR0GetKernelFeatur
return 0;
}
+SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+ return false;
+}
+
+
+SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+}
+
Index: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
@@ -2703,6 +2703,16 @@ SUPR0DECL(uint32_t) SUPR0GetKernelFeatur
return 0;
}
+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: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
@@ -1309,3 +1309,15 @@ SUPR0DECL(uint32_t) SUPR0GetKernelFeatur
return 0;
}
+SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+ return false;
+}
+
+
+SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
+{
+ RT_NOREF(fCtxHook);
+}
+
Index: VirtualBox-6.1.34/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
===================================================================
--- VirtualBox-6.1.34.orig/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
+++ VirtualBox-6.1.34/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
@@ -1454,6 +1454,31 @@ SUPR0DECL(uint32_t) SUPR0GetKernelFeatur
}
+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)

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri May 27 22:27:02 UTC 2022 - Larry Finger <Larry.Finger@gmail.com>
- Update fixes_for_kernel_5.18.patch to save and restore FPU status during interrupt.
The change fixes boo#1199803.
------------------------------------------------------------------- -------------------------------------------------------------------
Sat May 21 20:17:00 UTC 2022 - Ben Greiner <code@bnavigator.de> Sat May 21 20:17:00 UTC 2022 - Ben Greiner <code@bnavigator.de>

View File

@ -170,7 +170,6 @@ Patch142: fixes_for_leap15.3.patch
Patch143: vb-6.1.16-modal-dialog-parent.patch Patch143: vb-6.1.16-modal-dialog-parent.patch
Patch144: fixes_for_leap15.4.patch Patch144: fixes_for_leap15.4.patch
Patch145: fixes_for_kernel_5.18.patch Patch145: fixes_for_kernel_5.18.patch
#Patch998: fix_warnings.patch
Patch999: virtualbox-fix-ui-background-color.patch Patch999: virtualbox-fix-ui-background-color.patch
# #
# Common BuildRequires for both virtualbox and virtualbox-kmp # Common BuildRequires for both virtualbox and virtualbox-kmp
@ -296,6 +295,7 @@ the terms of the GNU Public License (GPL).
########################################## ##########################################
%package qt %package qt
Summary: Qt GUI part for %{name} Summary: Qt GUI part for %{name}
Group: System/Emulators/PC Group: System/Emulators/PC
@ -314,6 +314,7 @@ This package contains the code for the GUI used to control VMs.
######################################### #########################################
%package websrv %package websrv
Summary: WebService GUI part for %{name} Summary: WebService GUI part for %{name}
Group: System/Emulators/PC Group: System/Emulators/PC
@ -327,6 +328,7 @@ The VirtualBox web server is used to control headless VMs using a browser.
######################################### #########################################
%package guest-x11 %package guest-x11
Summary: VirtualBox X11 drivers for mouse and video Summary: VirtualBox X11 drivers for mouse and video
Group: System/X11/Servers/XF86_4 Group: System/X11/Servers/XF86_4
@ -342,6 +344,7 @@ This package contains X11 guest utilities and X11 guest mouse and video drivers
########################################### ###########################################
%package guest-tools %package guest-tools
Summary: VirtualBox guest tools Summary: VirtualBox guest tools
Group: System/Emulators/PC Group: System/Emulators/PC
@ -361,6 +364,7 @@ VirtualBox guest addition tools.
########################################### ###########################################
%package -n python3-%{name} %package -n python3-%{name}
Summary: Python bindings for %{name} Summary: Python bindings for %{name}
Group: Development/Libraries/Python Group: Development/Libraries/Python
@ -380,6 +384,7 @@ Python XPCOM bindings to %{name}. Used e.g. by vboxgtk package.
########################################### ###########################################
%package devel %package devel
Summary: Devel files for %{name} Summary: Devel files for %{name}
Group: Development/Libraries/Other Group: Development/Libraries/Other
@ -394,6 +399,7 @@ Development file for %{name}
########################################### ###########################################
%package host-source %package host-source
Summary: Source files for %{name} host kernel modules Summary: Source files for %{name} host kernel modules
Group: Development/Sources Group: Development/Sources
@ -425,6 +431,7 @@ sudo %{_sbindir}/vboxguestconfig
########################################### ###########################################
%package guest-desktop-icons %package guest-desktop-icons
Summary: Icons for guest desktop files Summary: Icons for guest desktop files
Group: System/Emulators/PC Group: System/Emulators/PC
@ -437,6 +444,7 @@ This package contains icons for guest desktop files that were created on the des
########################################### ###########################################
%package vnc %package vnc
Summary: VNC desktop sharing Summary: VNC desktop sharing
Group: System/Emulators/PC Group: System/Emulators/PC
@ -513,7 +521,6 @@ This package contains the kernel-modules that VirtualBox uses to create or run v
%endif %endif
%patch143 -p1 %patch143 -p1
%patch145 -p1 %patch145 -p1
#%patch998 -p1
# make VB UI background colors look sane again # make VB UI background colors look sane again
%patch999 -p1 %patch999 -p1