commit:     16f171d9bbc6820a7e417ec75413fe4c2bc631d1
Author:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  3 06:11:57 2023 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Mon Apr  3 06:12:43 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=16f171d9

app-emulation/virtualbox-modules: fix compilation with kernel 6.3

Bug: https://bugs.gentoo.org/903638
Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org>

 .../virtualbox-modules-7.0.6-kernel-6.3.patch      | 27 ++++++++++
 .../virtualbox-modules-6.1.42-r1.ebuild            | 61 ++++++++++++++++++++++
 .../virtualbox-modules-7.0.6-r1.ebuild             | 61 ++++++++++++++++++++++
 3 files changed, 149 insertions(+)

diff --git 
a/app-emulation/virtualbox-modules/files/virtualbox-modules-7.0.6-kernel-6.3.patch
 
b/app-emulation/virtualbox-modules/files/virtualbox-modules-7.0.6-kernel-6.3.patch
new file mode 100644
index 000000000000..3ea343791773
--- /dev/null
+++ 
b/app-emulation/virtualbox-modules/files/virtualbox-modules-7.0.6-kernel-6.3.patch
@@ -0,0 +1,27 @@
+Linux: vboxdrv: Introduce initial support for kernel 6.3.x series, 
bugref:10381.
+https://www.virtualbox.org/changeset/98867/vbox
+
+Index: trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
+===================================================================
+--- a/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
++++ b/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
+@@ -1402,5 +1402,9 @@
+             {
+                 flush_dcache_page(pMemLnx->apPages[rc]);
++#if RTLNX_VER_MIN(6,3,0)
++                vm_flags_set(papVMAs[rc], VM_DONTCOPY | VM_LOCKED);
++#else
+                 papVMAs[rc]->vm_flags |= VM_DONTCOPY | VM_LOCKED;
++#endif
+             }
+ 
+@@ -1873,5 +1877,8 @@
+                     /* Thes flags help making 100% sure some bad stuff wont 
happen (swap, core, ++).
+                      * See remap_pfn_range() in mm/memory.c */
+-#if    RTLNX_VER_MIN(3,7,0)
++
++#if    RTLNX_VER_MIN(6,3,0)
++                    vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
++#elif  RTLNX_VER_MIN(3,7,0)
+                     vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+ #else

diff --git 
a/app-emulation/virtualbox-modules/virtualbox-modules-6.1.42-r1.ebuild 
b/app-emulation/virtualbox-modules/virtualbox-modules-6.1.42-r1.ebuild
new file mode 100644
index 000000000000..3258677a03ed
--- /dev/null
+++ b/app-emulation/virtualbox-modules/virtualbox-modules-6.1.42-r1.ebuild
@@ -0,0 +1,61 @@
+# Copyright 2022-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# XXX: the tarball here is just the kernel modules split out of the binary
+#      package that comes from VirtualBox-*.run
+# XXX: update: now it is split from virtualbox-*-Debian~bullseye_amd64.deb
+
+EAPI=8
+
+inherit linux-mod toolchain-funcs
+
+MY_P="vbox-kernel-module-src-${PV}"
+DESCRIPTION="Kernel Modules for Virtualbox"
+HOMEPAGE="https://www.virtualbox.org/";
+SRC_URI="https://dev.gentoo.org/~ceamac/${CATEGORY}/${PN}/${MY_P}.tar.xz";
+S="${WORKDIR}"
+
+LICENSE="GPL-2"
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~amd64"
+
+BUILD_TARGETS="all"
+MODULE_NAMES="vboxdrv(misc:${S}) vboxnetflt(misc:${S}) vboxnetadp(misc:${S})"
+MODULESD_VBOXDRV_ENABLED="yes"
+MODULESD_VBOXNETADP_ENABLED="no"
+MODULESD_VBOXNETFLT_ENABLED="no"
+
+PATCHES=(
+       "${FILESDIR}"/virtualbox-modules-7.0.6-kernel-6.3.patch
+)
+
+pkg_setup() {
+       linux-mod_pkg_setup
+       BUILD_PARAMS="CC=\"$(tc-getBUILD_CC)\" KERN_DIR=${KV_DIR} 
KERN_VER=${KV_FULL} O=${KV_OUT_DIR} V=1 KBUILD_VERBOSE=1"
+       if linux_chkconfig_present CC_IS_CLANG; then
+               ewarn "Warning: building ${PN} with a clang-built kernel is 
experimental."
+
+               BUILD_PARAMS+=' CC=${CHOST}-clang'
+               if linux_chkconfig_present LD_IS_LLD; then
+                       BUILD_PARAMS+=' LD=ld.lld'
+                       if linux_chkconfig_present LTO_CLANG_THIN; then
+                               # kernel enables cache by default leading to 
sandbox violations
+                               BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= 
LDFLAGS_MODULE=--thinlto-cache-dir='
+                       fi
+               fi
+       fi
+}
+
+src_install() {
+       linux-mod_src_install
+       insinto /usr/lib/modules-load.d/
+       newins "${FILESDIR}"/virtualbox.conf-r1 virtualbox.conf
+}
+
+pkg_postinst() {
+       # Remove vboxpci.ko from current running kernel
+       # This module is obsolete, removed in december 2019, so it may be 
missing.  No || die
+       # TODO: consider removing this line in the near future
+       find /lib/modules/${KV_FULL}/misc -type f -name "vboxpci.ko" -delete
+       linux-mod_pkg_postinst
+}

diff --git 
a/app-emulation/virtualbox-modules/virtualbox-modules-7.0.6-r1.ebuild 
b/app-emulation/virtualbox-modules/virtualbox-modules-7.0.6-r1.ebuild
new file mode 100644
index 000000000000..e4544d662bf5
--- /dev/null
+++ b/app-emulation/virtualbox-modules/virtualbox-modules-7.0.6-r1.ebuild
@@ -0,0 +1,61 @@
+# Copyright 2022-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# XXX: the tarball here is just the kernel modules split out of the binary
+#      package that comes from VirtualBox-*.run
+# XXX: update: now it is split from virtualbox-*-Debian~bullseye_amd64.deb
+
+EAPI=8
+
+inherit linux-mod toolchain-funcs
+
+MY_P="vbox-kernel-module-src-${PV}"
+DESCRIPTION="Kernel Modules for Virtualbox"
+HOMEPAGE="https://www.virtualbox.org/";
+SRC_URI="https://dev.gentoo.org/~ceamac/${CATEGORY}/${PN}/${MY_P}.tar.xz";
+S="${WORKDIR}"
+
+LICENSE="GPL-3"
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~amd64"
+
+BUILD_TARGETS="all"
+MODULE_NAMES="vboxdrv(misc:${S}) vboxnetflt(misc:${S}) vboxnetadp(misc:${S})"
+MODULESD_VBOXDRV_ENABLED="yes"
+MODULESD_VBOXNETADP_ENABLED="no"
+MODULESD_VBOXNETFLT_ENABLED="no"
+
+PATCHES=(
+       "${FILESDIR}"/virtualbox-modules-7.0.6-kernel-6.3.patch
+)
+
+pkg_setup() {
+       linux-mod_pkg_setup
+       BUILD_PARAMS="CC=\"$(tc-getBUILD_CC)\" KERN_DIR=${KV_DIR} 
KERN_VER=${KV_FULL} O=${KV_OUT_DIR} V=1 KBUILD_VERBOSE=1"
+       if linux_chkconfig_present CC_IS_CLANG; then
+               ewarn "Warning: building ${PN} with a clang-built kernel is 
experimental."
+
+               BUILD_PARAMS+=' CC=${CHOST}-clang'
+               if linux_chkconfig_present LD_IS_LLD; then
+                       BUILD_PARAMS+=' LD=ld.lld'
+                       if linux_chkconfig_present LTO_CLANG_THIN; then
+                               # kernel enables cache by default leading to 
sandbox violations
+                               BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= 
LDFLAGS_MODULE=--thinlto-cache-dir='
+                       fi
+               fi
+       fi
+}
+
+src_install() {
+       linux-mod_src_install
+       insinto /usr/lib/modules-load.d/
+       newins "${FILESDIR}"/virtualbox.conf-r1 virtualbox.conf
+}
+
+pkg_postinst() {
+       # Remove vboxpci.ko from current running kernel
+       # This module is obsolete, removed in december 2019, so it may be 
missing.  No || die
+       # TODO: consider removing this line in the near future
+       find /lib/modules/${KV_FULL}/misc -type f -name "vboxpci.ko" -delete
+       linux-mod_pkg_postinst
+}

Reply via email to