1
0
forked from pool/virtualbox

Accepting request 814599 from Virtualization

OBS-URL: https://build.opensuse.org/request/show/814599
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/virtualbox?expand=0&rev=200
This commit is contained in:
Dominique Leuenberger 2020-06-22 15:41:10 +00:00 committed by Git OBS Bridge
commit 4f6e07d896
4 changed files with 271 additions and 24 deletions

236
fixes_for_5.8.patch Normal file
View File

@ -0,0 +1,236 @@
Fixes needed to build vboxdrv with kernel 5.8. The changes handle the following kernel API changes:
1. In struct mm_struct, member mmap_sem was renamed to mmap_lock.
2. The information in cpu_tlbstate is no longer exported.
3. The routines __get_vm_area() and map_vm_area() no longer exist and their
replacements are not exported. Two fixes have been attempted:
a. The missing routines were not available until kernel 2.6.23, thus the code was
changed to revert back to the "old" method. Unfortunately, this did not work, and
likely it will require Oracle to make the changes.
b. The replacements for __get_vm_area() and map_vm_area() are implemented. The resulting
code builds but gets missing globals on loading. For testing, the kernel is modified.
This change cannot be permanent, but it can be temporary.
Index: VirtualBox-6.1.10/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
===================================================================
--- VirtualBox-6.1.10.orig/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
+++ VirtualBox-6.1.10/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
@@ -222,9 +222,17 @@ static void *rtR0MemObjLinuxDoMmap(RTR3P
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
ulAddr = vm_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
down_write(&pTask->mm->mmap_sem);
+#else
+ down_write(&pTask->mm->mmap_lock);
+#endif
ulAddr = do_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
up_write(&pTask->mm->mmap_sem);
+#else
+ up_write(&pTask->mm->mmap_lock);
+#endif
#endif
}
else
@@ -232,9 +240,17 @@ static void *rtR0MemObjLinuxDoMmap(RTR3P
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
ulAddr = vm_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
down_write(&pTask->mm->mmap_sem);
+#else
+ down_write(&pTask->mm->mmap_lock);
+#endif
ulAddr = do_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
up_write(&pTask->mm->mmap_sem);
+#else
+ up_write(&pTask->mm->mmap_lock);
+#endif
#endif
if ( !(ulAddr & ~PAGE_MASK)
&& (ulAddr & (uAlignment - 1)))
@@ -269,13 +285,29 @@ static void rtR0MemObjLinuxDoMunmap(void
Assert(pTask == current); RT_NOREF_PV(pTask);
vm_munmap((unsigned long)pv, cb);
#elif defined(USE_RHEL4_MUNMAP)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
down_write(&pTask->mm->mmap_sem);
+#else
+ down_write(&pTask->mm->mmap_lock);
+#endif
do_munmap(pTask->mm, (unsigned long)pv, cb, 0); /* should it be 1 or 0? */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
up_write(&pTask->mm->mmap_sem);
#else
+ up_write(&pTask->mm->mmap_lock);
+#endif
+#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
down_write(&pTask->mm->mmap_sem);
+#else
+ down_write(&pTask->mm->mmap_lock);
+#endif
do_munmap(pTask->mm, (unsigned long)pv, cb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
up_write(&pTask->mm->mmap_sem);
+#else
+ up_write(&pTask->mm->mmap_lock);
+#endif
#endif
}
@@ -593,7 +625,11 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR
size_t iPage;
Assert(pTask);
if (pTask && pTask->mm)
- down_read(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ down_read(&pTask->mm->mmap_sem);
+#else
+ down_read(&pTask->mm->mmap_lock);
+#endif
iPage = pMemLnx->cPages;
while (iPage-- > 0)
@@ -608,7 +644,11 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR
}
if (pTask && pTask->mm)
- up_read(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ up_read(&pTask->mm->mmap_sem);
+#else
+ up_read(&pTask->mm->mmap_lock);
+#endif
}
/* else: kernel memory - nothing to do here. */
break;
@@ -1076,7 +1116,11 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser
papVMAs = (struct vm_area_struct **)RTMemAlloc(sizeof(*papVMAs) * cPages);
if (papVMAs)
{
- down_read(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ down_read(&pTask->mm->mmap_sem);
+#else
+ down_read(&pTask->mm->mmap_lock);
+#endif
/*
* Get user pages.
@@ -1162,7 +1206,11 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser
papVMAs[rc]->vm_flags |= VM_DONTCOPY | VM_LOCKED;
}
- up_read(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ up_read(&pTask->mm->mmap_sem);
+#else
+ up_read(&pTask->mm->mmap_lock);
+#endif
RTMemFree(papVMAs);
@@ -1189,7 +1237,11 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser
#endif
}
- up_read(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ up_read(&pTask->mm->mmap_sem);
+#else
+ up_read(&pTask->mm->mmap_lock);
+#endif
RTMemFree(papVMAs);
rc = VERR_LOCK_FAILED;
@@ -1604,7 +1656,11 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(
const size_t cPages = (offSub + cbSub) >> PAGE_SHIFT;
size_t iPage;
- down_write(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ down_write(&pTask->mm->mmap_sem);
+#else
+ down_write(&pTask->mm->mmap_lock);
+#endif
rc = VINF_SUCCESS;
if (pMemLnxToMap->cPages)
@@ -1721,7 +1777,11 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(
}
#endif /* CONFIG_NUMA_BALANCING */
- up_write(&pTask->mm->mmap_sem);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
+ up_write(&pTask->mm->mmap_sem);
+#else
+ up_write(&pTask->mm->mmap_lock);
+#endif
if (RT_SUCCESS(rc))
{
Index: VirtualBox-6.1.10/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
===================================================================
--- VirtualBox-6.1.10.orig/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
+++ VirtualBox-6.1.10/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
@@ -757,12 +757,19 @@ EXPORT_SYMBOL(SUPDrvLinuxIDC);
RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4);
+#else
+ RTCCUINTREG uOld = __read_cr4();
+#endif
RTCCUINTREG uNew = (uOld & fAndMask) | fOrMask;
if (uNew != uOld)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
this_cpu_write(cpu_tlbstate.cr4, uNew);
__write_cr4(uNew);
+#endif
+ ASMSetCR4(uNew);
}
#else
RTCCUINTREG uOld = ASMGetCR4();
Index: VirtualBox-6.1.10/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
===================================================================
--- VirtualBox-6.1.10.orig/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
+++ VirtualBox-6.1.10/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
@@ -168,7 +168,12 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(
struct vm_struct *pVmArea;
size_t iPage;
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+ pVmArea = __get_vm_area_caller(cbAlloc, VM_ALLOC, MODULES_VADDR, MODULES_END,
+ __builtin_return_address(0));
+#else
pVmArea = __get_vm_area(cbAlloc, VM_ALLOC, MODULES_VADDR, MODULES_END);
+#endif
if (!pVmArea)
return NULL;
pVmArea->nr_pages = 0; /* paranoia? */
@@ -201,6 +206,12 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(
# endif
pVmArea->nr_pages = cPages;
pVmArea->pages = papPages;
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+ unsigned long start = (unsigned long)pVmArea->addr;
+ unsigned long size = get_vm_area_size(pVmArea);
+
+ if (!map_kernel_range(start, size, PAGE_KERNEL_EXEC, papPages))
+#else
if (!map_vm_area(pVmArea, PAGE_KERNEL_EXEC,
# if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
&papPagesIterator
@@ -208,6 +219,7 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(
papPages
# endif
))
+#endif
{
PRTMEMLNXHDREX pHdrEx = (PRTMEMLNXHDREX)pVmArea->addr;
pHdrEx->pVmArea = pVmArea;

View File

@ -1,7 +1,7 @@
Index: VirtualBox-6.1.4/src/VBox/HostDrivers/linux/Makefile
Index: VirtualBox-6.1.10/src/VBox/HostDrivers/linux/Makefile
===================================================================
--- VirtualBox-6.1.4.orig/src/VBox/HostDrivers/linux/Makefile
+++ VirtualBox-6.1.4/src/VBox/HostDrivers/linux/Makefile
--- VirtualBox-6.1.10.orig/src/VBox/HostDrivers/linux/Makefile
+++ VirtualBox-6.1.10/src/VBox/HostDrivers/linux/Makefile
@@ -35,9 +35,6 @@ endif
ifneq ($(wildcard $(CURDIR)/vboxnetadp/Makefile),)
obj-m += vboxnetadp/
@ -34,7 +34,7 @@ Index: VirtualBox-6.1.4/src/VBox/HostDrivers/linux/Makefile
- if [ -f vboxdrv/Module.symvers ]; then \
- cp vboxdrv/Module.symvers vboxnetflt; \
- fi; \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxnetflt/Module.symvers; \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxdrv/Module.symvers; \
echo "=== Building 'vboxnetflt' module ==="; \
- $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxnetflt/Module.symvers) -C vboxnetflt || exit 1; \
+ $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxdrv/Module.symvers) -C vboxnetflt || exit 1; \
@ -47,10 +47,10 @@ Index: VirtualBox-6.1.4/src/VBox/HostDrivers/linux/Makefile
- if [ -f vboxdrv/Module.symvers ]; then \
- cp vboxdrv/Module.symvers vboxnetadp; \
- fi; \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxnetadp/Module.symvers; \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxdrv/Module.symvers; \
echo "=== Building 'vboxnetadp' module ==="; \
- $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxnetadp/Module.symvers) -C vboxnetadp || exit 1; \
+ $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxdrv/Module.symvers) -C vboxnetadp || exit 1; \
+ $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) KBUILD_EXTRA_SYMBOLS=$(abspath vboxdrv/Module.symvers) -C vboxnetadp || exit 1; \
cp vboxnetadp/vboxnetadp.ko .; \
echo; \
fi
@ -69,11 +69,11 @@ Index: VirtualBox-6.1.4/src/VBox/HostDrivers/linux/Makefile
install:
@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv install
@if [ -d vboxnetflt ]; then \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxnetflt/Module.symvers; \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxdrv/Module.symvers; \
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt install; \
fi
@if [ -d vboxnetadp ]; then \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxnetadp/Module.symvers; \
+ export KBUILD_EXTRA_SYMBOLS=${PWD}/vboxdrv/Module.symvers; \
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp install; \
fi
- @if [ -d vboxpci ]; then \
@ -117,10 +117,10 @@ Index: VirtualBox-6.1.4/src/VBox/HostDrivers/linux/Makefile
if test -f $$module.ko; then \
echo "Installing $$module module"; \
/sbin/insmod $$module.ko; \
Index: VirtualBox-6.1.4/src/VBox/Additions/linux/Makefile
Index: VirtualBox-6.1.10/src/VBox/Additions/linux/Makefile
===================================================================
--- VirtualBox-6.1.4.orig/src/VBox/Additions/linux/Makefile
+++ VirtualBox-6.1.4/src/VBox/Additions/linux/Makefile
--- VirtualBox-6.1.10.orig/src/VBox/Additions/linux/Makefile
+++ VirtualBox-6.1.10/src/VBox/Additions/linux/Makefile
@@ -24,6 +24,7 @@ obj-m = vboxguest/ vboxsf/ vboxvideo/
else # ! KERNELRELEASE
@ -157,10 +157,10 @@ Index: VirtualBox-6.1.4/src/VBox/Additions/linux/Makefile
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxvideo install; \
fi
Index: VirtualBox-6.1.4/include/iprt/x86.h
Index: VirtualBox-6.1.10/include/iprt/x86.h
===================================================================
--- VirtualBox-6.1.4.orig/include/iprt/x86.h
+++ VirtualBox-6.1.4/include/iprt/x86.h
--- VirtualBox-6.1.10.orig/include/iprt/x86.h
+++ VirtualBox-6.1.10/include/iprt/x86.h
@@ -840,37 +840,59 @@ typedef const X86CPUIDFEATEDX *PCX86CPUI
* reserved flags.
* @{ */
@ -762,10 +762,10 @@ Index: VirtualBox-6.1.4/include/iprt/x86.h
/** North bridge config? See BIOS & Kernel dev guides for
* details. */
#define MSR_K8_NB_CFG UINT32_C(0xc001001f)
Index: VirtualBox-6.1.4/include/VBox/vmm/hm_vmx.h
Index: VirtualBox-6.1.10/include/VBox/vmm/hm_vmx.h
===================================================================
--- VirtualBox-6.1.4.orig/include/VBox/vmm/hm_vmx.h
+++ VirtualBox-6.1.4/include/VBox/vmm/hm_vmx.h
--- VirtualBox-6.1.10.orig/include/VBox/vmm/hm_vmx.h
+++ VirtualBox-6.1.10/include/VBox/vmm/hm_vmx.h
@@ -1473,7 +1473,9 @@ AssertCompileSize(VMXABORT, 4);
/** VMCS (and related regions) memory type - Uncacheable. */
#define VMX_BASIC_MEM_TYPE_UC 0
@ -776,11 +776,11 @@ Index: VirtualBox-6.1.4/include/VBox/vmm/hm_vmx.h
/** Width of physical addresses used for VMCS and associated memory regions
* (1=32-bit, 0=processor's physical address width). */
#define VMX_BASIC_PHYSADDR_WIDTH_32BIT RT_BIT_64(48)
Index: VirtualBox-6.1.4/src/VBox/Additions/linux/drm/vbox_drv.h
Index: VirtualBox-6.1.10/src/VBox/Additions/linux/drm/vbox_drv.h
===================================================================
--- VirtualBox-6.1.4.orig/src/VBox/Additions/linux/drm/vbox_drv.h
+++ VirtualBox-6.1.4/src/VBox/Additions/linux/drm/vbox_drv.h
@@ -83,10 +83,8 @@
--- VirtualBox-6.1.10.orig/src/VBox/Additions/linux/drm/vbox_drv.h
+++ VirtualBox-6.1.10/src/VBox/Additions/linux/drm/vbox_drv.h
@@ -86,10 +86,8 @@
# endif
#endif

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Sat Jun 13 18:42:48 UTC 2020 - Larry Finger <Larry.Finger@gmail.com>
- Add fixes to build with kernel 5.8. File "fixes_for_5.8.patch" is added.
- Remove file "fixes_for_5.5.patch". Fixed upstream.
-`Add file "fixes_for_makefile.patch" to clean up the Makefile used from the
vboxdrv service routine when modules are not available.
-------------------------------------------------------------------
Fri Jun 5 20:42:04 UTC 2020 - Larry Finger <Larry.Finger@gmail.com>

View File

@ -148,14 +148,16 @@ Patch130: fixes_for_Leap42.3.patch
Patch132: fixes_for_qt5.13.patch
# Fixes for openSUSE Leap 15.2
Patch133: fixes_for_leap15.2.patch
# Fixes for API changes in kernel 5.6
Patch134: fixes_for_5.5.patch
# Fixes for kernel modules Makefile used at boot time
Patch134: fixes_for_makefile.patch
# Fix build for Qt 5.15
Patch135: fix-missing-includes-with-qt-5.15.patch
# Fix builds with GCC10
Patch136: fixes_for_gcc10.patch
# Fix for chanes in GSOAP 2.8.103
# Fix for changes in GSOAP 2.8.103
Patch137: handle_gsoap_208103.patch
# Fixes for kernel 5.8
Patch138: fixes_for_5.8.patch
Patch999: virtualbox-fix-ui-background-color.patch
#
BuildRequires: LibVNCServer-devel
@ -461,6 +463,7 @@ as an "extpack" for VirtualBox. The implementation is licensed under GPL.
%patch135 -p1
%patch136 -p1
%patch137 -p1
%patch138 -p1
# make VB UI background colors look sane again
%patch999 -p1