16 changes: 3 additions & 13 deletions emulators/virtualbox-ose-additions/Makefile
Expand Up @@ -2,10 +2,9 @@
# $FreeBSD$

PORTNAME= virtualbox-ose
PORTVERSION= 5.2.44
PORTREVISION= 3
PORTVERSION= 6.1.18
CATEGORIES= emulators
MASTER_SITES= https://download.oracle.com/virtualbox/${PORTVERSION}/
MASTER_SITES= https://download.virtualbox.com/virtualbox/${PORTVERSION}/
PKGNAMESUFFIX?= -additions
DISTNAME= VirtualBox-${PORTVERSION}

Expand All @@ -15,7 +14,7 @@ COMMENT= VirtualBox additions for FreeBSD guests
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/COPYING

ONLY_FOR_ARCHS= amd64 i386
ONLY_FOR_ARCHS= amd64
USES= compiler:c++11-lang cpe iconv kmod tar:bzip2
USE_RC_SUBR= vboxguest vboxservice

Expand Down Expand Up @@ -91,12 +90,6 @@ VBOX_WITH_X11=

.include <bsd.port.pre.mk>

.if ${COMPILER_TYPE} == clang
.if ${COMPILER_FEATURES:Mlibc++}
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
.endif
.endif

post-patch:
@${ECHO_CMD} 'VBOX_ONLY_ADDITIONS = 1' > ${WRKSRC}/LocalConfig.kmk
@${ECHO_CMD} 'VBOX_WITH_DRAG_AND_DROP = ${VBOX_WITH_X11}' >> \
Expand All @@ -111,13 +104,10 @@ post-patch:
-e 's| -fno-merge-constants||' \
-e 's| -mpreferred-stack-boundary=2||' ${WRKSRC}/Config.kmk
.endif
@${REINPLACE_CMD} -e 's|/usr/X11|${LOCALBASE}|g' \
${WRKSRC}/src/VBox/Additions/x11/VBoxClient/display.cpp
@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
${WRKSRC}/Config.kmk ${WRKSRC}/configure \
${WRKSRC}/kBuild/header.kmk ${WRKSRC}/kBuild/units/qt4.kmk \
${WRKSRC}/kBuild/units/qt5.kmk ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \
${WRKSRC}/src/VBox/Additions/common/crOpenGL/load.c \
${WRKSRC}/src/VBox/Additions/x11/Installer/98vboxadd-xclient \
${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \
${WRKSRC}/src/VBox/Additions/x11/vboxmouse/Makefile.kmk \
Expand Down
6 changes: 3 additions & 3 deletions emulators/virtualbox-ose-additions/distinfo
@@ -1,3 +1,3 @@
TIMESTAMP = 1594821235
SHA256 (VirtualBox-5.2.44.tar.bz2) = ad83b11cfae2734f7d6f619dd2f8bdada7d33492cd7682fab98cb4053122295e
SIZE (VirtualBox-5.2.44.tar.bz2) = 124016934
TIMESTAMP = 1613903085
SHA256 (VirtualBox-6.1.18.tar.bz2) = 108d42b9b391b7a332a33df1662cf7b0e9d9a80f3079d16288d8b9487f427d40
SIZE (VirtualBox-6.1.18.tar.bz2) = 165507486
108 changes: 108 additions & 0 deletions emulators/virtualbox-ose-kmod-legacy/Makefile
@@ -0,0 +1,108 @@
# Created by: Bernhard Froehlich <decke@bluelife.at>
# $FreeBSD$

PORTNAME= virtualbox-ose
PORTVERSION= 5.2.44
PORTREVISION= 4
CATEGORIES= emulators
MASTER_SITES= https://download.oracle.com/virtualbox/${PORTVERSION}/
PKGNAMESUFFIX= -kmod-legacy
DISTNAME= VirtualBox-${PORTVERSION}

MAINTAINER= vbox@FreeBSD.org
COMMENT= VirtualBox kernel module for FreeBSD

LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/COPYING

BUILD_DEPENDS= kmk:devel/kBuild

CPE_VENDOR= oracle
CPE_PRODUCT= vm_virtualbox

USES= cpe kmod tar:bzip2
PATCHDIR= ${.CURDIR}/../${PORTNAME}-legacy/files
WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION}
USE_RC_SUBR= vboxnet
ONLY_FOR_ARCHS= i386 amd64

HAS_CONFIGURE= yes
CONFIGURE_ARGS+= --build-headless
CONFIGURE_ARGS+= --disable-alsa \
--disable-dbus \
--disable-docs \
--disable-libvpx \
--disable-pulse \
--disable-python \
--disable-sdl-ttf \
--disable-xpcom
CONFIGURE_ARGS+= --nofatal --with-gcc="${CC}" --with-g++="${CXX}"

CONFLICTS_INSTALL= virtualbox-ose-kmod-devel-* \
virtualbox-ose-kmod-*

OPTIONS_DEFINE= DEBUG VIMAGE
OPTIONS_DEFAULT=VIMAGE
OPTIONS_SUB= yes
DEBUG_DESC= Debug symbols, additional logs and assertions
VIMAGE_DESC= VIMAGE virtual networking support

.include <bsd.port.options.mk>

VBOX_BIN= ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/src
VBOX_KMODS= vboxdrv \
vboxnetadp \
vboxnetflt

BUILD_WRKSRC= ${VBOX_BIN}

KMK_BUILDTYPE= release
KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys
KMK_FLAGS= HostDrivers-scripts vboxdrv-src VBoxNetFlt-src VBoxNetAdp-src

.if ${PORT_OPTIONS:MDEBUG}
KMK_FLAGS+= BUILD_TYPE=debug
KMK_BUILDTYPE= debug
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
MAKE_ARGS+= DEBUG_FLAGS="-O1 -g"
.endif

.if ${ARCH} == i386
KMK_ARCH= freebsd.x86
.else
KMK_ARCH= freebsd.${ARCH}
.endif

.include <bsd.port.pre.mk>

SYMBOLSUFFIX= debug
PLIST_SUB+= SYMBOLSUFFIX=${SYMBOLSUFFIX}

post-patch:
@${ECHO_CMD} 'VBOX_WITH_VBOXDRV = 1' > ${WRKSRC}/LocalConfig.kmk
@${ECHO_CMD} 'VBOX_WITH_NETFLT = 1' >> ${WRKSRC}/LocalConfig.kmk
@${ECHO_CMD} 'VBOX_WITH_NETADP = 1' >> ${WRKSRC}/LocalConfig.kmk
@${ECHO_CMD} 'VBOX_WITH_ADDITIONS =' >> ${WRKSRC}/LocalConfig.kmk
.if ${PORT_OPTIONS:MVIMAGE}
@${ECHO_CMD} 'VBOX_WITH_NETFLT_VIMAGE = 1' >> ${WRKSRC}/LocalConfig.kmk
.endif
@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
${WRKSRC}/Config.kmk ${WRKSRC}/configure
@${REINPLACE_CMD} \
-e 's|\$$KBUILDDIR_BIN/kmk_sed|${LOCALBASE}/bin/kmk_sed|g' \
${WRKSRC}/configure

pre-build:
cd ${WRKSRC}/src/VBox/HostDrivers && ${SH} -c \
'. ${WRKSRC}/env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS}'

do-install:
${MKDIR} ${STAGEDIR}${KMODDIR}
.for i in ${VBOX_KMODS}
${INSTALL_KLD} ${VBOX_BIN}/${i}/${i}.ko ${STAGEDIR}${KMODDIR}
.if ${PORT_OPTIONS:MDEBUG}
${INSTALL_KLD} ${VBOX_BIN}/${i}/${i}.ko.${SYMBOLSUFFIX} ${STAGEDIR}${KMODDIR}
.endif
.endfor

.include <bsd.port.post.mk>
3 changes: 3 additions & 0 deletions emulators/virtualbox-ose-kmod-legacy/distinfo
@@ -0,0 +1,3 @@
TIMESTAMP = 1594821147
SHA256 (VirtualBox-5.2.44.tar.bz2) = ad83b11cfae2734f7d6f619dd2f8bdada7d33492cd7682fab98cb4053122295e
SIZE (VirtualBox-5.2.44.tar.bz2) = 124016934
70 changes: 70 additions & 0 deletions emulators/virtualbox-ose-kmod-legacy/files/vboxnet.in
@@ -0,0 +1,70 @@
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: vboxnet
# BEFORE: NETWORKING
# REQUIRE: FILESYSTEMS
# KEYWORD: nojail

#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# vboxnet_enable (bool): Set to NO by default.
# Set it to YES to load network related kernel modules on startup

. /etc/rc.subr

name="vboxnet"
rcvar=vboxnet_enable
start_cmd="vboxnet_start"
stop_cmd="vboxnet_stop"

vboxnet_modules="vboxdrv vboxnetflt:ng_vboxnetflt vboxnetadp"

vboxnet_start()
{
local _k _m

for _m in ${vboxnet_modules}; do
_k=${_m%:*}
_m=${_m#*:}
if ! kldstat -q -m ${_m}; then
if ! kldload ${_k} > /dev/null 2>&1; then
warn "Can't load ${_k} module."
return 1
fi
fi
done

# initialize configured host-only interfaces
LD_LIBRARY_PATH=%%PREFIX%%/lib %%PREFIX%%/bin/VBoxManage list hostonlyifs >/dev/null
}

vboxnet_stop()
{
local _k _m _r

_r=
for _m in ${vboxnet_modules}; do
_r="${_m} ${_r}"
done
for _m in ${_r}; do
_k=${_m%:*}
_m=${_m#*:}
if kldstat -q -m ${_m}; then
if ! kldunload ${_k} > /dev/null 2>&1; then
warn "Can't unload ${_k} module."
return 1
fi
fi
done
}

load_rc_config $name

: ${vboxnet_enable="NO"}

run_rc_command "$1"
7 changes: 7 additions & 0 deletions emulators/virtualbox-ose-kmod-legacy/pkg-descr
@@ -0,0 +1,7 @@
VirtualBox is a family of powerful x86 virtualization products for
enterprise as well as home use. Not only is VirtualBox an extremely
feature rich, high performance product for enterprise customers, it
is also the only professional solution that is freely available as
Open Source Software under the terms of the GNU General Public License.

WWW: https://www.virtualbox.org/
6 changes: 6 additions & 0 deletions emulators/virtualbox-ose-kmod-legacy/pkg-plist
@@ -0,0 +1,6 @@
/%%KMODDIR%%/vboxdrv.ko
%%DEBUG%%/%%KMODDIR%%/vboxdrv.ko.%%SYMBOLSUFFIX%%
/%%KMODDIR%%/vboxnetadp.ko
%%DEBUG%%/%%KMODDIR%%/vboxnetadp.ko.%%SYMBOLSUFFIX%%
/%%KMODDIR%%/vboxnetflt.ko
%%DEBUG%%/%%KMODDIR%%/vboxnetflt.ko.%%SYMBOLSUFFIX%%
12 changes: 6 additions & 6 deletions emulators/virtualbox-ose-kmod/Makefile
Expand Up @@ -2,10 +2,9 @@
# $FreeBSD$

PORTNAME= virtualbox-ose
PORTVERSION= 5.2.44
PORTREVISION= 4
PORTVERSION= 6.1.18
CATEGORIES= emulators
MASTER_SITES= https://download.oracle.com/virtualbox/${PORTVERSION}/
MASTER_SITES= https://download.virtualbox.org/virtualbox/${PORTVERSION}/
PKGNAMESUFFIX= -kmod
DISTNAME= VirtualBox-${PORTVERSION}

Expand All @@ -20,11 +19,11 @@ BUILD_DEPENDS= kmk:devel/kBuild
CPE_VENDOR= oracle
CPE_PRODUCT= vm_virtualbox

USES= cpe kmod tar:bzip2
USES= cpe compiler:c++14-lang kmod tar:bzip2
PATCHDIR= ${.CURDIR}/../${PORTNAME}/files
WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION}
USE_RC_SUBR= vboxnet
ONLY_FOR_ARCHS= i386 amd64
ONLY_FOR_ARCHS= amd64

HAS_CONFIGURE= yes
CONFIGURE_ARGS+= --build-headless
Expand Down Expand Up @@ -63,7 +62,8 @@ KMK_FLAGS= HostDrivers-scripts vboxdrv-src VBoxNetFlt-src VBoxNetAdp-src
.if ${PORT_OPTIONS:MDEBUG}
KMK_FLAGS+= BUILD_TYPE=debug
KMK_BUILDTYPE= debug
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-Config.kmk \
${PATCHDIR}/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
MAKE_ARGS+= DEBUG_FLAGS="-O1 -g"
.endif

Expand Down
6 changes: 3 additions & 3 deletions emulators/virtualbox-ose-kmod/distinfo
@@ -1,3 +1,3 @@
TIMESTAMP = 1594821147
SHA256 (VirtualBox-5.2.44.tar.bz2) = ad83b11cfae2734f7d6f619dd2f8bdada7d33492cd7682fab98cb4053122295e
SIZE (VirtualBox-5.2.44.tar.bz2) = 124016934
TIMESTAMP = 1613865409
SHA256 (VirtualBox-6.1.18.tar.bz2) = 108d42b9b391b7a332a33df1662cf7b0e9d9a80f3079d16288d8b9487f427d40
SIZE (VirtualBox-6.1.18.tar.bz2) = 165507486
409 changes: 409 additions & 0 deletions emulators/virtualbox-ose-legacy/Makefile

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions emulators/virtualbox-ose-legacy/distinfo
@@ -0,0 +1,5 @@
TIMESTAMP = 1594897148
SHA256 (VirtualBox-5.2.44.tar.bz2) = ad83b11cfae2734f7d6f619dd2f8bdada7d33492cd7682fab98cb4053122295e
SIZE (VirtualBox-5.2.44.tar.bz2) = 124016934
SHA256 (VBoxGuestAdditions_5.2.44.iso) = 9883ee443a309f4ffa1d5dee2833f9e35ced598686c36d159f410e5edbac1ca4
SIZE (VBoxGuestAdditions_5.2.44.iso) = 49829888
File renamed without changes.
@@ -0,0 +1,11 @@
--- src/VBox/HostDrivers/Support/freebsd/Makefile.orig 2012-10-18 16:23:16.000000000 +0200
+++ src/VBox/HostDrivers/Support/freebsd/Makefile 2012-10-20 08:13:07.301179212 +0200
@@ -27,7 +27,7 @@

KMOD = vboxdrv

-CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS
+CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS -DDEBUG

.if (${MACHINE_ARCH} == "i386")
CFLAGS += -DRT_ARCH_X86
File renamed without changes.
File renamed without changes.
File renamed without changes.
239 changes: 239 additions & 0 deletions emulators/virtualbox-ose-legacy/files/patch-Config.kmk
@@ -0,0 +1,239 @@
--- Config.kmk.orig 2020-07-09 16:49:46 UTC
+++ Config.kmk
@@ -445,11 +445,11 @@ ifn1of ($(KBUILD_TARGET), win darwin)
# Enable OSS audio support.
VBOX_WITH_AUDIO_OSS = 1
endif
-if1of ($(KBUILD_TARGET), linux)
+if1of ($(KBUILD_TARGET), freebsd linux)
# Enable ALSA audio support.
VBOX_WITH_AUDIO_ALSA = 1
endif
-if1of ($(KBUILD_TARGET), linux)
+if1of ($(KBUILD_TARGET), freebsd linux)
# Enable PulseAudio audio support.
VBOX_WITH_AUDIO_PULSE = 1
endif
@@ -464,11 +464,11 @@ VBOX_WITH_AUDIO_MMNOTIFICATION_CLIENT = 1
# Enable PCI passthrough support.
VBOX_WITH_PCI_PASSTHROUGH = 1
# Enable statically linked dbus support.
-if1of ($(KBUILD_TARGET), linux solaris)
+if1of ($(KBUILD_TARGET), freebsd linux solaris)
VBOX_WITH_DBUS = 1
endif
# Enable building PAM modules.
-if1of ($(KBUILD_TARGET), linux solaris)
+if1of ($(KBUILD_TARGET), freebsd linux solaris)
VBOX_WITH_PAM = 1
endif
# Enable internal networking.
@@ -664,7 +664,7 @@ VBOX_WITH_TESTCASES = 1
VBOX_WITH_VDITOOL =
# Enable this to build vbox-img even if VBOX_WITH_TESTCASES is disabled
VBOX_WITH_VBOX_IMG =
-if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), darwin.x86 darwin.amd64 linux.x86 linux.amd64 solaris.amd64 win.x86 win.amd64)
+if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), darwin.x86 darwin.amd64 freebsd.x86 freebsd.amd64 linux.x86 linux.amd64 solaris.amd64 win.x86 win.amd64)
# Enables the video capturing support.
VBOX_WITH_VIDEOREC = 1
# Enable VPX (VP8 / VP9 codec), used for video capturing.
@@ -992,10 +992,6 @@ ifeq ($(KBUILD_TARGET),darwin)
VBOX_WITH_VBOXSDL=
endif

-ifeq ($(KBUILD_TARGET),freebsd)
- VBOX_WITH_DOCS=
-endif
-
ifeq ($(KBUILD_TARGET),haiku)
# Don't bother with SDL ttf for now.
VBOX_WITH_SECURELABEL=
@@ -1155,7 +1151,7 @@ ifdef VBOX_OSE
VBOX_WITH_KCHMVIEWER=
VBOX_WITH_PLUGIN_CRYPT=
VBOX_WITH_DRAG_AND_DROP_PROMISES=
- ifn1of ($(KBUILD_TARGET), linux)
+ ifn1of ($(KBUILD_TARGET), freebsd linux)
VBOX_WITH_DOCS=
VBOX_WITH_DOCS_PACKING=
endif
@@ -1176,14 +1172,14 @@ ifdef VBOX_OSE
ifn1of ($(KBUILD_TARGET), darwin linux solaris win)
VBOX_WITH_INSTALLER=
endif
- if1of ($(KBUILD_TARGET), win)
+ # if1of ($(KBUILD_TARGET), win)
# Undefine codec libraries which are not needed.
VBOX_WITH_LIBVPX=
VBOX_WITH_LIBOPUS=
# Disable video recording (with audio support).
VBOX_WITH_VIDEOREC=
VBOX_WITH_AUDIO_VIDEOREC=
- endif
+ # endif
# branding
VBOX_BRAND_LICENSE_HTML := $(PATH_ROOT)/doc/License-gpl-2.0.html
VBOX_BRAND_LICENSE_RTF := $(PATH_ROOT)/doc/License-gpl-2.0.rtf
@@ -1810,6 +1806,7 @@ ifndef VBOX_BLD_PYTHON
else
VBOX_BLD_PYTHON := $(firstword $(which python2.7$(HOSTSUFF_EXE)) $(which python2.6$(HOSTSUFF_EXE)) \
$(which python$(HOSTSUFF_EXE)) $(which python3$(HOSTSUFF_EXE)) \
+ $(which %%PYTHON_VERSION%%) \
python-not-found)
endif
endif
@@ -2550,6 +2547,10 @@ ifeq ($(KBUILD_HOST),win) ## @todo can drop this now,
# This isn't important (yet) on windows, so cook the result until
# cygwin is feeling better.
VBOX_GCC_VERSION := $(int-add $(int-mul 10000, 3), $(int-mul 100, 3), 3)
+else ifeq($(KBUILD_HOST,freebsd))
+ # At a minimum, we'll be building with GCC 4.2 on FreeBSD. LLVM will always
+ # pose as GCC 4.2 anyways, so this seems safe.
+ VBOX_GCC_VERSION := $(int-add $(int-mul 10000, 4), $(int-mul 100, 2), 0)
else
# This is kind of bad, the returned string needs to be re-evaluated before use.
# The reason for this hack is that the windows kmk_ash cannot deal with $((1+1)).
@@ -4218,6 +4219,7 @@ ifdef VBOX_WITH_RAW_MODE
TEMPLATE_VBoxRc_TOOL = $(VBOX_GCC32_TOOL)
TEMPLATE_VBoxRc_CXXFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden) -fno-rtti $(VBOX_GCC_IPRT_FMT_CHECK)
TEMPLATE_VBoxRc_CFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_IPRT_FMT_CHECK)
+ TEMPLATE_VBoxRc_CXXFLAGS.freebsd = -fno-builtin
ifeq ($(KBUILD_TARGET),solaris)
TEMPLATE_VBoxRc_LDFLAGS = -r
else
@@ -4359,6 +4361,7 @@ ifeq ($(VBOX_LDR_FMT),elf)
TEMPLATE_VBoxR0_TOOL = $(VBOX_GCC_TOOL)
TEMPLATE_VBoxR0_CFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions $(VBOX_GCC_fno-stack-protector) -fno-common $(VBOX_GCC_fvisibility-hidden) -std=gnu99 $(VBOX_GCC_IPRT_FMT_CHECK)
TEMPLATE_VBoxR0_CXXFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions $(VBOX_GCC_fno-stack-protector) -fno-common $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) -fno-rtti $(VBOX_GCC_IPRT_FMT_CHECK)
+TEMPLATE_VBoxR0_CXXFLAGS.freebsd = -fno-builtin
TEMPLATE_VBoxR0_CFLAGS.amd64 = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables -ffreestanding
TEMPLATE_VBoxR0_CXXFLAGS.amd64 = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables
ifeq ($(KBUILD_TARGET),solaris)
@@ -4683,13 +4686,13 @@ TEMPLATE_VBOXR0DRV_CFLAGS = \
-O2 -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 \
$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
-nostdinc -std=c99
-TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
+TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 --param inline-unit-growth=100 --param large-function-growth=1000 \
-fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx \
-mno-3dnow -msoft-float -fno-asynchronous-unwind-tables -Wundef
TEMPLATE_VBOXR0DRV_CXXFLAGS = -fno-exceptions -fno-rtti \
$(VBOX_GCC_WARN) -Wpointer-arith -Winline \
- -O2 -fno-strict-aliasing -fno-common -finline-limit=8000 \
+ -O2 -fno-builtin -fno-strict-aliasing -fno-common -finline-limit=8000 \
$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
-nostdinc
TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
@@ -4716,7 +4719,7 @@ define TOOL_FREEBSDKMODLD_LINK_SYSMOD_CMDS
| xargs -J% objcopy % $(out)

## Strip debug info (comment out if debugging or something).
- objcopy --strip-debug $(out)
+# objcopy --strip-debug $(out)
endef
else # x86
TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT = $(outbase).kld
@@ -4730,7 +4733,7 @@ define TOOL_FREEBSDKMODLD_LINK_SYSMOD_CMDS
| xargs -J% objcopy % $(outbase).kld

# Link the final .ko (a shared object).
- ld $(flags) -Bshareable -o $(out) $(outbase).kld
+ ld $(flags) -Bshareable -znotext -o $(out) $(outbase).kld
endef
endif # x86

@@ -5016,10 +5019,18 @@ TEMPLATE_VBOXR3EXE_LIBPATH += \
TEMPLATE_VBOXR3EXE_CFLAGS += -fno-pic
TEMPLATE_VBOXR3EXE_CXXFLAGS += -fno-pic
TEMPLATE_VBOXR3EXE_LDFLAGS += -fno-pic
- else if1of ($(KBUILD_TARGET), freebsd openbsd)
+ else ifeq ($(KBUILD_TARGET),freebsd)
TEMPLATE_VBOXR3EXE_TOOL = GXX3
TEMPLATE_VBOXR3EXE_LIBS = pthread
+TEMPLATE_VBOXR3EXE_LDFLAGS.freebsd.x86 = -Wl,-z,notext
TEMPLATE_VBOXR3EXE_INCS += \
+ /usr/local/include
+TEMPLATE_VBOXR3EXE_LIBPATH += \
+ /usr/local/lib
+ else ifeq ($(KBUILD_TARGET),openbsd)
+TEMPLATE_VBOXR3EXE_TOOL = GXX3
+TEMPLATE_VBOXR3EXE_LIBS = pthread
+TEMPLATE_VBOXR3EXE_INCS += \
/usr/include \
/usr/X11R6/include \
/usr/local/include
@@ -5310,7 +5321,7 @@ ifeq ($(KBUILD_TARGET),win) # No CRT!
TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.win.amd64 = $(TEMPLATE_VBOXR3EXE_LDFLAGS.win.amd64) /entry:suplibHardenedWindowsMain
TEMPLATE_VBOXR3HARDENEDEXE_LIBS.x86 = $(NOT_SUCH_VARIABLE)
TEMPLATE_VBOXR3HARDENEDEXE_LIBS.amd64 = $(NOT_SUCH_VARIABLE)
-else ifn1of ($(KBUILD_TARGET), os2 solaris)
+else ifn1of ($(KBUILD_TARGET), freebsd os2 solaris)
# We want to keep the RPATH on Solaris to be able to find libgcc_1/libstdc++ within $(VBOX_WITH_RUNPATH)
TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBOXR3EXE_LDFLAGS))
TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.linux))
@@ -5837,10 +5848,18 @@ TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTI
else ifeq ($(KBUILD_TARGET),haiku)
TEMPLATE_VBOXMAINEXE_TOOL = GXX3
TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME) network stdc++ supc++
- else if1of ($(KBUILD_TARGET), freebsd openbsd)
+ else ifeq ($(KBUILD_TARGET),freebsd)
TEMPLATE_VBOXMAINEXE_TOOL = GXX3
TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
+TEMPLATE_VBOXMAINEXE_LDFLAGS.freebsd.x86 = -Wl,-z,notext
TEMPLATE_VBOXMAINEXE_INCS += \
+ /usr/local/include
+TEMPLATE_VBOXMAINEXE_LIBPATH += \
+ /usr/local/lib
+ else ifeq ($(KBUILD_TARGET),openbsd)
+TEMPLATE_VBOXMAINEXE_TOOL = GXX3
+TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
+TEMPLATE_VBOXMAINEXE_INCS += \
/usr/include \
/usr/X11R6/include \
/usr/local/include
@@ -6382,13 +6401,10 @@ ifdef VBOX_WITH_QTGUI
TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
$(VBOX_LIBPATH_X11)
ifeq ($(KBUILD_TARGET),freebsd)
+ TEMPLATE_VBOXQTGUIEXE_LDFLAGS.freebsd.x86 = -Wl,-z,notext
TEMPLATE_VBOXQTGUIEXE_INCS += \
- /usr/include \
- /usr/X11R6/include \
/usr/local/include
TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
- /usr/lib \
- /usr/X11R6/lib \
/usr/local/lib
endif
ifeq ($(KBUILD_TARGET),solaris)
@@ -6617,12 +6633,8 @@ TEMPLATE_VBoxBldProg_LIBPATH += \
TEMPLATE_VBoxBldProg_TOOL = GXX3
TEMPLATE_VBoxBldProg_LIBS = pthread
TEMPLATE_VBoxBldProg_INCS += \
- /usr/include \
- /usr/X11R6/include \
/usr/local/include
TEMPLATE_VBoxBldProg_LIBPATH += \
- /usr/lib \
- /usr/X11R6/lib \
/usr/local/lib
else ifeq ($(KBUILD_HOST),netbsd)
TEMPLATE_VBoxBldProg_TOOL = GXX3
@@ -7008,7 +7020,7 @@
#
TEMPLATE_VBOXCROGLR3HOSTDLL = VBox OpenGL Host DLLs
TEMPLATE_VBOXCROGLR3HOSTDLL_EXTENDS := $(if-expr "$(KBUILD_TARGET)" == "win",VBOXR3,VBOXR3NP)
-TEMPLATE_VBOXCROGLR3HOSTDLL_EXTENDS_BY = prepending
+TEMPLATE_VBOXCROGLR3HOSTDLL_EXTENDS_BY = appending
TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS = VBOX_WITH_HGCM UNPACKS
TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.win = _WIN32_WINNT=0x0500 WINDOWS=1
TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.linux = Linux=1 _GNU_SOURCE
@@ -7023,6 +7035,7 @@ TEMPLATE_VBOXCROGLR3HOSTDLL_LDFLAGS.darwin += \
-current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
-compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
TEMPLATE_VBOXCROGLR3HOSTDLL_LDFLAGS.linux = -Wl,--no-as-needed
+TEMPLATE_VBOXCROGLR3HOSTDLL_LDFLAGS.freebsd = -Wl,--no-as-needed
TEMPLATE_VBOXCROGLR3HOSTDLL_BLDDIRS = $(VBOX_PATH_CROGL_GENFILES)/
ifeq ($(KBUILD_TARGET),darwin)
TEMPLATE_VBOXCROGLR3HOSTDLL_CFLAGS = $(TEMPLATE_VBOXR3NP_CFLAGS) -Wno-deprecated-declarations
121 changes: 121 additions & 0 deletions emulators/virtualbox-ose-legacy/files/patch-configure
@@ -0,0 +1,121 @@
--- configure.orig 2020-05-13 19:36:41 UTC
+++ configure
@@ -138,10 +138,14 @@ CXX_FLAGS=""
if [ "$OS" = "freebsd" ]; then
INCCURL="-I/usr/local/include"
LIBCURL="-L/usr/local/lib -lcurl"
+ INCALSA="-I/usr/local/include"
+ LIBALSA="-L/usr/local/lib"
INCPULSE="-I/usr/local/include"
LIBPULSE="-L/usr/local/lib"
INCPNG="-I/usr/local/include"
LIBPNG="-L/usr/local/lib -lpng"
+ INCVNCSERVER="-I/usr/local/include"
+ LIBVNCSERVER="-L/usr/local/lib"
else
INCCURL=""
LIBCURL="-lcurl"
@@ -441,6 +445,9 @@ check_gcc()
elif [ $cc_maj -eq 4 -a $cc_min -eq 0 -a "$OS" = "darwin" ]; then
log_success "found version $cc_ver"
# gcc-4.0 is allowed for Darwin only
+ elif [ $cc_maj -eq 4 -a $cc_min -eq 2 -a "$OS" = "freebsd" ]; then
+ log_success "found version $cc_ver"
+ # gcc-4.2 is allowed for FreeBSD only
elif [ $cc_maj -lt 4 \
-o \( $cc_maj -eq 4 -a $cc_min -lt 4 -a "$OS" != "darwin" \) \
-o \( $cc_maj -eq 4 -a $cc_min -lt 2 -a "$OS" = "darwin" \) ]; then
@@ -1208,7 +1215,7 @@ extern "C" int main(void)
#endif
}
EOF
- if test_compile "-lasound" asound asound; then
+ if test_compile "$INCALSA $LIBALSA -lasound" asound asound; then
test_execute
fi
}
@@ -1508,8 +1515,7 @@ EOF
if [ $? -eq 0 ]; then
echo "(Qt5 from pkg-config)" >> $LOG
FLGQT5=`pkg-config Qt5Core --cflags`
- # gcc 4.8 is able to compile with C++11 (see also VBOX_GCC_std in Config.kmk)
- [ $cc_maj -eq 4 -a $cc_min -eq 8 ] && FLGQT5="$FLGQT5 -std=c++11"
+ FLGQT5="$FLGQT5 -std=c++11"
INCQT5=`strip_I "$FLGQT5"`
LIBDIR5=`pkg-config Qt5Core --variable=libdir`
LIBQT5=`pkg-config Qt5Core --libs`
@@ -1648,7 +1654,7 @@ check_libopus()
fi
cat > $ODIR.tmp_src.cc << EOF
#include <cstdio>
-#include <opus/opus.h>
+#include <opus.h>
extern "C" int main(void)
{
OpusEncoder *test;
@@ -1980,8 +1986,8 @@ EOF
echo "compiling the following source file:" >> $LOG
cat $ODIR.tmp_src.cc >> $LOG
echo "using the following command line:" >> $LOG
- echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so" >> $LOG
- $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
+ echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so -pthread" >> $LOG
+ $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so -pthread >> $LOG 2>&1
if [ $? -eq 0 ]; then
found=1
break
@@ -2453,7 +2459,7 @@ for option in "$@"; do
--with-openssl-dir=*)
OPENSSLDIR=`echo $option | cut -d'=' -f2`
INCCRYPTO="-I${OPENSSLDIR}/include"
- LIBCRYPTO="${OPENSSLDIR}/lib/libcrypto.a ${OPENSSLDIR}/lib/libssl.a"
+ LIBCRYPTO="-L${OPENSSLDIR}/lib -lssl -lcrypto"
;;
--with-ow-dir=*)
WATCOM=`echo $option | cut -d'=' -f2`
@@ -2767,7 +2773,7 @@ if [ $ONLY_ADDITIONS -eq 0 ]; then
check_ssl
check_curl
[ $WITH_LIBVPX -eq 1 ] && check_vpx
- check_libopus
+ [ $OSE -eq 0 -a "$OS" != "win" ] && check_libopus
[ "$OS" != "darwin" ] && check_z
[ "$OS" != "darwin" ] && check_png
[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
@@ -2788,13 +2794,20 @@ if [ $ONLY_ADDITIONS -eq 0 ]; then
[ $WITH_PYTHON -eq 1 ] && check_python
[ $WITH_JAVA -eq 1 ] && check_java

- # PulseAudio
if [ "$OS" = "linux" -o "$OS" = "freebsd" -o "$OS" = "netbsd" ]; then
+ if [ $WITH_ALSA -eq 1 ]; then
+ check_alsa
+ else
+ cnf_append "VBOX_WITH_AUDIO_ALSA" ""
+ fi
if [ $WITH_PULSE -eq 1 ]; then
check_pulse
elif [ $WITH_PULSE -eq 0 ]; then
cnf_append "VBOX_WITH_AUDIO_PULSE" ""
fi
+ if [ $WITH_DBUS -eq 0 ]; then
+ cnf_append "VBOX_WITH_DBUS" ""
+ fi
fi
fi

@@ -2810,14 +2823,6 @@ if [ "$OS" = "linux" ]; then
cnf_append "VBOX_WITHOUT_LINUX_TEST_BUILDS" "1"
fi
if [ $ONLY_ADDITIONS -eq 0 ]; then
- if [ $WITH_ALSA -eq 1 ]; then
- check_alsa
- else
- cnf_append "VBOX_WITH_AUDIO_ALSA" ""
- fi
- if [ $WITH_DBUS -eq 0 ]; then
- cnf_append "VBOX_WITH_DBUS" ""
- fi
if [ $WITH_DEVMAPPER -eq 1 ]; then
check_libdevmapper
else
File renamed without changes.
19 changes: 19 additions & 0 deletions emulators/virtualbox-ose-legacy/files/patch-include-iprt-x86.h
@@ -0,0 +1,19 @@
--- include/iprt/x86.h.orig 2020-05-13 19:36:52 UTC
+++ include/iprt/x86.h
@@ -35,6 +35,16 @@
# pragma D depends_on library vbox-types.d
#endif

+/* Workaround for FreeBSD machine/specialreg.h defining MSRs */
+#ifdef RT_OS_FREEBSD
+# undef MSR_P5_MC_ADDR
+# undef MSR_P5_MC_TYPE
+# undef MSR_IA32_PLATFORM_ID
+# undef MSR_BBL_CR_CTL3
+# undef MSR_IA32_MISC_ENABLE
+# undef MSR_IA32_FEATURE_CONTROL
+#endif
+
/* Workaround for Solaris sys/regset.h defining CS, DS */
#ifdef RT_OS_SOLARIS
# undef CS
File renamed without changes.
@@ -0,0 +1,36 @@
--- include/VBox/com/array.h.orig 2019-04-12 15:47:42 UTC
+++ include/VBox/com/array.h
@@ -168,7 +168,7 @@

#include "VBox/com/defs.h"

-#if RT_GNUC_PREREQ(4, 6) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
+#if RT_GNUC_PREREQ(4, 6) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(_LIBCPP_VERSION)
/** @def VBOX_WITH_TYPE_TRAITS
* Type traits are a C++ 11 feature, so not available everywhere (yet).
* Only GCC 4.6 or newer and MSVC++ 16.0 (Visual Studio 2010) or newer.
@@ -940,12 +940,12 @@ class SafeArray : public Traits (public)
*/
T &operator[] (size_t aIdx)
{
- AssertReturn(m.arr != NULL, *((T *)NULL));
- AssertReturn(aIdx < size(), *((T *)NULL));
+ AssertReturn(m.arr != NULL, *((T *)1));
+ AssertReturn(aIdx < size(), *((T *)1));
#ifdef VBOX_WITH_XPCOM
return m.arr[aIdx];
#else
- AssertReturn(m.raw != NULL, *((T *)NULL));
+ AssertReturn(m.raw != NULL, *((T *)1));
return m.raw[aIdx];
#endif
}
@@ -960,7 +960,7 @@ class SafeArray : public Traits (public)
#ifdef VBOX_WITH_XPCOM
return m.arr[aIdx];
#else
- AssertReturn(m.raw != NULL, *((T *)NULL));
+ AssertReturn(m.raw != NULL, *((T *)1));
return m.raw[aIdx];
#endif
}
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions emulators/virtualbox-ose-legacy/files/patch-include_iprt_string.h
@@ -0,0 +1,14 @@
--- include/iprt/string.h.orig 2018-06-29 13:08:03 UTC
+++ include/iprt/string.h
@@ -43,6 +43,11 @@
#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
RT_C_DECLS_BEGIN
# include <sys/libkern.h>
+ /*
+ * Kludge for the FreeBSD kernel:
+ * sys/libkern.h includes sys/param.h via sys/systm.h since r335879.
+ */
+# undef PVM
RT_C_DECLS_END

#elif defined(RT_OS_NETBSD) && defined(_KERNEL)
File renamed without changes.
@@ -0,0 +1,259 @@
--- src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c.orig 2020-05-13 19:37:01 UTC
+++ src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c
@@ -102,8 +102,6 @@ struct VBoxGuestDeviceState
struct resource *pIrqRes;
/** Pointer to the IRQ handler. */
void *pfnIrqHandler;
- /** VMMDev version */
- uint32_t u32Version;
};


@@ -113,8 +111,7 @@ struct VBoxGuestDeviceState
/*
* Character device file handlers.
*/
-static d_fdopen_t vgdrvFreeBSDOpen;
-static d_close_t vgdrvFreeBSDClose;
+static d_open_t vgdrvFreeBSDOpen;
static d_ioctl_t vgdrvFreeBSDIOCtl;
static int vgdrvFreeBSDIOCtlSlow(PVBOXGUESTSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd);
static d_write_t vgdrvFreeBSDWrite;
@@ -145,8 +142,7 @@ static struct cdevsw g_vgdrvFreeBSDChrDevSW =
{
.d_version = D_VERSION,
.d_flags = D_TRACKCLOSE | D_NEEDMINOR,
- .d_fdopen = vgdrvFreeBSDOpen,
- .d_close = vgdrvFreeBSDClose,
+ .d_open = vgdrvFreeBSDOpen,
.d_ioctl = vgdrvFreeBSDIOCtl,
.d_read = vgdrvFreeBSDRead,
.d_write = vgdrvFreeBSDWrite,
@@ -154,81 +150,28 @@ static struct cdevsw g_vgdrvFreeBSDChrDevSW =
.d_name = "vboxguest"
};

+/** Device structure. */
+static struct cdev *g_pDev;
+
/** Device extention & session data association structure. */
static VBOXGUESTDEVEXT g_DevExt;

-/** List of cloned device. Managed by the kernel. */
-static struct clonedevs *g_pvgdrvFreeBSDClones;
-/** The dev_clone event handler tag. */
-static eventhandler_tag g_vgdrvFreeBSDEHTag;
/** Reference counter */
static volatile uint32_t cUsers;
/** selinfo structure used for polling. */
static struct selinfo g_SelInfo;

-/**
- * DEVFS event handler.
- */
-static void vgdrvFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
+static void vgdrvFreeBSDDtr(void *pSession)
{
- int iUnit;
- int rc;
-
- Log(("vgdrvFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev));
-
- /*
- * One device node per user, si_drv1 points to the session.
- * /dev/vboxguest<N> where N = {0...255}.
- */
- if (!ppDev)
- return;
- if (strcmp(pszName, "vboxguest") == 0)
- iUnit = -1;
- else if (dev_stdclone(pszName, NULL, "vboxguest", &iUnit) != 1)
- return;
- if (iUnit >= 256)
- {
- Log(("vgdrvFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit));
- return;
- }
-
- Log(("vgdrvFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit));
-
- rc = clone_create(&g_pvgdrvFreeBSDClones, &g_vgdrvFreeBSDChrDevSW, &iUnit, ppDev, 0);
- Log(("vgdrvFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
- if (rc)
- {
- *ppDev = make_dev(&g_vgdrvFreeBSDChrDevSW,
- iUnit,
- UID_ROOT,
- GID_WHEEL,
- 0664,
- "vboxguest%d", iUnit);
- if (*ppDev)
- {
- dev_ref(*ppDev);
- (*ppDev)->si_flags |= SI_CHEAPCLONE;
- Log(("vgdrvFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
- *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
- (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL;
- }
- else
- Log(("vgdrvFreeBSDClone: make_dev iUnit=%d failed\n", iUnit));
- }
- else
- Log(("vgdrvFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
- *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
+ VGDrvCommonCloseSession(&g_DevExt, pSession);
+ ASMAtomicDecU32(&cUsers);
}

/**
* File open handler
*
*/
-#if __FreeBSD_version >= 700000
-static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd, struct file *pFd)
-#else
-static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd)
-#endif
+static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, int DevType, struct thread *pTd)
{
int rc;
PVBOXGUESTSESSION pSession;
@@ -236,25 +179,18 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
LogFlow(("vgdrvFreeBSDOpen:\n"));

/*
- * Try grab it (we don't grab the giant, remember).
- */
- if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, (void *)0x42, NULL))
- return EBUSY;
-
- /*
* Create a new session.
*/
rc = VGDrvCommonCreateUserSession(&g_DevExt, &pSession);
if (RT_SUCCESS(rc))
{
- if (ASMAtomicCmpXchgPtr(&pDev->si_drv1, pSession, (void *)0x42))
- {
- Log(("vgdrvFreeBSDOpen: success - g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
+ Log(("vgdrvFreeBSDOpen: success - g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
+ rc = devfs_set_cdevpriv(pSession, vgdrvFreeBSDDtr);
+ if (rc)
+ VGDrvCommonCloseSession(&g_DevExt, pSession);
+ else
ASMAtomicIncU32(&cUsers);
- return 0;
- }
-
- VGDrvCommonCloseSession(&g_DevExt, pSession);
+ return rc;
}

LogRel(("vgdrvFreeBSDOpen: failed. rc=%d\n", rc));
@@ -262,33 +198,6 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
}

/**
- * File close handler
- *
- */
-static int vgdrvFreeBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd)
-{
- PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
- Log(("vgdrvFreeBSDClose: fFile=%#x pSession=%p\n", fFile, pSession));
-
- /*
- * Close the session if it's still hanging on to the device...
- */
- if (VALID_PTR(pSession))
- {
- VGDrvCommonCloseSession(&g_DevExt, pSession);
- if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, NULL, pSession))
- Log(("vgdrvFreeBSDClose: si_drv1=%p expected %p!\n", pDev->si_drv1, pSession));
- ASMAtomicDecU32(&cUsers);
- /* Don't use destroy_dev here because it may sleep resulting in a hanging user process. */
- destroy_dev_sched(pDev);
- }
- else
- Log(("vgdrvFreeBSDClose: si_drv1=%p!\n", pSession));
- return 0;
-}
-
-
-/**
* I/O control request.
*
* @returns depends...
@@ -301,8 +210,12 @@ static int vgdrvFreeBSDClose(struct cdev *pDev, int fF
static int vgdrvFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
{
PVBOXGUESTSESSION pSession;
- devfs_get_cdevpriv((void **)&pSession);
+ int rc;
+ rc = devfs_get_cdevpriv((void **)&pSession);
+ if (rc)
+ return rc;
+
/*
* Deal with the fast ioctl path first.
*/
@@ -497,12 +410,14 @@ int VBOXCALL VBoxGuestIDC(void *pvSession, uintptr_t u

static int vgdrvFreeBSDPoll(struct cdev *pDev, int fEvents, struct thread *td)
{
- int fEventsProcessed;
+ PVBOXGUESTSESSION pSession;
+ int fEventsProcessed, rc;

LogFlow(("vgdrvFreeBSDPoll: fEvents=%d\n", fEvents));

- PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
- if (RT_UNLIKELY(!VALID_PTR(pSession))) {
+ rc = devfs_get_cdevpriv((void **)&pSession);
+ if (rc)
+ {
Log(("vgdrvFreeBSDPoll: no state data for %s\n", devtoname(pDev)));
return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
}
@@ -543,11 +458,8 @@ static int vgdrvFreeBSDDetach(device_t pDevice)
/*
* Reverse what we did in vgdrvFreeBSDAttach.
*/
- if (g_vgdrvFreeBSDEHTag != NULL)
- EVENTHANDLER_DEREGISTER(dev_clone, g_vgdrvFreeBSDEHTag);
+ destroy_dev(g_pDev);

- clone_cleanup(&g_pvgdrvFreeBSDClones);
-
vgdrvFreeBSDRemoveIRQ(pDevice, pState);

if (pState->pVMMDevMemRes)
@@ -698,18 +610,21 @@ static int vgdrvFreeBSDAttach(device_t pDevice)
if (RT_SUCCESS(rc))
{
/*
- * Configure device cloning.
+ * Configure device.
*/
- clone_setup(&g_pvgdrvFreeBSDClones);
- g_vgdrvFreeBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, vgdrvFreeBSDClone, 0, 1000);
- if (g_vgdrvFreeBSDEHTag)
+ g_pDev = make_dev(&g_vgdrvFreeBSDChrDevSW,
+ 0,
+ UID_ROOT,
+ GID_WHEEL,
+ 0664,
+ "vboxguest");
+ if (g_pDev)
{
printf(DEVICE_NAME ": loaded successfully\n");
return 0;
}

- printf(DEVICE_NAME ": EVENTHANDLER_REGISTER(dev_clone,,,) failed\n");
- clone_cleanup(&g_pvgdrvFreeBSDClones);
+ printf(DEVICE_NAME ": make_dev failed\n");
vgdrvFreeBSDRemoveIRQ(pDevice, pState);
}
else
@@ -0,0 +1,18 @@
--- src/VBox/Additions/common/VBoxGuest/freebsd/Makefile.orig 2020-05-13 19:37:01 UTC
+++ src/VBox/Additions/common/VBoxGuest/freebsd/Makefile
@@ -80,6 +80,7 @@ SRCS += \
handletable.c \
handletablectx.c \
once.c \
+ term.c \
thread.c

.PATH: ${.CURDIR}/common/string
@@ -139,6 +140,7 @@ SRCS += \

.PATH: ${.CURDIR}/r0drv
SRCS += \
+ alloc-ef-r0drv.c \
alloc-r0drv.c \
initterm-r0drv.c \
memobj-r0drv.c \
@@ -0,0 +1,26 @@
--- src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest.orig 2020-05-13 19:37:01 UTC
+++ src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest
@@ -109,6 +109,7 @@ FILES_VBOXGUEST_NOBIN=" \
${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.h=>common/misc/handletable.h \
${PATH_ROOT}/src/VBox/Runtime/common/misc/handletablectx.cpp=>common/misc/handletablectx.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/once.cpp=>common/misc/once.c \
+ ${PATH_ROOT}/src/VBox/Runtime/common/misc/term.cpp=>common/misc/term.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/thread.cpp=>common/misc/thread.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg1Weak.cpp=>common/misc/RTAssertMsg1Weak.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2.cpp=>common/misc/RTAssertMsg2.c \
@@ -171,6 +172,7 @@ FILES_VBOXGUEST_NOBIN=" \
${PATH_ROOT}/src/VBox/Runtime/generic/errvars-generic.cpp=>generic/errvars-generic.c \
${PATH_ROOT}/src/VBox/Runtime/generic/timer-generic.cpp=>generic/timer-generic.c \
${PATH_ROOT}/src/VBox/Runtime/generic/mppresent-generic.cpp=>generic/mppresent-generic.c \
+ ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-ef-r0drv.cpp=>r0drv/alloc-ef-r0drv.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.cpp=>r0drv/alloc-r0drv.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.h=>r0drv/alloc-r0drv.h \
${PATH_ROOT}/src/VBox/Runtime/r0drv/initterm-r0drv.cpp=>r0drv/initterm-r0drv.c \
@@ -197,6 +199,7 @@ FILES_VBOXGUEST_NOBIN=" \
${PATH_ROOT}/src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h=>r0drv/freebsd/sleepqueue-r0drv-freebsd.h \
${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/semspinmutex-r0drv-generic.c=>r0drv/generic/semspinmutex-r0drv-generic.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/mpnotification-r0drv-generic.cpp=>r0drv/generic/mpnotification-r0drv-generic.c \
+ ${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/threadctxhooks-r0drv-generic.cpp=>r0drv/generic/threadctxhooks-r0drv-generic.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.cpp=>r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/memobj-r0drv.cpp=>r0drv/memobj-r0drv.c \
${PATH_ROOT}/src/VBox/Runtime/VBox/log-vbox.cpp=>VBox/log-vbox.c \
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,18 @@
--- src/VBox/Additions/x11/Installer/98vboxadd-xclient.orig 2020-05-13 19:37:09 UTC
+++ src/VBox/Additions/x11/Installer/98vboxadd-xclient
@@ -30,10 +30,10 @@ elif test -z "${SSH_CONNECTION}"; then
# This script can also be triggered by a connection over SSH, which is not
# what we had in mind, so we do not start VBoxClient in that case. We do
# not use "exit" here as this script is "source"d, not executed.
- /usr/bin/VBoxClient --clipboard
- /usr/bin/VBoxClient --checkhostversion
- /usr/bin/VBoxClient --display
- /usr/bin/VBoxClient --seamless
- /usr/bin/VBoxClient --draganddrop
+ /usr/local/bin/VBoxClient --clipboard
+ /usr/local/bin/VBoxClient --checkhostversion
+ /usr/local/bin/VBoxClient --display
+ /usr/local/bin/VBoxClient --seamless
+ /usr/local/bin/VBoxClient --draganddrop
/usr/bin/VBoxClient --vmsvga-x11 # In case VMSVGA emulation is enabled
fi
@@ -0,0 +1,10 @@
--- src/VBox/Additions/x11/Installer/vboxclient.desktop.orig 2020-05-13 19:37:09 UTC
+++ src/VBox/Additions/x11/Installer/vboxclient.desktop
@@ -8,6 +8,6 @@ Comment[C]=VirtualBox User Session Services
Comment=VirtualBox User Session Services
Comment[it]=Servizi di sessione utente di VirtualBox
Comment[pl]=Usługi sesji użytkownika VirtualBox
-Exec=/usr/bin/VBoxClient-all
+Exec=/usr/local/bin/VBoxClient-all
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
@@ -0,0 +1,12 @@
--- src/VBox/Devices/Network/slirp/bsd/sys/mbuf.h.orig 2020-05-13 19:42:23 UTC
+++ src/VBox/Devices/Network/slirp/bsd/sys/mbuf.h
@@ -245,6 +245,9 @@ struct mbuf {
#define M_FRAG 0x00000800 /* packet is a fragment of a larger packet */
#define M_FIRSTFRAG 0x00001000 /* packet is first fragment */
#define M_LASTFRAG 0x00002000 /* packet is last fragment */
+#ifdef M_SKIP_FIREWALL
+#undef M_SKIP_FIREWALL
+#endif
#define M_SKIP_FIREWALL 0x00004000 /* skip firewall processing */
#define M_FREELIST 0x00008000 /* mbuf is on the free list */
#define M_VLANTAG 0x00010000 /* ether_vtag is valid */
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,27 @@
--- src/VBox/HostDrivers/Support/freebsd/Makefile.orig 2020-05-13 19:43:53 UTC
+++ src/VBox/HostDrivers/Support/freebsd/Makefile
@@ -82,6 +82,7 @@ SRCS += \
assert.c \
handletable.c \
handletablectx.c \
+ handletablesimple.c \
once.c \
term.c \
thread.c
@@ -94,13 +95,14 @@ SRCS += \
RTStrCopy.c \
RTStrCopyEx.c \
RTStrCopyP.c \
+ memchr.c \
strformat.c \
strformatrt.c \
strformattype.c \
+ stringalloc.c \
strprintf.c \
strtonum.c \
- memchr.c \
- stringalloc.c
+ utf-8.c

.PATH: ${.CURDIR}/common/rand
SRCS += \
@@ -0,0 +1,27 @@
--- src/VBox/HostDrivers/Support/freebsd/files_vboxdrv.orig 2020-05-13 19:43:53 UTC
+++ src/VBox/HostDrivers/Support/freebsd/files_vboxdrv
@@ -118,6 +118,7 @@ FILES_VBOXDRV_NOBIN=" \
${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.cpp=>common/misc/handletable.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.h=>common/misc/handletable.h \
${PATH_ROOT}/src/VBox/Runtime/common/misc/handletablectx.cpp=>common/misc/handletablectx.c \
+ ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletablesimple.cpp=>common/misc/handletablesimple.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/once.cpp=>common/misc/once.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/term.cpp=>common/misc/term.c \
${PATH_ROOT}/src/VBox/Runtime/common/misc/thread.cpp=>common/misc/thread.c \
@@ -127,13 +128,14 @@ FILES_VBOXDRV_NOBIN=" \
${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopyEx.cpp=>common/string/RTStrCopyEx.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrNCmp.cpp=>common/string/RTStrNCmp.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrNLen.cpp=>common/string/RTStrNLen.c \
+ ${PATH_ROOT}/src/VBox/Runtime/common/string/memchr.cpp=>common/string/memchr.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/strformat.cpp=>common/string/strformat.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/strformatrt.cpp=>common/string/strformatrt.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/strformattype.cpp=>common/string/strformattype.c \
+ ${PATH_ROOT}/src/VBox/Runtime/common/string/stringalloc.cpp=>common/string/stringalloc.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/strprintf.cpp=>common/string/strprintf.c \
${PATH_ROOT}/src/VBox/Runtime/common/string/strtonum.cpp=>common/string/strtonum.c \
- ${PATH_ROOT}/src/VBox/Runtime/common/string/memchr.cpp=>common/string/memchr.c \
- ${PATH_ROOT}/src/VBox/Runtime/common/string/stringalloc.cpp=>common/string/stringalloc.c \
+ ${PATH_ROOT}/src/VBox/Runtime/common/string/utf-8.cpp=>common/string/utf-8.c \
${PATH_ROOT}/src/VBox/Runtime/common/rand/rand.cpp=>common/rand/rand.c \
${PATH_ROOT}/src/VBox/Runtime/common/rand/randadv.cpp=>common/rand/randadv.c \
${PATH_ROOT}/src/VBox/Runtime/common/rand/randparkmiller.cpp=>common/rand/randparkmiller.c \
@@ -0,0 +1,25 @@
Fix kmod panic when VIMAGE is disabled in the kernel and port

Submitted by: Gleb Kurtsou <gleb@freebsd.org>
--- src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk.orig 2020-05-13 19:43:54 UTC
+++ src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk
@@ -203,12 +203,15 @@ $$(VBoxNetAdp-src_0_OUTDIR)/Makefile: \
$$(if $$(eq $$(VBoxNetAdp/freebsd/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
| $$(dir $$@)
$(QUIET)$(RM) -f -- $@
- ifndef VBOX_WITH_HARDENING
- $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
- else
$(QUIET)$(CP) -f $< $@
+ ifndef VBOX_WITH_HARDENING
+ $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@.tmp $@
+ ${QUIET}$(MV) -f $@.tmp $@
endif
-
+ ifndef VBOX_WITH_NETFLT_VIMAGE
+ $(QUIET)$(SED) -e "s;-DVIMAGE;;g" --output $@.tmp $@
+ ${QUIET}$(MV) -f $@.tmp $@
+ endif
endif # freebsd

include $(FILE_KBUILD_SUB_FOOTER)
File renamed without changes.
@@ -0,0 +1,273 @@
--- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c.orig 2018-10-15 14:30:58 UTC
+++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c
@@ -52,6 +52,7 @@
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/ethernet.h>
+#include <net/if_vlan_var.h>

#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
@@ -73,6 +74,7 @@

#define VBOXNETFLT_OS_SPECFIC 1
#include "../VBoxNetFltInternal.h"
+#include "freebsd/the-freebsd-kernel.h"

static int vboxnetflt_modevent(struct module *, int, void *);
static ng_constructor_t ng_vboxnetflt_constructor;
@@ -370,7 +372,11 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i
mtx_lock_spin(&pThis->u.s.inq.ifq_mtx);
_IF_ENQUEUE(&pThis->u.s.inq, m);
mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx);
+#if __FreeBSD_version >= 1100100
+ taskqueue_enqueue(taskqueue_fast, &pThis->u.s.tskin);
+#else
taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin);
+#endif
}
/*
* Handle mbufs on the outgoing hook, frames going to the interface
@@ -388,7 +394,11 @@ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p i
mtx_lock_spin(&pThis->u.s.outq.ifq_mtx);
_IF_ENQUEUE(&pThis->u.s.outq, m);
mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx);
+#if __FreeBSD_version >= 1100100
+ taskqueue_enqueue(taskqueue_fast, &pThis->u.s.tskout);
+#else
taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout);
+#endif
}
else
{
@@ -428,6 +438,8 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend
struct ifnet *ifp = pThis->u.s.ifp;
unsigned int cSegs = 0;
bool fDropIt = false, fActive;
+ bool is_vl_tagged = false;
+ uint16_t vl_tag;
PINTNETSG pSG;
VBOXCURVNET_SET(ifp->if_vnet);
@@ -440,6 +452,19 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend
if (m == NULL)
break;
+ /* Prepend a VLAN header for consumption by the virtual switch */
+ if (m->m_flags & M_VLANTAG) {
+ vl_tag = m->m_pkthdr.ether_vtag;
+ is_vl_tagged = true;
+
+ m = ether_vlanencap(m, m->m_pkthdr.ether_vtag);
+ if (m == NULL) {
+ printf("vboxflt: unable to prepend VLAN header\n");
+ break;
+ }
+ m->m_flags &= ~M_VLANTAG;
+ }
+
for (m0 = m; m0 != NULL; m0 = m0->m_next)
if (m0->m_len > 0)
cSegs++;
@@ -454,6 +479,27 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend
vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0);
fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, NULL /* pvIf */, pSG, INTNETTRUNKDIR_WIRE);
RTMemTmpFree(pSG);
+
+ /* Restore the VLAN flags before re-injecting the packet */
+ if (is_vl_tagged && !fDropIt) {
+ struct ether_vlan_header *vl_hdr;
+
+ /* This shouldn't fail, as the header was just prepended */
+ if (m->m_len < sizeof(*vl_hdr) && (m = m_pullup(m, sizeof(*vl_hdr))) == NULL) {
+ printf("vboxflt: unable to pullup VLAN header\n");
+ m_freem(m);
+ break;
+ }
+
+ /* Copy the MAC dhost/shost over the 802.1q field */
+ vl_hdr = mtod(m, struct ether_vlan_header *);
+ bcopy((char *)vl_hdr, (char *)vl_hdr + ETHER_VLAN_ENCAP_LEN, ETHER_HDR_LEN - ETHER_TYPE_LEN);
+ m_adj(m, ETHER_VLAN_ENCAP_LEN);
+
+ m->m_pkthdr.ether_vtag = vl_tag;
+ m->m_flags |= M_VLANTAG;
+ }
+
if (fDropIt)
m_freem(m);
else
@@ -513,6 +559,7 @@ static void vboxNetFltFreeBSDoutput(void *arg, int pen
*/
int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *pvIfData, PINTNETSG pSG, uint32_t fDst)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
NOREF(pvIfData);

void (*input_f)(struct ifnet *, struct mbuf *);
@@ -529,10 +576,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
{
m = vboxNetFltFreeBSDSGMBufFromSG(pThis, pSG);
if (m == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
m = m_pullup(m, ETHER_HDR_LEN);
if (m == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }

m->m_flags |= M_PKTHDR;
ether_output_frame(ifp, m);
@@ -542,10 +595,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
{
m = vboxNetFltFreeBSDSGMBufFromSG(pThis, pSG);
if (m == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
m = m_pullup(m, ETHER_HDR_LEN);
if (m == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
+ }
/*
* Delivering packets to the host will be captured by the
* input hook. Tag the packet with a mbuf tag so that we
@@ -556,6 +615,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
if (mtag == NULL)
{
m_freem(m);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_NO_MEMORY;
}
@@ -566,6 +626,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
ifp->if_input(ifp, m);
}
VBOXCURVNET_RESTORE();
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
@@ -578,6 +639,7 @@ static bool vboxNetFltFreeBsdIsPromiscuous(PVBOXNETFLT
int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
char nam[NG_NODESIZ];
struct ifnet *ifp;
node_p node;
@@ -586,7 +648,10 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi
NOREF(pvContext);
ifp = ifunit(pThis->szName);
if (ifp == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_INTNET_FLT_IF_NOT_FOUND;
+ }
/* Create a new netgraph node for this instance */
if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0)
@@ -630,12 +695,14 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi
vboxNetFltRelease(pThis, true /*fBusy*/);
}
VBOXCURVNET_RESTORE();
+ IPRT_FREEBSD_RESTORE_EFL_AC();

return VINF_SUCCESS;
}

bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThis)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
struct ifnet *ifp, *ifp0;

ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
@@ -652,6 +719,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi
pThis->u.s.node = NULL;
}
VBOXCURVNET_RESTORE();
+ IPRT_FREEBSD_RESTORE_EFL_AC();

if (ifp0 != NULL)
{
@@ -664,6 +732,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi

void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();

taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin);
taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout);
@@ -676,6 +745,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
ng_rmnode_self(pThis->u.s.node);
VBOXCURVNET_RESTORE();
pThis->u.s.node = NULL;
+ IPRT_FREEBSD_RESTORE_EFL_AC();
}

int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)
@@ -689,6 +759,7 @@ int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)

void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
struct ifnet *ifp;
struct ifreq ifreq;
int error;
@@ -722,7 +793,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b
NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT,
sizeof(struct ngm_connect), M_NOWAIT);
if (msg == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return;
+ }
con = (struct ngm_connect *)msg->data;
snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:", ifp->if_xname);
strlcpy(con->ourhook, "lower", NG_HOOKSIZ);
@@ -736,7 +810,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b
NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT,
sizeof(struct ngm_connect), M_NOWAIT);
if (msg == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return;
+ }
con = (struct ngm_connect *)msg->data;
snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:",
ifp->if_xname);
@@ -759,7 +836,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b
NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_RMHOOK,
sizeof(struct ngm_rmhook), M_NOWAIT);
if (msg == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return;
+ }
rm = (struct ngm_rmhook *)msg->data;
strlcpy(rm->ourhook, "input", NG_HOOKSIZ);
NG_SEND_MSG_PATH(error, node, msg, path, 0);
@@ -770,12 +850,16 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b
NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_RMHOOK,
sizeof(struct ngm_rmhook), M_NOWAIT);
if (msg == NULL)
+ {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return;
+ }
rm = (struct ngm_rmhook *)msg->data;
strlcpy(rm->ourhook, "output", NG_HOOKSIZ);
NG_SEND_MSG_PATH(error, node, msg, path, 0);
}
VBOXCURVNET_RESTORE();
+ IPRT_FREEBSD_RESTORE_EFL_AC();
}

int vboxNetFltOsDisconnectIt(PVBOXNETFLTINS pThis)
@@ -0,0 +1,10 @@
--- src/VBox/HostDrivers/VBoxNetFlt/freebsd/files_vboxnetflt.orig 2018-10-15 14:30:58 UTC
+++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/files_vboxnetflt
@@ -61,6 +61,7 @@ VBOX_VBOXNETFLT_SOURCES=" \
${PATH_ROOT}/include/iprt/uni.h=>include/iprt/uni.h \
${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
+ ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
@@ -0,0 +1,14 @@
--- src/VBox/Installer/Makefile.kmk.orig 2020-05-13 19:44:01 UTC
+++ src/VBox/Installer/Makefile.kmk
@@ -41,9 +41,11 @@ ifndef VBOX_ONLY_SDK
if "$(KBUILD_TARGET)" == "win" && "$(KBUILD_HOST)" == "win"
include $(PATH_SUB_CURRENT)/win/Makefile.kmk
endif
+if 0
if "$(KBUILD_TARGET)" == "freebsd" && "$(KBUILD_HOST)" == "freebsd"
include $(PATH_SUB_CURRENT)/freebsd/Makefile.kmk
endif
+endif
endif

include $(PATH_SUB_CURRENT)/common/Makefile.kmk
@@ -0,0 +1,67 @@
--- src/VBox/Installer/freebsd/VBox.sh.orig 2016-08-27 05:10:34 UTC
+++ src/VBox/Installer/freebsd/VBox.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# Oracle VM VirtualBox startup script, FreeBSD hosts.
+#
+# Copyright (C) 2006-2012 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+PATH="/usr/bin:/bin:/usr/sbin:/sbin"
+CONFIG="/usr/local/etc/vbox/vbox.cfg"
+
+test -r "${CONFIG}" &&
+ . "${CONFIG}"
+test -z "${INSTALL_DIR}" &&
+ if test -d /usr/local/lib/virtualbox &&
+ test -f /usr/local/lib/virtualbox/VBoxRT.so; then
+ INSTALL_DIR=/usr/local/lib/virtualbox
+ else
+ echo "Could not find VirtualBox installation. Please reinstall."
+ exit 1
+ fi
+
+# workaround for the KDE dialog problem
+KDE_FORK_SLAVES=1; export KDE_FORK_SLAVES
+
+APP=`basename $0`
+case "$APP" in
+ VirtualBox|virtualbox)
+ exec "$INSTALL_DIR/VirtualBox" "$@"
+ ;;
+ VBoxManage|vboxmanage)
+ exec "$INSTALL_DIR/VBoxManage" "$@"
+ ;;
+ VBoxSDL|vboxsdl)
+ exec "$INSTALL_DIR/VBoxSDL" "$@"
+ ;;
+ VBoxVRDP|VBoxHeadless|vboxheadless)
+ exec "$INSTALL_DIR/VBoxHeadless" "$@"
+ ;;
+ VBoxAutostart|vboxautostart)
+ exec "$INSTALL_DIR/VBoxAutostart" "$@"
+ ;;
+ VBoxBalloonCtrl|vboxballoonctrl)
+ exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
+ ;;
+ VBoxBugReport|vboxbugreport)
+ exec "$INSTALL_DIR/VBoxBugReport" "$@"
+ ;;
+ vboxwebsrv)
+ exec "$INSTALL_DIR/vboxwebsrv" "$@"
+ ;;
+ *)
+ echo "Unknown application - $APP"
+ exit 1
+ ;;
+esac
+exit 0
@@ -0,0 +1,10 @@
--- src/VBox/Installer/freebsd/virtualbox.desktop.orig 2020-05-13 19:44:01 UTC
+++ src/VBox/Installer/freebsd/virtualbox.desktop
@@ -7,7 +7,6 @@ GenericName=Virtual Machine
Type=Application
Exec=VirtualBox
TryExec=VirtualBox
-DocPath=file://$VBOX_DOC_PATH/UserManual.pdf
Icon=VBox
Categories=Emulator;System;
Comment=Run several virtual systems on a single host computer
@@ -0,0 +1,11 @@
--- src/VBox/Main/src-server/VirtualBoxImpl.cpp.orig 2020-05-13 19:44:10 UTC
+++ src/VBox/Main/src-server/VirtualBoxImpl.cpp
@@ -2251,7 +2251,7 @@ int VirtualBox::i_encryptSettingBytes(const uint8_t *a
if (aCiphertextSize < 32)
return VERR_INVALID_PARAMETER;

- AssertCompile(sizeof(m->SettingsCipherKey) >= 32);
+ // AssertCompile(sizeof(m->SettingsCipherKey) >= 32);

/* store the first 8 bytes of the cipherkey for verification */
for (i = 0, j = 0; i < 8; i++, j++)
File renamed without changes.
@@ -0,0 +1,39 @@
--- src/VBox/Main/webservice/Makefile.kmk.orig 2020-05-13 19:44:11 UTC
+++ src/VBox/Main/webservice/Makefile.kmk
@@ -158,7 +158,6 @@ VBOX_PATH_IDL := $(abspath $(PATH_SUB_
RECOMPILE_ON_MAKEFILE_CURRENT := $(MAKEFILE_CURRENT)

PATH_TARGET_SOAPDEMOXML := $(VBOXWEB_OUT_DIR)/demo_soapxml
-PATH_TARGET_SOAPDEMOHEADERS := $(VBOXWEB_OUT_DIR)/demo_headers
PATH_TARGET_SOAPDEMONSMAPS := $(VBOXWEB_OUT_DIR)/demo_namespacemaps
PATH_TARGET_WEBTEST := $(VBOXWEB_OUT_DIR)/webtest

@@ -553,8 +552,6 @@ $$(VBOX_JWSSRC_JAR): $$(VBOX_JWS_JAR) | $$(dir $$@)
$(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts \
$(wildcard $(PATH_TARGET_SOAPDEMOXML)/*) \
$(PATH_TARGET_SOAPDEMOXML)/dummy_file \
- $(wildcard $(PATH_TARGET_SOAPDEMOHEADERS)/*) \
- $(PATH_TARGET_SOAPDEMOHEADERS)/dummy_file \
$(wildcard $(PATH_TARGET_SOAPDEMONSMAPS)/*) \
$(PATH_TARGET_SOAPDEMONSMAPS)/dummy_file

@@ -774,17 +771,14 @@ endif
# any more. Ignoring the exit code is the simple solution, accepting the error.
$(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts: $(VBOXWEB_OUT_DIR)/gsoap_generate_all_ts | $$(dir $$@)
$(RM) -f $@
- $(MKDIR) -p $(PATH_TARGET_SOAPDEMOXML) $(PATH_TARGET_SOAPDEMOHEADERS) $(PATH_TARGET_SOAPDEMONSMAPS)
+ $(MKDIR) -p $(PATH_TARGET_SOAPDEMOXML) $(PATH_TARGET_SOAPDEMONSMAPS)
ifdef VBOX_GSOAP_VERBOSE
$(MV_EXT) -f -- $(VBOXWEB_OUT_DIR)/*.req.xml $(VBOXWEB_OUT_DIR)/*.res.xml $(PATH_TARGET_SOAPDEMOXML)/
endif
- -$(MV_EXT) -f -- $(VBOXWEB_OUT_DIR)/soapvbox*.h $(PATH_TARGET_SOAPDEMOHEADERS)/
$(MV_EXT) -f -- $(VBOXWEB_OUT_DIR)/vboxBinding.nsmap $(PATH_TARGET_SOAPDEMONSMAPS)/
$(APPEND) $@ done

-$(PATH_TARGET_SOAPDEMONSMAPS) \
-$(PATH_TARGET_SOAPDEMOHEADERS)/soapvboxBindingProxy.h \
-$(PATH_TARGET_SOAPDEMOHEADERS)/soapvboxBindingObject.h: $(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts
+$(PATH_TARGET_SOAPDEMONSMAPS): $(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts

# soapcpp2 -2: generate SOAP 1.2 calls
# soapcpp2 -S: server-side code only
@@ -0,0 +1,23 @@
--- src/VBox/Runtime/Makefile.kmk.orig 2020-07-09 16:57:23 UTC
+++ src/VBox/Runtime/Makefile.kmk
@@ -173,6 +173,11 @@ $(IPRT_OUT_DIR)/oiddb.h.ts +| $(IPRT_OUT_DIR)/oiddb.h:


#
+# Set the defines that utf8-posix.cpp needs. It's used by several targets.
+#
+r3/posix/utf8-posix.cpp_DEFS.freebsd = $(VBOX_ICONV_DEFS)
+
+#
# Unicode Specification reader used to regenerate unidata-*.cpp.
#
uniread_TEMPLATE = VBoxBldProg
@@ -1632,7 +1637,7 @@ VBoxRT_SOURCES.solaris += \
VBoxRT_SOURCES.darwin += \
r3/posix/fileaio-posix.cpp
VBoxRT_SOURCES.freebsd += \
- r3/freebsd/fileaio-freebsd.cpp
+ r3/posix/fileaio-posix.cpp
VBoxRT_INCS := $(RuntimeR3_INCS)
VBoxRT_INCS.$(KBUILD_TARGET) := $(RuntimeR3_INCS.$(KBUILD_TARGET))
VBoxRT_INCS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) := $(RuntimeR3_INCS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
@@ -0,0 +1,20 @@
Without this patch any waits for periods shorter than a single tick return
immediately leading to a lot of unnecessary spinning. For example, I observe that
my guest's idle loop does a lot of sleeps with periods slightly shorter than 1 ms
(1/hz), e.g. 900us. All that waiting turns into pure spinning and VirtualBox eats
100% of a core.
The patch improves the situation significantly. Also, it (approximately) follows
what tvtohz does.

Submitted by: Andriy Gapon <avg@FreeBSD.org>
--- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig 2020-05-13 19:44:32 UTC
+++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h
@@ -82,6 +82,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0
uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
if (cTicks >= INT_MAX)
return RTSEMWAIT_FLAGS_INDEFINITE;
+ else if (cTicks == 0 && uTimeout > 0)
+ pWait->iTimeout = 1;
else
pWait->iTimeout = (int)cTicks;
#endif
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,71 @@
--- src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp.orig 2017-03-08 17:15:20 UTC
+++ src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
@@ -71,8 +71,8 @@
# include <net/if.h>
# include <pwd.h> /* getpwuid */
# include <unistd.h>
-# if !defined(RT_OS_OS2) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_HAIKU)
-# include <utmpx.h> /** @todo FreeBSD 9 should have this. */
+# if !defined(RT_OS_OS2) && !defined(RT_OS_HAIKU)
+# include <utmpx.h>
# endif
# ifdef RT_OS_OS2
# include <net/if_dl.h>
@@ -531,7 +531,7 @@ static void vgsvcVMInfoWriteFixedPropert
}


-#if defined(VBOX_WITH_DBUS) && defined(RT_OS_LINUX) /* Not yet for Solaris/FreeBSB. */
+#if defined(VBOX_WITH_DBUS) && (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) /* Not yet for Solaris. */
/*
* Simple wrapper to work around compiler-specific va_list madness.
*/
@@ -562,12 +562,6 @@ static int vgsvcVMInfoWriteUsers(void)
rc = VERR_NOT_IMPLEMENTED;
# endif

-#elif defined(RT_OS_FREEBSD)
- /** @todo FreeBSD: Port logged on user info retrieval.
- * However, FreeBSD 9 supports utmpx, so we could use the code
- * block below (?). */
- rc = VERR_NOT_IMPLEMENTED;
-
#elif defined(RT_OS_HAIKU)
/** @todo Haiku: Port logged on user info retrieval. */
rc = VERR_NOT_IMPLEMENTED;
@@ -593,7 +587,7 @@ static int vgsvcVMInfoWriteUsers(void)
while ( (ut_user = getutxent())
&& RT_SUCCESS(rc))
{
-# ifdef RT_OS_DARWIN /* No ut_user->ut_session on Darwin */
+# if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) /* No ut_user->ut_session on Darwin/FreeBSD */
VGSvcVerbose(4, "Found entry '%s' (type: %d, PID: %RU32)\n", ut_user->ut_user, ut_user->ut_type, ut_user->ut_pid);
# else
VGSvcVerbose(4, "Found entry '%s' (type: %d, PID: %RU32, session: %RU32)\n",
@@ -628,7 +622,7 @@ static int vgsvcVMInfoWriteUsers(void)
}

# ifdef VBOX_WITH_DBUS
-# if defined(RT_OS_LINUX) /* Not yet for Solaris/FreeBSB. */
+# if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) /* Not yet for Solaris. */
DBusError dbErr;
DBusConnection *pConnection = NULL;
int rc2 = RTDBusLoadLib();
@@ -837,7 +831,7 @@ static int vgsvcVMInfoWriteUsers(void)
if ( fHaveLibDbus
&& dbus_error_is_set(&dbErr))
dbus_error_free(&dbErr);
-# endif /* RT_OS_LINUX */
+# endif /* RT_OS_LINUX || RT_OS_FREEBSD */
# endif /* VBOX_WITH_DBUS */

/** @todo Fedora/others: Handle systemd-loginctl. */
@@ -874,7 +868,7 @@ static int vgsvcVMInfoWriteUsers(void)
RTMemFree(papszUsers);

endutxent(); /* Close utmpx file. */
-#endif /* !RT_OS_WINDOWS && !RT_OS_FREEBSD && !RT_OS_HAIKU && !RT_OS_OS2 */
+#endif /* !RT_OS_WINDOWS && !RT_OS_HAIKU && !RT_OS_OS2 */

Assert(RT_FAILURE(rc) || cUsersInList == 0 || (pszUserList && *pszUserList));

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,20 @@
--- src/VBox/Additions/common/pam/pam_vbox.cpp.orig 2020-05-13 19:37:05 UTC
+++ src/VBox/Additions/common/pam/pam_vbox.cpp
@@ -105,7 +105,7 @@ static void pam_vbox_writesyslog(char *pszBuf)
openlog("pam_vbox", LOG_PID, LOG_AUTHPRIV);
syslog(LOG_ERR, "%s", pszBuf);
closelog();
-#elif defined(RT_OS_SOLARIS)
+#elif defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
syslog(LOG_ERR, "pam_vbox: %s\n", pszBuf);
#endif
}
@@ -184,7 +184,7 @@ static int vbox_set_msg(pam_handle_t *hPAM, int iStyle

pam_message msg;
msg.msg_style = iStyle;
-#ifdef RT_OS_SOLARIS
+#if defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
msg.msg = (char*)pszText;
#else
msg.msg = pszText;
@@ -0,0 +1,38 @@
--- src/VBox/Additions/freebsd/Makefile.orig 2020-05-13 19:37:06 UTC
+++ src/VBox/Additions/freebsd/Makefile
@@ -30,6 +30,14 @@ all:
cp vboxvfs/vboxvfs.ko .; \
fi; \
fi
+ @echo
+ @if [ -d mount_vboxvfs ]; then \
+ echo "=== Building mount_vboxvfs binary ==="; \
+ $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C mount_vboxvfs clean obj depend all; \
+ if [ -f mount_vboxvfs ]; then \
+ cp mount_vboxvfs/mount_vboxvfs .; \
+ fi; \
+ fi


install:
@@ -37,13 +45,19 @@ install:
@if [ -d vboxvfs ]; then \
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxvfs install; \
fi
+ @if [ -d mount_vboxvfs ]; then \
+ $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C mount_vboxvfs install; \
+ fi

clean:
@$(MAKE) -C vboxguest clean
@if [ -d vboxvfs ]; then \
$(MAKE) -C vboxvfs clean; \
fi
- rm -f vboxguest.*o vboxvfs.*o
+ @if [ -d mount_vboxvfs ]; then \
+ $(MAKE) -C mount_vboxvfs clean; \
+ fi
+ rm -f vboxguest.*o vboxvfs.*o mount_vboxvfs

load:
@/sbin/kldunload vboxvfs || true
@@ -0,0 +1,30 @@
--- src/VBox/Additions/freebsd/Makefile.kmk.orig 2019-07-12 08:42:35 UTC
+++ src/VBox/Additions/freebsd/Makefile.kmk
@@ -23,8 +23,9 @@ $(error "The FreeBSD guest additions installer can onl
endif

# Include sub-makefiles.
-#include $(PATH_SUB_CURRENT)/vboxvfs/Makefile.kmk
-include $(PATH_SUB_CURRENT)/drm/Makefile.kmk
+include $(PATH_SUB_CURRENT)/vboxvfs/Makefile.kmk
+#include $(PATH_SUB_CURRENT)/drm/Makefile.kmk
+include $(PATH_SUB_CURRENT)/mount_vboxvfs/Makefile.kmk

#
# Globals
@@ -67,11 +68,13 @@ VBOX_FBSD_ADD_STRIP_BIN = \
vboxvideo_drv_15.so \
vboxvideo_drv_16.so \
vboxvideo_drv_17.so \
- VBoxOGL.so
+ $(if $(VBOX_WITH_PAM),pam_vbox.so,) \
+ VBoxOGL.so \
+ mount_vboxvfs

VBOX_FBSD_ADD_MODULES = \
vboxguest \
- vboxvideo_drm
+ vboxvfs

#
# All the bin files that go into the archives.
@@ -0,0 +1,26 @@
--- src/VBox/Additions/freebsd/mount_vboxvfs/Makefile.kmk.orig 2018-11-29 19:03:21 UTC
+++ src/VBox/Additions/freebsd/mount_vboxvfs/Makefile.kmk
@@ -0,0 +1,23 @@
+# $Id: Makefile.kmk $
+## @file
+# Sub-Makefile for the FreeBSD Shared folder mount utility.
+#
+
+SUB_DEPTH = ../../../../..
+include $(KBUILD_PATH)/subheader.kmk
+
+ifneq ($(KBUILD_HOST),freebsd)
+$(error "The FreeBSD guest additions can only be built on FreeBSD!")
+endif
+
+MOUNT= $(VBOX_FREEBSD_SRC)/../sbin/mount
+
+CFLAGS+=-I$(MOUNT)
+
+PROGRAMS += mount_vboxvfs
+mount_vboxvfs_TEMPLATE = NewVBoxGuestR3Exe
+mount_vboxvfs_SOURCES = $(MOUNT)/getmntopts.c \
+ mount_vboxvfs.c
+
+include $(FILE_KBUILD_SUB_FOOTER)
+
@@ -0,0 +1,56 @@
--- src/VBox/Additions/freebsd/mount_vboxvfs/mount_vboxvfs.8.orig 1970-01-01 01:00:00.000000000 +0100
+++ src/VBox/Additions/freebsd/mount_vboxvfs/mount_vboxvfs.8 2017-07-12 19:24:26.106029000 +0200
@@ -0,0 +1,53 @@
+.\"
+.\" Copyright (c) 1992, 1993, 1994
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd August 5, 2013
+.Dt MOUNT_VBOXFS 8
+.Os
+.Sh NAME
+.Nm mount_vboxfs
+.Nd "Mount the VirtualBox shared folder NAME from the host system to MOUNTPOINT"
+.Sh SYNOPSIS
+.Nm
+.Op Fl o Ar options
+.Ar NAME
+.Ar MOUNTPOINT
+.Sh DESCRIPTION
+The
+.Nm
+Mount the VirtualBox shared folder NAME from the host system to MOUNTPOINT
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.Fl w
+mount the shared folder writably (the default)
+.Fl r
+mount the shared folder read-only
+.Fl o
+OPTION[,OPTION...] use the mount options specified
+.El
@@ -0,0 +1,171 @@
--- src/VBox/Additions/freebsd/mount_vboxvfs/mount_vboxvfs.c.orig 1970-01-01 01:00:00.000000000 +0100
+++ src/VBox/Additions/freebsd/mount_vboxvfs/mount_vboxvfs.c 2017-07-12 19:24:26.106029000 +0200
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 1992, 1993, 1994
+* The Regents of the University of California. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* 4. Neither the name of the University nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+*/
+
+#include <sys/cdio.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/iconv.h>
+#include <sys/param.h>
+#include <sys/linker.h>
+#include <sys/module.h>
+#include <sys/mount.h>
+#include <sys/uio.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include "mntopts.h"
+
+#define MAX_HOST_NAME 256
+static char mount_point[MAXPATHLEN + 1];
+static char vboxfs_vfsname[] = "vboxvfs";
+static struct mntopt mopts[] = {
+ MOPT_STDOPTS,
+ MOPT_END
+};
+
+static void usage(void) __dead2;
+
+static void
+usage(void)
+{
+ fprintf(stderr,
+ "Usage: [OPTIONS] NAME MOUNTPOINT\n"
+ "Mount the VirtualBox shared folder NAME to MOUNTPOINT.\n"
+ "\nOptions:\n"
+ " -w mount the shared folder writable \n"
+ " -r mount the shared folder read-only (the default)\n");
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct iovec *iov;
+ struct stat st;
+ char *host_name;
+ char errmsg[255];
+ uid_t uid;
+ gid_t gid;
+ mode_t dir_mode, file_mode;
+ int iovlen;
+ int ronly = 0;
+ int error, ch;
+ int mntflags = 0;
+
+ iov = NULL;
+ iovlen = 0;
+ errmsg[0] = '\0';
+ uid = (uid_t)-1;
+ gid = (gid_t)-1;
+ file_mode = 0;
+ dir_mode = 0;
+
+ while ((ch = getopt(argc, argv, "rwo:h")) != -1)
+ switch(ch) {
+ default:
+ fprintf(stderr, "unknown option `%c:%#x'\n", ch, ch);
+ return (1);
+
+ case '?':
+ case 'h':
+ usage();
+ case 'r':
+ ronly = 1;
+ break;
+ case 'w':
+ ronly = 0;
+ break;
+ case 'o':
+ getmntopts(optarg, mopts, &mntflags, 0);
+ break;
+ }
+
+ if (argc - optind < 2)
+ usage();
+
+ host_name = argv[optind];
+ realpath(argv[optind+1], mount_point);
+
+ if (stat(mount_point, &st) == -1)
+ err(EX_OSERR, "could not find mount point %s", mount_point);
+
+ if (!S_ISDIR(st.st_mode)) {
+ errno = ENOTDIR;
+ err(EX_OSERR, "can't mount on %s", mount_point);
+ }
+
+ if (strlen(host_name) > MAX_HOST_NAME - 1)
+ err(EX_OSERR, "host name is too big %s", host_name);
+
+ if (ronly == 0)
+ mntflags |= MNT_ASYNC;
+ if (uid == (uid_t)-1)
+ uid = st.st_uid;
+ if (gid == (gid_t)-1)
+ gid = st.st_gid;
+ if (file_mode == 0)
+ file_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+ if (dir_mode == 0) {
+ dir_mode = file_mode;
+ if (dir_mode & S_IRUSR)
+ dir_mode |= S_IXUSR;
+ if (dir_mode & S_IRGRP)
+ dir_mode |= S_IXGRP;
+ if (dir_mode & S_IROTH)
+ dir_mode |= S_IXOTH;
+ }
+
+ build_iovec(&iov, &iovlen, "fstype", vboxfs_vfsname, (size_t)-1);
+ build_iovec(&iov, &iovlen, "fspath", mount_point, (size_t)-1);
+ build_iovec(&iov, &iovlen, "from", host_name, (size_t)-1);
+ build_iovec_argf(&iov, &iovlen, "uid", "%d", uid);
+ build_iovec_argf(&iov, &iovlen, "gid", "%d", gid);
+ build_iovec_argf(&iov, &iovlen, "file_mode", "%o", file_mode);
+ build_iovec_argf(&iov, &iovlen, "dir_mode", "%o", dir_mode);
+ build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
+
+ error = nmount(iov, iovlen, mntflags);
+ if (error == -1) {
+ if (errmsg[0] != '\0')
+ err(1, "%s: error: %s", mount_point, errmsg);
+ else
+ err(1, "%s: error %d", mount_point, error);
+ }
+
+ return (0);
+}
@@ -0,0 +1,49 @@
--- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk.orig 2020-05-13 19:37:06 UTC
+++ src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk
@@ -33,32 +33,36 @@ vboxvfs_INCS = \
$(vboxvfs_0_OUTDIR)
vboxvfs_SOURCES = \
vboxvfs_vfsops.c \
- vboxvfs_vnops.c
+ vboxvfs_vnops.c \
+ vboxvfs_prov.c
vboxvfs_LIBS = \
$(VBOX_LIB_VBGL_R0) \
$(VBOX_LIB_IPRT_GUEST_R0)
vboxvfs_DEPS = \
- $$(vboxvfs_0_OUTDIR)/vnode_if.h \
- $$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \
- $$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h
+ $(vboxvfs_0_OUTDIR)/vnode_if.h \
+ $(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \
+ $(vboxvfs_0_OUTDIR)/vnode_if_typedef.h
vboxvfs_CLEAN += $(vboxvfs_DEPS)

VBOX_AWK := /usr/bin/awk

-$$(vboxvfs_0_OUTDIR)/vnode_if.h: $(VBOX_FREEBSD_SRC)/kern/vnode_if.src
+$$(vboxvfs_0_OUTDIR):
+ $(QUIET)$(MKDIR) -p $(vboxvfs_0_OUTDIR)
+
+$$(vboxvfs_0_OUTDIR)/vnode_if.h: $$(vboxvfs_0_OUTDIR) $(VBOX_FREEBSD_SRC)/kern/vnode_if.src
$(call MSG_TOOL,awk,VBoxGuest,$<,$@)
$(QUIET)$(VBOX_AWK) -f $(VBOX_FREEBSD_SRC)/tools/vnode_if.awk $(VBOX_FREEBSD_SRC)/kern/vnode_if.src -h
- $(QUIET)$(MV) $(vboxvfs_0_OUTDIR)/vnode_if.h $(vboxvfs_0_OUTDIR)/vnode_if.h
+ $(QUIET)$(MV) vnode_if.h $(vboxvfs_0_OUTDIR)/vnode_if.h

-$$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h: $(VBOX_FREEBSD_SRC)/kern/vnode_if.src
+$$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h: $$(vboxvfs_0_OUTDIR) $(VBOX_FREEBSD_SRC)/kern/vnode_if.src
$(call MSG_TOOL,awk,VBoxGuest,$<,$@)
$(QUIET)$(VBOX_AWK) -f $(VBOX_FREEBSD_SRC)/tools/vnode_if.awk $(VBOX_FREEBSD_SRC)/kern/vnode_if.src -p
- $(QUIET)$(MV) $(vboxvfs_0_OUTDIR)/vnode_if_newproto.h $(vboxvfs_0_OUTDIR)/vnode_if_newproto.h
+ $(QUIET)$(MV) vnode_if_newproto.h $(vboxvfs_0_OUTDIR)/vnode_if_newproto.h

-$$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h: $(VBOX_FREEBSD_SRC)/kern/vnode_if.src
+$$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h: $$(vboxvfs_0_OUTDIR) $(VBOX_FREEBSD_SRC)/kern/vnode_if.src
$(call MSG_TOOL,awk,VBoxGuest,$<,$@)
$(QUIET)$(VBOX_AWK) -f $(VBOX_FREEBSD_SRC)/tools/vnode_if.awk $(VBOX_FREEBSD_SRC)/kern/vnode_if.src -q
- $(QUIET)$(MV) $(vboxvfs_0_OUTDIR)/vnode_if_typedef.h $(vboxvfs_0_OUTDIR)/vnode_if_typedef.h
+ $(QUIET)$(MV) vnode_if_typedef.h $(vboxvfs_0_OUTDIR)/vnode_if_typedef.h

include $(FILE_KBUILD_SUB_FOOTER)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,29 @@
--- src/VBox/Additions/x11/vboxmouse/Makefile.kmk.orig 2019-01-25 18:24:30 UTC
+++ src/VBox/Additions/x11/vboxmouse/Makefile.kmk
@@ -227,10 +227,22 @@ endif # neq ($(KBUILD_TARGET),linux)


ifdef VBOX_USE_SYSTEM_XORG_HEADERS
- # As vboxmouse_drv is not needed at all for X.Org Server 1.7 and later do not
- # build it in this case.
- DLLS := $(filter-out vboxmouse_drv_%,$(DLLS))
- SYSMODS := $(filter-out vboxmouse_drv%,$(SYSMODS))
+ ifeq ($(KBUILD_TARGET),freebsd)
+ DLLS += vboxmouse_drv_system
+ vboxmouse_drv_system_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxmouse_drv_system_DEFS := $(vboxmouse_drv_70_DEFS) NO_ANSIC
+ vboxmouse_drv_system_INCS := \
+ /usr/local/include/pixman-1 \
+ /usr/local/include/xorg \
+ $(PATH_SUB_CURRENT)
+ vboxmouse_drv_system_SOURCES = \
+ vboxmouse.c
+ else
+ # As vboxmouse_drv is not needed at all for X.Org Server 1.7 and later do not
+ # build it in this case.
+ DLLS := $(filter-out vboxmouse_drv_%,$(DLLS))
+ SYSMODS := $(filter-out vboxmouse_drv%,$(SYSMODS))
+ endif
endif


@@ -0,0 +1,15 @@
--- src/VBox/Additions/x11/vboxvideo/Makefile.kmk.orig 2019-01-25 18:24:30 UTC
+++ src/VBox/Additions/x11/vboxvideo/Makefile.kmk
@@ -406,9 +406,10 @@ ifdef VBOX_USE_SYSTEM_XORG_HEADERS
vboxvideo_drv_system_INCS += \
$(PATH_ROOT)/src/VBox/Runtime/include \
$(VBOX_GRAPHICS_INCS) \
- /usr/include/xorg \
- /usr/include/pixman-1
+ /usr/local/include/xorg \
+ /usr/local/include/pixman-1
vboxvideo_drv_system_SOURCES := $(vboxvideo_drv_17_SOURCES)
+ vboxvideo_drv_system_LIBS += $(vboxvideo_drv_70_LIBS)
endif


@@ -0,0 +1,10 @@
--- src/VBox/Debugger/Makefile.kmk.orig 2020-05-13 19:39:41 UTC
+++ src/VBox/Debugger/Makefile.kmk
@@ -113,6 +113,7 @@ VBoxDbg_SOURCES = \
VBoxDbgBase.cpp \
VBoxDbgConsole.cpp \
VBoxDbgStatsQt.cpp
+VBoxDbg_CXXFLAGS.freebsd += -std=c++11
VBoxDbg_LIBS = \
$(VBOX_LIB_VMM_LAZY)
VBoxDbg_LDFLAGS.darwin = \
@@ -0,0 +1,18 @@
--- src/VBox/Devices/Audio/DrvHostALSAAudio.cpp.orig 2020-05-13 19:39:41 UTC
+++ src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
@@ -819,6 +819,7 @@ static DECLCALLBACK(int) drvHostALSAAudioStreamPlay(PP
continue;
}

+#if EPIPE != ESTRPIPE
case -ESTRPIPE:
{
/* Stream was suspended and waiting for a recovery. */
@@ -832,6 +833,7 @@ static DECLCALLBACK(int) drvHostALSAAudioStreamPlay(PP
LogFlowFunc(("Resumed suspended output stream\n"));
continue;
}
+#endif

default:
LogFlowFunc(("Failed to write %RU32 bytes, error unknown\n", cbToWrite));
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,34 @@
--- src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp.orig 2020-05-13 19:43:27 UTC
+++ src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
@@ -622,7 +622,7 @@ void printUsage(USAGECATEGORY fCategory, uint32_t fSub
RTStrmPrintf(pStrm, "|dsound");
#endif
}
- if (fLinux || fSolaris)
+ if (fLinux || fFreeBSD || fSolaris)
{
RTStrmPrintf(pStrm, ""
#ifdef VBOX_WITH_AUDIO_OSS
@@ -635,22 +635,6 @@ void printUsage(USAGECATEGORY fCategory, uint32_t fSub
"|pulse"
#endif
);
- }
- if (fFreeBSD)
- {
-#ifdef VBOX_WITH_AUDIO_OSS
- /* Get the line break sorted when dumping all option variants. */
- if (fDumpOpts)
- {
- RTStrmPrintf(pStrm, "|\n"
- " oss");
- }
- else
- RTStrmPrintf(pStrm, "|oss");
-#endif
-#ifdef VBOX_WITH_AUDIO_PULSE
- RTStrmPrintf(pStrm, "|pulse");
-#endif
}
if (fDarwin)
{
@@ -0,0 +1,18 @@
--- src/VBox/Frontends/VirtualBox/Makefile.kmk.orig 2020-05-13 19:43:28 UTC
+++ src/VBox/Frontends/VirtualBox/Makefile.kmk
@@ -897,6 +897,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_GUI
VirtualBox_SOURCES += \
src/VBoxFBOverlay.cpp \
src/VBoxGLSupportInfo.cpp
+ VirtualBox_CXXFLAGS.freebsd += -std=c++11
endif

#
@@ -1220,6 +1221,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL)
VBoxOGL2D_SOURCES = \
src/VBoxGLSupportInfo.cpp
VBoxOGL2D_INCS = include
+ VBoxOGL2D_CXXFLAGS.freebsd += -std=c++11
endif
endif

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,11 @@
--- src/VBox/HostDrivers/Support/SUPDrv.cpp.orig 2018-10-15 14:30:56 UTC
+++ src/VBox/HostDrivers/Support/SUPDrv.cpp
@@ -104,7 +104,7 @@
/** @def SUPDRV_CHECK_SMAP_CHECK
* Checks that the AC flag is set if SMAP is enabled. If AC is not set, it
* will be logged and @a a_BadExpr is executed. */
-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
# define SUPDRV_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
# define SUPDRV_CHECK_SMAP_CHECK(a_pDevExt, a_BadExpr) \
do { \
@@ -0,0 +1,11 @@
--- src/VBox/HostDrivers/Support/SUPDrvInternal.h.orig 2020-05-13 19:43:52 UTC
+++ src/VBox/HostDrivers/Support/SUPDrvInternal.h
@@ -208,7 +208,7 @@
# define SUPDRV_WITHOUT_MSR_PROBER
#endif

-#if 1
+#if 0
/** @def SUPDRV_USE_TSC_DELTA_THREAD
* Use a dedicated kernel thread to service TSC-delta measurement requests.
* @todo Test on servers with many CPUs and sockets. */
@@ -0,0 +1,220 @@
--- src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c.orig 2020-05-13 19:43:53 UTC
+++ src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
@@ -46,6 +46,7 @@
#include <sys/uio.h>

#include "../SUPDrvInternal.h"
+#include "freebsd/the-freebsd-kernel.h"
#include <VBox/version.h>
#include <iprt/initterm.h>
#include <iprt/string.h>
@@ -57,7 +58,14 @@
#include <iprt/alloc.h>
#include <iprt/err.h>
#include <iprt/asm.h>
+#include <iprt/x86.h>

+#ifdef VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
+# include <machine/cpufunc.h>
+# include <machine/md_var.h>
+# include <machine/specialreg.h>
+#endif
+
#ifdef VBOX_WITH_HARDENING
# define VBOXDRV_PERM 0600
#else
@@ -76,7 +84,9 @@ static d_open_t VBoxDrvFreeBSDOpenUsr;
static d_open_t VBoxDrvFreeBSDOpenSys;
static void vboxdrvFreeBSDDtr(void *pvData);
static d_ioctl_t VBoxDrvFreeBSDIOCtl;
+static d_ioctl_t VBoxDrvFreeBSDIOCtlSMAP;
static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd);
+static bool VBoxDrvFreeBSDCpuHasSMAP(void);


/*********************************************************************************************************************************
@@ -182,6 +192,13 @@ static int VBoxDrvFreeBSDLoad(void)
rc = supdrvInitDevExt(&g_VBoxDrvFreeBSDDevExt, sizeof(SUPDRVSESSION));
if (RT_SUCCESS(rc))
{
+ if (VBoxDrvFreeBSDCpuHasSMAP())
+ {
+ LogRel(("disabling SMAP for VBoxDrvFreeBSDIOCtl\n"));
+ g_VBoxDrvFreeBSDChrDevSwSys.d_ioctl = VBoxDrvFreeBSDIOCtlSMAP;
+ g_VBoxDrvFreeBSDChrDevSwUsr.d_ioctl = VBoxDrvFreeBSDIOCtlSMAP;
+ }
+
/*
* Configure character devices. Add symbolic links for compatibility.
*/
@@ -311,7 +328,21 @@ static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_lo
PSUPDRVSESSION pSession;
devfs_get_cdevpriv((void **)&pSession);

+#ifdef VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
/*
+ * Refuse all I/O control calls if we've ever detected EFLAGS.AC being cleared.
+ *
+ * This isn't a problem, as there is absolutely nothing in the kernel context that
+ * depend on user context triggering cleanups. That would be pretty wild, right?
+ */
+ if (RT_UNLIKELY(g_VBoxDrvFreeBSDDevExt.cBadContextCalls > 0))
+ {
+ SUPR0Printf("VBoxDrvFreBSDIOCtl: EFLAGS.AC=0 detected %u times, refusing all I/O controls!\n", g_VBoxDrvFreeBSDDevExt.cBadContextCalls);
+ return ESPIPE;
+ }
+#endif
+
+ /*
* Deal with the fast ioctl path first.
*/
if ( ( ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
@@ -325,6 +356,45 @@ static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_lo


/**
+ * Alternative Device I/O Control entry point on hosts with SMAP support.
+ *
+ * @returns depends...
+ * @param pDev The device.
+ * @param ulCmd The command.
+ * @param pvData Pointer to the data.
+ * @param fFile The file descriptor flags.
+ * @param pTd The calling thread.
+ */
+static int VBoxDrvFreeBSDIOCtlSMAP(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
+{
+ /*
+ * Allow VBox R0 code to touch R3 memory. Setting the AC bit disables the
+ * SMAP check.
+ */
+ RTCCUINTREG fSavedEfl = ASMAddFlags(X86_EFL_AC);
+
+ int rc = VBoxDrvFreeBSDIOCtl(pDev, ulCmd, pvData, fFile, pTd);
+
+#ifdef VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
+ /*
+ * Before we restore AC and the rest of EFLAGS, check if the IOCtl handler code
+ * accidentially modified it or some other important flag.
+ */
+ if (RT_UNLIKELY( (ASMGetFlags() & (X86_EFL_AC | X86_EFL_IF | X86_EFL_DF | X86_EFL_IOPL))
+ != ((fSavedEfl & (X86_EFL_AC | X86_EFL_IF | X86_EFL_DF | X86_EFL_IOPL)) | X86_EFL_AC) ))
+ {
+ char szTmp[48];
+ RTStrPrintf(szTmp, sizeof(szTmp), "ulCmd=%#x: %#x->%#x!", ulCmd, (uint32_t)fSavedEfl, (uint32_t)ASMGetFlags());
+ supdrvBadContext(&g_VBoxDrvFreeBSDDevExt, "SUPDrv-freebsd.c", __LINE__, szTmp);
+ }
+#endif
+
+ ASMSetFlags(fSavedEfl);
+ return rc;
+}
+
+
+/**
* Deal with the 'slow' I/O control requests.
*
* @returns 0 on success, appropriate errno on failure.
@@ -373,11 +443,10 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
*/
SUPREQHDR Hdr;
pvUser = *(void **)pvData;
- int rc = copyin(pvUser, &Hdr, sizeof(Hdr));
- if (RT_UNLIKELY(rc))
+ if (RT_FAILURE(RTR0MemUserCopyFrom(&Hdr, pvUser, sizeof(Hdr))))
{
- OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyin(%p,Hdr,) -> %#x; ulCmd=%#lx\n", pvUser, rc, ulCmd));
- return rc;
+ OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyin(%p,Hdr,); ulCmd=%#lx\n", pvUser, ulCmd));
+ return EFAULT;
}
if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
{
@@ -402,13 +471,12 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: failed to allocate buffer of %d bytes; ulCmd=%#lx\n", cbReq, ulCmd));
return ENOMEM;
}
- rc = copyin(pvUser, pHdr, Hdr.cbIn);
- if (RT_UNLIKELY(rc))
+ if (RT_FAILURE(RTR0MemUserCopyFrom(pHdr, pvUser, Hdr.cbIn)))
{
- OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyin(%p,%p,%#x) -> %#x; ulCmd=%#lx\n",
- pvUser, pHdr, Hdr.cbIn, rc, ulCmd));
+ OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyin(%p,%p,%#x); ulCmd=%#lx\n",
+ pvUser, pHdr, Hdr.cbIn, ulCmd));
RTMemTmpFree(pHdr);
- return rc;
+ return EFAULT;
}
if (Hdr.cbIn < cbReq)
RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn);
@@ -436,9 +504,8 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbOut, cbReq, ulCmd));
cbOut = cbReq;
}
- rc = copyout(pHdr, pvUser, cbOut);
- if (RT_UNLIKELY(rc))
- OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyout(%p,%p,%#x) -> %d; uCmd=%#lx!\n", pHdr, pvUser, cbOut, rc, ulCmd));
+ if (RT_FAILURE(RTR0MemUserCopyTo(pvUser, pHdr, cbOut)))
+ OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyout(%p,%p,%#x); uCmd=%#lx!\n", pHdr, pvUser, cbOut, ulCmd));

Log(("VBoxDrvFreeBSDIOCtlSlow: returns %d / %d ulCmd=%lx\n", 0, pHdr->rc, ulCmd));

@@ -541,8 +608,7 @@ bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDE

bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void)
{
- /** @todo verify this. */
- return false;
+ return true;
}


@@ -625,11 +691,25 @@ int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu,
#endif /* SUPDRV_WITH_MSR_PROBER */


+/**
+ * Check if the CPU has SMAP support.
+ */
+static bool VBoxDrvFreeBSDCpuHasSMAP(void)
+{
+#ifdef VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
+ if ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0)
+ return true;
+#endif
+ return false;
+}
+
+
SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...)
{
va_list va;
char szMsg[256];
int cch;
+ IPRT_FREEBSD_SAVE_EFL_AC();

va_start(va, pszFormat);
cch = RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, va);
@@ -637,12 +717,19 @@ SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...)

printf("%s", szMsg);

+ IPRT_FREEBSD_RESTORE_EFL_AC();
return cch;
}


SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void)
{
- return 0;
+ uint32_t fFlags = 0;
+#ifdef VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
+ if (g_VBoxDrvFreeBSDChrDevSwSys.d_ioctl == VBoxDrvFreeBSDIOCtlSMAP)
+ fFlags |= SUPKERNELFEATURES_SMAP;
+ else
+ Assert(!(ASMGetCR4() & X86_CR4_SMAP));
+#endif
+ return fFlags;
}
-
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,10 @@
--- src/VBox/Main/Makefile.kmk.orig 2020-05-13 19:44:04 UTC
+++ src/VBox/Main/Makefile.kmk
@@ -526,6 +526,7 @@ VBoxSVC_SOURCES.os2 = \

VBoxSVC_SOURCES.freebsd = \
src-server/freebsd/HostHardwareFreeBSD.cpp \
+ $(if $(VBOX_WITH_DBUS),src-server/linux/HostPowerLinux.cpp) \
src-server/HostDnsServiceResolvConf.cpp


@@ -0,0 +1,20 @@
--- src/VBox/Main/include/HostPower.h.orig 2017-10-18 07:12:54 UTC
+++ src/VBox/Main/include/HostPower.h
@@ -28,7 +28,7 @@

#include <vector>

-#ifdef RT_OS_LINUX
+#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
# include <VBox/dbus.h>
#endif

@@ -64,7 +64,7 @@ class HostPowerServiceWin : public HostPowerService (p
RTTHREAD mThread;
};
# endif
-# if defined(RT_OS_LINUX) || defined(DOXYGEN_RUNNING)
+# if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(DOXYGEN_RUNNING)
/**
* The Linux hosted Power Service.
*/
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,11 @@
--- src/VBox/Main/src-server/HostImpl.cpp.orig 2020-05-13 19:44:09 UTC
+++ src/VBox/Main/src-server/HostImpl.cpp
@@ -284,7 +284,7 @@ HRESULT Host::init(VirtualBox *aParent)

#if defined(RT_OS_WINDOWS)
m->pHostPowerService = new HostPowerServiceWin(m->pParent);
-#elif defined(RT_OS_LINUX) && defined(VBOX_WITH_DBUS)
+#elif (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && defined(VBOX_WITH_DBUS)
m->pHostPowerService = new HostPowerServiceLinux(m->pParent);
#elif defined(RT_OS_DARWIN)
m->pHostPowerService = new HostPowerServiceDarwin(m->pParent);
File renamed without changes.
@@ -0,0 +1,24 @@
--- src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp.orig 2017-07-27 13:18:27 UTC
+++ src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp
@@ -80,8 +80,10 @@ int CollectorFreeBSD::getHostMemoryUsage(ULONG *total,
cbParameter = sizeof(cPagesMemInactive);
if (!sysctlbyname("vm.stats.vm.v_inactive_count", &cPagesMemInactive, &cbParameter, NULL, 0))
cProcessed++;
+#if __FreeBSD_version < 1200016
cbParameter = sizeof(cPagesMemCached);
if (!sysctlbyname("vm.stats.vm.v_cache_count", &cPagesMemCached, &cbParameter, NULL, 0))
+#endif
cProcessed++;
cbParameter = sizeof(cbPage);
if (!sysctlbyname("hw.pagesize", &cbPage, &cbParameter, NULL, 0))
@@ -90,8 +92,8 @@ int CollectorFreeBSD::getHostMemoryUsage(ULONG *total,
if (cProcessed == 6)
{
*total = cbMemPhys / _1K;
- *used = cPagesMemUsed * (cbPage / _1K);
- *available = (cPagesMemFree + cPagesMemInactive + cPagesMemCached ) * (cbPage / _1K);
+ *used = (uint64_t)cPagesMemUsed * (cbPage / _1K);
+ *available = ((uint64_t)cPagesMemFree + cPagesMemInactive + cPagesMemCached) * (cbPage / _1K);
}
else
rc = VERR_NOT_SUPPORTED;
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,73 @@
--- src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+++ src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
@@ -54,6 +54,7 @@ MALLOC_DEFINE(M_IPRTCONT, "iprtcont", "IPRT - contiguo

DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
size_t cbAllocated = cb;
PRTMEMHDR pHdr = NULL;

@@ -76,8 +77,10 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE);

pVmObject = vm_object_allocate(OBJT_DEFAULT, cbAllocated >> PAGE_SHIFT);
- if (!pVmObject)
+ if (!pVmObject) {
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VERR_NO_EXEC_MEMORY;
+ }

/* Addr contains a start address vm_map_find will start searching for suitable space at. */
#if __FreeBSD_version >= 1000055
@@ -114,6 +117,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
fFlags & RTMEMHDR_FLAG_ZEROED ? M_NOWAIT | M_ZERO : M_NOWAIT);
}

+ IPRT_FREEBSD_RESTORE_EFL_AC();
+
if (RT_UNLIKELY(!pHdr))
return VERR_NO_MEMORY;

@@ -129,6 +134,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl

DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
+
pHdr->u32Magic += 1;

#ifdef RT_ARCH_AMD64
@@ -141,11 +148,14 @@ DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
else
#endif
free(pHdr, M_IPRTHEAP);
+
+ IPRT_FREEBSD_RESTORE_EFL_AC();
}


RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
void *pv;

/*
@@ -170,6 +180,7 @@ RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_
*pPhys = vtophys(pv);
Assert(!(*pPhys & PAGE_OFFSET_MASK));
}
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return pv;
}

@@ -179,7 +190,9 @@ RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
if (pv)
{
AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
+ IPRT_FREEBSD_SAVE_EFL_AC();
contigfree(pv, cb, M_IPRTCONT);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
}
}

@@ -0,0 +1,29 @@
--- src/VBox/Runtime/r0drv/freebsd/assert-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+++ src/VBox/Runtime/r0drv/freebsd/assert-r0drv-freebsd.c
@@ -44,15 +44,18 @@

DECLHIDDEN(void) rtR0AssertNativeMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
printf("\r\n!!Assertion Failed!!\r\n"
"Expression: %s\r\n"
"Location : %s(%d) %s\r\n",
pszExpr, pszFile, uLine, pszFunction);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
}


DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial, const char *pszFormat, va_list va)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
char szMsg[256];

RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
@@ -60,6 +63,7 @@ DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial,
printf("%s", szMsg);

NOREF(fInitial);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
}