aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Falsi <madpilot@FreeBSD.org>2021-03-09 18:27:36 +0000
committerGuido Falsi <madpilot@FreeBSD.org>2021-03-09 18:27:36 +0000
commit42d8425b62bb66d04dd01c96d516c11451fd86dd (patch)
treee2c43c73c1351cea5743d20d5dc2626d9bcb2c04
parent82a7880d546383cb6825198f005cf50498300c87 (diff)
downloadports-42d8425b62bb66d04dd01c96d516c11451fd86dd.tar.gz
ports-42d8425b62bb66d04dd01c96d516c11451fd86dd.zip
- Update VirtualBox OSE to 6.1.18
- Old VirtualBox OSE 5.2.44 preserved as "-legacy" versions of the ports (repocopied) - Add back extra patch removed in r528258, actually required to build DEBUG kmod - Correctly define WITH_DEBUG when enabling the DEBUG option, so binaries are not stripped Please note that this new version supports only amd64 CPUs. If you need to use older hardware please install the legacy ports. Note that moving VM snapshots across major updates is unsupported, it's strongly suggested to properly shutdown VMs before upgrading, please check UPDATING for further details. This update is the result of work from many people, and thanks to all who gave feedback and tested things. Patch based on work from: Mario Lobo <lobo@bsd.com.br> and jkim. PR: 234878 Submitted by: kunda <chitty_cloud@me.com> Approved by: vbox (implicit) Reviewed by: decke Tested by: jwb, martin ilavsky <ilavsky.martin@gmail.com>, Mario Lobo <lobo@bsd.com.br> Relnotes: https://www.virtualbox.org/wiki/Changelog-6.1 Differential Revision: https://reviews.freebsd.org/D28871
Notes
Notes: svn path=/head/; revision=567950
-rw-r--r--MOVED2
-rw-r--r--UPDATING28
-rw-r--r--emulators/Makefile5
-rw-r--r--emulators/virtualbox-ose-additions-legacy/Makefile174
-rw-r--r--emulators/virtualbox-ose-additions-legacy/distinfo3
-rw-r--r--emulators/virtualbox-ose-additions-legacy/files/vboxguest.in67
-rw-r--r--emulators/virtualbox-ose-additions-legacy/files/vboxservice.in25
-rw-r--r--emulators/virtualbox-ose-additions-legacy/files/vboxvideo.conf5
-rw-r--r--emulators/virtualbox-ose-additions-legacy/pkg-descr9
-rw-r--r--emulators/virtualbox-ose-additions-legacy/pkg-message23
-rw-r--r--emulators/virtualbox-ose-additions-legacy/pkg-plist12
-rw-r--r--emulators/virtualbox-ose-additions-nox11-legacy/Makefile9
-rw-r--r--emulators/virtualbox-ose-additions/Makefile16
-rw-r--r--emulators/virtualbox-ose-additions/distinfo6
-rw-r--r--emulators/virtualbox-ose-kmod-legacy/Makefile108
-rw-r--r--emulators/virtualbox-ose-kmod-legacy/distinfo3
-rw-r--r--emulators/virtualbox-ose-kmod-legacy/files/vboxnet.in70
-rw-r--r--emulators/virtualbox-ose-kmod-legacy/pkg-descr7
-rw-r--r--emulators/virtualbox-ose-kmod-legacy/pkg-plist6
-rw-r--r--emulators/virtualbox-ose-kmod/Makefile12
-rw-r--r--emulators/virtualbox-ose-kmod/distinfo6
-rw-r--r--emulators/virtualbox-ose-legacy/Makefile409
-rw-r--r--emulators/virtualbox-ose-legacy/distinfo5
-rw-r--r--emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk (renamed from emulators/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile11
-rw-r--r--emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderAdditions.cpp (renamed from emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderAdditions.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderExtensionPack.cpp (renamed from emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderExtensionPack.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_settings_global_UIGlobalSettingsNetworkDetailsHost.cpp (renamed from emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_settings_global_UIGlobalSettingsNetworkDetailsHost.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-Config.kmk239
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-configure121
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include-VBox-vmm-cpumctx.h (renamed from emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include-iprt-x86.h19
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include_VBox_VBoxGL2D.h (renamed from emulators/virtualbox-ose/files/patch-include_VBox_VBoxGL2D.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include_VBox_com_array.h36
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include_iprt_assertcompile.h (renamed from emulators/virtualbox-ose/files/patch-include_iprt_assertcompile.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include_iprt_cdefs.h (renamed from emulators/virtualbox-ose/files/patch-include_iprt_cdefs.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include_iprt_string.h14
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-include_iprt_types.h (renamed from emulators/virtualbox-ose/files/patch-include_iprt_types.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c259
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile18
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest26
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient18
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop10
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h12
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-PC-ipxe-Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Devices-PC-ipxe-Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Storage-DrvHostBase-freebsd.cpp (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Devices-Storage-DrvHostBase-freebsd.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile27
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv27
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk25
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (renamed from emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c273
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt10
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-Makefile.kmk14
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-VBox.sh67
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-virtualbox.desktop10
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp11
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp (renamed from emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-webservice-Makefile.kmk39
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-Makefile.kmk23
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h20
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-recompiler-Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src-recompiler-Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src-recompiler-Sun-testmath.c (renamed from emulators/virtualbox-ose/files/patch-src-recompiler-Sun-testmath.c)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp71
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_dri__glx.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_dri__glx.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx.c (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx.c)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx__c__exports.c (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx__c__exports.c)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx__proto.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx__proto.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_stub.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_stub.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp20
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile38
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile.kmk30
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_Makefile.kmk26
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.856
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.c171
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk49
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h463
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__prov.c1023
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c644
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c1486
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxmouse_Makefile.kmk29
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxvideo_Makefile.kmk15
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Debugger_Makefile.kmk10
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp18
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_PC_vbox-cpuhotplug.dsl (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_vbox-cpuhotplug.dsl)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Storage_DrvHostBase-freebsd.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Devices_Storage_DrvHostBase-freebsd.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp34
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk18
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_globals_UIImageTools.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_globals_UIImageTools.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMenuToolBar.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMenuToolBar.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMiniToolBar.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMiniToolBar.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIPopupBox.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIPopupBox.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_GuestHost_OpenGL_include_chromium.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_GuestHost_OpenGL_include_chromium.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp11
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h11
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c220
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c (renamed from emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_Makefile.kmk10
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_HostPower.h20
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_USBProxyBackend.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Main_include_USBProxyBackend.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_HostImpl.cpp11
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_NetIf-freebsd.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_freebsd_NetIf-freebsd.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_PerformanceFreeBSD.cpp24
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_RDP-client-1.8.4-Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src_VBox_RDP-client-1.8.4-Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_common_err_RTErrConvertFromErrno.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_Runtime_common_err_RTErrConvertFromErrno.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c73
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c29
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c490
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memuserkernel-r0drv-freebsd.c22
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c159
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c53
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c73
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c59
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semmutex-r0drv-freebsd.c80
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c30
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h47
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread-r0drv-freebsd.c99
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c35
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c43
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c68
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_freebsd_systemmem-freebsd.cpp39
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_VMMR0_GVMMR0.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_VMM_VMMR0_GVMMR0.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_VMMR3_VMReq.cpp (renamed from emulators/virtualbox-ose/files/patch-src_VBox_VMM_VMMR3_VMReq.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_include_IEMInternal.h (renamed from emulators/virtualbox-ose/files/patch-src_VBox_VMM_include_IEMInternal.h)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_Makefile.kmk11
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c22
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_io_nsLocalFileUnix.h17
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp (renamed from emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/patch-src_recompiler_Makefile.kmk (renamed from emulators/virtualbox-ose/files/patch-src_recompiler_Makefile.kmk)0
-rw-r--r--emulators/virtualbox-ose-legacy/files/vboxheadless.in142
-rw-r--r--emulators/virtualbox-ose-legacy/files/vboxwatchdog.in53
-rw-r--r--emulators/virtualbox-ose-legacy/files/vboxwebsrv.in49
-rw-r--r--emulators/virtualbox-ose-legacy/pkg-descr7
-rw-r--r--emulators/virtualbox-ose-legacy/pkg-message69
-rw-r--r--emulators/virtualbox-ose-legacy/pkg-plist612
-rw-r--r--emulators/virtualbox-ose-nox11-legacy/Makefile10
-rw-r--r--emulators/virtualbox-ose/Makefile47
-rw-r--r--emulators/virtualbox-ose/distinfo10
-rw-r--r--emulators/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk11
-rw-r--r--emulators/virtualbox-ose/files/patch-Config.kmk253
-rw-r--r--emulators/virtualbox-ose/files/patch-configure66
-rw-r--r--emulators/virtualbox-ose/files/patch-include-iprt-x86.h4
-rw-r--r--emulators/virtualbox-ose/files/patch-include_VBox_com_array.h22
-rw-r--r--emulators/virtualbox-ose/files/patch-include_iprt_string.h4
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c46
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile13
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest16
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient9
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile5
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv7
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk21
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c64
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt4
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh5
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp4
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Main-webservice-Makefile.kmk6
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Runtime-Makefile.kmk13
-rw-r--r--emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp20
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp6
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_Makefile.kmk9
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk5
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_bcmp.c12
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h50
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c16
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_VBoxClient_logging.cpp10
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_x11include_xproto-7.0.18_X11_Xfuncproto.h230
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Debugger_Makefile.kmk4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp6
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostOSSAudio.cpp31
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.cpp29
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.h11
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-ogl.cpp38
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_Makefile.kmk44
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_ipxe_Makefile.kmk20
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp15
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp29
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk10
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c49
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetAdp_freebsd_Makefile11
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk11
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_Makefile11
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Main_Makefile.kmk4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Main_include_HostPower.h6
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_HostImpl.cpp4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_NetworkServices_Dhcpd_VBoxNetDhcpd.cpp11
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c16
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c6
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c181
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c109
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c12
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c16
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c12
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c8
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h10
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c10
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c6
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c16
-rw-r--r--emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_posix_process-creation-posix.cpp29
-rw-r--r--emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_Makefile.kmk4
-rw-r--r--emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c8
-rw-r--r--emulators/virtualbox-ose/pkg-plist15
212 files changed, 10278 insertions, 766 deletions
diff --git a/MOVED b/MOVED
index f7e273cf8804..ae4354528bd4 100644
--- a/MOVED
+++ b/MOVED
@@ -6868,8 +6868,6 @@ databases/p5-DBD-FrontBase||2014-09-07|Cascade removal (databases/frontbase)
databases/ruby-frontbase||2014-09-07|Cascade removal (databases/frontbase)
devel/flex-sdk2||2014-09-07|Not staged
devel/flex_compiler_shell||2014-09-07|Cascade removal (devel/flex-sdk2)
-emulators/virtualbox-ose-legacy||2014-09-09|Not staged
-emulators/virtualbox-ose-kmod-legacy||2014-09-09|No purpose after removal of virtualbox-ose-legacy
devel/arm-eabi-gcc||2014-09-09|Not staged
devel/cross-gcc||2014-09-09|Not staged
devel/arm-eabi-binutils||2014-09-09|No purpose after removal of arm-eabi-gcc
diff --git a/UPDATING b/UPDATING
index 639ea94d3861..d663bce4c4d6 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,34 @@ they are unavoidable.
You should get into the habit of checking this file for changes each time
you update your ports collection, before attempting any port upgrades.
+20210309:
+ AFFECTS: users of emulators/virtualbox-ose
+ AUTHOR: madpilot@FreeBSD.org
+
+ emulators/virtualbox-ose has been updated to 6.1.18. This new
+ version only works on amd64 hardware.
+
+ Previous version 5.x of the virtualbox ports have been preserved
+ as emulators/virtualbox-ose-legacy and similarly named ports for
+ the other parts.
+
+ If you can't run the latest version or wish to stay with the old
+ version, please install the legacy ports.
+
+ Also the additions at present build successfully only for amd64.
+ If you need i386 additions you can fallback to the old legacy
+ ones.
+
+ NOTE: There is no support for moving saved running machine states
+ across major updates of virtualbox. It is recommended to properly
+ shutdown all virtual machines before upgrading. Otherwise the saved
+ state can simply be discarded after the upgrade, if it's not
+ important to preserve it.
+
+ It should also be possible to downgrade to the legacy ports and
+ shutdown the machine properly from the saved state and then upgrade
+ back again.
+
20210302:
AFFECTS: users of editors/emacs-devel
AUTHOR: jrm@FreeBSD.org
diff --git a/emulators/Makefile b/emulators/Makefile
index 9c2a8b32f678..35c736166b12 100644
--- a/emulators/Makefile
+++ b/emulators/Makefile
@@ -153,9 +153,14 @@
SUBDIR += vice
SUBDIR += virtualbox-ose
SUBDIR += virtualbox-ose-additions
+ SUBDIR += virtualbox-ose-additions-legacy
SUBDIR += virtualbox-ose-additions-nox11
+ SUBDIR += virtualbox-ose-additions-nox11-legacy
SUBDIR += virtualbox-ose-kmod
+ SUBDIR += virtualbox-ose-kmod-legacy
+ SUBDIR += virtualbox-ose-legacy
SUBDIR += virtualbox-ose-nox11
+ SUBDIR += virtualbox-ose-nox11-legacy
SUBDIR += visualboyadvance-m
SUBDIR += vmips
SUBDIR += vmsbackup
diff --git a/emulators/virtualbox-ose-additions-legacy/Makefile b/emulators/virtualbox-ose-additions-legacy/Makefile
new file mode 100644
index 000000000000..80da0c5920e1
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/Makefile
@@ -0,0 +1,174 @@
+# Created by: Bernhard Froehlich <decke@bluelife.at>
+# $FreeBSD$
+
+PORTNAME= virtualbox-ose
+PORTVERSION= 5.2.44
+PORTREVISION= 3
+CATEGORIES= emulators
+MASTER_SITES= https://download.oracle.com/virtualbox/${PORTVERSION}/
+PKGNAMESUFFIX?= -additions-legacy
+DISTNAME= VirtualBox-${PORTVERSION}
+
+MAINTAINER= vbox@FreeBSD.org
+COMMENT= VirtualBox additions for FreeBSD guests
+
+LICENSE= GPLv2
+LICENSE_FILE= ${WRKSRC}/COPYING
+
+ONLY_FOR_ARCHS= amd64 i386
+USES= compiler:c++11-lang cpe iconv kmod tar:bzip2
+USE_RC_SUBR= vboxguest vboxservice
+
+BUILD_DEPENDS= yasm:devel/yasm \
+ kmk:devel/kBuild \
+ xsltproc:textproc/libxslt
+
+CPE_VENDOR= oracle
+CPE_PRODUCT= vm_virtualbox
+
+PATCHDIR= ${.CURDIR}/../${PORTNAME}-legacy/files
+WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION}
+MAKE_JOBS_UNSAFE= yes
+
+HAS_CONFIGURE= yes
+CONFIGURE_ARGS+= --disable-alsa \
+ --disable-docs \
+ --disable-libvpx \
+ --disable-opengl \
+ --disable-pulse \
+ --disable-python \
+ --disable-sdl-ttf \
+ --disable-xpcom
+CONFIGURE_ARGS+= --nofatal --with-gcc="${CC}" --with-g++="${CXX}"
+
+CONFLICTS_INSTALL= virtualbox-ose-[0-9]* \
+ virtualbox-ose-additions-devel-[0-9]* \
+ virtualbox-ose-devel-[0-9]* \
+ virtualbox-ose-[0-9]* \
+ virtualbox-ose-lite-[0-9]* \
+ virtualbox-ose-nox11-[0-9]*
+
+OPTIONS_DEFINE= DBUS DEBUG X11
+OPTIONS_DEFAULT= DBUS X11
+OPTIONS_SUB= yes
+
+DBUS_CONFIGURE_OFF= --disable-dbus
+DBUS_LIB_DEPENDS= libdbus-1.so:devel/dbus
+DEBUG_CONFIGURE_ON= --build-debug
+DEBUG_VARS= KMK_BUILDTYPE=debug
+DEBUG_VARS_OFF= KMK_BUILDTYPE=release
+X11_BUILD_DEPENDS= ${LOCALBASE}/include/xorg/compiler.h:x11-servers/xorg-server
+X11_RUN_DEPENDS= xrandr:x11/xrandr
+X11_USE= XORG=x11,xcursor,xext,xorgproto,xmu,xrandr,xt
+X11_USES= pkgconfig xorg
+X11_VARS= VBOX_WITH_X11=1
+
+.include <bsd.port.options.mk>
+
+.if ${SLAVE_PORT} == no
+CONFLICTS_INSTALL+= virtualbox-ose-additions-nox11-[0-9]*
+.else
+CONFLICTS_INSTALL+= virtualbox-ose-additions-[0-9]*
+.endif
+
+VIDEODIR= ${PREFIX}/lib/xorg/modules/drivers
+INPUTDIR= ${PREFIX}/lib/xorg/modules/input
+
+VBOX_BIN= ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/additions
+VBOX_SBINS= VBoxControl \
+ VBoxService \
+ mount_vboxvfs
+
+BUILD_WRKSRC= ${VBOX_BIN}/src
+
+KMK_ARCH= freebsd.${ARCH:S/i386/x86/}
+KMK_CONFIG+= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys
+
+.if ${PORT_OPTIONS:MX11}
+.else
+VBOX_WITH_X11=
+.endif
+
+.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}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_DRAG_AND_DROP_GH = ${VBOX_WITH_X11}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_X11_ADDITIONS = ${VBOX_WITH_X11}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_GCC_std = -std=c++11' >> ${WRKSRC}/LocalConfig.kmk
+.if ${COMPILER_TYPE} == clang
+ @${REINPLACE_CMD} -e 's| -finline-limit=8000||' \
+ -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 \
+ ${WRKSRC}/src/VBox/Additions/x11/vboxvideo/Makefile.kmk
+ @${REINPLACE_CMD} \
+ -e 's|\$$KBUILDDIR_BIN/kmk_sed|${LOCALBASE}/bin/kmk_sed|g' \
+ ${WRKSRC}/configure
+.if empty(ICONV_LIB)
+ @${REINPLACE_CMD} -e 's|iconv||' ${WRKSRC}/Config.kmk \
+ ${WRKSRC}/src/VBox/Runtime/Makefile.kmk \
+ ${WRKSRC}/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
+ @${ECHO_CMD} 'VBOX_ICONV_DEFS = LIBICONV_PLUG' >> ${WRKSRC}/LocalConfig.kmk
+.endif
+
+post-patch-X11-on:
+ @${ECHO_CMD} 'VBOX_USE_SYSTEM_XORG_HEADERS = 1' >> \
+ ${WRKSRC}/LocalConfig.kmk
+
+pre-build:
+ cd ${WRKSRC} && ${SH} -c \
+ ". env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk"
+
+do-install:
+ ${MKDIR} ${STAGEDIR}${KMODDIR}
+ ${INSTALL_KLD} ${VBOX_BIN}/src/vboxguest/vboxguest.ko \
+ ${STAGEDIR}${KMODDIR}
+ ${INSTALL_KLD} ${VBOX_BIN}/vboxvfs.ko ${STAGEDIR}${KMODDIR}
+ ${INSTALL_LIB} ${VBOX_BIN}/pam_vbox.so ${STAGEDIR}${PREFIX}/lib
+ ${INSTALL_PROGRAM} ${VBOX_SBINS:S|^|${VBOX_BIN}/|} \
+ ${STAGEDIR}${PREFIX}/sbin/
+
+do-install-X11-on:
+ ${INSTALL_PROGRAM} ${VBOX_BIN}/VBoxClient ${STAGEDIR}${PREFIX}/bin/
+ ${INSTALL_SCRIPT} \
+ ${WRKSRC}/src/VBox/Additions/x11/Installer/98vboxadd-xclient \
+ ${STAGEDIR}${PREFIX}/bin/VBoxClient-all
+ # X11 autostart
+ ${MKDIR} ${STAGEDIR}${PREFIX}/etc/xdg/autostart/
+ ${INSTALL_DATA} \
+ ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \
+ ${STAGEDIR}${PREFIX}/etc/xdg/autostart/
+ # KDE autostart
+ ${MKDIR} ${STAGEDIR}${PREFIX}/share/autostart/
+ ${INSTALL_DATA} \
+ ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \
+ ${STAGEDIR}${PREFIX}/share/autostart/
+ ${MKDIR} ${STAGEDIR}${VIDEODIR}
+ ${INSTALL_DATA} ${VBOX_BIN}/vboxvideo_drv_system.so \
+ ${STAGEDIR}${VIDEODIR}/vboxvideo_drv.so
+ ${MKDIR} ${STAGEDIR}${INPUTDIR}
+ ${INSTALL_DATA} ${VBOX_BIN}/vboxmouse_drv_system.so \
+ ${STAGEDIR}${INPUTDIR}/vboxmouse_drv.so
+
+.include <bsd.port.post.mk>
diff --git a/emulators/virtualbox-ose-additions-legacy/distinfo b/emulators/virtualbox-ose-additions-legacy/distinfo
new file mode 100644
index 000000000000..ec47b980d44c
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1594821235
+SHA256 (VirtualBox-5.2.44.tar.bz2) = ad83b11cfae2734f7d6f619dd2f8bdada7d33492cd7682fab98cb4053122295e
+SIZE (VirtualBox-5.2.44.tar.bz2) = 124016934
diff --git a/emulators/virtualbox-ose-additions-legacy/files/vboxguest.in b/emulators/virtualbox-ose-additions-legacy/files/vboxguest.in
new file mode 100644
index 000000000000..08f3ef8ebab7
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/files/vboxguest.in
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: vboxguest
+# REQUIRE: FILESYSTEMS
+# BEFORE: netif
+# KEYWORD: nojail
+
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# vboxguest_enable (bool): Set to NO by default.
+# Set it to YES to enable vboxguest on startup
+
+. /etc/rc.subr
+
+name="vboxguest"
+rcvar=vboxguest_enable
+start_cmd="vboxguest_start"
+stop_cmd="vboxguest_stop"
+
+vboxguest_modules="vboxguest:pci/vboxguest"
+
+vboxguest_start()
+{
+ local _k _m
+
+ for _m in ${vboxguest_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
+}
+
+vboxguest_stop()
+{
+ local _k _m _r
+
+ _r=
+ for _m in ${vboxguest_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
+
+: ${vboxguest_enable="NO"}
+
+run_rc_command "$1"
diff --git a/emulators/virtualbox-ose-additions-legacy/files/vboxservice.in b/emulators/virtualbox-ose-additions-legacy/files/vboxservice.in
new file mode 100644
index 000000000000..cb2375868ca9
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/files/vboxservice.in
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# $FreeBSD$
+
+# PROVIDE: vboxservice
+# REQUIRE: DAEMON vboxguest
+# BEFORE: LOGIN
+# KEYWORD: shutdown
+
+# Define vboxservice_enable in /etc/rc.conf[.local] to enable it.
+#
+# vboxservice_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable VBoxService.
+
+. /etc/rc.subr
+
+name="vboxservice"
+rcvar=vboxservice_enable
+command="%%PREFIX%%/sbin/VBoxService"
+
+load_rc_config $name
+
+: ${vboxservice_enable="NO"}
+
+run_rc_command "$1"
diff --git a/emulators/virtualbox-ose-additions-legacy/files/vboxvideo.conf b/emulators/virtualbox-ose-additions-legacy/files/vboxvideo.conf
new file mode 100644
index 000000000000..dd6626429703
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/files/vboxvideo.conf
@@ -0,0 +1,5 @@
+libEGL.so.1 VBoxEGL.so
+libGL.so.1 VBoxOGL.so
+
+[libglx.so]
+libGL.so.1 libGL.so.1
diff --git a/emulators/virtualbox-ose-additions-legacy/pkg-descr b/emulators/virtualbox-ose-additions-legacy/pkg-descr
new file mode 100644
index 000000000000..e93c940f7f4a
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/pkg-descr
@@ -0,0 +1,9 @@
+These additions are for installation inside a FreeBSD guest.
+
+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/
diff --git a/emulators/virtualbox-ose-additions-legacy/pkg-message b/emulators/virtualbox-ose-additions-legacy/pkg-message
new file mode 100644
index 000000000000..e8b5c6a5edfa
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/pkg-message
@@ -0,0 +1,23 @@
+[
+{ type: install
+ message: <<EOM
+VirtualBox Guest Additions were installed.
+
+
+You need to enable the vboxguest startscript to load the kernel module and
+vboxservice to use host time synchronization.
+
+vboxguest_enable="YES"
+vboxservice_enable="YES"
+
+You also have to add all X11 users that want to use any of the additional
+features (clipboard sharing, window scaling) to the wheel group.
+
+% pw groupmod wheel -m jerry
+
+Reboot the machine to load the needed kernel modules.
+
+For detailed informations please visit http://wiki.freebsd.org/VirtualBox
+EOM
+}
+]
diff --git a/emulators/virtualbox-ose-additions-legacy/pkg-plist b/emulators/virtualbox-ose-additions-legacy/pkg-plist
new file mode 100644
index 000000000000..dac84dc22bcc
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-legacy/pkg-plist
@@ -0,0 +1,12 @@
+%%X11%%bin/VBoxClient
+%%X11%%bin/VBoxClient-all
+%%X11%%etc/xdg/autostart/vboxclient.desktop
+lib/pam_vbox.so
+%%X11%%lib/xorg/modules/drivers/vboxvideo_drv.so
+%%X11%%lib/xorg/modules/input/vboxmouse_drv.so
+sbin/VBoxControl
+sbin/VBoxService
+sbin/mount_vboxvfs
+%%X11%%share/autostart/vboxclient.desktop
+/%%KMODDIR%%/vboxguest.ko
+/%%KMODDIR%%/vboxvfs.ko
diff --git a/emulators/virtualbox-ose-additions-nox11-legacy/Makefile b/emulators/virtualbox-ose-additions-nox11-legacy/Makefile
new file mode 100644
index 000000000000..99b7a6873890
--- /dev/null
+++ b/emulators/virtualbox-ose-additions-nox11-legacy/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+PKGNAMESUFFIX= -additions-nox11-legacy
+
+OPTIONS_EXCLUDE= DBUS DEBUG OPENGL X11
+
+MASTERDIR= ${.CURDIR}/../virtualbox-ose-additions-legacy
+
+.include "${MASTERDIR}/Makefile"
diff --git a/emulators/virtualbox-ose-additions/Makefile b/emulators/virtualbox-ose-additions/Makefile
index ee9dbe426bc3..7e60ad7366ae 100644
--- a/emulators/virtualbox-ose-additions/Makefile
+++ b/emulators/virtualbox-ose-additions/Makefile
@@ -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}
@@ -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
@@ -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}' >> \
@@ -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 \
diff --git a/emulators/virtualbox-ose-additions/distinfo b/emulators/virtualbox-ose-additions/distinfo
index ec47b980d44c..bd3152a6518c 100644
--- a/emulators/virtualbox-ose-additions/distinfo
+++ b/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
diff --git a/emulators/virtualbox-ose-kmod-legacy/Makefile b/emulators/virtualbox-ose-kmod-legacy/Makefile
new file mode 100644
index 000000000000..6b115d5c93f3
--- /dev/null
+++ b/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>
diff --git a/emulators/virtualbox-ose-kmod-legacy/distinfo b/emulators/virtualbox-ose-kmod-legacy/distinfo
new file mode 100644
index 000000000000..2ca899b86014
--- /dev/null
+++ b/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
diff --git a/emulators/virtualbox-ose-kmod-legacy/files/vboxnet.in b/emulators/virtualbox-ose-kmod-legacy/files/vboxnet.in
new file mode 100644
index 000000000000..8c69dcc0ebd6
--- /dev/null
+++ b/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"
diff --git a/emulators/virtualbox-ose-kmod-legacy/pkg-descr b/emulators/virtualbox-ose-kmod-legacy/pkg-descr
new file mode 100644
index 000000000000..e9481f3a81fa
--- /dev/null
+++ b/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/
diff --git a/emulators/virtualbox-ose-kmod-legacy/pkg-plist b/emulators/virtualbox-ose-kmod-legacy/pkg-plist
new file mode 100644
index 000000000000..b08a5706a028
--- /dev/null
+++ b/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%%
diff --git a/emulators/virtualbox-ose-kmod/Makefile b/emulators/virtualbox-ose-kmod/Makefile
index b1077ca8198c..47c98ad31d43 100644
--- a/emulators/virtualbox-ose-kmod/Makefile
+++ b/emulators/virtualbox-ose-kmod/Makefile
@@ -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}
@@ -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
@@ -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
diff --git a/emulators/virtualbox-ose-kmod/distinfo b/emulators/virtualbox-ose-kmod/distinfo
index 2ca899b86014..fd36c0cc9df7 100644
--- a/emulators/virtualbox-ose-kmod/distinfo
+++ b/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
diff --git a/emulators/virtualbox-ose-legacy/Makefile b/emulators/virtualbox-ose-legacy/Makefile
new file mode 100644
index 000000000000..7cb730424fbe
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/Makefile
@@ -0,0 +1,409 @@
+# 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?= -legacy
+DISTFILES= VirtualBox-${PORTVERSION}${EXTRACT_SUFX} ${GUESTADDITIONS}
+EXTRACT_ONLY= VirtualBox-${PORTVERSION}${EXTRACT_SUFX}
+
+MAINTAINER= vbox@FreeBSD.org
+COMMENT= General-purpose full virtualizer for x86 hardware
+
+LICENSE= GPLv2
+LICENSE_FILE= ${WRKSRC}/COPYING
+
+PATCH_DEPENDS+= ${LOCALBASE}/share/kBuild/tools/GXX3.kmk:devel/kBuild
+BUILD_DEPENDS= yasm:devel/yasm \
+ xsltproc:textproc/libxslt \
+ kmk:devel/kBuild \
+ gtar:archivers/gtar
+LIB_DEPENDS= libpng.so:graphics/png \
+ libxslt.so:textproc/libxslt \
+ libcurl.so:ftp/curl
+RUN_DEPENDS= ${LOCALBASE}/etc/rc.d/vboxnet:emulators/virtualbox-ose-kmod-legacy
+
+CPE_VENDOR= oracle
+CPE_PRODUCT= vm_virtualbox
+
+WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION}
+ONLY_FOR_ARCHS= i386 amd64
+USES= compiler:c++14-lang cpe gnome iconv pkgconfig ssl tar:bzip2
+USE_GNOME= libidl libxml2
+
+HAS_CONFIGURE= yes
+CONFIGURE_ARGS= --disable-java --passive-mesa
+CONFIGURE_ARGS+= --with-gcc="${CC}" --with-g++="${CXX}"
+
+CONFLICTS_INSTALL= virtualbox-ose-additions-* \
+ virtualbox-ose-devel-[0-9]* \
+ virtualbox-ose-[0-9]* \
+ virtualbox-ose-lite-[0-9]*
+
+LDFLAGS= -lpthread
+
+VBOXUSER?= vboxusers
+VBOXWSUSER?= vboxusers
+VBOXGROUP?= vboxusers
+USERS= ${VBOXUSER}
+GROUPS= ${VBOXGROUP}
+VBOX_DIR= ${PREFIX}/${VBOX_DIR_REL}
+VBOX_DIR_REL= lib/virtualbox
+VBOX_LINKS= VBoxVRDP
+VBOX_PROGS= VBoxAutostart VBoxBalloonCtrl VBoxBugReport VBoxHeadless \
+ VBoxManage
+VBOX_UTILS= VBoxExtPackHelperApp VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT \
+ VBoxSVC VBoxXPCOMIPCD
+
+OPTIONS_DEFINE= ALSA DBUS DEBUG GUESTADDITIONS MANUAL NLS PULSEAUDIO \
+ PYTHON QT5 R0LOGGING UDPTUNNEL VDE VNC WEBSERVICE VPX X11
+OPTIONS_DEFAULT= DBUS QT5 UDPTUNNEL VNC WEBSERVICE X11
+OPTIONS_SUB= yes
+
+DEBUG_DESC= Debug symbols, additional logs and assertions
+GUESTADDITIONS_DESC= Build with Guest Additions
+MANUAL_DESC= Build with user manual
+NLS_DESC= Native language support (requires QT5)
+QT5_DESC= Build with QT5 frontend (requires X11)
+R0LOGGING_DESC= Enable R0 logging (requires DEBUG)
+UDPTUNNEL_DESC= Build with UDP tunnel support
+VDE_DESC= Build with VDE support
+VNC_DESC= Build with VNC support
+VPX_DESC= Use libvpx for video recording
+WEBSERVICE_DESC= Build Webservice
+
+ALSA_CONFIGURE_OFF= --disable-alsa
+ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib
+DBUS_CONFIGURE_OFF= --disable-dbus
+DBUS_LIB_DEPENDS= libdbus-1.so:devel/dbus
+DEBUG_CONFIGURE_ON= --build-debug
+MANUAL_BUILD_DEPENDS= ${LOCALBASE}/share/xml/docbook/4.4/docbookx.dtd:textproc/docbook-xml
+MANUAL_CONFIGURE_OFF= --disable-docs
+NLS_IMPLIES= QT5
+PULSEAUDIO_CONFIGURE_OFF= --disable-pulse
+PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio
+PYTHON_CONFIGURE_OFF= --disable-python
+QT5_IMPLIES= X11
+R0LOGGING_IMPLIES= DEBUG
+UDPTUNNEL_CONFIGURE_OFF= --disable-udptunnel
+VDE_CONFIGURE_ON= --enable-vde
+VDE_RUN_DEPENDS= vde_switch:net/vde2
+VNC_CONFIGURE_ON= --enable-vnc
+VNC_LIB_DEPENDS= libvncserver.so:net/libvncserver
+VPX_CONFIGURE_OFF= --disable-libvpx
+VPX_LIB_DEPENDS= libvpx.so:multimedia/libvpx
+X11_CONFIGURE_OFF= --build-headless
+
+ENV=
+.export ENV
+
+PLIST_SUB= GUEST_VER=${PORTVERSION} \
+ PYTHON_VERU=${PYTHON_VER:S/./_/}${PYTHON_ABIVER} \
+ VBOXGROUP=${VBOXGROUP}
+SUB_LIST= VBOXDIR=${VBOX_DIR} \
+ VBOXGROUP=${VBOXGROUP} \
+ VBOXUSER=${VBOXUSER} \
+ VBOXWSUSER=${VBOXWSUSER}
+USE_RC_SUBR= vboxheadless vboxwatchdog
+
+.include <bsd.port.options.mk>
+
+.if ${SLAVE_PORT} == no
+CONFLICTS_INSTALL+= virtualbox-ose-nox11-[0-9]*
+OPTIONS_DEFAULT+= PYTHON
+.else
+CONFLICTS_INSTALL+= virtualbox-ose-[0-9]*
+.endif
+
+.if ${ARCH} == "amd64"
+_ELF32!= kldstat -q -m elf32 && echo yes || echo no
+.endif
+
+.if ${PORT_OPTIONS:MDEBUG}
+KMK_BUILDTYPE= debug
+KMK_FLAGS+= BUILD_TYPE=debug
+.else
+KMK_BUILDTYPE= release
+.endif
+
+.if ${PORT_OPTIONS:MGUESTADDITIONS}
+GUESTADDITIONS= VBoxGuestAdditions_${PORTVERSION}.iso
+RESTRICTED= for personal use only
+RESTRICTED_FILES= ${GUESTADDITIONS}
+.endif
+
+.if ${PORT_OPTIONS:MMANUAL}
+DBKXMLDIR= ${LOCALBASE}/share/xml/docbook/4.4
+DBKXSLDIR= ${LOCALBASE}/share/xsl/docbook
+USE_TEX= dvipsk:build formats:build
+.endif
+
+.if ${PORT_OPTIONS:MPYTHON}
+USES+= python
+USE_PYTHON= distutils noegginfo noflavors
+PYDISTUTILS_PKGNAME= vboxapi
+PYDISTUTILS_PKGVERSION= 1.0
+.else
+USES+= python:build
+.endif
+
+.if ${PORT_OPTIONS:MQT5}
+CONFIGURE_ARGS+= --enable-qt5
+PLIST_SUB+= QT=""
+USES+= gl qmake:no_env qt:5 xorg
+USE_GL= gl glu
+USE_QT= buildtools_build core dbus gui linguisttools_build opengl
+USE_QT+= printsupport widgets x11extras
+USE_XORG= xcb
+INSTALLS_ICONS= yes
+VBOX_PROGS+= VirtualBox
+VBOX_UTILS+= VBoxTestOGL
+VBOX_WITH_QT= 1
+.else
+CONFIGURE_ARGS+= --disable-qt
+PLIST_SUB+= QT="@comment "
+.endif
+
+.if ${PORT_OPTIONS:MWEBSERVICE}
+BUILD_DEPENDS+= soapcpp2:devel/gsoap
+USE_RC_SUBR+= vboxwebsrv
+VBOX_LINKS+= vboxwebsrv
+VBOX_UTILS+= vboxwebsrv webtest
+.endif
+
+.if ${PORT_OPTIONS:MX11}
+USES+= sdl
+USE_SDL= sdl
+USE_XORG+= xorgproto x11 xcursor xext xinerama xmu xt
+VBOX_PROGS+= VBoxSDL
+.endif
+
+.if ${PORT_OPTIONS:MPYTHON} || ${PORT_OPTIONS:MWEBSERVICE}
+PLIST_SUB+= SDK=""
+.else
+PLIST_SUB+= SDK="@comment "
+.endif
+
+.if ${ARCH} == i386
+KMK_ARCH= freebsd.x86
+PLIST_SUB+= I386=""
+.else
+KMK_ARCH= freebsd.${ARCH}
+PLIST_SUB+= I386="@comment "
+.endif
+
+PLIST_SUB+= ARCH="${KMK_ARCH}"
+
+KMK_BUILDDIR= ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}
+KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys
+KMK_FLAGS+= -j${MAKE_JOBS_NUMBER}
+
+.include <bsd.port.pre.mk>
+
+.if ${PYTHON_MAJOR_VER} >= 3
+PLIST_SUB+= PYTHON_PYCDIR=/__pycache__/ \
+ PYTHON_PYCEXT=.cpython-${PYTHON_SUFFIX}.pyc
+.else
+PLIST_SUB+= PYTHON_PYCDIR=/ \
+ PYTHON_PYCEXT=.pyc
+.endif
+
+.if ${SSL_DEFAULT} != base
+CONFIGURE_ARGS+= --with-openssl-dir="${OPENSSLBASE}"
+.endif
+
+pre-everything::
+.if ${ARCH} == "amd64"
+.if ${_ELF32} != yes
+ @${ECHO_MSG} 'Requires 32-bit runtime support in kernel.'
+ @${ECHO_MSG} 'Rebuild kernel with "options COMPAT_FREEBSD32" and reboot.'
+ @${FALSE}
+.elif !exists(/usr/lib32/libc.so)
+ @${ECHO_MSG} 'Requires 32-bit libraries installed under /usr/lib32.'
+ @${ECHO_MSG} 'Do: cd /usr/src; make build32 install32; service ldconfig restart'
+ @${FALSE}
+.endif
+.endif
+
+post-patch:
+ @${ECHO_CMD} 'VBOX_PATH_APP_PRIVATE_ARCH = ${VBOX_DIR}' > \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_DOCBOOK = ${DBKXSLDIR}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_DOCBOOK_DTD = ${DBKXMLDIR}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_SHARED_LIBS = ${VBOX_DIR}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ # Please keep this even if using Clang to avoid repeated regressions.
+ # PR 245048
+ @${ECHO_CMD} "VBOX_WITH_RUNPATH = ${_GCC_RUNTIME:D${_GCC_RUNTIME}\:}${VBOX_DIR}" >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk
+.if ${SSL_DEFAULT} != base
+ @${ECHO_CMD} 'VBOX_WITH_ALT_HASH_CODE = 1' >> ${WRKSRC}/LocalConfig.kmk
+.endif
+ @${ECHO_CMD} 'VBOX_WITH_EXTPACK_VBOXDTRACE =' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_VBOXDRV =' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_TESTCASES =' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'SDK_VBOX_LIBPNG_INCS = ${PREFIX}/include/libpng' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'SDK_VBOX_LIBPNG_LIBS = png' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_ADDITIONS =' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_DRAG_AND_DROP = ${VBOX_WITH_QT}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_DRAG_AND_DROP_GH = ${VBOX_WITH_QT}' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_VALIDATIONKIT =' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_WITH_X11_ADDITIONS =' >> ${WRKSRC}/LocalConfig.kmk
+.if ${PORT_OPTIONS:MR0LOGGING}
+ @${ECHO_CMD} 'VBOX_WITH_R0_LOGGING = 1' >> ${WRKSRC}/LocalConfig.kmk
+.endif
+.if ${PORT_OPTIONS:MWEBSERVICE}
+ @${ECHO_CMD} 'VBOX_WITH_WEBSERVICES = 1' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_GSOAP_INSTALLED = 1' >> ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_GSOAP = ${PREFIX}/lib/gsoap' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_GSOAP_BIN = ${PREFIX}/bin' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_PATH_GSOAP_IMPORT = ${PREFIX}/share/gsoap/import' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${ECHO_CMD} 'VBOX_GCC_PEDANTIC_CXX = -Wshadow $$(VBOX_GCC_WARN) -Wno-long-long' >> \
+ ${WRKSRC}/LocalConfig.kmk
+ @${REINPLACE_CMD} -E -e '/soap_socket_errno\(/s/(soap_socket_errno)(\([^)]+\))/\1/' \
+ ${WRKSRC}/src/VBox/Main/webservice/vboxweb.cpp
+.endif
+ @${REINPLACE_CMD} -e 's| -finline-limit=8000||' \
+ -e 's| -mpreferred-stack-boundary=2||' \
+ -e 's|%%PYTHON_VERSION%%|${PYTHON_VERSION}|' \
+ ${WRKSRC}/Config.kmk
+ @${REINPLACE_CMD} -e 's| -fpermissive||' ${WRKSRC}/Config.kmk \
+ ${WRKSRC}/src/VBox/Main/webservice/Makefile.kmk
+ @${ECHO_CMD} 'TOOL_VBoxGccFreeBSD_LD = ${CXX}' >> ${WRKSRC}/LocalConfig.kmk
+ @${SED} -e 's|GXX3|VBoxGccFreeBSD|g' \
+ ${LOCALBASE}/share/kBuild/tools/GXX3.kmk > \
+ ${WRKSRC}/tools/kBuildTools/VBoxGccFreeBSD.kmk
+ @${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/libs/xpcom18a4/python/gen_python_deps.py
+ @${REINPLACE_CMD} \
+ -e 's|\$$KBUILDDIR_BIN/kmk_sed|${LOCALBASE}/bin/kmk_sed|g' \
+ -e 's|SUPPYTHONLIBS=.*|SUPPYTHONLIBS="${PYTHON_VERSION}${PYTHON_ABIVER}"|' \
+ ${WRKSRC}/configure
+.if empty(ICONV_LIB)
+ @${REINPLACE_CMD} -e 's|iconv||' ${WRKSRC}/Config.kmk \
+ ${WRKSRC}/src/VBox/Runtime/Makefile.kmk
+ @${ECHO_CMD} 'VBOX_ICONV_DEFS = LIBICONV_PLUG' >> ${WRKSRC}/LocalConfig.kmk
+.endif
+ @${REINPLACE_CMD} -e 's|/usr/local/lib/virtualbox|${VBOX_DIR}|' \
+ -e 's|/usr/local|${PREFIX}|' \
+ ${WRKSRC}/src/VBox/Installer/freebsd/VBox.sh
+ @${REINPLACE_CMD} \
+ -e 's|^versions =.*|versions = ["${PYTHON_VER}${PYTHON_ABIVER}"]|' \
+ ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py
+
+do-build:
+ cd ${WRKSRC} && ${SH} -c '. ${WRKSRC}/env.sh && \
+ ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS}'
+.if ${PORT_OPTIONS:MPYTHON}
+ ${PYTHON_CMD} -mcompileall \
+ ${KMK_BUILDDIR}/bin/sdk/bindings/xpcom/python/xpcom
+.endif
+
+do-install:
+.if ${PORT_OPTIONS:MPYTHON} || ${PORT_OPTIONS:MWEBSERVICE}
+ ${MKDIR} ${STAGEDIR}${DATADIR}/sdk
+.endif
+ cd ${KMK_BUILDDIR}/bin/sdk/bindings/xpcom && \
+ ${COPYTREE_SHARE} "idl samples" ${STAGEDIR}${DATADIR}
+
+ ${MKDIR} ${STAGEDIR}${PREFIX}/include/virtualbox
+ cd ${KMK_BUILDDIR}/bin/sdk/bindings/xpcom/include && \
+ ${COPYTREE_SHARE} "*" ${STAGEDIR}${PREFIX}/include/virtualbox
+
+ ${MKDIR} ${STAGEDIR}${VBOX_DIR}
+ cd ${KMK_BUILDDIR}/bin && ${COPYTREE_SHARE} \
+ "*.fd *.r0 *.rc *.so components" ${STAGEDIR}${VBOX_DIR}
+.if ${PORT_OPTIONS:MPYTHON} || ${PORT_OPTIONS:MWEBSERVICE}
+ ${RLN} ${STAGEDIR}${DATADIR}/sdk ${STAGEDIR}${VBOX_DIR}
+.endif
+
+ ${INSTALL_SCRIPT} ${WRKSRC}/src/VBox/Installer/freebsd/VBox.sh \
+ ${STAGEDIR}${VBOX_DIR}
+.for f in ${VBOX_PROGS} ${VBOX_UTILS}
+ ${INSTALL_PROGRAM} ${KMK_BUILDDIR}/bin/${f} ${STAGEDIR}${VBOX_DIR}
+.endfor
+.for f in ${VBOX_PROGS} ${VBOX_LINKS}
+ ${LN} -fs ../${VBOX_DIR_REL}/VBox.sh ${STAGEDIR}${PREFIX}/bin/${f}
+.endfor
+.for f in ${VBOX_PROGS}
+ ${LN} -fs ../${VBOX_DIR_REL}/VBox.sh ${STAGEDIR}${PREFIX}/bin/${f:tl}
+.endfor
+
+.if ${PORT_OPTIONS:MGUESTADDITIONS}
+ ${MKDIR} ${STAGEDIR}${VBOX_DIR}/additions
+ ${INSTALL_DATA} ${DISTDIR}/${GUESTADDITIONS} \
+ ${STAGEDIR}${VBOX_DIR}/additions/
+ ${RLN} ${STAGEDIR}${VBOX_DIR}/additions/${GUESTADDITIONS} \
+ ${STAGEDIR}${VBOX_DIR}/additions/VBoxGuestAdditions.iso
+.endif
+
+.if ${PORT_OPTIONS:MMANUAL}
+ ${MKDIR} ${STAGEDIR}${DOCSDIR}
+ ${INSTALL_DATA} ${KMK_BUILDDIR}/bin/UserManual*.pdf \
+ ${STAGEDIR}${DOCSDIR}
+.endif
+
+.if ${PORT_OPTIONS:MNLS}
+ cd ${KMK_BUILDDIR}/obj/VirtualBox/qtnls && \
+ ${COPYTREE_SHARE} "*.qm" ${STAGEDIR}${DATADIR}/nls
+.endif
+
+.if ${PORT_OPTIONS:MPYTHON}
+ cd ${KMK_BUILDDIR}/bin/sdk/installer && \
+ ${SETENV} VBOX_INSTALL_PATH="${VBOX_DIR}" \
+ ${PYTHON_CMD} vboxapisetup.py install --root=${STAGEDIR}
+
+ @${MKDIR} ${STAGEDIR}${PYTHON_SITELIBDIR}/xpcom
+ cd ${KMK_BUILDDIR}/bin/sdk/bindings/xpcom/python/xpcom && \
+ ${COPYTREE_SHARE} "*" ${STAGEDIR}${PYTHON_SITELIBDIR}/xpcom
+ @${MKDIR} ${STAGEDIR}${DATADIR}/sdk/bindings/xpcom/python
+ ${RLN} ${STAGEDIR}${PYTHON_SITELIBDIR}/xpcom \
+ ${STAGEDIR}${DATADIR}/sdk/bindings/xpcom/python
+.endif
+
+.if ${PORT_OPTIONS:MQT5}
+ ${INSTALL_DATA} \
+ ${WRKSRC}/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png \
+ ${STAGEDIR}${PREFIX}/share/pixmaps/VBox.png
+ ${INSTALL_DATA} \
+ ${WRKSRC}/src/VBox/Installer/freebsd/virtualbox.desktop \
+ ${STAGEDIR}${PREFIX}/share/applications/virtualbox.desktop
+.endif
+
+.if ${PORT_OPTIONS:MVNC}
+ ${MKDIR} ${STAGEDIR}${VBOX_DIR}/ExtensionPacks/VNC/${KMK_ARCH}
+ ${INSTALL_DATA} ${KMK_BUILDDIR}/bin/ExtensionPacks/VNC/ExtPack* \
+ ${STAGEDIR}${VBOX_DIR}/ExtensionPacks/VNC/
+ ${INSTALL_LIB} ${KMK_BUILDDIR}/bin/ExtensionPacks/VNC/${KMK_ARCH}/* \
+ ${STAGEDIR}${VBOX_DIR}/ExtensionPacks/VNC/${KMK_ARCH}/
+.endif
+
+.if ${PORT_OPTIONS:MWEBSERVICE}
+ ${MKDIR} ${STAGEDIR}${DATADIR}/sdk/bindings/webservice
+ ${INSTALL_DATA} ${KMK_BUILDDIR}/obj/webservice/vboxweb.wsdl \
+ ${STAGEDIR}${DATADIR}/sdk/bindings/webservice/
+.endif
+
+post-install:
+ ${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/virtualbox/*.so \
+ ${STAGEDIR}${PREFIX}/lib/virtualbox/components/*.so
+
+.include <bsd.port.post.mk>
diff --git a/emulators/virtualbox-ose-legacy/distinfo b/emulators/virtualbox-ose-legacy/distinfo
new file mode 100644
index 000000000000..ac8004bf0188
--- /dev/null
+++ b/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
diff --git a/emulators/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
index 70fce51927bb..70fce51927bb 100644
--- a/emulators/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
diff --git a/emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile b/emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
new file mode 100644
index 000000000000..67361da543f7
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
@@ -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
diff --git a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderAdditions.cpp b/emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderAdditions.cpp
index 23ac13f74c7c..23ac13f74c7c 100644
--- a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderAdditions.cpp
+++ b/emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderAdditions.cpp
diff --git a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderExtensionPack.cpp b/emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderExtensionPack.cpp
index ab47ece4df6d..ab47ece4df6d 100644
--- a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderExtensionPack.cpp
+++ b/emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_net_UIDownloaderExtensionPack.cpp
diff --git a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_settings_global_UIGlobalSettingsNetworkDetailsHost.cpp b/emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_settings_global_UIGlobalSettingsNetworkDetailsHost.cpp
index 1c93bf7c096a..1c93bf7c096a 100644
--- a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Frontends_VirtualBox_src_settings_global_UIGlobalSettingsNetworkDetailsHost.cpp
+++ b/emulators/virtualbox-ose-legacy/files/extrapatch-src_VBox_Frontends_VirtualBox_src_settings_global_UIGlobalSettingsNetworkDetailsHost.cpp
diff --git a/emulators/virtualbox-ose-legacy/files/patch-Config.kmk b/emulators/virtualbox-ose-legacy/files/patch-Config.kmk
new file mode 100644
index 000000000000..784ec4295655
--- /dev/null
+++ b/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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-configure b/emulators/virtualbox-ose-legacy/files/patch-configure
new file mode 100644
index 000000000000..31d4bd082fe3
--- /dev/null
+++ b/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
diff --git a/emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h b/emulators/virtualbox-ose-legacy/files/patch-include-VBox-vmm-cpumctx.h
index e046347ef77a..e046347ef77a 100644
--- a/emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-include-VBox-vmm-cpumctx.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-include-iprt-x86.h b/emulators/virtualbox-ose-legacy/files/patch-include-iprt-x86.h
new file mode 100644
index 000000000000..9a1001296bc9
--- /dev/null
+++ b/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
diff --git a/emulators/virtualbox-ose/files/patch-include_VBox_VBoxGL2D.h b/emulators/virtualbox-ose-legacy/files/patch-include_VBox_VBoxGL2D.h
index a319e03b6f8a..a319e03b6f8a 100644
--- a/emulators/virtualbox-ose/files/patch-include_VBox_VBoxGL2D.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-include_VBox_VBoxGL2D.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-include_VBox_com_array.h b/emulators/virtualbox-ose-legacy/files/patch-include_VBox_com_array.h
new file mode 100644
index 000000000000..ad8071687bbf
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-include_VBox_com_array.h
@@ -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
+ }
diff --git a/emulators/virtualbox-ose/files/patch-include_iprt_assertcompile.h b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_assertcompile.h
index 28fe48256a27..28fe48256a27 100644
--- a/emulators/virtualbox-ose/files/patch-include_iprt_assertcompile.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_assertcompile.h
diff --git a/emulators/virtualbox-ose/files/patch-include_iprt_cdefs.h b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_cdefs.h
index ddef5a0020ba..ddef5a0020ba 100644
--- a/emulators/virtualbox-ose/files/patch-include_iprt_cdefs.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_cdefs.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-include_iprt_string.h b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_string.h
new file mode 100644
index 000000000000..d2792545c97e
--- /dev/null
+++ b/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)
diff --git a/emulators/virtualbox-ose/files/patch-include_iprt_types.h b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_types.h
index ff27f2b25641..ff27f2b25641 100644
--- a/emulators/virtualbox-ose/files/patch-include_iprt_types.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-include_iprt_types.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
new file mode 100644
index 000000000000..c6eda2f9587d
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
new file mode 100644
index 000000000000..a2f9863c8f3b
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
@@ -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 \
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
new file mode 100644
index 000000000000..48db97765cf7
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
@@ -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 \
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py
index 8edc22523121..8edc22523121 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py
index a9e69194540b..a9e69194540b 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py
index 093be916fb24..093be916fb24 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk
index 09913503d958..09913503d958 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
new file mode 100644
index 000000000000..01fd1fc9b586
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop
new file mode 100644
index 000000000000..a76eb7616038
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h
new file mode 100644
index 000000000000..b6ed2d2915db
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h
@@ -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 */
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Devices-PC-ipxe-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-PC-ipxe-Makefile.kmk
index fb854420a641..fb854420a641 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Devices-PC-ipxe-Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-PC-ipxe-Makefile.kmk
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Devices-Storage-DrvHostBase-freebsd.cpp b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Storage-DrvHostBase-freebsd.cpp
index 7a472483318e..7a472483318e 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Devices-Storage-DrvHostBase-freebsd.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Devices-Storage-DrvHostBase-freebsd.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk
index f21f7c11c11c..f21f7c11c11c 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
new file mode 100644
index 000000000000..8633e8a2269a
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
@@ -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 += \
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
new file mode 100644
index 000000000000..82fc839a0267
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
@@ -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 \
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
new file mode 100644
index 000000000000..c141ba29fb6c
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
@@ -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)
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c
index 75a18c10f559..75a18c10f559 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
new file mode 100644
index 000000000000..4c0df373227c
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
@@ -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)
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt
new file mode 100644
index 000000000000..c6b681245e91
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt
@@ -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 \
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-Makefile.kmk
new file mode 100644
index 000000000000..45546433c627
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-Makefile.kmk
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-VBox.sh b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-VBox.sh
new file mode 100644
index 000000000000..cebabd64d010
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-VBox.sh
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-virtualbox.desktop b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-virtualbox.desktop
new file mode 100644
index 000000000000..ae2253daf847
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Installer-freebsd-virtualbox.desktop
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
new file mode 100644
index 000000000000..a908f2c17a51
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
@@ -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++)
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp
index 4c11eb0e735b..4c11eb0e735b 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-webservice-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-webservice-Makefile.kmk
new file mode 100644
index 000000000000..a5485e8aee1d
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Main-webservice-Makefile.kmk
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-Makefile.kmk
new file mode 100644
index 000000000000..915f57ae49b0
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-Makefile.kmk
@@ -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))
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
new file mode 100644
index 000000000000..8c4376c342e7
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
@@ -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
diff --git a/emulators/virtualbox-ose/files/patch-src-recompiler-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src-recompiler-Makefile.kmk
index f58e3edcd791..f58e3edcd791 100644
--- a/emulators/virtualbox-ose/files/patch-src-recompiler-Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-recompiler-Makefile.kmk
diff --git a/emulators/virtualbox-ose/files/patch-src-recompiler-Sun-testmath.c b/emulators/virtualbox-ose-legacy/files/patch-src-recompiler-Sun-testmath.c
index 5118238bd7d7..5118238bd7d7 100644
--- a/emulators/virtualbox-ose/files/patch-src-recompiler-Sun-testmath.c
+++ b/emulators/virtualbox-ose-legacy/files/patch-src-recompiler-Sun-testmath.c
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
new file mode 100644
index 000000000000..8f6810a5bc82
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
@@ -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));
+
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_dri__glx.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_dri__glx.h
index 80463ac59e77..80463ac59e77 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_dri__glx.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_dri__glx.h
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.h
index a9879fad7180..a9879fad7180 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.h
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx.c
index 7f0cc189a1aa..7f0cc189a1aa 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx.c
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx.c
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx__c__exports.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx__c__exports.c
index dcdbc68e271f..dcdbc68e271f 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx__c__exports.c
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx__c__exports.c
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx__proto.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx__proto.h
index 748a63864991..748a63864991 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_glx__proto.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_glx__proto.h
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_stub.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_stub.h
index 8b49aa94686a..8b49aa94686a 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_crOpenGL_stub.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_crOpenGL_stub.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp
new file mode 100644
index 000000000000..47111c1ded45
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp
@@ -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;
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile
new file mode 100644
index 000000000000..c38d8013a6d6
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile.kmk
new file mode 100644
index 000000000000..fce921705363
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_Makefile.kmk
@@ -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.
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_Makefile.kmk
new file mode 100644
index 000000000000..4d327e1089b1
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_Makefile.kmk
@@ -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)
++
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.8 b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.8
new file mode 100644
index 000000000000..88460e155de3
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.8
@@ -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
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.c
new file mode 100644
index 000000000000..7dd7e6271e03
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_mount__vboxvfs_mount__vboxvfs.c
@@ -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);
++}
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk
new file mode 100644
index 000000000000..4522bc83e422
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk
@@ -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)
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h
new file mode 100644
index 000000000000..09bb8575898e
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h
@@ -0,0 +1,463 @@
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h.orig 2018-06-29 13:08:17 UTC
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h
+@@ -1,8 +1,3 @@
+-/* $Id: vboxvfs.h $ */
+-/** @file
+- * Description.
+- */
+-
+ /*
+ * Copyright (C) 2010-2017 Oracle Corporation
+ *
+@@ -21,72 +16,413 @@
+ #define VBOXVFS_VFSNAME "vboxvfs"
+ #define VBOXVFS_VERSION 1
+
+-#define MAX_HOST_NAME 256
+-#define MAX_NLS_NAME 32
++#define MAX_HOST_NAME 256
++#define MAX_NLS_NAME 32
++//#define MODEMASK 07777 /* mode bits plus permission bits */
++/** Helper macros */
++#define VFSTOVBOXFS(mp) ((struct vboxfs_mnt *)((mp)->mnt_data))
++#define VP_TO_VBOXFS_NODE(vp) ((struct vboxfs_node *)(vp)->v_data)
++#define VBOXTOV(np) ((struct vnode *)(np)->n_vnode)
+
+-struct vboxvfs_mount_info {
+- char name[MAX_HOST_NAME];
+- char nls_name[MAX_NLS_NAME];
+- int uid;
+- int gid;
+- int ttl;
+-};
++#define ROOTDIR_INO 1
++#define THEFILE_INO 2
++#define THEFILE_NAME "thefile"
+
++#define VBOXFS_NODE_LOCK(node) mtx_lock(&(node)->sf_interlock)
++#define VBOXFS_NODE_UNLOCK(node) mtx_unlock(&(node)->sf_interlock)
++#define VBOXFS_NODE_MTX(node) (&(node)->sf_interlock)
++#define VBOXFS_NODE_ASSERT_LOCKED(node) mtx_assert(VBOXFS_NODE_MTX(node), \
++ MA_OWNED)
++
++#ifdef INVARIANTS
++#define VBOXFS_ASSERT_LOCKED(node) do { \
++ MPASS(node != NULL); \
++ MPASS(node->sf_vnode != NULL); \
++ if (!VOP_ISLOCKED(node->sf_vnode) && \
++ !mtx_owned(VBOXFS_NODE_MTX(node))) \
++ panic("vboxfs: node is not locked: %p", node); \
++ } while (0)
++#define VBOXFS_ASSERT_ELOCKED(node) do { \
++ MPASS((node) != NULL); \
++ MPASS((node)->sf_vnode != NULL); \
++ mtx_assert(VBOXFS_NODE_MTX(node), MA_OWNED); \
++ ASSERT_VOP_LOCKED((node)->sf_vnode, "vboxfs"); \
++ } while (0)
++#else
++#define VBOXFS_ASSERT_LOCKED(node) (void)0
++#define VBOXFS_ASSERT_ELOCKED(node) (void)0
++#endif
++
++#define VBOXFS_VNODE_ALLOCATING 1
++#define VBOXFS_VNODE_WANT 2
++#define VBOXFS_VNODE_DOOMED 4
++#define VBOXFS_VNODE_WRECLAIM 8
++
++MALLOC_DECLARE(M_VBOXVFS);
++
+ #ifdef _KERNEL
++#ifndef FREEBSD_STYLE
++#include "../../../../../include/iprt/nocrt/limits.h"
++#include "../../../../../include/iprt/alloc.h"
++#include "../../../../../include/iprt/asm.h"
++#include "../../../../../include/iprt/asm-amd64-x86.h"
++#include "../../../../../include/iprt/asm-math.h"
++#include "../../../../../include/iprt/assert.h"
++#include "../../../../../include/iprt/cdefs.h"
++#include "../../../../../include/iprt/err.h"
++#include "../../../../../include/iprt/fs.h"
++#include "../../../../../include/iprt/log.h"
++#include "../../../../../include/iprt/mangling.h"
++#include "../../../../../include/iprt/mem.h"
++#include "../../../../../include/iprt/param.h"
++#include "../../../../../include/iprt/path.h"
++#include "../../../../../include/iprt/semaphore.h"
++#include "../../../../../include/iprt/stdarg.h"
++#include "../../../../../include/iprt/stdint.h"
++#include "../../../../../include/iprt/string.h"
++#include "../../../../../include/iprt/time.h"
++#include "../../../../../include/iprt/types.h"
++#include "../../../../../include/iprt/uni.h"
++#include "../../../../../include/iprt/nocrt/limits.h"
++#include "../../../../../include/iprt/alloc.h"
++#include "../../../../../include/iprt/asm.h"
++#include "../../../../../include/iprt/asm-amd64-x86.h"
++#include "../../../../../include/iprt/asm-math.h"
++#include "../../../../../include/iprt/assert.h"
++#include "../../../../../include/iprt/cdefs.h"
++#include "../../../../../include/iprt/err.h"
++#include "../../../../../include/iprt/fs.h"
++#include "../../../../../include/iprt/log.h"
++#include "../../../../../include/iprt/mangling.h"
++#include "../../../../../include/iprt/mem.h"
++#include "../../../../../include/iprt/param.h"
++#include "../../../../../include/iprt/path.h"
++#include "../../../../../include/iprt/semaphore.h"
++#include "../../../../../include/iprt/stdarg.h"
++#include "../../../../../include/iprt/stdint.h"
++#include "../../../../../include/iprt/string.h"
++#include "../../../../../include/iprt/time.h"
++#include "../../../../../include/iprt/types.h"
++#include "../../../../../include/iprt/uni.h"
+
+-#include <VBox/VBoxGuestLibSharedFolders.h>
++#else
++
++#include "iprt/nocrt/limits.h"
++#include "iprt/alloc.h"
++#include "iprt/asm.h"
++#include "iprt/asm-amd64-x86.h"
++#include "iprt/asm-math.h"
++#include "iprt/assert.h"
++#include "iprt/cdefs.h"
++#include "iprt/err.h"
++#include "iprt/fs.h"
++#include "iprt/log.h"
++#include "iprt/mem.h"
++#include "iprt/param.h"
++#include "iprt/path.h"
++#include "iprt/semaphore.h"
++#include "iprt/stdarg.h"
++#include "iprt/stdint.h"
++#include "iprt/string.h"
++#include "iprt/time.h"
++#include "iprt/types.h"
++#include "iprt/uni.h"
++#include "iprt/nocrt/limits.h"
++#include "iprt/alloc.h"
++#include "iprt/asm.h"
++#include "iprt/asm-amd64-x86.h"
++#include "iprt/asm-math.h"
++#include "iprt/assert.h"
++#include "iprt/cdefs.h"
++#include "iprt/err.h"
++#include "iprt/fs.h"
++#include "iprt/log.h"
++#include "iprt/mem.h"
++#include "iprt/param.h"
++#include "iprt/path.h"
++#include "iprt/semaphore.h"
++#include "iprt/stdarg.h"
++#include "iprt/stdint.h"
++#include "iprt/string.h"
++#include "iprt/time.h"
++#include "iprt/types.h"
++#include "iprt/uni.h"
++
++#include "common/VBoxGuestLib/SysHlp.h"
++
++#endif /* !FREEBSD_STYLE */
++
+ #include <sys/mount.h>
+ #include <sys/vnode.h>
++#include <sys/_timespec.h>
+
+-struct vboxvfsmount {
+- uid_t uid;
+- gid_t gid;
+- mode_t file_mode;
+- mode_t dir_mode;
+- struct mount *mp;
+- struct ucred *owner;
+- u_int flags;
+- long nextino;
+- int caseopt;
+- int didrele;
++#include <VBox/VBoxGuestLibSharedFolders.h>
++
++#define VBOXVFS_DEBUG(lvl, ...) do { \
++ if (vboxvfs_debug >= (lvl)) { \
++ printf("VBOXVFS[%u]: ", lvl); \
++ printf(__VA_ARGS__); \
++ printf("\n"); \
++ } \
++} while (0)
++
++/*
++ * representation of an active mount point
++ */
++struct sfp_mount {
++ VBGLSFMAP map;
+ };
+
+-/* structs - stolen from the linux shared module code */
++/*
++ * Mount / Unmount a shared folder.
++ *
++ * sfprov_mount() takes as input the connection pointer and the name of
++ * the shared folder. On success, it returns zero and supplies an
++ * sfp_mount_t handle. On failure it returns any relevant errno value.
++ *
++ * sfprov_unmount() unmounts the mounted file system. It returns 0 on
++ * success and any relevant errno on failure.
++ */
++typedef struct sfp_mount sfp_mount_t;
++
++struct sfp_file {
++ SHFLHANDLE handle;
++ VBGLSFMAP map; /* need this again for the close operation */
++};
++
++typedef struct sfp_file sfp_file_t;
++
++/*
++ * File operations: open/close/read/write/etc.
++ *
++ * open/create can return any relevant errno, however ENOENT
++ * generally means that the host file didn't exist.
++ */
++typedef struct sffs_stat {
++ mode_t sf_mode;
++ off_t sf_size;
++ off_t sf_alloc;
++ struct timespec sf_atime;
++ struct timespec sf_mtime;
++ struct timespec sf_ctime;
++} sffs_stat_t;
++
++/*
++ * Read directory entries.
++ */
++/*
++ * a singly linked list of buffers, each containing an array of stat's+dirent's.
++ * sf_len is length of the sf_entries array, in bytes.
++ */
++typedef struct sffs_dirents {
++ struct sffs_dirents *sf_next;
++ long long sf_len;
++ struct sffs_dirent {
++ sffs_stat_t sf_stat;
++ struct dirent sf_entry; /* this is variable length */
++ off_t sf_off;
++ } sf_entries[1];
++} sffs_dirents_t;
++
++/*
++ * Shared Folders filesystem per-mount data structure.
++ */
++struct vboxfs_mnt {
++ struct mount *sf_vfsp; /* filesystem's vfs struct */
++ sfp_mount_t *sf_handle; /* guest-host communication handle */
++ uid_t sf_uid; /* owner of all shared folders */
++ gid_t sf_gid; /* group of all shared folders */
++ mode_t sf_dmode; /* mode of all directories */
++ mode_t sf_fmode; /* mode of all files */
++ mode_t sf_dmask; /* mask of all directories */
++ mode_t sf_fmask; /* mask of all files */
++ int sf_stat_ttl; /* ttl for stat caches (in ms) */
++ int sf_fsync; /* whether to honor fsync or not */
++ uint64_t sf_ino; /* per FS ino generator */
++ uma_zone_t sf_node_pool;
++ struct vboxfs_node *sf_root;
++};
++
++/*
++ * vboxfs_node is the file system dependent vnode data for vboxfs.
++ * vboxfs_node's also track all files ever accessed, both open and closed.
++ * It duplicates some of the information in vnode, since it holds
++ * information for files that may have been completely closed.
++ *
++ */
++struct vboxfs_node {
++ struct vboxfs_mnt *vboxfsmp; /* containing mounted file system */
++ char *sf_path; /* full pathname to file or dir */
++ uint64_t sf_ino; /* assigned unique ID number */
++ struct vnode *sf_vnode; /* vnode if active */
++ sfp_file_t *sf_file; /* non NULL if open */
++ struct vboxfs_node *sf_parent; /* parent sfnode of this one */
++ uint16_t sf_children; /* number of children sfnodes */
++ uint8_t sf_type; /* VDIR or VREG */
++ uint8_t sf_vpstate; /* XXX: ADD COMMENT */
++ uint8_t sf_is_stale; /* this is stale and should be purged */
++ sffs_stat_t sf_stat; /* cached file attrs for this node */
++ uint64_t sf_stat_time; /* last-modified time of sf_stat */
++ sffs_dirents_t *sf_dir_list; /* list of entries for this directory */
++
++ /* interlock to protect sf_vpstate */
++ struct mtx sf_interlock;
++};
++
++struct vboxfs_mount_info {
++ char name[MAX_HOST_NAME]; /* share name */
++ char nls_name[MAX_NLS_NAME];/* name of an I/O charset */
++ int uid; /* user ID for all entries, default 0=root */
++ int gid; /* group ID for all entries, default 0=root */
++ int ttl; /* time to live */
++ int dmode; /* mode for directories if != 0xffffffff */
++ int fmode; /* mode for regular files if != 0xffffffff */
++ int dmask; /* umask applied to directories */
++ int fmask; /* umask applied to regular files */
++};
++
+ struct sf_glob_info {
+- VBGLSFMAP map;
+-/* struct nls_table *nls;*/
+- int ttl;
+- int uid;
+- int gid;
+- struct vnode *vnode_root;
++ VBGLSFMAP map;
++/* struct nls_table *nls;*/
++ int ttl;
++ int uid;
++ int gid;
++ struct vnode *vnode_root;
+ };
+
++/** Per-file system mount instance data. */
++typedef struct vboxfs_globinfo
++{
++ VBGLSFMAP Map;
++ int Ttl;
++ int Uid;
++ int Gid;
++ struct mount *pVFS;
++ struct vboxfs_node *pVNodeRoot;
++} vboxfs_globinfo_t;
++
+ struct sf_inode_info {
+- SHFLSTRING *path;
+- int force_restat;
++ SHFLSTRING *path;
++ int force_restat;
+ };
+
+ #if 0
+ struct sf_dir_info {
+- struct list_head info_list;
++ struct list_head info_list;
+ };
+ #endif
+
+ struct sf_dir_buf {
+- size_t nb_entries;
+- size_t free_bytes;
+- size_t used_bytes;
+- void *buf;
++ size_t nb_entries;
++ size_t free_bytes;
++ size_t used_bytes;
++ void *buf;
+ #if 0
+- struct list_head head;
++ struct list_head head;
+ #endif
+ };
+
+ struct sf_reg_info {
+- SHFLHANDLE handle;
++ SHFLHANDLE handle;
+ };
+
++int vboxfs_alloc_vp(struct mount *, struct vboxfs_node *, int,
++ struct vnode **);
++void vboxfs_free_vp(struct vnode *);
++
++int vboxfs_alloc_node(struct mount *, struct vboxfs_mnt *, const char*,
++ enum vtype, uid_t, gid_t, mode_t, struct vboxfs_node *,
++ struct vboxfs_node **);
++void vboxfs_free_node(struct vboxfs_mnt *, struct vboxfs_node *);
++
++/*
++ * These are the provider interfaces used by sffs to access the underlying
++ * shared file system.
++ */
++#define SFPROV_VERSION 1
++
++/*
++ * Initialization and termination.
++ * sfprov_connect() is called once before any other interfaces and returns
++ * a handle used in further calls. The argument should be SFPROV_VERSION
++ * from above. On failure it returns a NULL pointer.
++ *
++ * sfprov_disconnect() must only be called after all sf file systems have been
++ * unmounted.
++ */
++typedef struct sfp_connection sfp_connection_t;
++
++extern sfp_connection_t *sfprov_connect(int);
++extern void sfprov_disconnect(void);
++
++extern int sfprov_mount(char *, sfp_mount_t **);
++extern int sfprov_unmount(sfp_mount_t *);
++
++/*
++ * query information about a mounted file system
++ */
++typedef struct sffs_fsinfo {
++ uint64_t blksize;
++ uint64_t blksused;
++ uint64_t blksavail;
++ uint32_t maxnamesize;
++ uint32_t readonly;
++ uint32_t serial;
++} sffs_fsinfo_t;
++
++extern int sfprov_get_fsinfo(sfp_mount_t *, sffs_fsinfo_t *);
++
++extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode,
++ sfp_file_t **fp, sffs_stat_t *stat);
++extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp);
++extern int sfprov_close(sfp_file_t *fp);
++extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset,
++ uint32_t *numbytes, int buflocked);
++extern int sfprov_write(sfp_file_t *, char * buffer, uint64_t offset,
++ uint32_t *numbytes, int buflocked);
++extern int sfprov_fsync(sfp_file_t *fp);
++
++
++/*
++ * get/set information about a file (or directory) using pathname
++ */
++extern int sfprov_get_mode(sfp_mount_t *, char *, mode_t *);
++extern int sfprov_get_size(sfp_mount_t *, char *, uint64_t *);
++extern int sfprov_get_atime(sfp_mount_t *, char *, struct timespec *);
++extern int sfprov_get_mtime(sfp_mount_t *, char *, struct timespec *);
++extern int sfprov_get_ctime(sfp_mount_t *, char *, struct timespec *);
++extern int sfprov_get_attr(sfp_mount_t *, char *, sffs_stat_t *);
++extern int sfprov_set_attr(sfp_mount_t *, char *, mode_t,
++ struct timespec, struct timespec, struct timespec);
++extern int sfprov_set_size(sfp_mount_t *, char *, uint64_t);
++
++
++/*
++ * File/Directory operations
++ */
++extern int sfprov_trunc(sfp_mount_t *, char *);
++extern int sfprov_remove(sfp_mount_t *, char *path, u_int is_link);
++extern int sfprov_mkdir(sfp_mount_t *, char *path, mode_t mode,
++ sfp_file_t **fp, sffs_stat_t *stat);
++extern int sfprov_rmdir(sfp_mount_t *, char *path);
++extern int sfprov_rename(sfp_mount_t *, char *from, char *to, u_int is_dir);
++
++
++/*
++ * Symbolic link operations
++ */
++extern int sfprov_set_show_symlinks(void);
++extern int sfprov_readlink(sfp_mount_t *, char *path, char *target,
++ size_t tgt_size);
++extern int sfprov_symlink(sfp_mount_t *, char *linkname, char *target,
++ sffs_stat_t *stat);
++
++#define SFFS_DIRENTS_SIZE 8192
++#define SFFS_DIRENTS_OFF (offsetof(sffs_dirents_t, sf_entries[0]))
++
++extern int sfprov_readdir(sfp_mount_t *mnt, char *path,
++ sffs_dirents_t **dirents);
++
+ #endif /* KERNEL */
+
+ #endif /* !___VBOXVFS_H___ */
+-
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__prov.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__prov.c
new file mode 100644
index 000000000000..bf094e6a854a
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__prov.c
@@ -0,0 +1,1023 @@
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c.orig 2020-06-26 09:59:35 UTC
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c
+@@ -0,0 +1,1020 @@
++/*
++ * Copyright (C) 2008-2016 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.
++ *
++ * The contents of this file may alternatively be used under the terms
++ * of the Common Development and Distribution License Version 1.0
++ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
++ * VirtualBox OSE distribution, in which case the provisions of the
++ * CDDL are applicable instead of those of the GPL.
++ *
++ * You may elect to license modified versions of this file under the
++ * terms and conditions of either the GPL or the CDDL or both.
++ */
++
++/*
++ * Provider interfaces for shared folder file system.
++ */
++
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/param.h>
++#include <sys/systm.h>
++#include <sys/kernel.h>
++#include <sys/malloc.h>
++#include <sys/mount.h>
++#include <sys/vnode.h>
++#include <sys/dirent.h>
++#include <sys/proc.h>
++#include <vm/vm.h>
++#include <vm/pmap.h>
++#include <vm/vm_kern.h>
++#include <vm/vm_map.h>
++#include <vm/vm_object.h>
++#include <vm/vm_extern.h>
++#include "vboxvfs.h"
++
++#define DIRENT_RECLEN(namelen) \
++ ((offsetof(struct dirent, d_name[0]) + 1 + (namelen) + 7) & ~ 7)
++#define DIRENT_NAMELEN(reclen) \
++ ((reclen) - (offsetof(struct dirent, d_name[0])))
++
++static VBGLSFCLIENT vbox_client;
++
++extern u_int vboxvfs_debug;
++
++static int
++sfprov_vbox2errno(int rc)
++{
++ if (rc == VERR_ACCESS_DENIED)
++ return (EACCES);
++ if (rc == VERR_INVALID_NAME)
++ return (ENOENT);
++ return (RTErrConvertToErrno(rc));
++}
++
++/*
++ * utility to create strings
++ */
++static SHFLSTRING *
++sfprov_string(char *path, int *sz)
++{
++ SHFLSTRING *str;
++ int len = strlen(path);
++
++ *sz = len + 1 + sizeof (*str) - sizeof (str->String);
++ str = malloc(*sz, M_VBOXVFS, M_WAITOK | M_ZERO);
++ str->u16Size = len + 1;
++ str->u16Length = len;
++ strcpy(str->String.utf8, path);
++ return (str);
++}
++
++sfp_connection_t *
++sfprov_connect(int version)
++{
++ /* only one version for now, so must match */
++ int error = -1;
++
++ if (version != SFPROV_VERSION) {
++ printf("%s: version mismatch (%d, expected %d)\n", __func__,
++ version, SFPROV_VERSION);
++ return (NULL);
++ }
++
++ if (RT_FAILURE(VbglR0SfInit()))
++ return (NULL);
++
++ if (RT_FAILURE(VbglR0SfConnect(&vbox_client))) {
++ VbglR0SfTerm();
++ return (NULL);
++ }
++
++ if (RT_FAILURE(VbglR0SfSetUtf8(&vbox_client))) {
++ VbglR0SfDisconnect(&vbox_client);
++ VbglR0SfTerm();
++ return (NULL);
++ }
++ return ((sfp_connection_t *)&vbox_client);
++}
++
++void
++sfprov_disconnect()
++{
++ VbglR0SfDisconnect(&vbox_client);
++ VbglR0SfTerm();
++}
++
++int
++sfprov_mount(char *path, sfp_mount_t **mnt)
++{
++ sfp_mount_t *m;
++ SHFLSTRING *str;
++ int size;
++ int rc;
++
++ VBOXVFS_DEBUG(1, "%s: Enter", __FUNCTION__);
++ VBOXVFS_DEBUG(1, "%s: path: [%s]", __FUNCTION__, path);
++
++ m = malloc(sizeof (*m), M_VBOXVFS, M_WAITOK | M_ZERO);
++ str = sfprov_string(path, &size);
++
++ int error;
++ rc = VbglR0SfMapFolder(&vbox_client, str, &m->map);
++ if (RT_FAILURE(rc)) {
++ free(m, M_VBOXVFS);
++ *mnt = NULL;
++ error = sfprov_vbox2errno(rc);
++ } else {
++ *mnt = m;
++ error = 0;
++ }
++ free(str, M_VBOXVFS);
++ printf("%s(%s): error=%d rc=%d\n", __func__, path, error, rc);
++ return (error);
++}
++
++int
++sfprov_unmount(sfp_mount_t *mnt)
++{
++ int rc;
++
++ rc = VbglR0SfUnmapFolder(&vbox_client, &mnt->map);
++ if (RT_FAILURE(rc)) {
++ printf("sfprov_unmount: VbglR0SfUnmapFolder() failed rc=%d\n", rc);
++ rc = sfprov_vbox2errno(rc);
++ } else {
++ rc = 0;
++ }
++
++ free(mnt, M_VBOXVFS);
++ return (rc);
++}
++
++/*
++ * query information about a mounted file system
++ */
++int
++sfprov_get_fsinfo(sfp_mount_t *mnt, sffs_fsinfo_t *fsinfo)
++{
++ int rc;
++ SHFLVOLINFO info;
++ uint32_t bytes = sizeof(SHFLVOLINFO);
++ size_t bytesused;
++
++ rc = VbglR0SfFsInfo(&vbox_client, &mnt->map, 0,
++ (SHFL_INFO_GET | SHFL_INFO_VOLUME), &bytes, (SHFLDIRINFO *)&info);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++
++ fsinfo->blksize = info.ulBytesPerAllocationUnit;
++ bytesused =
++ info.ullTotalAllocationBytes - info.ullAvailableAllocationBytes;
++ fsinfo->blksused = bytesused / info.ulBytesPerAllocationUnit;
++ fsinfo->blksavail = info.ullAvailableAllocationBytes /
++ info.ulBytesPerAllocationUnit;
++ fsinfo->maxnamesize = info.fsProperties.cbMaxComponent;
++ fsinfo->readonly = info.fsProperties.fReadOnly;
++ fsinfo->serial = info.ulSerial;
++ return (0);
++}
++
++/*
++ * file/directory information conversions.
++ */
++static void
++sfprov_fmode_from_mode(RTFMODE *fMode, mode_t mode)
++{
++ RTFMODE m = 0;
++
++#define mode_set(r) ((mode & (S_##r)) ? RTFS_UNIX_##r : 0)
++ m = mode_set (ISUID);
++ m |= mode_set (ISGID);
++ m |= (mode & S_ISVTX) ? RTFS_UNIX_ISTXT : 0;
++ m |= mode_set (IRUSR);
++ m |= mode_set (IWUSR);
++ m |= mode_set (IXUSR);
++ m |= mode_set (IRGRP);
++ m |= mode_set (IWGRP);
++ m |= mode_set (IXGRP);
++ m |= mode_set (IROTH);
++ m |= mode_set (IWOTH);
++ m |= mode_set (IXOTH);
++
++ if (S_ISDIR(mode))
++ m |= RTFS_TYPE_DIRECTORY;
++ else if (S_ISREG(mode))
++ m |= RTFS_TYPE_FILE;
++ else if (S_ISFIFO(mode))
++ m |= RTFS_TYPE_FIFO;
++ else if (S_ISCHR(mode))
++ m |= RTFS_TYPE_DEV_CHAR;
++ else if (S_ISBLK(mode))
++ m |= RTFS_TYPE_DEV_BLOCK;
++ else if (S_ISLNK(mode))
++ m |= RTFS_TYPE_SYMLINK;
++ else if (S_ISSOCK(mode))
++ m |= RTFS_TYPE_SOCKET;
++ else
++ m |= RTFS_TYPE_FILE;
++
++ *fMode = m;
++}
++
++static void
++sfprov_mode_from_fmode(mode_t *mode, RTFMODE fMode)
++{
++ mode_t m = 0;
++
++ if (RTFS_IS_DIRECTORY(fMode))
++ m |= S_IFDIR;
++ else if (RTFS_IS_FILE(fMode))
++ m |= S_IFREG;
++ else if (RTFS_IS_FIFO(fMode))
++ m |= S_IFIFO;
++ else if (RTFS_IS_DEV_CHAR(fMode))
++ m |= S_IFCHR;
++ else if (RTFS_IS_DEV_BLOCK(fMode))
++ m |= S_IFBLK;
++ else if (RTFS_IS_SYMLINK(fMode))
++ m |= S_IFLNK;
++ else if (RTFS_IS_SOCKET(fMode))
++ m |= S_IFSOCK;
++
++ if (fMode & RTFS_UNIX_IRUSR)
++ m |= S_IRUSR;
++ if (fMode & RTFS_UNIX_IWUSR)
++ m |= S_IWUSR;
++ if (fMode & RTFS_UNIX_IXUSR)
++ m |= S_IXUSR;
++ if (fMode & RTFS_UNIX_IRGRP)
++ m |= S_IRGRP;
++ if (fMode & RTFS_UNIX_IWGRP)
++ m |= S_IWGRP;
++ if (fMode & RTFS_UNIX_IXGRP)
++ m |= S_IXGRP;
++ if (fMode & RTFS_UNIX_IROTH)
++ m |= S_IROTH;
++ if (fMode & RTFS_UNIX_IWOTH)
++ m |= S_IWOTH;
++ if (fMode & RTFS_UNIX_IXOTH)
++ m |= S_IXOTH;
++ if (fMode & RTFS_UNIX_ISUID)
++ m |= S_ISUID;
++ if (fMode & RTFS_UNIX_ISGID)
++ m |= S_ISGID;
++ if (fMode & RTFS_UNIX_ISTXT)
++ m |= S_ISVTX;
++ *mode = m;
++}
++
++static void
++sfprov_ftime_from_timespec(struct timespec *time, RTTIMESPEC *ts)
++{
++ uint64_t nanosec = RTTimeSpecGetNano(ts);
++ time->tv_sec = nanosec / UINT64_C(1000000000);
++ time->tv_nsec = nanosec % UINT64_C(1000000000);
++}
++
++static void
++sfprov_stat_from_info(sffs_stat_t *stat, SHFLFSOBJINFO *info)
++{
++ sfprov_mode_from_fmode(&stat->sf_mode, info->Attr.fMode);
++ stat->sf_size = info->cbObject;
++ stat->sf_alloc = info->cbAllocated;
++ sfprov_ftime_from_timespec(&stat->sf_atime, &info->AccessTime);
++ sfprov_ftime_from_timespec(&stat->sf_mtime, &info->ModificationTime);
++ sfprov_ftime_from_timespec(&stat->sf_ctime, &info->ChangeTime);
++}
++
++/*
++ * File operations: open/close/read/write/etc.
++ *
++ * open/create can return any relevant errno, however ENOENT
++ * generally means that the host file didn't exist.
++ */
++int
++sfprov_create(
++ sfp_mount_t *mnt,
++ char *path,
++ mode_t mode,
++ sfp_file_t **fp,
++ sffs_stat_t *stat)
++{
++ int rc;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ int size;
++ sfp_file_t *newfp;
++
++ str = sfprov_string(path, &size);
++ parms.Handle = SHFL_HANDLE_NIL;
++ parms.Info.cbObject = 0;
++ sfprov_fmode_from_mode(&parms.Info.Attr.fMode, mode);
++ parms.CreateFlags = SHFL_CF_ACT_CREATE_IF_NEW |
++ SHFL_CF_ACT_REPLACE_IF_EXISTS | SHFL_CF_ACCESS_READWRITE;
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++ free(str, M_VBOXVFS);
++
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ if (parms.Handle == SHFL_HANDLE_NIL) {
++ if (parms.Result == SHFL_FILE_EXISTS)
++ return (EEXIST);
++ return (ENOENT);
++ }
++ newfp = malloc(sizeof(sfp_file_t), M_VBOXVFS, M_WAITOK | M_ZERO);
++ newfp->handle = parms.Handle;
++ newfp->map = mnt->map;
++ *fp = newfp;
++ sfprov_stat_from_info(stat, &parms.Info);
++ return (0);
++}
++
++int
++sfprov_open(sfp_mount_t *mnt, char *path, sfp_file_t **fp)
++{
++ int rc;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ int size;
++ sfp_file_t *newfp;
++
++ /*
++ * First we attempt to open it read/write. If that fails we
++ * try read only.
++ */
++ bzero(&parms, sizeof(parms));
++ str = sfprov_string(path, &size);
++ parms.Handle = SHFL_HANDLE_NIL;
++ parms.Info.cbObject = 0;
++ parms.CreateFlags = SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READWRITE;
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++ if (RT_FAILURE(rc) && rc != VERR_ACCESS_DENIED) {
++ free(str, M_VBOXVFS);
++ return (sfprov_vbox2errno(rc));
++ }
++ if (parms.Handle == SHFL_HANDLE_NIL) {
++ if (parms.Result == SHFL_PATH_NOT_FOUND ||
++ parms.Result == SHFL_FILE_NOT_FOUND) {
++ free(str, M_VBOXVFS);
++ return (ENOENT);
++ }
++ parms.CreateFlags =
++ SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ;
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++ if (RT_FAILURE(rc)) {
++ free(str, M_VBOXVFS);
++ return (sfprov_vbox2errno(rc));
++ }
++ if (parms.Handle == SHFL_HANDLE_NIL) {
++ free(str, M_VBOXVFS);
++ return (ENOENT);
++ }
++ }
++ else
++ free(str, M_VBOXVFS);
++ newfp = malloc(sizeof(sfp_file_t), M_VBOXVFS, M_WAITOK | M_ZERO);
++ newfp->handle = parms.Handle;
++ newfp->map = mnt->map;
++ *fp = newfp;
++ return (0);
++}
++
++int
++sfprov_trunc(sfp_mount_t *mnt, char *path)
++{
++ int rc;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ int size;
++
++ /*
++ * open it read/write.
++ */
++ str = sfprov_string(path, &size);
++ parms.Handle = 0;
++ parms.Info.cbObject = 0;
++ parms.CreateFlags = SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READWRITE |
++ SHFL_CF_ACT_OVERWRITE_IF_EXISTS;
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++ free(str, M_VBOXVFS);
++
++ if (RT_FAILURE(rc)) {
++ return (sfprov_vbox2errno(rc));
++ }
++ (void)VbglR0SfClose(&vbox_client, &mnt->map, parms.Handle);
++ return (0);
++}
++
++int
++sfprov_close(sfp_file_t *fp)
++{
++ int rc;
++
++ rc = VbglR0SfClose(&vbox_client, &fp->map, fp->handle);
++ free(fp, M_VBOXVFS);
++ return (0);
++}
++
++int
++sfprov_read(sfp_file_t *fp, char *buffer, uint64_t offset, uint32_t *numbytes,
++ int buflocked)
++{
++ int rc;
++
++ rc = VbglR0SfRead(&vbox_client, &fp->map, fp->handle, offset,
++ numbytes, (uint8_t *)buffer, buflocked);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ return (0);
++}
++
++int
++sfprov_write(sfp_file_t *fp, char *buffer, uint64_t offset, uint32_t *numbytes,
++ int buflocked)
++{
++ int rc;
++
++ rc = VbglR0SfWrite(&vbox_client, &fp->map, fp->handle, offset,
++ numbytes, (uint8_t *)buffer, buflocked);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ return (0);
++}
++
++int
++sfprov_fsync(sfp_file_t *fp)
++{
++ int rc;
++
++ rc = VbglR0SfFlush(&vbox_client, &fp->map, fp->handle);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ return (0);
++}
++
++
++static int
++sfprov_getinfo(sfp_mount_t *mnt, char *path, PSHFLFSOBJINFO info)
++{
++ int rc;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ int size;
++
++ str = sfprov_string(path, &size);
++ parms.Handle = 0;
++ parms.Info.cbObject = 0;
++ parms.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++ free(str, M_VBOXVFS);
++
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ if (parms.Result != SHFL_FILE_EXISTS)
++ return (ENOENT);
++ *info = parms.Info;
++ return (0);
++}
++
++/*
++ * get information about a file (or directory)
++ */
++int
++sfprov_get_mode(sfp_mount_t *mnt, char *path, mode_t *mode)
++{
++ int rc;
++ SHFLFSOBJINFO info;
++
++ rc = sfprov_getinfo(mnt, path, &info);
++ if (rc)
++ return (rc);
++ sfprov_mode_from_fmode(mode, info.Attr.fMode);
++ return (0);
++}
++
++int
++sfprov_get_size(sfp_mount_t *mnt, char *path, uint64_t *size)
++{
++ int rc;
++ SHFLFSOBJINFO info;
++
++ rc = sfprov_getinfo(mnt, path, &info);
++ if (rc)
++ return (rc);
++ *size = info.cbObject;
++ return (0);
++}
++
++
++int
++sfprov_get_atime(sfp_mount_t *mnt, char *path, struct timespec *time)
++{
++ int rc;
++ SHFLFSOBJINFO info;
++
++ rc = sfprov_getinfo(mnt, path, &info);
++ if (rc)
++ return (rc);
++ sfprov_ftime_from_timespec(time, &info.AccessTime);
++ return (0);
++}
++
++int
++sfprov_get_mtime(sfp_mount_t *mnt, char *path, struct timespec *time)
++{
++ int rc;
++ SHFLFSOBJINFO info;
++
++ rc = sfprov_getinfo(mnt, path, &info);
++ if (rc)
++ return (rc);
++ sfprov_ftime_from_timespec(time, &info.ModificationTime);
++ return (0);
++}
++
++int
++sfprov_get_ctime(sfp_mount_t *mnt, char *path, struct timespec *time)
++{
++ int rc;
++ SHFLFSOBJINFO info;
++
++ rc = sfprov_getinfo(mnt, path, &info);
++ if (rc)
++ return (rc);
++ sfprov_ftime_from_timespec(time, &info.ChangeTime);
++ return (0);
++}
++
++int
++sfprov_get_attr(sfp_mount_t *mnt, char *path, sffs_stat_t *attr)
++{
++ int rc;
++ SHFLFSOBJINFO info;
++
++ rc = sfprov_getinfo(mnt, path, &info);
++ if (rc)
++ return (rc);
++ sfprov_stat_from_info(attr, &info);
++ return (0);
++}
++
++static void
++sfprov_timespec_from_ftime(RTTIMESPEC *ts, struct timespec time)
++{
++ uint64_t nanosec = UINT64_C(1000000000) * time.tv_sec + time.tv_nsec;
++ RTTimeSpecSetNano(ts, nanosec);
++}
++
++int
++sfprov_set_attr(
++ sfp_mount_t *mnt,
++ char *path,
++ mode_t mode,
++ struct timespec atime,
++ struct timespec mtime,
++ struct timespec ctime)
++{
++ int rc, err;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ SHFLFSOBJINFO info;
++ uint32_t bytes;
++ int str_size;
++
++ str = sfprov_string(path, &str_size);
++ parms.Handle = 0;
++ parms.Info.cbObject = 0;
++ parms.CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS
++ | SHFL_CF_ACT_FAIL_IF_NEW
++ | SHFL_CF_ACCESS_ATTR_WRITE;
++
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++
++ if (RT_FAILURE(rc)) {
++ printf("sfprov_set_attr: VbglR0SfCreate(%s) failed rc=%d\n",
++ path, rc);
++ err = sfprov_vbox2errno(rc);
++ goto fail2;
++ }
++ if (parms.Result != SHFL_FILE_EXISTS) {
++ err = ENOENT;
++ goto fail1;
++ }
++
++ RT_ZERO(info);
++#if 0
++ if (mask & AT_MODE)
++ sfprov_fmode_from_mode(&info.Attr.fMode, mode);
++ if (mask & AT_ATIME)
++ sfprov_timespec_from_ftime(&info.AccessTime, atime);
++ if (mask & AT_MTIME)
++ sfprov_timespec_from_ftime(&info.ModificationTime, mtime);
++ if (mask & AT_CTIME)
++ sfprov_timespec_from_ftime(&info.ChangeTime, ctime);
++#endif
++ bytes = sizeof(info);
++ rc = VbglR0SfFsInfo(&vbox_client, &mnt->map, parms.Handle,
++ (SHFL_INFO_SET | SHFL_INFO_FILE), &bytes, (SHFLDIRINFO *)&info);
++ if (RT_FAILURE(rc)) {
++ if (rc != VERR_ACCESS_DENIED && rc != VERR_WRITE_PROTECT)
++ {
++ printf("sfprov_set_attr: VbglR0SfFsInfo(%s, FILE) failed rc=%d\n",
++ path, rc);
++ }
++ err = sfprov_vbox2errno(rc);
++ goto fail1;
++ }
++
++ err = 0;
++
++fail1:
++ rc = VbglR0SfClose(&vbox_client, &mnt->map, parms.Handle);
++ if (RT_FAILURE(rc)) {
++ printf("sfprov_set_attr: VbglR0SfClose(%s) failed rc=%d\n",
++ path, rc);
++ }
++fail2:
++ free(str, M_VBOXVFS);
++ return err;
++}
++
++int
++sfprov_set_size(sfp_mount_t *mnt, char *path, uint64_t size)
++{
++ int rc, err;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ SHFLFSOBJINFO info;
++ uint32_t bytes;
++ int str_size;
++
++ str = sfprov_string(path, &str_size);
++ parms.Handle = 0;
++ parms.Info.cbObject = 0;
++ parms.CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS
++ | SHFL_CF_ACT_FAIL_IF_NEW
++ | SHFL_CF_ACCESS_WRITE;
++
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++
++ if (RT_FAILURE(rc)) {
++ printf("sfprov_set_size: VbglR0SfCreate(%s) failed rc=%d\n",
++ path, rc);
++ err = sfprov_vbox2errno(rc);
++ goto fail2;
++ }
++ if (parms.Result != SHFL_FILE_EXISTS) {
++ err = ENOENT;
++ goto fail1;
++ }
++
++ RT_ZERO(info);
++ info.cbObject = size;
++ bytes = sizeof(info);
++ rc = VbglR0SfFsInfo(&vbox_client, &mnt->map, parms.Handle,
++ (SHFL_INFO_SET | SHFL_INFO_SIZE), &bytes, (SHFLDIRINFO *)&info);
++ if (RT_FAILURE(rc)) {
++ printf("sfprov_set_size: VbglR0SfFsInfo(%s, SIZE) failed rc=%d\n",
++ path, rc);
++ err = sfprov_vbox2errno(rc);
++ goto fail1;
++ }
++
++ err = 0;
++
++fail1:
++ rc = VbglR0SfClose(&vbox_client, &mnt->map, parms.Handle);
++ if (RT_FAILURE(rc)) {
++ printf("sfprov_set_size: VbglR0SfClose(%s) failed rc=%d\n",
++ path, rc);
++ }
++fail2:
++ free(str, M_VBOXVFS);
++ return err;
++}
++
++/*
++ * Directory operations
++ */
++int
++sfprov_mkdir(
++ sfp_mount_t *mnt,
++ char *path,
++ mode_t mode,
++ sfp_file_t **fp,
++ sffs_stat_t *stat)
++{
++ int rc;
++ SHFLCREATEPARMS parms;
++ SHFLSTRING *str;
++ int size;
++ sfp_file_t *newfp;
++
++ str = sfprov_string(path, &size);
++ parms.Handle = SHFL_HANDLE_NIL;
++ parms.Info.cbObject = 0;
++ sfprov_fmode_from_mode(&parms.Info.Attr.fMode, mode);
++ parms.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_CREATE_IF_NEW |
++ SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACCESS_READ;
++ rc = VbglR0SfCreate(&vbox_client, &mnt->map, str, &parms);
++ free(str, M_VBOXVFS);
++
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ if (parms.Handle == SHFL_HANDLE_NIL) {
++ if (parms.Result == SHFL_FILE_EXISTS)
++ return (EEXIST);
++ return (ENOENT);
++ }
++ newfp = malloc(sizeof(sfp_file_t), M_VBOXVFS, M_WAITOK | M_ZERO);
++ newfp->handle = parms.Handle;
++ newfp->map = mnt->map;
++ *fp = newfp;
++ sfprov_stat_from_info(stat, &parms.Info);
++ return (0);
++}
++
++int
++sfprov_set_show_symlinks(void)
++{
++ int rc;
++
++ rc = VbglR0SfSetSymlinks(&vbox_client);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++
++ return (0);
++}
++
++int
++sfprov_remove(sfp_mount_t *mnt, char *path, u_int is_link)
++{
++ int rc;
++ SHFLSTRING *str;
++ int size;
++
++ str = sfprov_string(path, &size);
++ rc = VbglR0SfRemove(&vbox_client, &mnt->map, str,
++ SHFL_REMOVE_FILE | (is_link ? SHFL_REMOVE_SYMLINK : 0));
++ free(str, M_VBOXVFS);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ return (0);
++}
++
++int
++sfprov_readlink(
++ sfp_mount_t *mnt,
++ char *path,
++ char *target,
++ size_t tgt_size)
++{
++ int rc;
++ SHFLSTRING *str;
++ int size;
++
++ str = sfprov_string(path, &size);
++
++ rc = VbglR0SfReadLink(&vbox_client, &mnt->map, str, (uint32_t) tgt_size,
++ target);
++ if (RT_FAILURE(rc))
++ rc = sfprov_vbox2errno(rc);
++
++ free(str, M_VBOXVFS);
++ return (rc);
++}
++
++int
++sfprov_symlink(
++ sfp_mount_t *mnt,
++ char *linkname,
++ char *target,
++ sffs_stat_t *stat)
++{
++ int rc;
++ SHFLSTRING *lnk, *tgt;
++ int lnk_size, tgt_size;
++ SHFLFSOBJINFO info;
++
++ lnk = sfprov_string(linkname, &lnk_size);
++ tgt = sfprov_string(target, &tgt_size);
++
++ rc = VbglR0SfSymlink(&vbox_client, &mnt->map, lnk, tgt, &info);
++ if (RT_FAILURE(rc)) {
++ rc = sfprov_vbox2errno(rc);
++ goto done;
++ }
++
++ if (stat != NULL)
++ sfprov_stat_from_info(stat, &info);
++
++done:
++ free(lnk, M_VBOXVFS);
++ free(tgt, M_VBOXVFS);
++
++ return (rc);
++}
++
++int
++sfprov_rmdir(sfp_mount_t *mnt, char *path)
++{
++ int rc;
++ SHFLSTRING *str;
++ int size;
++
++ str = sfprov_string(path, &size);
++ rc = VbglR0SfRemove(&vbox_client, &mnt->map, str, SHFL_REMOVE_DIR);
++ free(str, M_VBOXVFS);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ return (0);
++}
++
++int
++sfprov_rename(sfp_mount_t *mnt, char *from, char *to, u_int is_dir)
++{
++ int rc;
++ SHFLSTRING *old, *new;
++ int old_size, new_size;
++
++ old = sfprov_string(from, &old_size);
++ new = sfprov_string(to, &new_size);
++ rc = VbglR0SfRename(&vbox_client, &mnt->map, old, new,
++ (is_dir ? SHFL_RENAME_DIR : SHFL_RENAME_FILE) |
++ SHFL_RENAME_REPLACE_IF_EXISTS);
++ free(old, M_VBOXVFS);
++ free(new, M_VBOXVFS);
++ if (RT_FAILURE(rc))
++ return (sfprov_vbox2errno(rc));
++ return (0);
++}
++
++/*
++ * Read all filenames in a directory.
++ *
++ * - success - all entries read and returned
++ * - ENOENT - Couldn't open the directory for reading
++ * - EINVAL - Internal error of some kind
++ *
++ * On successful return, *dirents points to a list of sffs_dirents_t;
++ * for each dirent, all fields except the d_ino will be set appropriately.
++ * The caller is responsible for freeing the dirents buffer.
++ */
++int
++sfprov_readdir(
++ sfp_mount_t *mnt,
++ char *path,
++ sffs_dirents_t **dirents)
++{
++ int error;
++ char *cp;
++ int len;
++ SHFLSTRING *mask_str = NULL; /* must be path with "/" appended */
++ int mask_size;
++ sfp_file_t *fp;
++ uint32_t infobuff_alloc = 16384;
++ SHFLDIRINFO *infobuff = NULL, *info;
++ uint32_t numbytes;
++ uint32_t nents;
++ uint32_t size;
++ off_t offset;
++ sffs_dirents_t *cur_buf;
++ struct sffs_dirent *dirent;
++ unsigned short reclen;
++ unsigned short entlen;
++
++ *dirents = NULL;
++
++ error = sfprov_open(mnt, path, &fp);
++ if (error != 0)
++ return (ENOENT);
++
++ /*
++ * Allocate the first dirents buffers.
++ */
++ *dirents = malloc(SFFS_DIRENTS_SIZE, M_VBOXVFS, M_WAITOK | M_ZERO);
++ if (*dirents == NULL) {
++ error = (ENOSPC);
++ goto done;
++ }
++ cur_buf = *dirents;
++ cur_buf->sf_next = NULL;
++ cur_buf->sf_len = 0;
++
++ /*
++ * Create mask that VBox expects. This needs to be the directory path,
++ * plus a "*" wildcard to get all files.
++ */
++ len = strlen(path) + 3;
++ cp = malloc(len, M_VBOXVFS, M_WAITOK | M_ZERO);
++ if (cp == NULL) {
++ error = (ENOSPC);
++ goto done;
++ }
++ strcpy(cp, path);
++ strcat(cp, "/*");
++ mask_str = sfprov_string(cp, &mask_size);
++ free(cp, M_VBOXVFS);
++
++ /*
++ * Now loop using VbglR0SfDirInfo
++ */
++ infobuff = malloc(infobuff_alloc, M_VBOXVFS, M_WAITOK | M_ZERO);
++ if (infobuff == NULL) {
++ error = (ENOSPC);
++ goto done;
++ }
++
++ offset = 0;
++ for (;;) {
++ numbytes = infobuff_alloc;
++ error = VbglR0SfDirInfo(&vbox_client, &fp->map, fp->handle,
++ mask_str, 0, 0, &numbytes, infobuff, &nents);
++
++ switch (error) {
++ case VINF_SUCCESS:
++ /* fallthrough */
++ case VERR_NO_MORE_FILES:
++ break;
++ case VERR_NO_TRANSLATION:
++ /* XXX ??? */
++ break;
++ default:
++ error = sfprov_vbox2errno(error);
++ goto done;
++ }
++
++ /*
++ * Create the dirent_t's and save the stats for each name
++ */
++ for (info = infobuff; (char *) info < (char *) infobuff + numbytes; nents--) {
++ size_t buflen;
++
++ /* expand buffers if we need more space */
++ reclen = DIRENT_RECLEN(strlen(info->name.String.utf8));
++ entlen = sizeof(struct sffs_dirent) + reclen;
++ buflen = SFFS_DIRENTS_OFF + cur_buf->sf_len + entlen;
++ if (buflen > SFFS_DIRENTS_SIZE) {
++ cur_buf->sf_next = malloc(SFFS_DIRENTS_SIZE,
++ M_VBOXVFS, M_WAITOK | M_ZERO);
++ if (cur_buf->sf_next == NULL) {
++ error = ENOSPC;
++ goto done;
++ }
++ cur_buf = cur_buf->sf_next;
++ cur_buf->sf_next = NULL;
++ cur_buf->sf_len = 0;
++ }
++
++ /* create the dirent with the name, offset, and len */
++ dirent = (struct sffs_dirent *)
++ (((char *) &cur_buf->sf_entries[0]) + cur_buf->sf_len);
++ strncpy(&dirent->sf_entry.d_name[0],
++ info->name.String.utf8, DIRENT_NAMELEN(reclen));
++ dirent->sf_entry.d_reclen = reclen;
++ dirent->sf_entry.d_namlen = strlen(info->name.String.utf8);
++ dirent->sf_entry.d_name[dirent->sf_entry.d_namlen] = 0;
++ offset += entlen;
++ dirent->sf_off = offset;
++
++ /* save the stats */
++ sfprov_stat_from_info(&dirent->sf_stat, &info->Info);
++
++ /* next info */
++ cur_buf->sf_len += entlen;
++ size = offsetof (SHFLDIRINFO, name.String) + info->name.u16Size;
++ info = (SHFLDIRINFO *) ((uintptr_t) info + size);
++ }
++ KASSERT(nents == 0, ("nents != 0"));
++ KASSERT((char *) info == (char *) infobuff + numbytes, "(char *) info != (char *) infobuff + numbytes");
++
++ if (error == VERR_NO_MORE_FILES)
++ break;
++ }
++ error = 0;
++
++done:
++ if (error != 0) {
++ while (*dirents) {
++ cur_buf = (*dirents)->sf_next;
++ free(*dirents, M_VBOXVFS);
++ *dirents = cur_buf;
++ }
++ }
++ if (infobuff != NULL)
++ free(infobuff, M_VBOXVFS);
++ if (mask_str != NULL)
++ free(mask_str, M_VBOXVFS);
++ sfprov_close(fp);
++
++ return (error);
++}
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c
new file mode 100644
index 000000000000..128085de6cb9
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c
@@ -0,0 +1,644 @@
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c.orig 2020-07-09 16:50:11 UTC
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c
+@@ -1,8 +1,3 @@
+-/* $Id: vboxvfs_vfsops.c $ */
+-/** @file
+- * Description.
+- */
+-
+ /*
+ * Copyright (C) 2008-2017 Oracle Corporation
+ *
+@@ -14,245 +9,478 @@
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+-
+-#include "vboxvfs.h"
++#include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/systm.h>
+ #include <sys/proc.h>
+ #include <sys/bio.h>
+ #include <sys/buf.h>
++#include <sys/conf.h>
++#include <sys/dirent.h>
+ #include <sys/kernel.h>
+ #include <sys/sysctl.h>
+ #include <sys/vnode.h>
+ #include <sys/mount.h>
++#include <sys/namei.h>
++#include <sys/fcntl.h>
++#include <sys/priv.h>
+ #include <sys/stat.h>
+ #include <sys/malloc.h>
+ #include <sys/module.h>
++#include <sys/sbuf.h>
+
+-#include <iprt/mem.h>
++#include <geom/geom.h>
++#include <geom/geom_vfs.h>
+
++#include "vboxvfs.h"
++
+ #define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data)
+
+-static int vboxvfs_version = VBOXVFS_VERSION;
++#ifdef MALLOC_DECLARE
++MALLOC_DEFINE(M_VBOXVFS, "vboxvfs", "VBOX VFS");
++#endif
+
+-SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem");
+-SYSCTL_INT(_vfs_vboxvfs, OID_AUTO, version, CTLFLAG_RD, &vboxvfs_version, 0, "");
++static sfp_connection_t *sfprov = NULL;
+
+-/* global connection to the host service. */
+-static VBGLSFCLIENT g_vboxSFClient;
++static int vboxfs_version = VBOXVFS_VERSION;
++u_int vboxvfs_debug = 1;
+
+-static vfs_init_t vboxvfs_init;
+-static vfs_uninit_t vboxvfs_uninit;
+-static vfs_cmount_t vboxvfs_cmount;
+-static vfs_mount_t vboxvfs_mount;
+-static vfs_root_t vboxvfs_root;
+-static vfs_quotactl_t vboxvfs_quotactl;
+-static vfs_statfs_t vboxvfs_statfs;
+-static vfs_unmount_t vboxvfs_unmount;
++SYSCTL_NODE(_vfs, OID_AUTO, vboxfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem");
++SYSCTL_INT(_vfs_vboxfs, OID_AUTO, version, CTLFLAG_RD, &vboxfs_version, 0, "");
++SYSCTL_UINT(_vfs_vboxfs, OID_AUTO, debug, CTLFLAG_RW, &vboxvfs_debug, 0, "Debug level");
+
+-static struct vfsops vboxvfs_vfsops = {
+- .vfs_init = vboxvfs_init,
+- .vfs_cmount = vboxvfs_cmount,
+- .vfs_mount = vboxvfs_mount,
+- .vfs_quotactl = vboxvfs_quotactl,
+- .vfs_root = vboxvfs_root,
+- .vfs_statfs = vboxvfs_statfs,
+- .vfs_sync = vfs_stdsync,
+- .vfs_uninit = vboxvfs_uninit,
+- .vfs_unmount = vboxvfs_unmount,
++static vfs_init_t vboxfs_init;
++static vfs_uninit_t vboxfs_uninit;
++static vfs_cmount_t vboxfs_cmount;
++static vfs_mount_t vboxfs_mount;
++static vfs_root_t vboxfs_root;
++static vfs_quotactl_t vboxfs_quotactl;
++static vfs_statfs_t vboxfs_statfs;
++static vfs_unmount_t vboxfs_unmount;
++
++static struct vfsops vboxfs_vfsops = {
++ .vfs_init = vboxfs_init,
++ .vfs_cmount = vboxfs_cmount,
++ .vfs_mount = vboxfs_mount,
++ .vfs_quotactl = vboxfs_quotactl,
++ .vfs_root = vboxfs_root,
++ .vfs_statfs = vboxfs_statfs,
++ .vfs_sync = vfs_stdsync,
++ .vfs_uninit = vboxfs_uninit,
++ .vfs_unmount = vboxfs_unmount
+ };
+
+
+-VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK);
++VFS_SET(vboxfs_vfsops, vboxvfs, VFCF_NETWORK);
+ MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1);
+
+-static int vboxvfs_cmount(struct mntarg *ma, void * data, int flags, struct thread *td)
++/*
++ * Allocates a new node of type 'type' inside the 'tmp' mount point, with
++ * its owner set to 'uid', its group to 'gid' and its mode set to 'mode',
++ * using the credentials of the process 'p'.
++ *
++ * If the node type is set to 'VDIR', then the parent parameter must point
++ * to the parent directory of the node being created. It may only be NULL
++ * while allocating the root node.
++ *
++ * If the node type is set to 'VBLK' or 'VCHR', then the rdev parameter
++ * specifies the device the node represents.
++ *
++ * If the node type is set to 'VLNK', then the parameter target specifies
++ * the file name of the target file for the symbolic link that is being
++ * created.
++ *
++ * Note that new nodes are retrieved from the available list if it has
++ * items or, if it is empty, from the node pool as long as there is enough
++ * space to create them.
++ *
++ * Returns zero on success or an appropriate error code on failure.
++ */
++int
++vboxfs_alloc_node(struct mount *mp, struct vboxfs_mnt *vsfmp, const char *fullpath,
++ enum vtype type, uid_t uid, gid_t gid, mode_t mode, struct vboxfs_node *parent,
++ struct vboxfs_node **node)
+ {
+- struct vboxvfs_mount_info args;
+- int rc = 0;
++ struct vboxfs_node *nnode;
+
+- printf("%s: Enter\n", __FUNCTION__);
++ if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) {
++ /*
++ * When a new tmpfs node is created for fully
++ * constructed mount point, there must be a parent
++ * node, which vnode is locked exclusively. As
++ * consequence, if the unmount is executing in
++ * parallel, vflush() cannot reclaim the parent vnode.
++ * Due to this, the check for MNTK_UNMOUNT flag is not
++ * racy: if we did not see MNTK_UNMOUNT flag, then tmp
++ * cannot be destroyed until node construction is
++ * finished and the parent vnode unlocked.
++ *
++ * Tmpfs does not need to instantiate new nodes during
++ * unmount.
++ */
++ return (EBUSY);
++ }
+
+- rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info));
+- if (rc)
+- return rc;
++ nnode = (struct vboxfs_node *)uma_zalloc_arg(
++ vsfmp->sf_node_pool, vsfmp, M_WAITOK);
+
+- ma = mount_argf(ma, "uid", "%d", args.uid);
+- ma = mount_argf(ma, "gid", "%d", args.gid);
+- ma = mount_arg(ma, "from", args.name, -1);
++ /* Generic initialization. */
++ nnode->sf_type = type;
++ nnode->sf_ino = vsfmp->sf_ino++;
++ nnode->sf_path = strdup(fullpath, M_VBOXVFS);
++ nnode->sf_parent = parent;
++ nnode->vboxfsmp = vsfmp;
+
+- rc = kernel_mount(ma, flags);
++ /* Type-specific initialization. */
++ switch (nnode->sf_type) {
++ case VBLK:
++ case VCHR:
++ case VDIR:
++ case VFIFO:
++ case VSOCK:
++ case VLNK:
++ case VREG:
++ break;
+
+- printf("%s: Leave rc=%d\n", __FUNCTION__, rc);
++ default:
++ panic("vboxfs_alloc_node: type %p %d", nnode, (int)nnode->sf_type);
++ }
+
+- return rc;
++ *node = nnode;
++ return 0;
+ }
+
+-static const char *vboxvfs_opts[] = {
+- "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL
+-};
+-
+-static int vboxvfs_mount(struct mount *mp, struct thread *td)
++void
++vboxfs_free_node(struct vboxfs_mnt *vboxfs, struct vboxfs_node *node)
+ {
+- int rc;
+- char *pszShare;
+- int cbShare, cbOption;
+- int uid = 0, gid = 0;
+- struct sf_glob_info *pShFlGlobalInfo;
+- SHFLSTRING *pShFlShareName = NULL;
+- int cbShFlShareName;
+
+- printf("%s: Enter\n", __FUNCTION__);
++#ifdef INVARIANTS
++ TMPFS_NODE_LOCK(node);
++ MPASS(node->sf_vnode == NULL);
++ MPASS((node->sf_vpstate & TMPFS_VNODE_ALLOCATING) == 0);
++ TMPFS_NODE_UNLOCK(node);
++#endif
++ if (node->sf_path)
++ free(node->sf_path, M_VBOXVFS);
+
+- if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
+- return EOPNOTSUPP;
++ uma_zfree(vboxfs->sf_node_pool, node);
++}
+
+- if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts))
+- {
+- vfs_mount_error(mp, "%s", "Invalid option");
+- return EINVAL;
+- }
++static int
++vboxfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
++{
++ struct vboxfs_mount_info args;
++ int error = 0;
+
+- rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare);
+- if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe)
+- return EINVAL;
++ if (data == NULL)
++ return (EINVAL);
++ error = copyin(data, &args, sizeof(struct vboxfs_mount_info));
++ if (error)
++ return (error);
+
+- rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption);
+- if ((rc != ENOENT) && (rc || cbOption != sizeof(gid)))
+- return EINVAL;
++ ma = mount_argf(ma, "uid", "%d", args.uid);
++ ma = mount_argf(ma, "gid", "%d", args.gid);
++ ma = mount_argf(ma, "file_mode", "%d", args.fmode);
++ ma = mount_argf(ma, "dir_mode", "%d", args.dmode);
++ ma = mount_arg(ma, "from", args.name, -1);
+
+- rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption);
+- if ((rc != ENOENT) && (rc || cbOption != sizeof(uid)))
+- return EINVAL;
++ return (kernel_mount(ma, flags));
++}
+
+- pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
+- if (!pShFlGlobalInfo)
+- return ENOMEM;
++static const char *vboxfs_opts[] = {
++ "fstype",
++ "fspath",
++ "from",
++ "uid",
++ "gid",
++ "file_mode",
++ "dir_mode",
++ "errmsg",
++ NULL
++};
+
+- cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1;
+- pShFlShareName = RTMemAllocZ(cbShFlShareName);
+- if (!pShFlShareName)
+- return VERR_NO_MEMORY;
++#define VBOX_INTOPT(optname, val, base) do { \
++ char *ep, *optarg = NULL; \
++ if (vfs_getopt(opts, optname, (void **)&optarg, NULL) == 0) { \
++ if (optarg != NULL && *optarg == '\0') \
++ optarg = NULL; \
++ if (optarg != NULL) \
++ val = strtoul(optarg, &ep, base); \
++ if (optarg == NULL || *ep != '\0') { \
++ struct sbuf *sb = sbuf_new_auto(); \
++ sbuf_printf(sb, "Invalid %s: \"%s\"", optname, \
++ optarg); \
++ sbuf_finish(sb); \
++ vfs_mount_error(mp, sbuf_data(sb)); \
++ sbuf_delete(sb); \
++ return (EINVAL); \
++ } \
++ } \
++} while (0)
+
+- pShFlShareName->u16Length = cbShare;
+- pShFlShareName->u16Size = cbShare + 1;
+- memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1);
++static int
++vboxfs_node_ctor(void *mem, int size, void *arg, int flags)
++{
++ struct vboxfs_node *node = (struct vboxfs_node *)mem;
+
+- rc = VbglR0SfMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
+- RTMemFree(pShFlShareName);
++ node->sf_vnode = NULL;
++ node->sf_vpstate = 0;
+
+- if (RT_FAILURE (rc))
+- {
+- RTMemFree(pShFlGlobalInfo);
+- printf("VbglR0SfMapFolder failed rc=%d\n", rc);
+- return EPROTO;
+- }
++ return (0);
++}
+
+- pShFlGlobalInfo->uid = uid;
+- pShFlGlobalInfo->gid = gid;
++static void
++vboxfs_node_dtor(void *mem, int size, void *arg)
++{
++ struct vboxfs_node *node = (struct vboxfs_node *)mem;
++ node->sf_type = VNON;
++}
+
+- mp->mnt_data = pShFlGlobalInfo;
++static int
++vboxfs_node_init(void *mem, int size, int flags)
++{
++ struct vboxfs_node *node = (struct vboxfs_node *)mem;
++ node->sf_ino = 0;
+
+- /** @todo root vnode. */
++ mtx_init(&node->sf_interlock, "tmpfs node interlock", NULL, MTX_DEF);
+
+- vfs_getnewfsid(mp);
+- vfs_mountedfrom(mp, pszShare);
++ return (0);
++}
+
+- printf("%s: Leave rc=0\n", __FUNCTION__);
++static void
++vboxfs_node_fini(void *mem, int size)
++{
++ struct vboxfs_node *node = (struct vboxfs_node *)mem;
+
+- return 0;
++ mtx_destroy(&node->sf_interlock);
+ }
+
+-static int vboxvfs_unmount(struct mount *mp, int mntflags, struct thread *td)
++static int
++vboxfs_mount(struct mount *mp)
+ {
+- struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
+- int rc;
+- int flags = 0;
++ struct vboxfs_mnt *vboxfsmp = NULL;
++ struct vfsoptlist *opts = mp->mnt_optnew;
++ sfp_mount_t *handle = NULL;
++ int readonly = 0;
++ sffs_fsinfo_t fsinfo;
++ int error, share_len;
++ char *share_name;
++ mode_t file_mode = 0, dir_mode = 0;
++ uid_t uid = 0;
++ gid_t gid = 0;
++ struct vboxfs_node *root;
+
+- rc = VbglR0SfUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map);
+- if (RT_FAILURE(rc))
+- printf("Failed to unmap shared folder\n");
++ if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
++ return (EOPNOTSUPP);
+
+- if (mntflags & MNT_FORCE)
+- flags |= FORCECLOSE;
++ if (vfs_filteropt(opts, vboxfs_opts)) {
++ vfs_mount_error(mp, "%s", "Invalid option");
++ return (EINVAL);
++ }
+
+- /* There is 1 extra root vnode reference (vnode_root). */
+- rc = vflush(mp, 1, flags, td);
+- if (rc)
+- return rc;
++ VBOX_INTOPT("uid", uid, 10);
++ VBOX_INTOPT("gid", gid, 10);
++ VBOX_INTOPT("file_mode", file_mode, 8);
++ VBOX_INTOPT("dir_mode", dir_mode, 8);
++ VBOX_INTOPT("ro", readonly, 10);
+
++ error = vfs_getopt(opts, "from", (void **)&share_name, &share_len);
++ if (error != 0 || share_len == 0) {
++ vfs_mount_error(mp, "Invalid from");
++ return (EINVAL);
++ }
+
+- RTMemFree(pShFlGlobalInfo);
+- mp->mnt_data = NULL;
++ vboxfsmp = malloc(sizeof(struct vboxfs_mnt), M_VBOXVFS, M_WAITOK | M_ZERO);
++ vboxfsmp->sf_uid = uid;
++ vboxfsmp->sf_gid = gid;
++ vboxfsmp->sf_fmode = file_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
++ vboxfsmp->sf_dmode = dir_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
++ vboxfsmp->sf_ino = 3;
++ vboxfsmp->sf_stat_ttl = 200;
+
+- return 0;
++ /* Invoke Hypervisor mount interface before proceeding */
++ error = sfprov_mount(share_name, &handle);
++ if (error)
++ return (error);
++
++ /* Determine whether the filesystem must be read-only. */
++ error = sfprov_get_fsinfo(handle, &fsinfo);
++ if (error != 0) {
++ sfprov_unmount(handle);
++ return (error);
++ }
++ if (readonly == 0)
++ readonly = (fsinfo.readonly != 0);
++
++ vboxfsmp->sf_handle = handle;
++ vboxfsmp->sf_vfsp = mp;
++
++ vboxfsmp->sf_node_pool = uma_zcreate("VBOXFS node",
++ sizeof(struct vboxfs_node),
++ vboxfs_node_ctor, vboxfs_node_dtor,
++ vboxfs_node_init, vboxfs_node_fini,
++ UMA_ALIGN_PTR, 0);
++
++ /* Allocate the root node. */
++ error = vboxfs_alloc_node(mp, vboxfsmp, "", VDIR, 0,
++ 0, 0755, NULL, &root);
++
++ if (error != 0 || root == NULL) {
++ uma_zdestroy(vboxfsmp->sf_node_pool);
++ free(vboxfsmp, M_VBOXVFS);
++ return error;
++ }
++
++ root->sf_parent = root;
++ vboxfsmp->sf_root = root;
++
++ MNT_ILOCK(mp);
++ mp->mnt_data = vboxfsmp;
++ mp->mnt_stat.f_fsid.val[0] = fsinfo.serial;
++ mp->mnt_stat.f_fsid.val[1] = 0;
++ mp->mnt_flag |= MNT_LOCAL;
++ if (readonly != 0)
++ mp->mnt_flag |= MNT_RDONLY;
++#if __FreeBSD_version >= 1000021
++ mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED;
++#else
++ mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED |
++ MNTK_EXTENDED_SHARED;
++#endif
++ MNT_IUNLOCK(mp);
++ vfs_mountedfrom(mp, share_name);
++
++ return (0);
+ }
+
+-static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
++/*
++ * Unmount a shared folder.
++ *
++ * vboxfs_unmount umounts the mounted file system. It return 0
++ * on sucess and any relevant errno on failure.
++ */
++static int
++vboxfs_unmount(struct mount *mp, int mntflags)
+ {
+- int rc = 0;
+- struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
+- struct vnode *vp;
++ struct vboxfs_mnt *vboxfsmp;
++ struct thread *td;
++ int error;
++ int flags;
+
+- printf("%s: Enter\n", __FUNCTION__);
++ vboxfsmp = VFSTOVBOXFS(mp);
++ td = curthread;
++ flags = 0;
++ if (mntflags & MNT_FORCE)
++ flags |= FORCECLOSE;
+
+- vp = pShFlGlobalInfo->vnode_root;
+- VREF(vp);
++ error = vflush(mp, 0, flags, td);
++ if (error)
++ return (error);
+
+- vn_lock(vp, flags | LK_RETRY, td);
+- *vpp = vp;
++ /* Invoke Hypervisor unmount interface before proceeding */
++ error = sfprov_unmount(vboxfsmp->sf_handle);
++ if (error != 0) {
++ /* TBD anything here? */
++ }
+
+- printf("%s: Leave\n", __FUNCTION__);
++ uma_zdestroy(vboxfsmp->sf_node_pool);
+
+- return rc;
++ free(vboxfsmp, M_VBOXVFS);
++ MNT_ILOCK(mp);
++ mp->mnt_data = NULL;
++ mp->mnt_flag &= ~MNT_LOCAL;
++ MNT_IUNLOCK(mp);
++
++ return (0);
+ }
+
+-static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, struct thread *td)
++static int
++vboxfs_root(struct mount *mp, int flags, struct vnode **vpp)
+ {
+- return EOPNOTSUPP;
++ int error;
++ error = vboxfs_alloc_vp(mp, VFSTOVBOXFS(mp)->sf_root, flags, vpp);
++
++ if (!error)
++ (*vpp)->v_vflag |= VV_ROOT;
++
++ return error;
+ }
+
+-int vboxvfs_init(struct vfsconf *vfsp)
++/*
++ * Do operation associated with quotas, not supported
++ */
++static int
++vboxfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg)
+ {
+- int rc;
++ return (EOPNOTSUPP);
++}
+
+- /* Initialize the R0 guest library. */
+- rc = VbglR0SfInit();
+- if (RT_FAILURE(rc))
+- return ENXIO;
++/*
++ * Initialize the filesystem globals.
++ */
++static int
++vboxfs_init(struct vfsconf *vfsp)
++{
++ int error;
+
+- /* Connect to the host service. */
+- rc = VbglR0SfConnect(&g_vboxSFClient);
+- if (RT_FAILURE(rc))
+- {
+- printf("Failed to get connection to host! rc=%d\n", rc);
+- VbglR0SfTerm();
+- return ENXIO;
+- }
++ DROP_GIANT();
+
+- rc = VbglR0SfSetUtf8(&g_vboxSFClient);
+- if (RT_FAILURE (rc))
+- {
+- printf("VbglR0SfSetUtf8 failed, rc=%d\n", rc);
+- VbglR0SfDisconnect(&g_vboxSFClient);
+- VbglR0SfTerm();
+- return EPROTO;
+- }
++ sfprov = sfprov_connect(SFPROV_VERSION);
++ if (sfprov == NULL) {
++ printf("%s: couldn't connect to sf provider", __func__);
++ return (ENODEV);
++ }
+
+- printf("Successfully loaded shared folder module\n");
++ error = sfprov_set_show_symlinks();
++ if (error != 0)
++ printf("%s: host unable to show symlinks, error=%d\n",
++ __func__, error);
+
+- return 0;
++ PICKUP_GIANT();
++ return (0);
+ }
+
+-int vboxvfs_uninit(struct vfsconf *vfsp)
++/*
++ * Undo the work of vboxfs_init().
++ */
++static int
++vboxfs_uninit(struct vfsconf *vfsp)
+ {
+- VbglR0SfDisconnect(&g_vboxSFClient);
+- VbglR0SfTerm();
+
+- return 0;
++ DROP_GIANT();
++ sfprov_disconnect();
++ PICKUP_GIANT();
++ return (0);
+ }
+
+-int vboxvfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
++/*
++ * Get filesystem statistics.
++ */
++static int
++vboxfs_statfs(struct mount *mp, struct statfs *sbp)
+ {
+- return 0;
++ struct vboxfs_mnt *vboxfsmp;
++ sffs_fsinfo_t fsinfo;
++ int error;
++
++ vboxfsmp = VFSTOVBOXFS(mp);
++
++ error = sfprov_get_fsinfo(vboxfsmp->sf_handle, &fsinfo);
++ if (error != 0)
++ return (error);
++
++ sbp->f_iosize = fsinfo.blksize;
++ sbp->f_bsize = fsinfo.blksize;
++
++ sbp->f_bfree = fsinfo.blksavail;
++ sbp->f_bavail = fsinfo.blksavail;
++ sbp->f_files = fsinfo.blksavail / 4; /* some kind of reasonable value */
++ sbp->f_ffree = fsinfo.blksavail / 4;
++
++ sbp->f_blocks = fsinfo.blksused + sbp->f_bavail;
++ sbp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
++ sbp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
++ sbp->f_namemax = fsinfo.maxnamesize;
++
++ return (0);
+ }
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
new file mode 100644
index 000000000000..bc42812105e4
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
@@ -0,0 +1,1486 @@
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig 2020-07-09 16:50:11 UTC
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c
+@@ -1,10 +1,6 @@
+-/* $Id: vboxvfs_vnops.c $ */
+-/** @file
+- * Description.
+- */
+-
+ /*
+ * Copyright (C) 2008-2017 Oracle Corporation
++ * Copyright (C) 2017 Mahdi Mokhtari
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+@@ -14,228 +10,1347 @@
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+-
+-#include "vboxvfs.h"
+ #include <sys/param.h>
+ #include <sys/systm.h>
+ #include <sys/namei.h>
+ #include <sys/kernel.h>
+-#include <sys/proc.h>
++#include <sys/types.h>
++#include <sys/malloc.h>
++#include <sys/stat.h>
+ #include <sys/bio.h>
++#include <sys/conf.h>
+ #include <sys/buf.h>
+-#include <sys/fcntl.h>
++#include <sys/iconv.h>
+ #include <sys/mount.h>
+-#include <sys/unistd.h>
+ #include <sys/vnode.h>
+-#include <sys/limits.h>
+-#include <sys/lockf.h>
+-#include <sys/stat.h>
++#include <sys/dirent.h>
++#include <sys/queue.h>
++#include <sys/unistd.h>
++#include <sys/endian.h>
+
+-#include <vm/vm.h>
+-#include <vm/vm_extern.h>
++#include <vm/uma.h>
+
++#include "vboxvfs.h"
++
++#if __FreeBSD_version < 1300063
++#define VN_IS_DOOMED(vp) (((vp)->v_iflag & VI_DOOMED) != 0)
++#endif
++
+ /*
+ * Prototypes for VBOXVFS vnode operations
+ */
+-static vop_create_t vboxvfs_create;
+-static vop_mknod_t vboxvfs_mknod;
+-static vop_open_t vboxvfs_open;
+-static vop_close_t vboxvfs_close;
+-static vop_access_t vboxvfs_access;
+-static vop_getattr_t vboxvfs_getattr;
+-static vop_setattr_t vboxvfs_setattr;
+-static vop_read_t vboxvfs_read;
+-static vop_write_t vboxvfs_write;
+-static vop_fsync_t vboxvfs_fsync;
+-static vop_remove_t vboxvfs_remove;
+-static vop_link_t vboxvfs_link;
+-static vop_lookup_t vboxvfs_lookup;
+-static vop_rename_t vboxvfs_rename;
+-static vop_mkdir_t vboxvfs_mkdir;
+-static vop_rmdir_t vboxvfs_rmdir;
+-static vop_symlink_t vboxvfs_symlink;
+-static vop_readdir_t vboxvfs_readdir;
+-static vop_strategy_t vboxvfs_strategy;
+-static vop_print_t vboxvfs_print;
+-static vop_pathconf_t vboxvfs_pathconf;
+-static vop_advlock_t vboxvfs_advlock;
+-static vop_getextattr_t vboxvfs_getextattr;
+-static vop_ioctl_t vboxvfs_ioctl;
+-static vop_getpages_t vboxvfs_getpages;
+-static vop_inactive_t vboxvfs_inactive;
+-static vop_putpages_t vboxvfs_putpages;
+-static vop_reclaim_t vboxvfs_reclaim;
++static vop_create_t vboxfs_create;
++static vop_open_t vboxfs_open;
++static vop_close_t vboxfs_close;
++static vop_access_t vboxfs_access;
++static vop_getattr_t vboxfs_getattr;
++static vop_setattr_t vboxfs_setattr;
++static vop_read_t vboxfs_read;
++static vop_readlink_t vboxfs_readlink;
++static vop_write_t vboxfs_write;
++static vop_fsync_t vboxfs_fsync;
++static vop_remove_t vboxfs_remove;
++static vop_link_t vboxfs_link;
++static vop_cachedlookup_t vboxfs_lookup;
++static vop_rename_t vboxfs_rename;
++static vop_mkdir_t vboxfs_mkdir;
++static vop_rmdir_t vboxfs_rmdir;
++static vop_symlink_t vboxfs_symlink;
++static vop_readdir_t vboxfs_readdir;
++static vop_print_t vboxfs_print;
++static vop_pathconf_t vboxfs_pathconf;
++static vop_advlock_t vboxfs_advlock;
++static vop_ioctl_t vboxfs_ioctl;
++static vop_inactive_t vboxfs_inactive;
++static vop_reclaim_t vboxfs_reclaim;
++static vop_vptofh_t vboxfs_vptofh;
+
+-struct vop_vector vboxvfs_vnodeops = {
+- .vop_default = &default_vnodeops,
++struct vop_vector vboxfs_vnodeops = {
++ .vop_default = &default_vnodeops,
+
+- .vop_access = vboxvfs_access,
+- .vop_advlock = vboxvfs_advlock,
+- .vop_close = vboxvfs_close,
+- .vop_create = vboxvfs_create,
+- .vop_fsync = vboxvfs_fsync,
+- .vop_getattr = vboxvfs_getattr,
+- .vop_getextattr = vboxvfs_getextattr,
+- .vop_getpages = vboxvfs_getpages,
+- .vop_inactive = vboxvfs_inactive,
+- .vop_ioctl = vboxvfs_ioctl,
+- .vop_link = vboxvfs_link,
+- .vop_lookup = vboxvfs_lookup,
+- .vop_mkdir = vboxvfs_mkdir,
+- .vop_mknod = vboxvfs_mknod,
+- .vop_open = vboxvfs_open,
+- .vop_pathconf = vboxvfs_pathconf,
+- .vop_print = vboxvfs_print,
+- .vop_putpages = vboxvfs_putpages,
+- .vop_read = vboxvfs_read,
+- .vop_readdir = vboxvfs_readdir,
+- .vop_reclaim = vboxvfs_reclaim,
+- .vop_remove = vboxvfs_remove,
+- .vop_rename = vboxvfs_rename,
+- .vop_rmdir = vboxvfs_rmdir,
+- .vop_setattr = vboxvfs_setattr,
+- .vop_strategy = vboxvfs_strategy,
+- .vop_symlink = vboxvfs_symlink,
+- .vop_write = vboxvfs_write,
++ .vop_access = vboxfs_access,
++ .vop_advlock = VOP_EOPNOTSUPP,
++ .vop_close = vboxfs_close,
++ .vop_create = vboxfs_create,
++ .vop_fsync = vboxfs_fsync,
++ .vop_getattr = vboxfs_getattr,
++ .vop_getextattr = VOP_EOPNOTSUPP,
++ .vop_inactive = vboxfs_inactive,
++ .vop_ioctl = vboxfs_ioctl,
++ .vop_link = vboxfs_link,
++ .vop_lookup = vfs_cache_lookup,
++ .vop_cachedlookup = vboxfs_lookup,
++ .vop_mkdir = vboxfs_mkdir,
++ .vop_mknod = VOP_EOPNOTSUPP,
++ .vop_open = vboxfs_open,
++ .vop_pathconf = vboxfs_pathconf,
++ .vop_print = vboxfs_print,
++ .vop_read = vboxfs_read,
++ .vop_readdir = vboxfs_readdir,
++ .vop_readlink = vboxfs_readlink,
++ .vop_reclaim = vboxfs_reclaim,
++ .vop_remove = vboxfs_remove,
++ .vop_rename = vboxfs_rename,
++ .vop_rmdir = vboxfs_rmdir,
++ .vop_setattr = vboxfs_setattr,
++ .vop_vptofh = vboxfs_vptofh,
++ .vop_symlink = vboxfs_symlink,
++ .vop_write = vboxfs_write,
++ .vop_bmap = VOP_EOPNOTSUPP
+ };
+
+-static int vboxvfs_access(struct vop_access_args *ap)
++static uint64_t
++vsfnode_cur_time_usec(void)
+ {
+- return 0;
++ struct timeval now;
++
++ getmicrotime(&now);
++
++ return (now.tv_sec*1000 + now.tv_usec);
+ }
+
+-static int vboxvfs_open(struct vop_open_args *ap)
++static int
++vsfnode_stat_cached(struct vboxfs_node *np)
+ {
+- return 0;
++ return (vsfnode_cur_time_usec() - np->sf_stat_time) <
++ np->vboxfsmp->sf_stat_ttl * 1000UL;
+ }
+
+-static int vboxvfs_close(struct vop_close_args *ap)
++static int
++vsfnode_update_stat_cache(struct vboxfs_node *np)
+ {
+- return 0;
++ int error;
++
++ error = sfprov_get_attr(np->vboxfsmp->sf_handle, np->sf_path,
++ &np->sf_stat);
++#if 0
++ if (error == ENOENT)
++ sfnode_make_stale(node);
++#endif
++ if (error == 0)
++ np->sf_stat_time = vsfnode_cur_time_usec();
++
++ return (error);
+ }
+
+-static int vboxvfs_getattr(struct vop_getattr_args *ap)
++/*
++ * Need to clear v_object for insmntque failure.
++ */
++static void
++vboxfs_insmntque_dtr(struct vnode *vp, void *dtr_arg)
+ {
+- return 0;
++
++ // XXX: vboxfs_destroy_vobject(vp, vp->v_object);
++ vp->v_object = NULL;
++ vp->v_data = NULL;
++ vp->v_op = &dead_vnodeops;
++ vgone(vp);
++ vput(vp);
+ }
+
+-static int vboxvfs_setattr(struct vop_setattr_args *ap)
++/*
++ * Allocates a new vnode for the node node or returns a new reference to
++ * an existing one if the node had already a vnode referencing it. The
++ * resulting locked vnode is returned in *vpp.
++ *
++ * Returns zero on success or an appropriate error code on failure.
++ */
++int
++vboxfs_alloc_vp(struct mount *mp, struct vboxfs_node *node, int lkflag,
++ struct vnode **vpp)
+ {
+- return 0;
++ struct vnode *vp;
++ int error;
++
++ error = 0;
++loop:
++ VBOXFS_NODE_LOCK(node);
++loop1:
++ if ((vp = node->sf_vnode) != NULL) {
++ MPASS((node->sf_vpstate & VBOXFS_VNODE_DOOMED) == 0);
++ VI_LOCK(vp);
++ if ((node->sf_type == VDIR && node->sf_parent == NULL) ||
++ (VN_IS_DOOMED(vp) &&
++ (lkflag & LK_NOWAIT) != 0)) {
++ VI_UNLOCK(vp);
++ VBOXFS_NODE_UNLOCK(node);
++ error = ENOENT;
++ vp = NULL;
++ goto out;
++ }
++ if (VN_IS_DOOMED(vp)) {
++ VI_UNLOCK(vp);
++ node->sf_vpstate |= VBOXFS_VNODE_WRECLAIM;
++ while ((node->sf_vpstate & VBOXFS_VNODE_WRECLAIM) != 0) {
++ msleep(&node->sf_vnode, VBOXFS_NODE_MTX(node),
++ 0, "vsfE", 0);
++ }
++ goto loop1;
++ }
++ VBOXFS_NODE_UNLOCK(node);
++#if __FreeBSD_version < 1300109
++ error = vget(vp, lkflag | LK_INTERLOCK, curthread);
++#else
++ error = vget(vp, lkflag | LK_INTERLOCK);
++#endif
++ if (error == ENOENT)
++ goto loop;
++ if (error != 0) {
++ vp = NULL;
++ goto out;
++ }
++
++ /*
++ * Make sure the vnode is still there after
++ * getting the interlock to avoid racing a free.
++ */
++ if (node->sf_vnode == NULL || node->sf_vnode != vp) {
++ vput(vp);
++ goto loop;
++ }
++
++ goto out;
++ }
++
++ if ((node->sf_vpstate & VBOXFS_VNODE_DOOMED) ||
++ (node->sf_type == VDIR && node->sf_parent == NULL)) {
++ VBOXFS_NODE_UNLOCK(node);
++ error = ENOENT;
++ vp = NULL;
++ goto out;
++ }
++
++ /*
++ * otherwise lock the vp list while we call getnewvnode
++ * since that can block.
++ */
++ if (node->sf_vpstate & VBOXFS_VNODE_ALLOCATING) {
++ node->sf_vpstate |= VBOXFS_VNODE_WANT;
++ error = msleep((caddr_t) &node->sf_vpstate,
++ VBOXFS_NODE_MTX(node), PDROP | PCATCH,
++ "vboxfs_alloc_vp", 0);
++ if (error)
++ return error;
++
++ goto loop;
++ } else
++ node->sf_vpstate |= VBOXFS_VNODE_ALLOCATING;
++
++ VBOXFS_NODE_UNLOCK(node);
++
++ /* Get a new vnode and associate it with our node. */
++ error = getnewvnode("vboxfs", mp, &vboxfs_vnodeops, &vp);
++ if (error != 0)
++ goto unlock;
++ MPASS(vp != NULL);
++
++ /* lkflag is ignored, the lock is exclusive */
++ (void) vn_lock(vp, lkflag | LK_RETRY);
++
++ vp->v_data = node;
++ vp->v_type = node->sf_type;
++
++ /* Type-specific initialization. */
++ switch (node->sf_type) {
++ case VBLK:
++ /* FALLTHROUGH */
++ case VCHR:
++ /* FALLTHROUGH */
++ case VLNK:
++ /* FALLTHROUGH */
++ case VSOCK:
++ /* FALLTHROUGH */
++ case VFIFO:
++ /* FALLTHROUGH */
++ case VREG:
++ break;
++ case VDIR:
++ MPASS(node->sf_parent != NULL);
++ if (node->sf_parent == node)
++ vp->v_vflag |= VV_ROOT;
++ break;
++
++ default:
++ panic("vboxfs_alloc_vp: type %p %d", node, (int)node->sf_type);
++ }
++
++ if (vp->v_type != VFIFO)
++ VN_LOCK_ASHARE(vp);
++
++ error = insmntque1(vp, mp, vboxfs_insmntque_dtr, NULL);
++ if (error)
++ vp = NULL;
++
++unlock:
++ VBOXFS_NODE_LOCK(node);
++
++ MPASS(node->sf_vpstate & VBOXFS_VNODE_ALLOCATING);
++ node->sf_vpstate &= ~VBOXFS_VNODE_ALLOCATING;
++ node->sf_vnode = vp;
++
++ if (node->sf_vpstate & VBOXFS_VNODE_WANT) {
++ node->sf_vpstate &= ~VBOXFS_VNODE_WANT;
++ VBOXFS_NODE_UNLOCK(node);
++ wakeup((caddr_t) &node->sf_vpstate);
++ } else
++ VBOXFS_NODE_UNLOCK(node);
++
++out:
++ *vpp = vp;
++
++#ifdef INVARIANTS
++ if (error == 0) {
++ MPASS(*vpp != NULL && VOP_ISLOCKED(*vpp));
++ VBOXFS_NODE_LOCK(node);
++ MPASS(*vpp == node->sf_vnode);
++ VBOXFS_NODE_UNLOCK(node);
++ }
++#endif
++
++ return error;
+ }
+
+-static int vboxvfs_read(struct vop_read_args *ap)
++/*
++ * Destroys the association between the vnode vp and the node it
++ * references.
++ */
++void
++vboxfs_free_vp(struct vnode *vp)
+ {
+- return 0;
++ struct vboxfs_node *node;
++
++ node = VP_TO_VBOXFS_NODE(vp);
++
++ VBOXFS_NODE_ASSERT_LOCKED(node);
++ node->sf_vnode = NULL;
++ if ((node->sf_vpstate & VBOXFS_VNODE_WRECLAIM) != 0)
++ wakeup(&node->sf_vnode);
++ node->sf_vpstate &= ~VBOXFS_VNODE_WRECLAIM;
++ vp->v_data = NULL;
+ }
+
+-static int vboxvfs_write(struct vop_write_args *ap)
++/*
++ * Allocate new vboxfs_node and vnode for given file
++ */
++static int
++vboxfs_alloc_file(struct vboxfs_mnt *vboxfsmp, const char *fullpath,
++ enum vtype type, mode_t mode, struct vboxfs_node *parent,
++ int lkflag, struct vnode **vpp)
+ {
+- return 0;
++ int error;
++ struct vboxfs_node *unode;
++
++ error = vboxfs_alloc_node(vboxfsmp->sf_vfsp, vboxfsmp, fullpath, type,
++ vboxfsmp->sf_uid, vboxfsmp->sf_gid, mode, parent, &unode);
++
++ if (error)
++ goto out;
++
++ error = vboxfs_alloc_vp(vboxfsmp->sf_vfsp, unode, lkflag, vpp);
++ if (error)
++ vboxfs_free_node(vboxfsmp, unode);
++
++out:
++ return (error);
+ }
+
+-static int vboxvfs_create(struct vop_create_args *ap)
++static int
++vboxfs_vn_get_ino_alloc(struct mount *mp, void *arg, int lkflags,
++ struct vnode **rvp)
+ {
+- return 0;
++
++ return (vboxfs_alloc_vp(mp, arg, lkflags, rvp));
+ }
+
+-static int vboxvfs_remove(struct vop_remove_args *ap)
++/*
++ * Construct a new pathname given an sfnode plus an optional tail
++ * component of length len
++ * This handles ".." and "."
++ */
++static char *
++sfnode_construct_path(struct vboxfs_node *node, char *tail, int len)
+ {
+- return 0;
++ char *p;
++
++ if (len <= 2 && tail[0] == '.' && (len == 1 || tail[1] == '.'))
++ panic("construct path for %s", tail);
++ p = malloc(strlen(node->sf_path) + 1 + len + 1, M_VBOXVFS, M_WAITOK);
++ strcpy(p, node->sf_path);
++ strcat(p, "/");
++ strcat(p, tail);
++ return (p);
+ }
+
+-static int vboxvfs_rename(struct vop_rename_args *ap)
++static int
++vboxfs_access(struct vop_access_args *ap)
+ {
+- return 0;
++ struct vnode *vp = ap->a_vp;
++ accmode_t accmode = ap->a_accmode;
++ struct vboxfs_node *node;
++ int error;
++ mode_t m;
++
++ MPASS(VOP_ISLOCKED(vp));
++
++ node = VP_TO_VBOXFS_NODE(vp);
++
++ if ((accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
++ switch (vp->v_type) {
++ case VDIR:
++ case VLNK:
++ case VREG:
++ return (EROFS);
++ /* NOT REACHED */
++ default:
++ break;
++ }
++ }
++
++ if (vsfnode_stat_cached(node))
++ error = 0;
++ else
++ error = vsfnode_update_stat_cache(node);
++ m = (error == 0) ? node->sf_stat.sf_mode : 0;
++
++#if __FreeBSD_version < 1300105
++ return (vaccess(vp->v_type, m, node->vboxfsmp->sf_uid,
++ node->vboxfsmp->sf_gid, accmode, ap->a_cred, NULL));
++#else
++ return (vaccess(vp->v_type, m, node->vboxfsmp->sf_uid,
++ node->vboxfsmp->sf_gid, accmode, ap->a_cred));
++#endif
+ }
+
+-static int vboxvfs_link(struct vop_link_args *ap)
++/*
++ * Clears the (cached) directory listing for the node.
++ */
++static void
++vfsnode_clear_dir_list(struct vboxfs_node *np)
+ {
+- return EOPNOTSUPP;
++ while (np->sf_dir_list != NULL) {
++ sffs_dirents_t *next = np->sf_dir_list->sf_next;
++ free(np->sf_dir_list, M_VBOXVFS);
++ np->sf_dir_list = next;
++ }
+ }
+
+-static int vboxvfs_symlink(struct vop_symlink_args *ap)
++static int
++vboxfs_open(struct vop_open_args *ap)
+ {
+- return EOPNOTSUPP;
++ struct vboxfs_node *np;
++ sfp_file_t *fp;
++ int error;
++
++ MPASS(VOP_ISLOCKED(vp));
++
++ np = VP_TO_VBOXFS_NODE(ap->a_vp);
++ error = sfprov_open(np->vboxfsmp->sf_handle, np->sf_path, &fp);
++ if (error != 0)
++ goto out;
++
++ np->sf_file = fp;
++ vnode_create_vobject(ap->a_vp, 0, ap->a_td);
++
++out:
++ MPASS(VOP_ISLOCKED(vp));
++
++ return (error);
+ }
+
+-static int vboxvfs_mknod(struct vop_mknod_args *ap)
++static void
++vfsnode_invalidate_stat_cache(struct vboxfs_node *np)
+ {
+- return EOPNOTSUPP;
++ np->sf_stat_time = 0;
+ }
+
+-static int vboxvfs_mkdir(struct vop_mkdir_args *ap)
++static int
++vboxfs_close(struct vop_close_args *ap)
+ {
+- return 0;
++ struct vnode *vp = ap->a_vp;
++ struct vboxfs_node *np;
++
++ np = VP_TO_VBOXFS_NODE(vp);
++
++ /*
++ * Free the directory entries for the node. We do this on this call
++ * here because the directory node may not become inactive for a long
++ * time after the readdir is over. Case in point, if somebody cd's into
++ * the directory then it won't become inactive until they cd away again.
++ * In such a case we would end up with the directory listing not getting
++ * updated (i.e. the result of 'ls' always being the same) until they
++ * change the working directory.
++ */
++ vfsnode_clear_dir_list(np);
++
++ vfsnode_invalidate_stat_cache(np);
++
++ if (np->sf_file != NULL && vp->v_usecount <= 1) {
++ (void) sfprov_close(np->sf_file);
++ np->sf_file = NULL;
++ }
++
++ return (0);
+ }
+
+-static int vboxvfs_rmdir(struct vop_rmdir_args *ap)
++static int
++vboxfs_getattr(struct vop_getattr_args *ap)
+ {
+- return 0;
++ struct vnode *vp = ap->a_vp;
++ struct vattr *vap = ap->a_vap;
++ struct vboxfs_node *np = VP_TO_VBOXFS_NODE(vp);
++ struct vboxfs_mnt *mp = np->vboxfsmp;
++ mode_t mode;
++ int error = 0;
++
++ mode = 0;
++ vap->va_type = vp->v_type;
++
++ vap->va_nlink = 1; /* number of references to file */
++ vap->va_uid = mp->sf_uid; /* owner user id */
++ vap->va_gid = mp->sf_gid; /* owner group id */
++ vap->va_rdev = NODEV; /* device the special file represents */
++ vap->va_gen = VNOVAL; /* generation number of file */
++ vap->va_flags = 0; /* flags defined for file */
++ vap->va_filerev = 0; /* file modification number */
++ vap->va_vaflags = 0; /* operations flags */
++ vap->va_fileid = np->sf_ino; /* file id */
++ vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
++ if (vap->va_fileid == 0)
++ vap->va_fileid = 2;
++
++ vap->va_atime.tv_sec = VNOVAL;
++ vap->va_atime.tv_nsec = VNOVAL;
++ vap->va_mtime.tv_sec = VNOVAL;
++ vap->va_mtime.tv_nsec = VNOVAL;
++ vap->va_ctime.tv_sec = VNOVAL;
++ vap->va_ctime.tv_nsec = VNOVAL;
++
++ if (!vsfnode_stat_cached(np)) {
++ error = vsfnode_update_stat_cache(np);
++ if (error != 0)
++ goto done;
++ }
++
++ vap->va_atime = np->sf_stat.sf_atime;
++ vap->va_mtime = np->sf_stat.sf_mtime;
++ vap->va_ctime = np->sf_stat.sf_ctime;
++
++ mode = np->sf_stat.sf_mode;
++
++ vap->va_mode = mode;
++ if (S_ISDIR(mode)) {
++ vap->va_type = VDIR; /* vnode type (for create) */
++ vap->va_mode = mp->sf_dmode != 0 ? (mp->sf_dmode & 0777) : vap->va_mode;
++ vap->va_mode &= ~mp->sf_dmask;
++ vap->va_mode |= S_IFDIR;
++ } else if (S_ISREG(mode)) {
++ vap->va_type = VREG;
++ vap->va_mode = mp->sf_fmode != 0 ? (mp->sf_fmode & 0777) : vap->va_mode;
++ vap->va_mode &= ~mp->sf_fmask;
++ vap->va_mode |= S_IFREG;
++ } else if (S_ISFIFO(mode))
++ vap->va_type = VFIFO;
++ else if (S_ISCHR(mode))
++ vap->va_type = VCHR;
++ else if (S_ISBLK(mode))
++ vap->va_type = VBLK;
++ else if (S_ISLNK(mode)) {
++ vap->va_type = VLNK;
++ vap->va_mode = mp->sf_fmode != 0 ? (mp->sf_fmode & 0777) : vap->va_mode;
++ vap->va_mode &= ~mp->sf_fmask;
++ vap->va_mode |= S_IFLNK;
++ } else if (S_ISSOCK(mode))
++ vap->va_type = VSOCK;
++
++ vap->va_size = np->sf_stat.sf_size;
++ vap->va_blocksize = 512;
++ /* bytes of disk space held by file */
++ vap->va_bytes = (np->sf_stat.sf_alloc + 511) / 512;
++
++done:
++ return (error);
+ }
+
+-static int vboxvfs_readdir(struct vop_readdir_args *ap)
++static int
++vboxfs_setattr(struct vop_setattr_args *ap)
+ {
+- return 0;
++ struct vnode *vp = ap->a_vp;
++ struct vattr *vap = ap->a_vap;
++ struct vboxfs_node *np = VP_TO_VBOXFS_NODE(vp);
++ int error;
++ mode_t mode;
++
++ mode = vap->va_mode;
++ if (vp->v_type == VREG)
++ mode |= S_IFREG;
++ else if (vp->v_type == VDIR)
++ mode |= S_IFDIR;
++ else if (vp->v_type == VBLK)
++ mode |= S_IFBLK;
++ else if (vp->v_type == VCHR)
++ mode |= S_IFCHR;
++ else if (vp->v_type == VLNK)
++ mode |= S_IFLNK;
++ else if (vp->v_type == VFIFO)
++ mode |= S_IFIFO;
++ else if (vp->v_type == VSOCK)
++ mode |= S_IFSOCK;
++
++ vfsnode_invalidate_stat_cache(np);
++
++ error = sfprov_set_attr(np->vboxfsmp->sf_handle, np->sf_path,
++ mode, vap->va_atime, vap->va_mtime, vap->va_ctime);
++#if 0
++ if (error == ENOENT)
++ sfnode_make_stale(np);
++#endif
++ if (vap->va_size != (u_quad_t)VNOVAL) {
++ switch (vp->v_type) {
++ case VDIR:
++ return (EISDIR);
++ case VLNK:
++ /* FALLTHROUGH */
++ case VREG:
++ error = sfprov_set_size(np->vboxfsmp->sf_handle, np->sf_path, vap->va_size);
++ break;
++ case VCHR:
++ /* FALLTHROUGH */
++ case VBLK:
++ /* FALLTHROUGH */
++ case VSOCK:
++ /* FALLTHROUGH */
++ case VFIFO:
++ /* FALLTHROUGH */
++ case VNON:
++ /* FALLTHROUGH */
++ case VBAD:
++ /* FALLTHROUGH */
++ case VMARKER:
++ return (0);
++ }
++ }
++
++ return (error);
+ }
+
+-static int vboxvfs_fsync(struct vop_fsync_args *ap)
++#define blkoff(vboxfsmp, loc) ((loc) & (vboxfsmp)->bmask)
++
++static int
++vboxfs_read(struct vop_read_args *ap)
+ {
+- return 0;
++ struct vnode *vp = ap->a_vp;
++ struct uio *uio = ap->a_uio;
++ struct vboxfs_node *np = VP_TO_VBOXFS_NODE(vp);
++ int error = 0;
++ uint32_t bytes;
++ uint32_t done;
++ unsigned long offset;
++ ssize_t total;
++ void *tmpbuf;
++
++ if (vp->v_type == VDIR)
++ return (EISDIR);
++
++ if (vp->v_type != VREG)
++ return (EINVAL);
++
++ if (uio->uio_offset < 0)
++ return (EINVAL);
++
++ total = uio->uio_resid;
++ if (total == 0)
++ return (0);
++
++ /*
++ * XXXGONZO: this is just to get things working
++ * should be optimized
++ */
++ tmpbuf = contigmalloc(PAGE_SIZE, M_DEVBUF, M_WAITOK, 0, ~0, PAGE_SIZE, 0);
++ if (tmpbuf == 0)
++ return (ENOMEM);
++
++ do {
++ offset = uio->uio_offset;
++ done = bytes = min(PAGE_SIZE, uio->uio_resid);
++ error = sfprov_read(np->sf_file, tmpbuf,
++ offset, &done, 0);
++ if (error == 0 && done > 0)
++ error = uiomove(tmpbuf, done, uio);
++ } while (error == 0 && uio->uio_resid > 0 && done > 0);
++
++ contigfree(tmpbuf, PAGE_SIZE, M_DEVBUF);
++
++ /* a partial read is never an error */
++ if (total != uio->uio_resid)
++ error = 0;
++
++ return (error);
+ }
+
+-static int vboxvfs_print (struct vop_print_args *ap)
++static int
++vboxfs_write(struct vop_write_args *ap)
+ {
+- return 0;
++ struct vnode *vp = ap->a_vp;
++ struct uio *uio = ap->a_uio;
++ struct vboxfs_node *np = VP_TO_VBOXFS_NODE(vp);
++ int error = 0;
++ uint32_t bytes;
++ uint32_t done;
++ unsigned long offset;
++ ssize_t total;
++ void *tmpbuf;
++
++ if (vp->v_type == VDIR)
++ return (EISDIR);
++
++ if (vp->v_type != VREG)
++ return (EINVAL);
++
++ if (uio->uio_offset < 0)
++ return (EINVAL);
++
++ total = uio->uio_resid;
++ if (total == 0)
++ return (0);
++
++ /*
++ * XXXGONZO: this is just to get things working
++ * should be optimized
++ */
++ tmpbuf = contigmalloc(PAGE_SIZE, M_DEVBUF, M_WAITOK, 0, ~0, PAGE_SIZE, 0);
++ if (tmpbuf == 0)
++ return (ENOMEM);
++
++ do {
++ offset = uio->uio_offset;
++ bytes = min(PAGE_SIZE, uio->uio_resid);
++ error = uiomove(tmpbuf, bytes, uio);
++ if (error != 0)
++ break;
++ done = bytes;
++ error = sfprov_write(np->sf_file, tmpbuf,
++ offset, &done, 0);
++ if (error != 0)
++ break;
++ total -= done;
++ if (done != bytes)
++ uio->uio_resid += bytes - done;
++ } while (error == 0 && uio->uio_resid > 0 && done > 0);
++
++ contigfree(tmpbuf, PAGE_SIZE, M_DEVBUF);
++
++ /* a partial write is never an error */
++ if (total != uio->uio_resid)
++ error = 0;
++
++ return (error);
+ }
+
+-static int vboxvfs_pathconf (struct vop_pathconf_args *ap)
++static int
++vboxfs_create(struct vop_create_args *ap)
+ {
+- return 0;
++ struct vnode *dvp = ap->a_dvp;
++ struct vnode **vpp = ap->a_vpp;
++ struct componentname *cnp = ap->a_cnp;
++ struct vattr *vap = ap->a_vap;
++ sffs_stat_t stat;
++ char *fullpath = NULL;
++ struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
++ sfp_file_t *fp;
++ int error;
++ struct vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
++
++ MPASS(vap->va_type == VREG);
++
++ fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
++ error = sfprov_create(dir->vboxfsmp->sf_handle, fullpath, vap->va_mode,
++ &fp, &stat);
++
++ if (error)
++ goto out;
++
++ error = vboxfs_alloc_file(vboxfsmp, fullpath, VREG, vap->va_mode, dir, cnp->cn_lkflags, vpp);
++
++out:
++ if (fullpath)
++ free(fullpath, M_VBOXVFS);
++
++ if (error == 0) {
++ vfsnode_clear_dir_list(dir);
++ if ((cnp->cn_flags & MAKEENTRY) != 0)
++ cache_enter(dvp, *vpp, cnp);
++ }
++
++ return (error);
+ }
+
+-static int vboxvfs_strategy (struct vop_strategy_args *ap)
++static int
++vboxfs_remove(struct vop_remove_args *ap)
+ {
+- return 0;
++ struct vnode *dvp = ap->a_dvp;
++ struct vnode *vp = ap->a_vp;
++ struct vboxfs_node *np, *dir;
++
++ int error;
++
++ MPASS(VOP_ISLOCKED(dvp));
++ MPASS(VOP_ISLOCKED(vp));
++
++ error = 0;
++
++ np = VP_TO_VBOXFS_NODE(vp);
++ dir = VP_TO_VBOXFS_NODE(vp);
++
++ /*
++ * If anything else is using this vnode, then fail the remove.
++ * Why? Windows hosts can't sfprov_remove() a file that is open,
++ * so we have to sfprov_close() it first.
++ * There is no errno for this - since it's not a problem on UNIX,
++ * but ETXTBSY is the closest.
++ */
++ if (np->sf_file != NULL) {
++ if (vp->v_usecount > 1) {
++ error = ETXTBSY;
++ goto out;
++ }
++ sfprov_close(np->sf_file);
++ np->sf_file = NULL;
++ }
++
++ error = sfprov_remove(np->vboxfsmp->sf_handle, np->sf_path,
++ np->sf_type == VLNK);
++
++#if 0
++ if (error == ENOENT || error == 0)
++ sfnode_make_stale(np);
++#endif
++
++ if (error == 0)
++ vfsnode_clear_dir_list(dir);
++
++out:
++ return (error);
+ }
+
+-static int vboxvfs_ioctl(struct vop_ioctl_args *ap)
++static int
++vboxfs_rename(struct vop_rename_args *ap)
+ {
+- return ENOTTY;
++ struct vnode *fvp;
++ struct vnode *fdvp;
++ struct vnode *tvp;
++ struct vnode *tdvp;
++ struct componentname *fcnp;
++ struct componentname *tcnp;
++ struct vboxfs_node *np;
++ int ret;
++
++ fvp = ap->a_fvp;
++ fdvp = ap->a_fdvp;
++ tvp = ap->a_tvp;
++ tdvp = ap->a_tdvp;
++ fcnp = ap->a_fcnp;
++ tcnp = ap->a_tcnp;
++
++ /* Check for cross-device rename */
++ if ((fvp->v_mount != tdvp->v_mount) ||
++ (tvp && (fvp->v_mount != tvp->v_mount))) {
++ ret = EXDEV;
++ goto out;
++ }
++ np = VP_TO_VBOXFS_NODE(fvp);
++ if (np == NULL)
++ return (0);
++ ret = sfprov_rename(np->vboxfsmp->sf_handle,
++ fcnp->cn_nameptr, tcnp->cn_nameptr, fvp->v_type == VDIR);
++out:
++ if (tdvp == tvp)
++ vrele(tdvp);
++ else
++ vput(tdvp);
++ if (tvp)
++ vput(tvp);
++ vrele(fdvp);
++ vrele(fvp);
++ return (ret);
+ }
+
+-static int vboxvfs_getextattr(struct vop_getextattr_args *ap)
++static int
++vboxfs_link(struct vop_link_args *ap)
+ {
+- return 0;
++ return (EOPNOTSUPP);
+ }
+
+-static int vboxvfs_advlock(struct vop_advlock_args *ap)
++static int
++vboxfs_symlink(struct vop_symlink_args *ap)
+ {
+- return 0;
++ struct vnode *dvp = ap->a_dvp;
++ struct vnode **vpp = ap->a_vpp;
++ struct componentname *cnp = ap->a_cnp;
++ struct vattr *vap = ap->a_vap;
++ sffs_stat_t stat;
++ char *fullpath = NULL;
++ struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
++ int error;
++ struct vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
++
++ MPASS(vap->va_type == VLNK);
++
++ fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
++ error = sfprov_symlink(dir->vboxfsmp->sf_handle, fullpath, ap->a_target, &stat);
++
++ if (error)
++ goto out;
++
++ error = vboxfs_alloc_file(vboxfsmp, fullpath, VLNK, vap->va_mode, dir, cnp->cn_lkflags, vpp);
++
++out:
++ if (fullpath)
++ free(fullpath, M_VBOXVFS);
++
++ if (error == 0)
++ vfsnode_clear_dir_list(dir);
++
++ return (error);
+ }
+
+-static int vboxvfs_lookup(struct vop_lookup_args *ap)
++static int
++vboxfs_mkdir(struct vop_mkdir_args *ap)
+ {
+- return 0;
++ struct vnode *dvp = ap->a_dvp;
++ struct vnode **vpp = ap->a_vpp;
++ struct componentname *cnp = ap->a_cnp;
++ struct vattr *vap = ap->a_vap;
++ sffs_stat_t stat;
++ char *fullpath = NULL;
++ struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
++ sfp_file_t *fp;
++ int error;
++ struct vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
++
++ MPASS(vap->va_type == VDIR);
++
++ fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
++ error = sfprov_mkdir(dir->vboxfsmp->sf_handle, fullpath, vap->va_mode,
++ &fp, &stat);
++
++ if (error)
++ goto out;
++
++ error = vboxfs_alloc_file(vboxfsmp, fullpath, VDIR, vap->va_mode, dir, cnp->cn_lkflags, vpp);
++
++out:
++ if (fullpath)
++ free(fullpath, M_VBOXVFS);
++
++ if (error == 0)
++ vfsnode_clear_dir_list(dir);
++
++ return (error);
+ }
+
+-static int vboxvfs_inactive(struct vop_inactive_args *ap)
++static int
++vboxfs_rmdir(struct vop_rmdir_args *ap)
+ {
+- return 0;
++ struct vnode *dvp = ap->a_dvp;
++ struct vnode *vp = ap->a_vp;
++ struct vboxfs_node *np, *dir;
++
++ int error;
++
++ MPASS(VOP_ISLOCKED(dvp));
++ MPASS(VOP_ISLOCKED(vp));
++
++ error = 0;
++
++ np = VP_TO_VBOXFS_NODE(vp);
++ dir = VP_TO_VBOXFS_NODE(vp);
++
++ /*
++ * If anything else is using this vnode, then fail the remove.
++ * Why? Windows hosts can't sfprov_remove() a file that is open,
++ * so we have to sfprov_close() it first.
++ * There is no errno for this - since it's not a problem on UNIX,
++ * but ETXTBSY is the closest.
++ */
++ if (np->sf_file != NULL) {
++ if (vp->v_usecount > 1) {
++ error = ETXTBSY;
++ goto out;
++ }
++ sfprov_close(np->sf_file);
++ np->sf_file = NULL;
++ }
++
++ error = sfprov_rmdir(np->vboxfsmp->sf_handle, np->sf_path);
++
++#if 0
++ if (error == ENOENT || error == 0)
++ sfnode_make_stale(np);
++#endif
++
++ if (error == 0)
++ vfsnode_clear_dir_list(dir);
++
++out:
++ return (error);
+ }
+
+-static int vboxvfs_reclaim(struct vop_reclaim_args *ap)
++static int
++vboxfs_readdir(struct vop_readdir_args *ap)
+ {
+- return 0;
++ int *eofp = ap->a_eofflag;
++ struct vnode *vp = ap->a_vp;
++ struct uio *uio = ap->a_uio;
++ struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(vp);
++ struct vboxfs_node *node;
++ struct sffs_dirent *dirent = NULL;
++ sffs_dirents_t *cur_buf;
++ off_t offset = 0;
++ off_t orig_off = uio->uio_offset;
++ int error = 0;
++ int dummy_eof;
++
++ if (vp->v_type != VDIR)
++ return (ENOTDIR);
++
++ if (eofp == NULL)
++ eofp = &dummy_eof;
++ *eofp = 0;
++
++ /*
++ * Get the directory entry names from the host. This gets all
++ * entries. These are stored in a linked list of sffs_dirents_t
++ * buffers, each of which contains a list of dirent64_t's.
++ */
++ if (dir->sf_dir_list == NULL) {
++ error = sfprov_readdir(dir->vboxfsmp->sf_handle, dir->sf_path,
++ &dir->sf_dir_list);
++ if (error != 0)
++ goto done;
++ }
++
++ /*
++ * Validate and skip to the desired offset.
++ */
++ cur_buf = dir->sf_dir_list;
++ offset = 0;
++
++ while (cur_buf != NULL && offset + cur_buf->sf_len <= uio->uio_offset) {
++ offset += cur_buf->sf_len;
++ cur_buf = cur_buf->sf_next;
++ }
++
++ if (cur_buf == NULL && offset != uio->uio_offset) {
++ error = EINVAL;
++ goto done;
++ }
++
++ if (cur_buf != NULL && offset != uio->uio_offset) {
++ off_t off = offset;
++ int step;
++ dirent = &cur_buf->sf_entries[0];
++
++ while (off < uio->uio_offset) {
++ if (dirent->sf_off == uio->uio_offset)
++ break;
++ step = sizeof(struct sffs_dirent) + dirent->sf_entry.d_reclen;
++ dirent = (struct sffs_dirent *) (((char *) dirent) + step);
++ off += step;
++ }
++
++ if (off >= uio->uio_offset) {
++ error = EINVAL;
++ goto done;
++ }
++ }
++
++ offset = uio->uio_offset - offset;
++
++ /*
++ * Lookup each of the names, so that we have ino's, and copy to
++ * result buffer.
++ */
++ while (cur_buf != NULL) {
++ if (offset >= cur_buf->sf_len) {
++ cur_buf = cur_buf->sf_next;
++ offset = 0;
++ continue;
++ }
++
++ dirent = (struct sffs_dirent *)
++ (((char *) &cur_buf->sf_entries[0]) + offset);
++ if (dirent->sf_entry.d_reclen > uio->uio_resid)
++ break;
++
++ if (strcmp(dirent->sf_entry.d_name, ".") == 0) {
++ node = dir;
++ } else if (strcmp(dirent->sf_entry.d_name, "..") == 0) {
++ node = dir->sf_parent;
++ if (node == NULL)
++ node = dir;
++ } else {
++#if 0
++ node = vsfnode_lookup(dir, dirent->sf_entry.d_name, VNON,
++ 0, &dirent->sf_stat, vsfnode_cur_time_usec(), NULL);
++ if (node == NULL)
++ panic("sffs_readdir() lookup failed");
++#endif
++ }
++
++ if (node)
++ dirent->sf_entry.d_fileno = node->sf_ino;
++ else
++ dirent->sf_entry.d_fileno = 0xdeadbeef;
++
++ error = uiomove(&dirent->sf_entry, dirent->sf_entry.d_reclen, uio);
++ if (error != 0)
++ break;
++
++ uio->uio_offset = dirent->sf_off;
++ offset += sizeof(struct sffs_dirent) + dirent->sf_entry.d_reclen;
++ }
++
++ if (error == 0 && cur_buf == NULL)
++ *eofp = 1;
++done:
++ if (error != 0)
++ uio->uio_offset = orig_off;
++ return (error);
+ }
+
+-static int vboxvfs_getpages(struct vop_getpages_args *ap)
++static int
++vboxfs_readlink(struct vop_readlink_args *v)
+ {
+- return 0;
++ struct vnode *vp = v->a_vp;
++ struct uio *uio = v->a_uio;
++
++ int error;
++ struct vboxfs_node *np;
++ void *tmpbuf;
++
++ MPASS(uio->uio_offset == 0);
++ MPASS(vp->v_type == VLNK);
++
++ np = VP_TO_VBOXFS_NODE(vp);
++
++ tmpbuf = contigmalloc(MAXPATHLEN, M_DEVBUF, M_WAITOK, 0, ~0, 1, 0);
++ if (tmpbuf == NULL)
++ return (ENOMEM);
++
++ error = sfprov_readlink(np->vboxfsmp->sf_handle, np->sf_path, tmpbuf,
++ MAXPATHLEN);
++ if (error)
++ goto done;
++
++ error = uiomove(tmpbuf, strlen(tmpbuf), uio);
++
++done:
++ if (tmpbuf)
++ contigfree(tmpbuf, MAXPATHLEN, M_DEVBUF);
++ return (error);
+ }
+
+-static int vboxvfs_putpages(struct vop_putpages_args *ap)
++static int
++vboxfs_fsync(struct vop_fsync_args *ap)
+ {
+- return 0;
++ struct vnode *vp;
++ struct vboxfs_node *np;
++ int ret;
++
++ vp = ap->a_vp;
++ np = VP_TO_VBOXFS_NODE(vp);
++ if (np == NULL)
++ return (0);
++ ret = sfprov_fsync(np->sf_file);
++ return (ret);
+ }
+
++static int
++vboxfs_print(struct vop_print_args *ap)
++{
++ struct vnode *vp = ap->a_vp;
++ struct vboxfs_node *np;
++
++ np = VP_TO_VBOXFS_NODE(vp);
++
++ if (np == NULL) {
++ printf("No vboxfs_node data\n");
++ return (0);
++ }
++
++ printf("\tpath = %s, parent = %p", np->sf_path,
++ np->sf_parent ? np->sf_parent : NULL);
++ printf("\n");
++ return (0);
++}
++
++static int
++vboxfs_pathconf(struct vop_pathconf_args *ap)
++{
++ register_t *retval = ap->a_retval;
++ int error = 0;
++
++ switch (ap->a_name) {
++ case _PC_LINK_MAX:
++ *retval = 65535;
++ break;
++ case _PC_NAME_MAX:
++ *retval = NAME_MAX;
++ break;
++ case _PC_PATH_MAX:
++ *retval = PATH_MAX;
++ break;
++ default:
++ error = EINVAL;
++ break;
++ }
++ return (error);
++}
++
++/*
++ * File specific ioctls.
++ */
++static int
++vboxfs_ioctl(struct vop_ioctl_args *ap)
++{
++ return (ENOTTY);
++}
++
++/*
++ * Lookup an entry in a directory and create a new vnode if found.
++ */
++static int
++vboxfs_lookup(struct vop_cachedlookup_args /* {
++ struct vnodeop_desc *a_desc;
++ struct vnode *a_dvp;
++ struct vnode **a_vpp;
++ struct componentname *a_cnp;
++ } */ *ap)
++{
++ struct componentname *cnp = ap->a_cnp;
++ struct vnode *dvp = ap->a_dvp; /* the directory vnode */
++ char *nameptr = cnp->cn_nameptr; /* the name of the file or directory */
++ struct vnode **vpp = ap->a_vpp; /* the vnode we found or NULL */
++ struct vnode *tdp = NULL;
++ struct vboxfs_node *node = VP_TO_VBOXFS_NODE(dvp);
++ struct vboxfs_mnt *vboxfsmp = node->vboxfsmp;
++ u_long nameiop = cnp->cn_nameiop;
++ u_long flags = cnp->cn_flags;
++ sffs_stat_t stat;
++ //long namelen;
++ ino_t id = 0;
++ int ltype, type, error = 0;
++ int lkflags = cnp->cn_lkflags;
++ char *fullpath = NULL;
++
++ error = ENOENT;
++ if (cnp->cn_flags & ISDOTDOT) {
++ error = vn_vget_ino_gen(dvp, vboxfs_vn_get_ino_alloc,
++ node->sf_parent, cnp->cn_lkflags, vpp);
++ error = ENOENT;
++ if (error != 0)
++ goto out;
++
++ } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
++ VREF(dvp);
++ *vpp = dvp;
++ error = 0;
++ } else {
++ mode_t m;
++ type = VNON;
++ fullpath = sfnode_construct_path(node, cnp->cn_nameptr, cnp->cn_namelen);
++ error = sfprov_get_attr(node->vboxfsmp->sf_handle,
++ fullpath, &stat);
++ // stat_time = vsfnode_cur_time_usec();
++
++ m = stat.sf_mode;
++ if (error != 0) {
++ /* The entry was not found in the directory.
++ * This is OK if we are creating or renaming an
++ * entry and are working on the last component of
++ * the path name. */
++ if ((cnp->cn_flags & ISLASTCN) &&
++ (cnp->cn_nameiop == CREATE || \
++ cnp->cn_nameiop == RENAME ||
++ (cnp->cn_nameiop == DELETE &&
++ cnp->cn_flags & DOWHITEOUT &&
++ cnp->cn_flags & ISWHITEOUT))) {
++ error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
++ cnp->cn_thread);
++ if (error != 0)
++ goto out;
++
++ /* Keep the component name in the buffer for
++ * future uses. */
++ cnp->cn_flags |= SAVENAME;
++
++ error = EJUSTRETURN;
++ } else
++ error = ENOENT;
++ }
++ else {
++ if (S_ISDIR(m))
++ type = VDIR;
++ else if (S_ISREG(m))
++ type = VREG;
++ else if (S_ISLNK(m))
++ type = VLNK;
++ error = vboxfs_alloc_file(vboxfsmp, fullpath, type, 0755, node, cnp->cn_lkflags, vpp);
++ }
++ }
++
++ if ((cnp->cn_flags & MAKEENTRY) != 0)
++ cache_enter(dvp, *vpp, cnp);
++out:
++ if (fullpath)
++ free(fullpath, M_VBOXVFS);
++
++ return (error);
++}
++
++static int
++vboxfs_inactive(struct vop_inactive_args *ap)
++{
++ return (0);
++}
++
++static int
++vboxfs_reclaim(struct vop_reclaim_args *ap)
++{
++ struct vnode *vp;
++ struct vboxfs_node *node;
++ struct vboxfs_mnt *vboxfsmp;
++
++ vp = ap->a_vp;
++ node = VP_TO_VBOXFS_NODE(vp);
++ vboxfsmp = node->vboxfsmp;
++
++ vnode_destroy_vobject(vp);
++ vp->v_object = NULL;
++ cache_purge(vp);
++
++ VBOXFS_NODE_LOCK(node);
++ VBOXFS_ASSERT_ELOCKED(node);
++ vboxfs_free_vp(vp);
++
++ /* If the node referenced by this vnode was deleted by the user,
++ * we must free its associated data structures (now that the vnode
++ * is being reclaimed). */
++ if ((node->sf_vpstate & VBOXFS_VNODE_ALLOCATING) == 0) {
++ node->sf_vpstate = VBOXFS_VNODE_DOOMED;
++ VBOXFS_NODE_UNLOCK(node);
++ vboxfs_free_node(vboxfsmp, node);
++ } else
++ VBOXFS_NODE_UNLOCK(node);
++
++ MPASS(vp->v_data == NULL);
++
++ return (0);
++}
++
++static int
++vboxfs_vptofh(struct vop_vptofh_args *ap)
++{
++
++ return (EOPNOTSUPP);
++}
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxmouse_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxmouse_Makefile.kmk
new file mode 100644
index 000000000000..afb19c804d7a
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxmouse_Makefile.kmk
@@ -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
+
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxvideo_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxvideo_Makefile.kmk
new file mode 100644
index 000000000000..398c835b4b43
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_x11_vboxvideo_Makefile.kmk
@@ -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
+
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Debugger_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Debugger_Makefile.kmk
new file mode 100644
index 000000000000..9edb9747e085
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Debugger_Makefile.kmk
@@ -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 = \
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp
new file mode 100644
index 000000000000..5362e4029517
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp
@@ -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));
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_vbox-cpuhotplug.dsl b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_PC_vbox-cpuhotplug.dsl
index bfbe891e6bea..bfbe891e6bea 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_vbox-cpuhotplug.dsl
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_PC_vbox-cpuhotplug.dsl
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Storage_DrvHostBase-freebsd.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Storage_DrvHostBase-freebsd.cpp
index 30d4c541aa99..30d4c541aa99 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Storage_DrvHostBase-freebsd.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Devices_Storage_DrvHostBase-freebsd.cpp
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
new file mode 100644
index 000000000000..b3ba3993fe3d
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
@@ -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)
+ {
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
new file mode 100644
index 000000000000..ee9bc539d71f
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
@@ -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
+
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_globals_UIImageTools.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_globals_UIImageTools.cpp
index f2eee8ce26ae..f2eee8ce26ae 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_globals_UIImageTools.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_globals_UIImageTools.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMenuToolBar.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMenuToolBar.cpp
index a481fe55d98c..a481fe55d98c 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMenuToolBar.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMenuToolBar.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMiniToolBar.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMiniToolBar.cpp
index caf25a643fba..caf25a643fba 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMiniToolBar.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIMiniToolBar.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIPopupBox.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIPopupBox.h
index 8ac5c9cce599..8ac5c9cce599 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIPopupBox.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Frontends_VirtualBox_src_widgets_UIPopupBox.h
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_GuestHost_OpenGL_include_chromium.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_GuestHost_OpenGL_include_chromium.h
index 958b7256bbdf..958b7256bbdf 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_GuestHost_OpenGL_include_chromium.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_GuestHost_OpenGL_include_chromium.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
new file mode 100644
index 000000000000..11c13584a97b
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
@@ -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 { \
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
new file mode 100644
index 000000000000..68e5920ecdbc
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
@@ -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. */
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c
new file mode 100644
index 000000000000..63e8769ce7c2
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c
@@ -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;
+ }
+-
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c
index 7476660805bb..7476660805bb 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_VBoxNetFlt-freebsd.c
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk
index d71d05265078..d71d05265078 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_Makefile.kmk
new file mode 100644
index 000000000000..154ce9130b56
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_Makefile.kmk
@@ -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
+
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_HostPower.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_HostPower.h
new file mode 100644
index 000000000000..4c6a36061a8d
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_HostPower.h
@@ -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.
+ */
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Main_include_USBProxyBackend.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_USBProxyBackend.h
index 0f0e71dac2e4..0f0e71dac2e4 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Main_include_USBProxyBackend.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_include_USBProxyBackend.h
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp
index a75feffc7bbf..a75feffc7bbf 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_HostImpl.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_HostImpl.cpp
new file mode 100644
index 000000000000..c7807331a213
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_HostImpl.cpp
@@ -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);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_freebsd_NetIf-freebsd.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_NetIf-freebsd.cpp
index f493bb8c154b..f493bb8c154b 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_freebsd_NetIf-freebsd.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_NetIf-freebsd.cpp
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_PerformanceFreeBSD.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_PerformanceFreeBSD.cpp
new file mode 100644
index 000000000000..631547ac9cee
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Main_src-server_freebsd_PerformanceFreeBSD.cpp
@@ -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;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_RDP-client-1.8.4-Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_RDP-client-1.8.4-Makefile.kmk
index 9a65cb1f06d8..9a65cb1f06d8 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_RDP-client-1.8.4-Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_RDP-client-1.8.4-Makefile.kmk
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_common_err_RTErrConvertFromErrno.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_common_err_RTErrConvertFromErrno.cpp
index 928bf1fdac54..928bf1fdac54 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_common_err_RTErrConvertFromErrno.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_common_err_RTErrConvertFromErrno.cpp
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c
new file mode 100644
index 000000000000..b82ec16c3ccc
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c
@@ -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();
+ }
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c
new file mode 100644
index 000000000000..4ad72bc7dd59
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c
@@ -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();
+ }
+
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c
new file mode 100644
index 000000000000..51111ee95102
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c
@@ -0,0 +1,490 @@
+--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig 2020-07-09 16:57:38 UTC
++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
+@@ -105,6 +105,7 @@ static vm_map_t rtR0MemObjFreeBSDGetMap(PRTR0MEMOBJINT
+
+ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)pMem;
+ int rc;
+
+@@ -121,16 +122,15 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
+
+ case RTR0MEMOBJTYPE_LOCK:
+ {
+- vm_map_t pMap = kernel_map;
++ if (pMemFreeBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS) {
++ vm_map_t pMap = &((struct proc *)pMemFreeBSD->Core.u.Lock.R0Process)->p_vmspace->vm_map;
+
+- if (pMemFreeBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
+- pMap = &((struct proc *)pMemFreeBSD->Core.u.Lock.R0Process)->p_vmspace->vm_map;
+-
+- rc = vm_map_unwire(pMap,
++ rc = vm_map_unwire(pMap,
+ (vm_offset_t)pMemFreeBSD->Core.pv,
+ (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb,
+ VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
+- AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
++ AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
++ }
+ break;
+ }
+
+@@ -194,6 +194,7 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
+ return VERR_INTERNAL_ERROR;
+ }
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -224,18 +225,23 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelpe
+ #else
+ VM_OBJECT_UNLOCK(pObject);
+ #endif
+- if (pPages)
++ if (pPages || cTries >= 1)
+ break;
++#if __FreeBSD_version >= 1100092
++ if (!vm_page_reclaim_contig(fFlags, cPages, 0, VmPhysAddrHigh, uAlignment, 0))
++ break;
++#elif __FreeBSD_version >= 1000015
+ vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
++#else
++ vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
++#endif
+ cTries++;
+ }
+-
+- return pPages;
+ #else
+- while (cTries <= 1)
++ while (1)
+ {
+ pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
+- if (pPages)
++ if (pPages || cTries >= 1)
+ break;
+ vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
+ cTries++;
+@@ -243,11 +249,8 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelpe
+
+ if (!pPages)
+ return pPages;
+-#if __FreeBSD_version >= 1000030
+- VM_OBJECT_WLOCK(pObject);
+-#else
++
+ VM_OBJECT_LOCK(pObject);
+-#endif
+ for (vm_pindex_t iPage = 0; iPage < cPages; iPage++)
+ {
+ vm_page_t pPage = pPages + iPage;
+@@ -259,13 +262,9 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelpe
+ atomic_add_int(&cnt.v_wire_count, 1);
+ }
+ }
+-#if __FreeBSD_version >= 1000030
+- VM_OBJECT_WUNLOCK(pObject);
+-#else
+ VM_OBJECT_UNLOCK(pObject);
+ #endif
+ return pPages;
+-#endif
+ }
+
+ static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
+@@ -292,16 +291,17 @@ static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_
+ #else
+ VM_OBJECT_LOCK(pObject);
+ #endif
++
+ while (iPage-- > 0)
+ {
+ pPage = vm_page_lookup(pObject, iPage);
+-#if __FreeBSD_version < 1000000
++#if __FreeBSD_version < 900000
+ vm_page_lock_queues();
+ #endif
+ if (fWire)
+ vm_page_unwire(pPage, 0);
+ vm_page_free(pPage);
+-#if __FreeBSD_version < 1000000
++#if __FreeBSD_version < 900000
+ vm_page_unlock_queues();
+ #endif
+ }
+@@ -323,7 +323,8 @@ static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFRE
+ size_t cPages = atop(pMemFreeBSD->Core.cb);
+ int rc;
+
+- pMemFreeBSD->pObject = vm_object_allocate(OBJT_PHYS, cPages);
++ pMemFreeBSD->pObject = vm_pager_allocate(OBJT_PHYS, NULL,
++ pMemFreeBSD->Core.cb, VM_PROT_ALL, 0, curthread->td_ucred);
+
+ /* No additional object reference for auto-deallocation upon unmapping. */
+ #if __FreeBSD_version >= 1000055
+@@ -364,58 +365,77 @@ static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFRE
+ }
+ DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD),
+ RTR0MEMOBJTYPE_PAGE, NULL, cb);
+ if (!pMemFreeBSD)
++ {
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
++ }
+
+ int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, ~(vm_paddr_t)0, false, VERR_NO_MEMORY);
+ if (RT_FAILURE(rc))
+ {
+ rtR0MemObjDelete(&pMemFreeBSD->Core);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+
+ DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD),
+ RTR0MEMOBJTYPE_LOW, NULL, cb);
+ if (!pMemFreeBSD)
++ {
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
++ }
+
+ int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G - 1, false, VERR_NO_LOW_MEMORY);
+ if (RT_FAILURE(rc))
+ {
+ rtR0MemObjDelete(&pMemFreeBSD->Core);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+
+ DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD),
+ RTR0MEMOBJTYPE_CONT, NULL, cb);
+ if (!pMemFreeBSD)
++ {
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
++ }
+
+ int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G - 1, true, VERR_NO_CONT_MEMORY);
+ if (RT_FAILURE(rc))
+ {
+ rtR0MemObjDelete(&pMemFreeBSD->Core);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+ pMemFreeBSD->Core.u.Cont.Phys = vtophys(pMemFreeBSD->Core.pv);
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+@@ -425,6 +445,7 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
+ RTHCPHYS PhysHighest, size_t uAlignment,
+ bool fContiguous, int rcNoMem)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ uint32_t cPages = atop(cb);
+ vm_paddr_t VmPhysAddrHigh;
+
+@@ -432,9 +453,13 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD),
+ enmType, NULL, cb);
+ if (!pMemFreeBSD)
++ {
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
++ }
+
+- pMemFreeBSD->pObject = vm_object_allocate(OBJT_PHYS, atop(cb));
++ pMemFreeBSD->pObject = vm_pager_allocate(OBJT_PHYS, NULL,
++ pMemFreeBSD->Core.cb, VM_PROT_ALL, 0, curthread->td_ucred);
+
+ if (PhysHighest != NIL_RTHCPHYS)
+ VmPhysAddrHigh = PhysHighest;
+@@ -470,6 +495,7 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
+ rtR0MemObjDelete(&pMemFreeBSD->Core);
+ }
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
+@@ -489,17 +515,22 @@ DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMO
+ DECLHIDDEN(int) rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
+ {
+ AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_SUPPORTED);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ /* create the object. */
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD), RTR0MEMOBJTYPE_PHYS, NULL, cb);
+ if (!pMemFreeBSD)
++ {
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
++ }
+
+ /* there is no allocation here, it needs to be mapped somewhere first. */
+ pMemFreeBSD->Core.u.Phys.fAllocated = false;
+ pMemFreeBSD->Core.u.Phys.PhysBase = Phys;
+ pMemFreeBSD->Core.u.Phys.uCachePolicy = uCachePolicy;
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -511,6 +542,7 @@ static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTER
+ vm_offset_t AddrStart, size_t cb, uint32_t fAccess,
+ RTR0PROCESS R0Process, int fFlags)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ int rc;
+ NOREF(fAccess);
+
+@@ -519,21 +551,28 @@ static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTER
+ if (!pMemFreeBSD)
+ return VERR_NO_MEMORY;
+
+- /*
+- * We could've used vslock here, but we don't wish to be subject to
+- * resource usage restrictions, so we'll call vm_map_wire directly.
+- */
+- rc = vm_map_wire(pVmMap, /* the map */
+- AddrStart, /* start */
+- AddrStart + cb, /* end */
+- fFlags); /* flags */
++ if (pVmMap != kernel_map) {
++ /*
++ * We could've used vslock here, but we don't wish to be subject to
++ * resource usage restrictions, so we'll call vm_map_wire directly.
++ */
++ rc = vm_map_wire(pVmMap, /* the map */
++ AddrStart, /* start */
++ AddrStart + cb, /* end */
++ fFlags); /* flags */
++ }
++ else
++ rc = KERN_SUCCESS;
++
+ if (rc == KERN_SUCCESS)
+ {
+ pMemFreeBSD->Core.u.Lock.R0Process = R0Process;
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+ rtR0MemObjDelete(&pMemFreeBSD->Core);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;/** @todo fix mach -> vbox error conversion for freebsd. */
+ }
+
+@@ -569,6 +608,7 @@ DECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOB
+ */
+ static int rtR0MemObjNativeReserveInMap(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process, vm_map_t pMap)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ int rc;
+
+ /*
+@@ -626,11 +666,13 @@ static int rtR0MemObjNativeReserveInMap(PPRTR0MEMOBJIN
+ pMemFreeBSD->Core.pv = (void *)MapAddress;
+ pMemFreeBSD->Core.u.ResVirt.R0Process = R0Process;
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+ rc = VERR_NO_MEMORY; /** @todo fix translation (borrow from darwin) */
+ rtR0MemObjDelete(&pMemFreeBSD->Core);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+
+ }
+@@ -652,6 +694,8 @@ DECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMO
+ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
+ unsigned fProt, size_t offSub, size_t cbSub)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ // AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
+ AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
+
+@@ -707,6 +751,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
+ Assert((vm_offset_t)pMemFreeBSD->Core.pv == Addr);
+ pMemFreeBSD->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+ rc = vm_map_remove(kernel_map, Addr, Addr + cbSub);
+@@ -715,6 +760,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
+ else
+ vm_object_deallocate(pMemToMapFreeBSD->pObject);
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
+ }
+
+@@ -722,6 +768,8 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
+ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
+ unsigned fProt, RTR0PROCESS R0Process)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ /*
+ * Check for unsupported stuff.
+ */
+@@ -751,7 +799,12 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+ {
+ /** @todo is this needed?. */
+ PROC_LOCK(pProc);
+- AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr + lim_max(pProc, RLIMIT_DATA));
++ AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr +
++#if __FreeBSD_version >= 1100077
++ lim_max_proc(pProc, RLIMIT_DATA));
++#else
++ lim_max(pProc, RLIMIT_DATA));
++#endif
+ PROC_UNLOCK(pProc);
+ }
+ else
+@@ -774,10 +827,9 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+ 0); /* copy-on-write and similar flags */
+
+ if (rc == KERN_SUCCESS)
+- {
+ rc = vm_map_wire(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
+- AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
+-
++ if (rc == KERN_SUCCESS)
++ {
+ rc = vm_map_inherit(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_INHERIT_SHARE);
+ AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
+
+@@ -793,6 +845,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+ Assert((vm_offset_t)pMemFreeBSD->Core.pv == AddrR3);
+ pMemFreeBSD->Core.u.Mapping.R0Process = R0Process;
+ *ppMem = &pMemFreeBSD->Core;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -802,19 +855,25 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+ else
+ vm_object_deallocate(pMemToMapFreeBSD->pObject);
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
+ }
+
+
+ DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINTERNAL pMem, size_t offSub, size_t cbSub, uint32_t fProt)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ vm_prot_t ProtectionFlags = 0;
+ vm_offset_t AddrStart = (uintptr_t)pMem->pv + offSub;
+ vm_offset_t AddrEnd = AddrStart + cbSub;
+ vm_map_t pVmMap = rtR0MemObjFreeBSDGetMap(pMem);
+
+ if (!pVmMap)
++ {
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NOT_SUPPORTED;
++ }
+
+ if ((fProt & RTMEM_PROT_NONE) == RTMEM_PROT_NONE)
+ ProtectionFlags = VM_PROT_NONE;
+@@ -825,7 +884,12 @@ DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINT
+ if ((fProt & RTMEM_PROT_EXEC) == RTMEM_PROT_EXEC)
+ ProtectionFlags |= VM_PROT_EXECUTE;
+
++#if __FreeBSD_version >= 1300135
++ int krc = vm_map_protect(pVmMap, AddrStart, AddrEnd, ProtectionFlags, 0, VM_MAP_PROTECT_SET_PROT);
++#else
+ int krc = vm_map_protect(pVmMap, AddrStart, AddrEnd, ProtectionFlags, FALSE);
++#endif
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ if (krc == KERN_SUCCESS)
+ return VINF_SUCCESS;
+
+@@ -850,11 +914,19 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
+
+ vm_offset_t pb = (vm_offset_t)pMemFreeBSD->Core.pv + ptoa(iPage);
+
+- struct proc *pProc = (struct proc *)pMemFreeBSD->Core.u.Lock.R0Process;
+- struct vm_map *pProcMap = &pProc->p_vmspace->vm_map;
+- pmap_t pPhysicalMap = vm_map_pmap(pProcMap);
++ if (pMemFreeBSD->Core.u.Mapping.R0Process != NIL_RTR0PROCESS)
++ {
++ RTHCPHYS addr;
++ IPRT_FREEBSD_SAVE_EFL_AC();
++ struct proc *pProc = (struct proc *)pMemFreeBSD->Core.u.Lock.R0Process;
++ struct vm_map *pProcMap = &pProc->p_vmspace->vm_map;
++ pmap_t pPhysicalMap = vm_map_pmap(pProcMap);
+
+- return pmap_extract(pPhysicalMap, pb);
++ addr = pmap_extract(pPhysicalMap, pb);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
++ return addr;
++ }
++ return vtophys(pb);
+ }
+
+ case RTR0MEMOBJTYPE_MAPPING:
+@@ -863,11 +935,15 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
+
+ if (pMemFreeBSD->Core.u.Mapping.R0Process != NIL_RTR0PROCESS)
+ {
++ RTHCPHYS addr;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ struct proc *pProc = (struct proc *)pMemFreeBSD->Core.u.Mapping.R0Process;
+ struct vm_map *pProcMap = &pProc->p_vmspace->vm_map;
+ pmap_t pPhysicalMap = vm_map_pmap(pProcMap);
+
+- return pmap_extract(pPhysicalMap, pb);
++ addr = pmap_extract(pPhysicalMap, pb);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
++ return addr;
+ }
+ return vtophys(pb);
+ }
+@@ -877,6 +953,7 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
+ case RTR0MEMOBJTYPE_PHYS_NC:
+ {
+ RTHCPHYS addr;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ #if __FreeBSD_version >= 1000030
+ VM_OBJECT_WLOCK(pMemFreeBSD->pObject);
+ #else
+@@ -888,6 +965,7 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
+ #else
+ VM_OBJECT_UNLOCK(pMemFreeBSD->pObject);
+ #endif
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return addr;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memuserkernel-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memuserkernel-r0drv-freebsd.c
new file mode 100644
index 000000000000..53bac187bde0
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_memuserkernel-r0drv-freebsd.c
@@ -0,0 +1,22 @@
+--- src/VBox/Runtime/r0drv/freebsd/memuserkernel-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/memuserkernel-r0drv-freebsd.c
+@@ -36,7 +36,9 @@
+
+ RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ int rc = copyin((const void *)R3PtrSrc, pvDst, cb);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ if (RT_LIKELY(rc == 0))
+ return VINF_SUCCESS;
+ return VERR_ACCESS_DENIED;
+@@ -45,7 +47,9 @@ RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR
+
+ RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ int rc = copyout(pvSrc, (void *)R3PtrDst, cb);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ if (RT_LIKELY(rc == 0))
+ return VINF_SUCCESS;
+ return VERR_ACCESS_DENIED;
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c
new file mode 100644
index 000000000000..1de5b95f38b0
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c
@@ -0,0 +1,159 @@
+--- src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c
+@@ -36,6 +36,15 @@
+ #include <iprt/cpuset.h>
+ #include "r0drv/mp-r0drv.h"
+
++#if __FreeBSD_version >= 700000 && __FreeBSD_version < 900000
++#define cpuset_t cpumask_t
++#define all_cpus (~(cpumask_t)0)
++#define CPU_CLR(n, p) do { *(p) &= ~((cpumask_t)1 << (n)); } while (0)
++#define CPU_SETOF(n, p) do { *(p) = (cpumask_t)1 << (n); } while (0)
++#endif
++#if __FreeBSD_version < 1200028
++#define smp_no_rendezvous_barrier smp_no_rendevous_barrier
++#endif
+
+ RTDECL(RTCPUID) RTMpCpuId(void)
+ {
+@@ -143,7 +152,9 @@ RTDECL(RTCPUID) RTMpGetOnlineCount(void)
+ static void rtmpOnAllFreeBSDWrapper(void *pvArg)
+ {
+ PRTMPARGS pArgs = (PRTMPARGS)pvArg;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ pArgs->pfnWorker(curcpu, pArgs->pvUser1, pArgs->pvUser2);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ }
+
+
+@@ -155,7 +166,9 @@ RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *p
+ Args.pvUser2 = pvUser2;
+ Args.idCpu = NIL_RTCPUID;
+ Args.cHits = 0;
+- smp_rendezvous(NULL, rtmpOnAllFreeBSDWrapper, smp_no_rendevous_barrier, &Args);
++ IPRT_FREEBSD_SAVE_EFL_AC();
++ smp_rendezvous(NULL, rtmpOnAllFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -171,7 +184,11 @@ static void rtmpOnOthersFreeBSDWrapper(void *pvArg)
+ PRTMPARGS pArgs = (PRTMPARGS)pvArg;
+ RTCPUID idCpu = curcpu;
+ if (pArgs->idCpu != idCpu)
++ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
++ }
+ }
+
+
+@@ -180,10 +197,8 @@ RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void
+ /* Will panic if no rendezvousing cpus, so check up front. */
+ if (RTMpGetOnlineCount() > 1)
+ {
+-#if __FreeBSD_version >= 900000
+- cpuset_t Mask;
+-#elif __FreeBSD_version >= 700000
+- cpumask_t Mask;
++#if __FreeBSD_version >= 700000
++ cpuset_t Cpus;
+ #endif
+ RTMPARGS Args;
+
+@@ -192,17 +207,15 @@ RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void
+ Args.pvUser2 = pvUser2;
+ Args.idCpu = RTMpCpuId();
+ Args.cHits = 0;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ #if __FreeBSD_version >= 700000
+-# if __FreeBSD_version >= 900000
+- Mask = all_cpus;
+- CPU_CLR(curcpu, &Mask);
+-# else
+- Mask = ~(cpumask_t)curcpu;
+-# endif
+- smp_rendezvous_cpus(Mask, NULL, rtmpOnOthersFreeBSDWrapper, smp_no_rendevous_barrier, &Args);
++ Cpus = all_cpus;
++ CPU_CLR(curcpu, &Cpus);
++ smp_rendezvous_cpus(Cpus, NULL, rtmpOnOthersFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
+ #else
+ smp_rendezvous(NULL, rtmpOnOthersFreeBSDWrapper, NULL, &Args);
+ #endif
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ }
+ return VINF_SUCCESS;
+ }
+@@ -220,18 +233,18 @@ static void rtmpOnSpecificFreeBSDWrapper(void *pvArg)
+ RTCPUID idCpu = curcpu;
+ if (pArgs->idCpu == idCpu)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
+ ASMAtomicIncU32(&pArgs->cHits);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ }
+ }
+
+
+ RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
+ {
+-#if __FreeBSD_version >= 900000
+- cpuset_t Mask;
+-#elif __FreeBSD_version >= 700000
+- cpumask_t Mask;
++#if __FreeBSD_version >= 700000
++ cpuset_t Cpus;
+ #endif
+ RTMPARGS Args;
+
+@@ -244,16 +257,14 @@ RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKE
+ Args.pvUser2 = pvUser2;
+ Args.idCpu = idCpu;
+ Args.cHits = 0;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ #if __FreeBSD_version >= 700000
+-# if __FreeBSD_version >= 900000
+- CPU_SETOF(idCpu, &Mask);
+-# else
+- Mask = (cpumask_t)1 << idCpu;
+-# endif
+- smp_rendezvous_cpus(Mask, NULL, rtmpOnSpecificFreeBSDWrapper, smp_no_rendevous_barrier, &Args);
++ CPU_SETOF(idCpu, &Cpus);
++ smp_rendezvous_cpus(Cpus, NULL, rtmpOnSpecificFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
+ #else
+ smp_rendezvous(NULL, rtmpOnSpecificFreeBSDWrapper, NULL, &Args);
+ #endif
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return Args.cHits == 1
+ ? VINF_SUCCESS
+ : VERR_CPU_NOT_FOUND;
+@@ -273,22 +284,16 @@ static void rtmpFreeBSDPokeCallback(void *pvArg)
+
+ RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
+ {
+-#if __FreeBSD_version >= 900000
+- cpuset_t Mask;
+-#elif __FreeBSD_version >= 700000
+- cpumask_t Mask;
+-#endif
++ cpuset_t Cpus;
+
+ /* Will panic if no rendezvousing cpus, so make sure the cpu is online. */
+ if (!RTMpIsCpuOnline(idCpu))
+ return VERR_CPU_NOT_FOUND;
+
+-# if __FreeBSD_version >= 900000
+- CPU_SETOF(idCpu, &Mask);
+-# else
+- Mask = (cpumask_t)1 << idCpu;
+-# endif
+- smp_rendezvous_cpus(Mask, NULL, rtmpFreeBSDPokeCallback, smp_no_rendevous_barrier, NULL);
++ IPRT_FREEBSD_SAVE_EFL_AC();
++ CPU_SETOF(idCpu, &Cpus);
++ smp_rendezvous_cpus(Cpus, NULL, rtmpFreeBSDPokeCallback, smp_no_rendezvous_barrier, NULL);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+
+ return VINF_SUCCESS;
+ }
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c
new file mode 100644
index 000000000000..c570caf8f51b
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c
@@ -0,0 +1,53 @@
+--- src/VBox/Runtime/r0drv/freebsd/semevent-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/semevent-r0drv-freebsd.c
+@@ -77,7 +77,9 @@ RTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem
+ Assert(!(fFlags & RTSEMEVENT_FLAGS_BOOTSTRAP_HACK) || (fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL));
+ AssertPtrReturn(phEventSem, VERR_INVALID_POINTER);
+
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ PRTSEMEVENTINTERNAL pThis = (PRTSEMEVENTINTERNAL)RTMemAllocZ(sizeof(*pThis));
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ if (!pThis)
+ return VERR_NO_MEMORY;
+
+@@ -128,10 +130,12 @@ RTDECL(int) RTSemEventDestroy(RTSEMEVENT hEventSem)
+ /*
+ * Invalidate it and signal the object just in case.
+ */
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ ASMAtomicWriteU32(&pThis->u32Magic, ~RTSEMEVENT_MAGIC);
+ ASMAtomicWriteU32(&pThis->fState, 0);
+ rtR0SemBsdBroadcast(pThis);
+ rtR0SemEventBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -149,9 +153,11 @@ RTDECL(int) RTSemEventSignal(RTSEMEVENT hEventSem)
+ /*
+ * Signal the event object.
+ */
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ ASMAtomicWriteU32(&pThis->fState, 1);
+ rtR0SemBsdSignal(pThis);
+ rtR0SemEventBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -175,6 +181,7 @@ static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis,
+ AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
+ AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
+ AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ rtR0SemEventBsdRetain(pThis);
+
+ /*
+@@ -224,6 +231,7 @@ static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis,
+ }
+
+ rtR0SemEventBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c
new file mode 100644
index 000000000000..af139a58f91c
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c
@@ -0,0 +1,73 @@
+--- src/VBox/Runtime/r0drv/freebsd/semeventmulti-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/semeventmulti-r0drv-freebsd.c
+@@ -96,7 +96,9 @@ RTDECL(int) RTSemEventMultiCreateEx(PRTSEMEVENTMULTI
+ PRTSEMEVENTMULTIINTERNAL pThis;
+
+ AssertReturn(!(fFlags & ~RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ pThis = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pThis));
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ if (pThis)
+ {
+ pThis->u32Magic = RTSEMEVENTMULTI_MAGIC;
+@@ -152,10 +154,12 @@ RTDECL(int) RTSemEventMultiDestroy(RTSEMEVENTMULTI hE
+ /*
+ * Invalidate it and signal the object just in case.
+ */
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ ASMAtomicWriteU32(&pThis->u32Magic, ~RTSEMEVENTMULTI_MAGIC);
+ ASMAtomicAndU32(&pThis->fStateAndGen, RTSEMEVENTMULTIBSD_GEN_MASK);
+ rtR0SemBsdBroadcast(pThis);
+ rtR0SemEventMultiBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -164,6 +168,7 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEv
+ {
+ uint32_t fNew;
+ uint32_t fOld;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ /*
+ * Validate input.
+@@ -190,12 +195,15 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEv
+
+ rtR0SemBsdBroadcast(pThis);
+ rtR0SemEventMultiBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+
+ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEventMultiSem)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ /*
+ * Validate input.
+ */
+@@ -212,6 +220,7 @@ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEve
+ ASMAtomicAndU32(&pThis->fStateAndGen, ~RTSEMEVENTMULTIBSD_STATE_MASK);
+
+ rtR0SemEventMultiBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -228,6 +237,7 @@ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEve
+ static int rtR0SemEventMultiBsdWait(PRTSEMEVENTMULTIINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,
+ PCRTLOCKVALSRCPOS pSrcPos)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ uint32_t fOrgStateAndGen;
+ int rc;
+
+@@ -287,6 +297,7 @@ static int rtR0SemEventMultiBsdWait(PRTSEMEVENTMULTIIN
+ }
+
+ rtR0SemEventMultiBsdRelease(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c
new file mode 100644
index 000000000000..78ecef4a393d
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c
@@ -0,0 +1,59 @@
+--- src/VBox/Runtime/r0drv/freebsd/semfastmutex-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/semfastmutex-r0drv-freebsd.c
+@@ -62,6 +62,7 @@ RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFa
+ {
+ AssertCompile(sizeof(RTSEMFASTMUTEXINTERNAL) > sizeof(void *));
+ AssertPtrReturn(phFastMtx, VERR_INVALID_POINTER);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ PRTSEMFASTMUTEXINTERNAL pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
+ if (pThis)
+@@ -70,8 +71,10 @@ RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFa
+ sx_init_flags(&pThis->SxLock, "IPRT Fast Mutex Semaphore", SX_DUPOK);
+
+ *phFastMtx = pThis;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
+ }
+
+@@ -83,11 +86,13 @@ RTDECL(int) RTSemFastMutexDestroy(RTSEMFASTMUTEX hFas
+ return VINF_SUCCESS;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ ASMAtomicWriteU32(&pThis->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD);
+ sx_destroy(&pThis->SxLock);
+ RTMemFree(pThis);
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -97,8 +102,11 @@ RTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX hFas
+ PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ sx_xlock(&pThis->SxLock);
++
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -108,8 +116,11 @@ RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX hFas
+ PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ sx_xunlock(&pThis->SxLock);
++
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semmutex-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semmutex-r0drv-freebsd.c
new file mode 100644
index 000000000000..6345ae10c562
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_semmutex-r0drv-freebsd.c
@@ -0,0 +1,80 @@
+--- src/VBox/Runtime/r0drv/freebsd/semmutex-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/semmutex-r0drv-freebsd.c
+@@ -62,6 +62,7 @@ RTDECL(int) RTSemMutexCreate(PRTSEMMUTEX phMutexSem)
+ {
+ AssertCompile(sizeof(RTSEMMUTEXINTERNAL) > sizeof(void *));
+ AssertPtrReturn(phMutexSem, VERR_INVALID_POINTER);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ PRTSEMMUTEXINTERNAL pThis = (PRTSEMMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
+ if (pThis)
+@@ -70,8 +71,10 @@ RTDECL(int) RTSemMutexCreate(PRTSEMMUTEX phMutexSem)
+ sx_init_flags(&pThis->SxLock, "IPRT Mutex Semaphore", SX_RECURSE);
+
+ *phMutexSem = pThis;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VERR_NO_MEMORY;
+ }
+
+@@ -83,12 +86,14 @@ RTDECL(int) RTSemMutexDestroy(RTSEMMUTEX hMutexSem)
+ return VINF_SUCCESS;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTSEMMUTEX_MAGIC_DEAD, RTSEMMUTEX_MAGIC), VERR_INVALID_HANDLE);
+
+ sx_destroy(&pThis->SxLock);
+ RTMemFree(pThis);
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -99,6 +104,7 @@ RTDECL(int) RTSemMutexRequest(RTSEMMUTEX hMutexSem, R
+ int rc;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ if (cMillies == RT_INDEFINITE_WAIT)
+ {
+@@ -133,6 +139,7 @@ RTDECL(int) RTSemMutexRequest(RTSEMMUTEX hMutexSem, R
+ } while (RTTimeSystemMilliTS() - StartTS < cMillies);
+ }
+
++ IPRT_FREEBSD_RESTORE_EFL_ONLY_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -149,6 +156,7 @@ RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX hMut
+ int rc;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ if (cMillies == RT_INDEFINITE_WAIT)
+ {
+@@ -186,6 +194,7 @@ RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX hMut
+ } while (RTTimeSystemMilliTS() - StartTS < cMillies);
+ }
+
++ IPRT_FREEBSD_RESTORE_EFL_ONLY_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -201,8 +210,11 @@ RTDECL(int) RTSemMutexRelease(RTSEMMUTEX hMutexSem)
+ PRTSEMMUTEXINTERNAL pThis = hMutexSem;
+ AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+ AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ sx_xunlock(&pThis->SxLock);
++
++ IPRT_FREEBSD_RESTORE_EFL_ONLY_AC();
+ return VINF_SUCCESS;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c
new file mode 100644
index 000000000000..e76621407cea
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c
@@ -0,0 +1,30 @@
+--- src/VBox/Runtime/r0drv/freebsd/spinlock-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/spinlock-r0drv-freebsd.c
+@@ -82,7 +82,9 @@ RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, u
+ * Allocate.
+ */
+ AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAllocZ(sizeof(*pThis));
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ if (!pThis)
+ return VERR_NO_MEMORY;
+
+@@ -116,7 +118,9 @@ RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock)
+ * Make the lock invalid and release the memory.
+ */
+ ASMAtomicIncU32(&pThis->u32Magic);
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ RTMemFree(pThis);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -142,6 +146,7 @@ RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
+ {
+ RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
+ pThis->fIntSaved = fIntSaved;
++ IPRT_FREEBSD_RESTORE_EFL_ONLY_AC_EX(fIntSaved);
+ return;
+ }
+ if (--c <= 0)
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h
new file mode 100644
index 000000000000..47b7121abc8e
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h
@@ -0,0 +1,47 @@
+--- src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h.orig 2020-07-09 16:57:38 UTC
++++ src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h
+@@ -60,6 +60,7 @@
+ #include <sys/smp.h>
+ #include <sys/sleepqueue.h>
+ #include <sys/sx.h>
++#include <sys/vmmeter.h> /* vm_cnt */
+ #include <vm/vm.h>
+ #include <vm/pmap.h> /* for vtophys */
+ #include <vm/vm_map.h>
+@@ -67,10 +68,10 @@
+ #include <vm/vm_kern.h>
+ #include <vm/vm_param.h> /* KERN_SUCCESS ++ */
+ #include <vm/vm_page.h>
++#include <vm/vm_pager.h>
+ #include <vm/vm_phys.h> /* vm_phys_alloc_* */
+ #include <vm/vm_extern.h> /* kmem_alloc_attr */
+ #include <vm/vm_pageout.h> /* vm_contig_grow_cache */
+-#include <sys/vmmeter.h> /* cnt */
+ #include <sys/resourcevar.h>
+ #include <machine/cpu.h>
+
+@@ -114,6 +115,24 @@
+ */
+ #if 0 /** @todo Not available yet. */
+ # define USE_KMEM_ALLOC_PROT
++#endif
++
++/**
++ * Macros for preserving EFLAGS.AC (despair / paranoid)
++ */
++#if __FreeBSD_version >= 1200076 && defined(RT_ARCH_AMD64)
++# include <iprt/asm-amd64-x86.h>
++# include <iprt/x86.h>
++# define IPRT_FREEBSD_SAVE_EFL_AC() RTCCUINTREG const fSavedEfl = ASMGetFlags()
++# define IPRT_FREEBSD_RESTORE_EFL_AC() ASMSetFlags(fSavedEfl)
++# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC() ASMChangeFlags(~X86_EFL_AC, fSavedEfl & X86_EFL_AC)
++# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC_EX(f) ASMChangeFlags(~X86_EFL_AC, (f) & X86_EFL_AC)
++# define VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
++#else
++# define IPRT_FREEBSD_SAVE_EFL_AC() do { } while (0)
++# define IPRT_FREEBSD_RESTORE_EFL_AC() do { } while (0)
++# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC() do { } while (0)
++# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC_EX(f) do { } while (0)
+ #endif
+
+ #endif
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread-r0drv-freebsd.c
new file mode 100644
index 000000000000..2c65ff3a2029
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread-r0drv-freebsd.c
@@ -0,0 +1,99 @@
+--- src/VBox/Runtime/r0drv/freebsd/thread-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/thread-r0drv-freebsd.c
+@@ -49,7 +49,6 @@ RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
+ static int rtR0ThreadFbsdSleepCommon(RTMSINTERVAL cMillies)
+ {
+ int rc;
+- int cTicks;
+
+ /*
+ * 0 ms sleep -> yield.
+@@ -60,11 +59,28 @@ static int rtR0ThreadFbsdSleepCommon(RTMSINTERVAL cMil
+ return VINF_SUCCESS;
+ }
+
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ /*
+ * Translate milliseconds into ticks and go to sleep.
+ */
+ if (cMillies != RT_INDEFINITE_WAIT)
+ {
++#if __FreeBSD_version >= 1000029
++ struct timeval tv;
++
++ tv.tv_sec = cMillies / 1000;
++ tv.tv_usec = cMillies * 1000;
++
++ rc = tsleep_sbt((void *)RTThreadSleep,
++ PZERO | PCATCH,
++ "iprtsl", /* max 6 chars */
++ tvtosbt(tv),
++ 0,
++ C_ABSOLUTE);
++#else
++ int cTicks;
++
+ if (hz == 1000)
+ cTicks = cMillies;
+ else if (hz == 100)
+@@ -76,14 +92,24 @@ static int rtR0ThreadFbsdSleepCommon(RTMSINTERVAL cMil
+ if (cTicks != cTicks64)
+ cTicks = INT_MAX;
+ }
++ if (!cTicks)
++ cTicks = 1;
++
++ rc = tsleep((void *)RTThreadSleep,
++ PZERO | PCATCH,
++ "iprtsl", /* max 6 chars */
++ cTicks);
++#endif
+ }
+ else
+- cTicks = 0; /* requires giant lock! */
+-
+- rc = tsleep((void *)RTThreadSleep,
+- PZERO | PCATCH,
+- "iprtsl", /* max 6 chars */
+- cTicks);
++ {
++ /* requires giant lock! */
++ rc = tsleep((void *)RTThreadSleep,
++ PZERO | PCATCH,
++ "iprts0", /* max 6 chars */
++ 0);
++ }
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ switch (rc)
+ {
+ case 0:
+@@ -114,11 +140,13 @@ RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
+
+ RTDECL(bool) RTThreadYield(void)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ #if __FreeBSD_version >= 900032
+ kern_yield(curthread->td_user_pri);
+ #else
+ uio_yield();
+ #endif
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return false; /** @todo figure this one ... */
+ }
+
+@@ -167,12 +195,14 @@ RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTST
+
+ RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC(); /* paranoia */
+ AssertPtr(pState);
+ Assert(pState->u32Reserved == 42);
+ pState->u32Reserved = 0;
+
+ RT_ASSERT_PREEMPT_CPUID_RESTORE(pState);
+ critical_exit();
++ IPRT_FREEBSD_RESTORE_EFL_ONLY_AC(); /* paranoia */
+ }
+
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c
new file mode 100644
index 000000000000..c2defe1768b9
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c
@@ -0,0 +1,35 @@
+--- src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c
+@@ -70,6 +70,8 @@ DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT
+ return VERR_INVALID_PARAMETER;
+ }
+
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ #if __FreeBSD_version < 700000
+ /* Do like they're doing in subr_ntoskrnl.c... */
+ mtx_lock_spin(&sched_lock);
+@@ -86,6 +88,7 @@ DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT
+ thread_unlock(curthread);
+ #endif
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -135,6 +138,7 @@ static void rtThreadNativeMain(void *pvThreadInt)
+
+ DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
+ int rc;
+ struct proc *pProc;
+
+@@ -150,6 +154,7 @@ DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThr
+ }
+ else
+ rc = RTErrConvertFromErrno(rc);
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return rc;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c
new file mode 100644
index 000000000000..c54138933db1
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c
@@ -0,0 +1,43 @@
+--- src/VBox/Runtime/r0drv/freebsd/time-r0drv-freebsd.c.orig 2016-07-18 11:56:55 UTC
++++ src/VBox/Runtime/r0drv/freebsd/time-r0drv-freebsd.c
+@@ -40,16 +40,23 @@
+
+ RTDECL(uint64_t) RTTimeNanoTS(void)
+ {
+- struct timespec tsp;
+- nanouptime(&tsp);
+- return tsp.tv_sec * RT_NS_1SEC_64
+- + tsp.tv_nsec;
++ struct bintime bt;
++ uint64_t ns;
++ binuptime(&bt);
++ ns = RT_NS_1SEC_64 * bt.sec;
++ ns += (RT_NS_1SEC_64 * (uint32_t)(bt.frac >> 32)) >> 32;
++ return ns;
+ }
+
+
+ RTDECL(uint64_t) RTTimeMilliTS(void)
+ {
+- return RTTimeNanoTS() / RT_NS_1MS;
++ struct bintime bt;
++ uint64_t ms;
++ binuptime(&bt);
++ ms = RT_MS_1SEC_64 * bt.sec;
++ ms += (RT_MS_1SEC_64 * (uint32_t)(bt.frac >> 32)) >> 32;
++ return ms;
+ }
+
+
+@@ -67,8 +74,7 @@ RTDECL(uint64_t) RTTimeSystemMilliTS(voi
+
+ RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
+ {
+- struct timespec tsp;
+- nanotime(&tsp);
+- return RTTimeSpecSetTimespec(pTime, &tsp);
++ struct timespec ts;
++ nanotime(&ts);
++ return RTTimeSpecSetTimespec(pTime, &ts);
+ }
+-
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c
new file mode 100644
index 000000000000..9dc293692223
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c
@@ -0,0 +1,68 @@
+--- src/VBox/Runtime/r0drv/freebsd/timer-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
++++ src/VBox/Runtime/r0drv/freebsd/timer-r0drv-freebsd.c
+@@ -92,6 +92,7 @@ static void rtTimerFreeBSDCallback(void *pvTimer);
+ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_t fFlags, PFNRTTIMER pfnTimer, void *pvUser)
+ {
+ *ppTimer = NULL;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ /*
+ * Validate flags.
+@@ -121,6 +122,7 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_
+ callout_init(&pTimer->Callout, CALLOUT_MPSAFE);
+
+ *ppTimer = pTimer;
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -141,6 +143,8 @@ DECLINLINE(bool) rtTimerIsValid(PRTTIMER pTimer)
+
+ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ /* It's ok to pass NULL pointer. */
+ if (pTimer == /*NIL_RTTIMER*/ NULL)
+ return VINF_SUCCESS;
+@@ -153,6 +157,8 @@ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
+ pTimer->u32Magic++;
+ callout_stop(&pTimer->Callout);
+ RTMemFree(pTimer);
++
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+@@ -160,6 +166,7 @@ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
+ RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
+ {
+ struct timeval tv;
++ IPRT_FREEBSD_SAVE_EFL_AC();
+
+ if (!rtTimerIsValid(pTimer))
+ return VERR_INVALID_HANDLE;
+@@ -183,12 +190,15 @@ RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64
+ tv.tv_usec = (u64First % 1000000000) / 1000;
+ callout_reset(&pTimer->Callout, tvtohz(&tv), rtTimerFreeBSDCallback, pTimer);
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
+
+ RTDECL(int) RTTimerStop(PRTTIMER pTimer)
+ {
++ IPRT_FREEBSD_SAVE_EFL_AC();
++
+ if (!rtTimerIsValid(pTimer))
+ return VERR_INVALID_HANDLE;
+ if (pTimer->fSuspended)
+@@ -200,6 +210,7 @@ RTDECL(int) RTTimerStop(PRTTIMER pTimer)
+ pTimer->fSuspended = true;
+ callout_stop(&pTimer->Callout);
+
++ IPRT_FREEBSD_RESTORE_EFL_AC();
+ return VINF_SUCCESS;
+ }
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_freebsd_systemmem-freebsd.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_freebsd_systemmem-freebsd.cpp
new file mode 100644
index 000000000000..92af93646dd6
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_freebsd_systemmem-freebsd.cpp
@@ -0,0 +1,39 @@
+--- src/VBox/Runtime/r3/freebsd/systemmem-freebsd.cpp.orig 2017-07-27 13:18:46 UTC
++++ src/VBox/Runtime/r3/freebsd/systemmem-freebsd.cpp
+@@ -65,7 +65,6 @@ RTDECL(int) RTSystemQueryAvailableRam(uint64_t *pcb)
+ u_int cPagesMemFree = 0;
+ u_int cPagesMemInactive = 0;
+ u_int cPagesMemCached = 0;
+- u_int cPagesMemUsed = 0;
+ int cbPage = 0;
+ size_t cbParameter;
+ int cProcessed = 0;
+@@ -73,25 +72,23 @@ RTDECL(int) RTSystemQueryAvailableRam(uint64_t *pcb)
+ cbParameter = sizeof(cPagesMemFree);
+ if (sysctlbyname("vm.stats.vm.v_free_count", &cPagesMemFree, &cbParameter, NULL, 0))
+ rc = RTErrConvertFromErrno(errno);
+- cbParameter = sizeof(cPagesMemUsed);
+- if ( RT_SUCCESS(rc)
+- && sysctlbyname("vm.stats.vm.v_active_count", &cPagesMemUsed, &cbParameter, NULL, 0))
+- rc = RTErrConvertFromErrno(errno);
+ cbParameter = sizeof(cPagesMemInactive);
+ if ( RT_SUCCESS(rc)
+ && sysctlbyname("vm.stats.vm.v_inactive_count", &cPagesMemInactive, &cbParameter, NULL, 0))
+ rc = RTErrConvertFromErrno(errno);
++#if __FreeBSD_version < 1200016
+ cbParameter = sizeof(cPagesMemCached);
+ if ( RT_SUCCESS(rc)
+ && sysctlbyname("vm.stats.vm.v_cache_count", &cPagesMemCached, &cbParameter, NULL, 0))
+ rc = RTErrConvertFromErrno(errno);
++#endif
+ cbParameter = sizeof(cbPage);
+ if ( RT_SUCCESS(rc)
+ && sysctlbyname("hw.pagesize", &cbPage, &cbParameter, NULL, 0))
+ rc = RTErrConvertFromErrno(errno);
+
+ if (RT_SUCCESS(rc))
+- *pcb = (cPagesMemFree + cPagesMemInactive + cPagesMemCached ) * cbPage;
++ *pcb = ((uint64_t)cPagesMemFree + cPagesMemInactive + cPagesMemCached) * cbPage;
+
+ return rc;
+ }
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_VMM_VMMR0_GVMMR0.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_VMMR0_GVMMR0.cpp
index 86862b08934e..86862b08934e 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_VMM_VMMR0_GVMMR0.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_VMMR0_GVMMR0.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_VMM_VMMR3_VMReq.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_VMMR3_VMReq.cpp
index 0195d2a4686c..0195d2a4686c 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_VMM_VMMR3_VMReq.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_VMMR3_VMReq.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_VMM_include_IEMInternal.h b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_include_IEMInternal.h
index 8c919adf3f6c..8c919adf3f6c 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_VMM_include_IEMInternal.h
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_VMM_include_IEMInternal.h
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_Makefile.kmk
new file mode 100644
index 000000000000..2ff4313cda89
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_Makefile.kmk
@@ -0,0 +1,11 @@
+--- src/libs/xpcom18a4/Makefile.kmk.orig 2019-01-25 18:32:58 UTC
++++ src/libs/xpcom18a4/Makefile.kmk
+@@ -980,6 +980,8 @@ VBoxXPCOM_LIBS = \
+ $(VBox-xpcom-proxy_1_TARGET) \
+ $(VBox-xpcom-nspr_1_TARGET) \
+ $(VBoxXPCOMGlue_s_1_TARGET)
++VBoxXPCOM_LIBS.freebsd = \
++ pthread
+ VBoxXPCOM_LIBS.linux = \
+ pthread dl
+
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c
new file mode 100644
index 000000000000..971c86938f5e
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c
@@ -0,0 +1,22 @@
+--- src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c.orig 2020-05-13 19:46:23 UTC
++++ src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c
+@@ -49,6 +49,9 @@
+ #include <string.h>
+ #include <pthread.h>
+ #include <sys/time.h>
++#ifdef FREEBSD
++#include <sys/param.h>
++#endif
+
+ static pthread_mutexattr_t _pt_mattr;
+ static pthread_condattr_t _pt_cvar_attr;
+@@ -798,7 +801,8 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *
+ * From the semctl(2) man page in glibc 2.0
+ */
+ #if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \
+- || defined(FREEBSD) || defined(OPENBSD) || defined(BSDI)
++ || (defined(FREEBSD) && __FreeBSD_version < 1200059) \
++ || defined(OPENBSD) || defined(BSDI)
+ /* union semun is defined by including <sys/sem.h> */
+ #else
+ /* according to X/OPEN we have to define it ourselves */
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_io_nsLocalFileUnix.h b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_io_nsLocalFileUnix.h
new file mode 100644
index 000000000000..13af9aa6bffa
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_io_nsLocalFileUnix.h
@@ -0,0 +1,17 @@
+--- src/libs/xpcom18a4/xpcom/io/nsLocalFileUnix.h.orig 2020-05-13 19:46:34 UTC
++++ src/libs/xpcom18a4/xpcom/io/nsLocalFileUnix.h
+@@ -72,14 +72,6 @@
+ #define STATFS statfs
+ #endif
+
+-// so we can statfs on freebsd
+-#if defined(__FreeBSD__)
+- #define HAVE_SYS_STATFS_H
+- #define STATFS statfs
+- #include <sys/param.h>
+- #include <sys/mount.h>
+-#endif
+-
+ class NS_COM nsLocalFile : public nsILocalFile
+ {
+ public:
diff --git a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp
index f1cc9961e1f5..f1cc9961e1f5 100644
--- a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_recompiler_Makefile.kmk b/emulators/virtualbox-ose-legacy/files/patch-src_recompiler_Makefile.kmk
index c3f034ad715c..c3f034ad715c 100644
--- a/emulators/virtualbox-ose/files/patch-src_recompiler_Makefile.kmk
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_recompiler_Makefile.kmk
diff --git a/emulators/virtualbox-ose-legacy/files/vboxheadless.in b/emulators/virtualbox-ose-legacy/files/vboxheadless.in
new file mode 100644
index 000000000000..12c5be979369
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/vboxheadless.in
@@ -0,0 +1,142 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: vboxheadless
+# REQUIRE: LOGIN vboxnet
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxheadless
+#
+# vboxheadless_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable vboxheadless.
+# vboxheadless_machines (str): Space separated list of machines
+# vboxheadless_user (str): Default user account to run with.
+# (default: %%VBOXUSER%%)
+# vboxheadless_stop (str): Default stop cmd for VBoxManage controlvm.
+# (default: savestate)
+# vboxheadless_delay (int): Default startup/shutdown delay in seconds.
+# (default: 0)
+# vboxheadless_<machine>_name (str): Virtualbox machine name or UUID.
+# vboxheadless_<machine>_user (str): User account to run with.
+# vboxheadless_<machine>_flags (str): Additional flags for VBoxHeadless.
+# vboxheadless_<machine>_stop (str): Stop command for VBoxManage controlvm.
+# vboxheadless_<machine>_delay (int): Startup and shutdown delay in seconds.
+
+. /etc/rc.subr
+
+name="vboxheadless"
+rcvar=vboxheadless_enable
+rc_fast="YES"
+
+command="%%VBOXDIR%%/VBoxHeadless"
+pidbase="/var/run/${name}"
+
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+status_cmd="${name}_status"
+
+vboxheadless_start()
+{
+ local machine mpidfile pid vmname vmuser vmflags vmdelay
+
+ echo "Starting Virtual Machines:"
+ for machine in ${vboxheadless_machines}; do
+ mpidfile="${pidbase}_${machine}.pid"
+ pid=$(check_pidfile $mpidfile $command)
+ eval vmname="\${vboxheadless_${machine}_name:-${machine}}"
+ eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}"
+ eval vmflags="\${vboxheadless_${machine}_flags:-}"
+ eval vmdelay="\${vboxheadless_${machine}_delay:-${vboxheadless_delay}}"
+
+ HOME=$(/usr/sbin/pw usershow -7 -n "${vmuser}" | /usr/bin/cut -d: -f6)
+
+ /usr/bin/printf "%25s " "${vmname}"
+
+ /usr/bin/su ${vmuser} -c "%%VBOXDIR%%/VBoxManage showvminfo '${vmname}' >/dev/null" 2>/dev/null
+
+ if [ $? != 0 ]; then
+ echo "Unknown machine"
+ continue
+ fi
+
+ if [ -n "${pid}" ]; then
+ echo "Already running? (pid=${pid})"
+ continue
+ fi
+
+ /bin/sleep ${vmdelay}
+ /usr/bin/install -o ${vmuser} -g %%VBOXGROUP%% -m 644 /dev/null ${mpidfile}
+ /usr/sbin/daemon -f -p ${mpidfile} -u ${vmuser} ${command} --startvm "${vmname}" ${vmflags}
+ echo "Started"
+ done
+}
+
+vboxheadless_stop()
+{
+ local machine mpidfile pid pids vmname vmuser vmstop vmdelay
+
+ echo "Saving states for Virtual Machines:"
+ for machine in ${vboxheadless_machines}; do
+ mpidfile="${pidbase}_${machine}.pid"
+ pid=$(check_pidfile $mpidfile $command)
+ eval vmname="\${vboxheadless_${machine}_name:-${machine}}"
+ eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}"
+ eval vmstop="\${vboxheadless_${machine}_stop:-${vboxheadless_stop}}"
+ eval vmdelay="\${vboxheadless_${machine}_delay:-${vboxheadless_delay}}"
+
+ /usr/bin/printf "%25s " "${vmname}"
+
+ if [ -n "${pid}" ]; then
+ pids="${pids} ${pid}"
+ /bin/sleep ${vmdelay}
+ /usr/bin/su ${vmuser} -c "%%VBOXDIR%%/VBoxManage controlvm '${vmname}' ${vmstop} >/dev/null &" 2>/dev/null
+ fi
+ done
+ if [ -n "${pids}" ]; then
+ wait_for_pids $pids >/dev/null
+ echo "Stopped"
+ else
+ echo "Not running?"
+ fi
+}
+
+vboxheadless_status()
+{
+ local machine mpidfile pid vmname vmuser
+
+ /usr/bin/printf "%25s %s\n" "Machine" "Status"
+ /usr/bin/printf "%25s %s\n" "-------------------------" "------------"
+
+ for machine in ${vboxheadless_machines}; do
+ mpidfile="${pidbase}_${machine}.pid"
+ pid=$(check_pidfile $mpidfile $command)
+ eval vmname="\${vboxheadless_${machine}_name:-${machine}}"
+ eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}"
+
+ /usr/bin/su ${vmuser} -c "%%VBOXDIR%%/VBoxManage showvminfo '${vmname}' >/dev/null" 2>/dev/null
+
+ if [ $? != 0 ]; then
+ /usr/bin/printf "%20s %s\n" "${vmname}" "Unknown Machine"
+ elif [ -n "${pid}" ]; then
+ /usr/bin/printf "%25s %s\n" "${vmname}" "Running"
+ else
+ /usr/bin/printf "%25s %s\n" "${vmname}" "Powered Off"
+ fi
+ done
+}
+
+load_rc_config $name
+
+: ${vboxheadless_enable="NO"}
+: ${vboxheadless_user="%%VBOXUSER%%"}
+: ${vboxheadless_stop="savestate"}
+: ${vboxheadless_delay="0"}
+
+cmd_arg="$1" ; shift
+
+if [ -n "$*" ]; then
+ vboxheadless_machines="$*"
+fi
+
+run_rc_command "${cmd_arg}"
diff --git a/emulators/virtualbox-ose-legacy/files/vboxwatchdog.in b/emulators/virtualbox-ose-legacy/files/vboxwatchdog.in
new file mode 100644
index 000000000000..28af2913d92a
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/vboxwatchdog.in
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: vboxwatchdog
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxwatchdog
+#
+# vboxwatchdog_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable vboxwatchdog.
+# vboxwatchdog_user (str): User account to run with.
+# vboxwatchdog_flags (str): Custom flags for VBoxWatchdog.
+
+. /etc/rc.subr
+
+name=vboxwatchdog
+rcvar=vboxwatchdog_enable
+
+command="%%VBOXDIR%%/VBoxBalloonCtrl"
+pidfile="/var/run/${name}.pid"
+
+start_cmd="${name}_start"
+
+vboxwatchdog_start()
+{
+ local pid
+
+ HOME=$(/usr/sbin/pw usershow -7 -n "${vboxwatchdog_user}" | /usr/bin/cut -d: -f6)
+ pid=$(check_pidfile $pidfile $command)
+
+ if [ -n "${pid}" ]; then
+ echo "${name} already running? (pid=${pid})."
+ return 1
+ fi
+
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+
+ echo -n "Starting ${name}"
+ /usr/bin/install -o ${vboxwatchdog_user} -g %%VBOXGROUP%% -m 644 /dev/null ${pidfile}
+ /usr/sbin/daemon -f -p ${pidfile} -u ${vboxwatchdog_user} ${command} ${vboxwatchdog_flags}
+ echo '.'
+}
+
+load_rc_config $name
+
+: ${vboxwatchdog_enable="NO"}
+: ${vboxwatchdog_user="%%VBOXUSER%%"}
+: ${vboxwatchdog_flags=""}
+
+run_rc_command "$1"
diff --git a/emulators/virtualbox-ose-legacy/files/vboxwebsrv.in b/emulators/virtualbox-ose-legacy/files/vboxwebsrv.in
new file mode 100644
index 000000000000..a421324e5965
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/vboxwebsrv.in
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: vboxwebsrv
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxwebsrv
+#
+# vboxwebsrv_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable vboxwebsrv.
+# vboxwebsrv_user (str): User account to run with.
+# vboxwebsrv_flags (str): Custom flags for vboxwebsrv.
+
+. /etc/rc.subr
+
+name=vboxwebsrv
+rcvar=vboxwebsrv_enable
+
+command="%%VBOXDIR%%/vboxwebsrv"
+pidfile="/var/run/${name}.pid"
+
+start_cmd="${name}_start"
+
+vboxwebsrv_start()
+{
+ local pid
+
+ HOME=$(/usr/sbin/pw usershow -7 -n "${vboxwebsrv_user}" | /usr/bin/cut -d: -f6)
+ pid=$(check_pidfile $pidfile $command)
+
+ if [ -n "${pid}" ]; then
+ echo "${name} already running? (pid=${pid})."
+ return 1
+ fi
+
+ echo -n "Starting ${name}"
+ /usr/bin/install -o ${vboxwebsrv_user} -g %%VBOXGROUP%% -m 644 /dev/null ${pidfile}
+ /usr/sbin/daemon -f -p ${pidfile} -u ${vboxwebsrv_user} ${command} ${vboxwebsrv_flags}
+ echo '.'
+}
+
+load_rc_config $name
+
+: ${vboxwebsrv_enable="NO"}
+: ${vboxwebsrv_user="%%VBOXWSUSER%%"}
+
+run_rc_command "$1"
diff --git a/emulators/virtualbox-ose-legacy/pkg-descr b/emulators/virtualbox-ose-legacy/pkg-descr
new file mode 100644
index 000000000000..e9481f3a81fa
--- /dev/null
+++ b/emulators/virtualbox-ose-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/
diff --git a/emulators/virtualbox-ose-legacy/pkg-message b/emulators/virtualbox-ose-legacy/pkg-message
new file mode 100644
index 000000000000..0cf6996bbefa
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/pkg-message
@@ -0,0 +1,69 @@
+[
+{ type: install
+ message: <<EOM
+VirtualBox was installed.
+
+You need to load the vboxdrv kernel module via /boot/loader.conf:
+
+vboxdrv_load="YES"
+
+You also have to add all users to your vboxusers group in order to use vbox.
+
+% pw groupmod vboxusers -m jerry
+
+Reboot the machine to load the needed kernel modules.
+
+
+Bridging Support:
+=================
+
+For bridged networking please add the following line to your /etc/rc.conf:
+
+vboxnet_enable="YES"
+
+
+USB Support:
+============
+
+For USB support your user needs to be in the operator group and needs read
+and write permissions to the USB device.
+
+% pw groupmod operator -m jerry
+
+Add the following to /etc/devfs.rules (create if it doesn't exist):
+
+[system=10]
+add path 'usb/*' mode 0660 group operator
+
+To load these new rule add the following to /etc/rc.conf:
+
+devfs_system_ruleset="system"
+
+Then restart devfs to load the new rules:
+
+% /etc/rc.d/devfs restart
+
+
+Troubleshooting:
+================
+
+Running VirtualBox as non-root user may fail with a fatal error
+NS_ERROR_FACTORY_NOT_REGISTERED. In this case delete /tmp/.vbox-*-ipc file.
+
+If you experience "Network: write Failed: Cannot allocate memory" errors
+try to increase net.graph.maxdata in /boot/loader.conf
+
+If you are using AIO, then increase these limits (PR#168298):
+vfs.aio.max_buf_aio=8192
+vfs.aio.max_aio_queue_per_proc=65536
+vfs.aio.max_aio_per_proc=8192
+vfs.aio.max_aio_queue=65536
+To check if AIO is used use: kldstat -v | grep aio
+
+Check wiki page for known issues and troubleshooting:
+http://wiki.freebsd.org/VirtualBox
+
+Please report any problems to emulation@. Thanks!
+EOM
+}
+]
diff --git a/emulators/virtualbox-ose-legacy/pkg-plist b/emulators/virtualbox-ose-legacy/pkg-plist
new file mode 100644
index 000000000000..9f2ed04af928
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/pkg-plist
@@ -0,0 +1,612 @@
+bin/VBoxAutostart
+bin/VBoxBalloonCtrl
+bin/VBoxBugReport
+bin/VBoxHeadless
+bin/VBoxManage
+%%X11%%bin/VBoxSDL
+bin/VBoxVRDP
+%%QT%%bin/VirtualBox
+bin/vboxautostart
+bin/vboxballoonctrl
+bin/vboxbugreport
+bin/vboxheadless
+bin/vboxmanage
+%%X11%%bin/vboxsdl
+%%WEBSERVICE%%bin/vboxwebsrv
+%%QT%%bin/virtualbox
+include/virtualbox/VirtualBox_XPCOM.h
+include/virtualbox/ipcIClientObserver.h
+include/virtualbox/ipcIDConnectService.h
+include/virtualbox/ipcILockService.h
+include/virtualbox/ipcIMessageObserver.h
+include/virtualbox/ipcIService.h
+include/virtualbox/ipcITransactionObserver.h
+include/virtualbox/ipcITransactionService.h
+include/virtualbox/nsIArray.h
+include/virtualbox/nsIAsyncInputStream.h
+include/virtualbox/nsIAsyncOutputStream.h
+include/virtualbox/nsIAtom.h
+include/virtualbox/nsIAtomService.h
+include/virtualbox/nsIBinaryInputStream.h
+include/virtualbox/nsIBinaryOutputStream.h
+include/virtualbox/nsIByteArrayInputStream.h
+include/virtualbox/nsICategoryManager.h
+include/virtualbox/nsIClassInfo.h
+include/virtualbox/nsICollection.h
+include/virtualbox/nsIComponentLoader.h
+include/virtualbox/nsIComponentLoaderManager.h
+include/virtualbox/nsIComponentManager.h
+include/virtualbox/nsIComponentManagerObsolete.h
+include/virtualbox/nsIComponentRegistrar.h
+include/virtualbox/nsIConsoleListener.h
+include/virtualbox/nsIConsoleMessage.h
+include/virtualbox/nsIConsoleService.h
+include/virtualbox/nsIDebug.h
+include/virtualbox/nsIDirectoryEnumerator.h
+include/virtualbox/nsIDirectoryService.h
+include/virtualbox/nsIEnumerator.h
+include/virtualbox/nsIEnvironment.h
+include/virtualbox/nsIErrorService.h
+include/virtualbox/nsIEventQueue.h
+include/virtualbox/nsIEventQueueService.h
+include/virtualbox/nsIEventTarget.h
+include/virtualbox/nsIException.h
+include/virtualbox/nsIExceptionService.h
+include/virtualbox/nsIFactory.h
+include/virtualbox/nsIFastLoadFileControl.h
+include/virtualbox/nsIFastLoadService.h
+include/virtualbox/nsIFile.h
+include/virtualbox/nsIHashable.h
+include/virtualbox/nsIInputStream.h
+include/virtualbox/nsIInputStreamTee.h
+include/virtualbox/nsIInterfaceInfo.h
+include/virtualbox/nsIInterfaceInfoManager.h
+include/virtualbox/nsIInterfaceRequestor.h
+include/virtualbox/nsILineInputStream.h
+include/virtualbox/nsILocalFile.h
+include/virtualbox/nsILocalFileMac.h
+include/virtualbox/nsIMemory.h
+include/virtualbox/nsIModule.h
+include/virtualbox/nsIMultiplexInputStream.h
+include/virtualbox/nsINativeComponentLoader.h
+include/virtualbox/nsIObjectInputStream.h
+include/virtualbox/nsIObjectOutputStream.h
+include/virtualbox/nsIObserver.h
+include/virtualbox/nsIObserverService.h
+include/virtualbox/nsIOutputStream.h
+include/virtualbox/nsIPersistentProperties2.h
+include/virtualbox/nsIPipe.h
+include/virtualbox/nsIProcess.h
+include/virtualbox/nsIProgrammingLanguage.h
+include/virtualbox/nsIProperties.h
+include/virtualbox/nsIPropertyBag.h
+include/virtualbox/nsIProxyObjectManager.h
+include/virtualbox/nsIRecyclingAllocator.h
+include/virtualbox/nsIRunnable.h
+include/virtualbox/nsIScriptableInputStream.h
+include/virtualbox/nsISeekableStream.h
+include/virtualbox/nsISerializable.h
+include/virtualbox/nsIServiceManager.h
+include/virtualbox/nsISimpleEnumerator.h
+include/virtualbox/nsIStorageStream.h
+include/virtualbox/nsIStreamBufferAccess.h
+include/virtualbox/nsIStringEnumerator.h
+include/virtualbox/nsIStringStream.h
+include/virtualbox/nsISupports.h
+include/virtualbox/nsISupportsArray.h
+include/virtualbox/nsISupportsIterators.h
+include/virtualbox/nsISupportsPrimitives.h
+include/virtualbox/nsIThread.h
+include/virtualbox/nsITimelineService.h
+include/virtualbox/nsITimer.h
+include/virtualbox/nsITimerInternal.h
+include/virtualbox/nsITimerManager.h
+include/virtualbox/nsITraceRefcnt.h
+include/virtualbox/nsIVariant.h
+include/virtualbox/nsIWeakReference.h
+include/virtualbox/nsIXPTLoader.h
+include/virtualbox/nsrootidl.h
+include/virtualbox/ipcd/ipcCID.h
+include/virtualbox/ipcd/ipcLockCID.h
+include/virtualbox/ipcd/ipcMessageReader.h
+include/virtualbox/ipcd/ipcMessageWriter.h
+include/virtualbox/ipcd/ipcModule.h
+include/virtualbox/ipcd/ipcModuleUtil.h
+include/virtualbox/ipcd/ipcdclient.h
+include/virtualbox/nsprpub/nspr.h
+include/virtualbox/nsprpub/plarena.h
+include/virtualbox/nsprpub/plarenas.h
+include/virtualbox/nsprpub/plbase64.h
+include/virtualbox/nsprpub/plerror.h
+include/virtualbox/nsprpub/plgetopt.h
+include/virtualbox/nsprpub/plhash.h
+include/virtualbox/nsprpub/plresolv.h
+include/virtualbox/nsprpub/plstr.h
+include/virtualbox/nsprpub/pratom.h
+include/virtualbox/nsprpub/prbit.h
+include/virtualbox/nsprpub/prclist.h
+include/virtualbox/nsprpub/prcmon.h
+include/virtualbox/nsprpub/prcountr.h
+include/virtualbox/nsprpub/prcpucfg.h
+include/virtualbox/nsprpub/prcvar.h
+include/virtualbox/nsprpub/prdtoa.h
+include/virtualbox/nsprpub/prenv.h
+include/virtualbox/nsprpub/prerr.h
+include/virtualbox/nsprpub/prerror.h
+include/virtualbox/nsprpub/prinet.h
+include/virtualbox/nsprpub/prinit.h
+include/virtualbox/nsprpub/prinrval.h
+include/virtualbox/nsprpub/prio.h
+include/virtualbox/nsprpub/pripcsem.h
+include/virtualbox/nsprpub/prlink.h
+include/virtualbox/nsprpub/prlock.h
+include/virtualbox/nsprpub/prlog.h
+include/virtualbox/nsprpub/prlong.h
+include/virtualbox/nsprpub/prmem.h
+include/virtualbox/nsprpub/prmon.h
+include/virtualbox/nsprpub/prmwait.h
+include/virtualbox/nsprpub/prnetdb.h
+include/virtualbox/nsprpub/prolock.h
+include/virtualbox/nsprpub/prpdce.h
+include/virtualbox/nsprpub/prprf.h
+include/virtualbox/nsprpub/prproces.h
+include/virtualbox/nsprpub/prrng.h
+include/virtualbox/nsprpub/prrwlock.h
+include/virtualbox/nsprpub/prshm.h
+include/virtualbox/nsprpub/prshma.h
+include/virtualbox/nsprpub/prsystem.h
+include/virtualbox/nsprpub/prthread.h
+include/virtualbox/nsprpub/prtime.h
+include/virtualbox/nsprpub/prtpool.h
+include/virtualbox/nsprpub/prtrace.h
+include/virtualbox/nsprpub/prtypes.h
+include/virtualbox/nsprpub/prvrsion.h
+include/virtualbox/nsprpub/prwin16.h
+include/virtualbox/nsprpub/md/_darwin.cfg
+include/virtualbox/nsprpub/md/_darwin.h
+include/virtualbox/nsprpub/md/_freebsd.cfg
+include/virtualbox/nsprpub/md/_freebsd.h
+include/virtualbox/nsprpub/md/_iprt_atomic.h
+include/virtualbox/nsprpub/md/_linux.cfg
+include/virtualbox/nsprpub/md/_linux.h
+include/virtualbox/nsprpub/md/_macos.h
+include/virtualbox/nsprpub/md/_netbsd.cfg
+include/virtualbox/nsprpub/md/_netbsd.h
+include/virtualbox/nsprpub/md/_openbsd.cfg
+include/virtualbox/nsprpub/md/_openbsd.h
+include/virtualbox/nsprpub/md/_os2.cfg
+include/virtualbox/nsprpub/md/_os2.h
+include/virtualbox/nsprpub/md/_os2_errors.h
+include/virtualbox/nsprpub/md/_pcos.h
+include/virtualbox/nsprpub/md/_pth.h
+include/virtualbox/nsprpub/md/_solaris.h
+include/virtualbox/nsprpub/md/_solaris32.cfg
+include/virtualbox/nsprpub/md/_solaris64.cfg
+include/virtualbox/nsprpub/md/_unix_errors.h
+include/virtualbox/nsprpub/md/_unixos.h
+include/virtualbox/nsprpub/md/prosdep.h
+include/virtualbox/nsprpub/obsolete/pralarm.h
+include/virtualbox/nsprpub/obsolete/probslet.h
+include/virtualbox/nsprpub/obsolete/protypes.h
+include/virtualbox/nsprpub/obsolete/prsem.h
+include/virtualbox/nsprpub/private/pprio.h
+include/virtualbox/nsprpub/private/pprthred.h
+include/virtualbox/nsprpub/private/prpriv.h
+include/virtualbox/string/nsAString.h
+include/virtualbox/string/nsAlgorithm.h
+include/virtualbox/string/nsCharTraits.h
+include/virtualbox/string/nsDependentString.h
+include/virtualbox/string/nsDependentSubstring.h
+include/virtualbox/string/nsEmbedString.h
+include/virtualbox/string/nsLiteralString.h
+include/virtualbox/string/nsObsoleteAString.h
+include/virtualbox/string/nsPrintfCString.h
+include/virtualbox/string/nsPromiseFlatString.h
+include/virtualbox/string/nsReadableUtils.h
+include/virtualbox/string/nsString.h
+include/virtualbox/string/nsStringAPI.h
+include/virtualbox/string/nsStringFwd.h
+include/virtualbox/string/nsStringIterator.h
+include/virtualbox/string/nsSubstring.h
+include/virtualbox/string/nsSubstringTuple.h
+include/virtualbox/string/nsTAString.h
+include/virtualbox/string/nsTDependentString.h
+include/virtualbox/string/nsTDependentSubstring.h
+include/virtualbox/string/nsTObsoleteAString.h
+include/virtualbox/string/nsTPromiseFlatString.h
+include/virtualbox/string/nsTString.h
+include/virtualbox/string/nsTSubstring.h
+include/virtualbox/string/nsTSubstringTuple.h
+include/virtualbox/string/nsUTF8Utils.h
+include/virtualbox/string/nsXPIDLString.h
+include/virtualbox/string/string-template-def-char.h
+include/virtualbox/string/string-template-def-unichar.h
+include/virtualbox/string/string-template-undef.h
+include/virtualbox/xpcom/nsAgg.h
+include/virtualbox/xpcom/nsAppDirectoryServiceDefs.h
+include/virtualbox/xpcom/nsArray.h
+include/virtualbox/xpcom/nsArrayEnumerator.h
+include/virtualbox/xpcom/nsAtomService.h
+include/virtualbox/xpcom/nsAutoBuffer.h
+include/virtualbox/xpcom/nsAutoLock.h
+include/virtualbox/xpcom/nsAutoPtr.h
+include/virtualbox/xpcom/nsBaseHashtable.h
+include/virtualbox/xpcom/nsCOMArray.h
+include/virtualbox/xpcom/nsCOMPtr.h
+include/virtualbox/xpcom/nsCRT.h
+include/virtualbox/xpcom/nsCategoryManagerUtils.h
+include/virtualbox/xpcom/nsCheapSets.h
+include/virtualbox/xpcom/nsClassHashtable.h
+include/virtualbox/xpcom/nsCom.h
+include/virtualbox/xpcom/nsComponentManagerObsolete.h
+include/virtualbox/xpcom/nsComponentManagerUtils.h
+include/virtualbox/xpcom/nsCppSharedAllocator.h
+include/virtualbox/xpcom/nsDataHashtable.h
+include/virtualbox/xpcom/nsDebug.h
+include/virtualbox/xpcom/nsDebugImpl.h
+include/virtualbox/xpcom/nsDeque.h
+include/virtualbox/xpcom/nsDirectoryService.h
+include/virtualbox/xpcom/nsDirectoryServiceDefs.h
+include/virtualbox/xpcom/nsDirectoryServiceUtils.h
+include/virtualbox/xpcom/nsDoubleHashtable.h
+include/virtualbox/xpcom/nsEnumeratorUtils.h
+include/virtualbox/xpcom/nsError.h
+include/virtualbox/xpcom/nsEscape.h
+include/virtualbox/xpcom/nsEventQueueUtils.h
+include/virtualbox/xpcom/nsFastLoadPtr.h
+include/virtualbox/xpcom/nsFastLoadService.h
+include/virtualbox/xpcom/nsFixedSizeAllocator.h
+include/virtualbox/xpcom/nsGenericFactory.h
+include/virtualbox/xpcom/nsHashKeys.h
+include/virtualbox/xpcom/nsHashSets.h
+include/virtualbox/xpcom/nsHashtable.h
+include/virtualbox/xpcom/nsIAllocator.h
+include/virtualbox/xpcom/nsIByteBuffer.h
+include/virtualbox/xpcom/nsID.h
+include/virtualbox/xpcom/nsIGenericFactory.h
+include/virtualbox/xpcom/nsIID.h
+include/virtualbox/xpcom/nsIInterfaceRequestorUtils.h
+include/virtualbox/xpcom/nsIServiceManagerObsolete.h
+include/virtualbox/xpcom/nsIServiceManagerUtils.h
+include/virtualbox/xpcom/nsISupportsBase.h
+include/virtualbox/xpcom/nsISupportsImpl.h
+include/virtualbox/xpcom/nsISupportsObsolete.h
+include/virtualbox/xpcom/nsISupportsUtils.h
+include/virtualbox/xpcom/nsIUnicharBuffer.h
+include/virtualbox/xpcom/nsIUnicharInputStream.h
+include/virtualbox/xpcom/nsIWeakReferenceUtils.h
+include/virtualbox/xpcom/nsInt64.h
+include/virtualbox/xpcom/nsInterfaceHashtable.h
+include/virtualbox/xpcom/nsLinebreakConverter.h
+include/virtualbox/xpcom/nsLocalFile.h
+include/virtualbox/xpcom/nsLocalFileOS2.h
+include/virtualbox/xpcom/nsLocalFileOSX.h
+include/virtualbox/xpcom/nsLocalFileUnix.h
+include/virtualbox/xpcom/nsMemory.h
+include/virtualbox/xpcom/nsModule.h
+include/virtualbox/xpcom/nsMultiplexInputStream.h
+include/virtualbox/xpcom/nsNativeCharsetUtils.h
+include/virtualbox/xpcom/nsNativeComponentLoader.h
+include/virtualbox/xpcom/nsObserverService.h
+include/virtualbox/xpcom/nsObsoleteModuleLoading.h
+include/virtualbox/xpcom/nsProcess.h
+include/virtualbox/xpcom/nsProxiedService.h
+include/virtualbox/xpcom/nsProxyEvent.h
+include/virtualbox/xpcom/nsProxyRelease.h
+include/virtualbox/xpcom/nsQuickSort.h
+include/virtualbox/xpcom/nsRecyclingAllocator.h
+include/virtualbox/xpcom/nsRefPtrHashtable.h
+include/virtualbox/xpcom/nsScriptableInputStream.h
+include/virtualbox/xpcom/nsStaticAtom.h
+include/virtualbox/xpcom/nsStaticComponent.h
+include/virtualbox/xpcom/nsStaticNameTable.h
+include/virtualbox/xpcom/nsStorageStream.h
+include/virtualbox/xpcom/nsStreamUtils.h
+include/virtualbox/xpcom/nsStringEnumerator.h
+include/virtualbox/xpcom/nsStringIO.h
+include/virtualbox/xpcom/nsStringStream.h
+include/virtualbox/xpcom/nsSupportsArray.h
+include/virtualbox/xpcom/nsSupportsPrimitives.h
+include/virtualbox/xpcom/nsTHashtable.h
+include/virtualbox/xpcom/nsTextFormatter.h
+include/virtualbox/xpcom/nsTime.h
+include/virtualbox/xpcom/nsTraceRefcnt.h
+include/virtualbox/xpcom/nsTraceRefcntImpl.h
+include/virtualbox/xpcom/nsUnitConversion.h
+include/virtualbox/xpcom/nsValueArray.h
+include/virtualbox/xpcom/nsVariant.h
+include/virtualbox/xpcom/nsVoidArray.h
+include/virtualbox/xpcom/nsWeakPtr.h
+include/virtualbox/xpcom/nsWeakReference.h
+include/virtualbox/xpcom/nsXPCOM.h
+include/virtualbox/xpcom/nsXPCOMCID.h
+include/virtualbox/xpcom/nsXPCOMGlue.h
+include/virtualbox/xpcom/nscore.h
+include/virtualbox/xpcom/pldhash.h
+include/virtualbox/xpcom/plevent.h
+include/virtualbox/xpcom/xcDll.h
+include/virtualbox/xpcom/xpcom-config.h
+include/virtualbox/xpcom/xpt_arena.h
+include/virtualbox/xpcom/xpt_struct.h
+include/virtualbox/xpcom/xpt_xdr.h
+include/virtualbox/xpcom/xptcall.h
+include/virtualbox/xpcom/xptcstubsdecl.inc
+include/virtualbox/xpcom/xptcstubsdef.inc
+include/virtualbox/xpcom/xptinfo.h
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/vboxapi-1.0-py%%PYTHON_VER%%.egg-info
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/vboxapi/VirtualBox_constants.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/vboxapi%%PYTHON_PYCDIR%%VirtualBox_constants%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/vboxapi/__init__.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/vboxapi%%PYTHON_PYCDIR%%__init__%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/__init__.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%__init__%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/components.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%components%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/file.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%file%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/nsError.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%nsError%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/primitives.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%primitives%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/vboxxpcom.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%vboxxpcom%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/xpcom_consts.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%xpcom_consts%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/xpt.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom%%PYTHON_PYCDIR%%xpt%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/client/__init__.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/client%%PYTHON_PYCDIR%%__init__%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server/__init__.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server%%PYTHON_PYCDIR%%__init__%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server/enumerator.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server%%PYTHON_PYCDIR%%enumerator%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server/factory.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server%%PYTHON_PYCDIR%%factory%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server/loader.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server%%PYTHON_PYCDIR%%loader%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server/module.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server%%PYTHON_PYCDIR%%module%%PYTHON_PYCEXT%%
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server/policy.py
+%%PYTHON%%%%PYTHON_SITELIBDIR%%/xpcom/server%%PYTHON_PYCDIR%%policy%%PYTHON_PYCEXT%%
+%%QT%%lib/virtualbox/DbgPlugInDiggers.so
+lib/virtualbox/VBox.sh
+lib/virtualbox/VBoxAuth.so
+lib/virtualbox/VBoxAuthSimple.so
+lib/virtualbox/VBoxAutostart
+lib/virtualbox/VBoxBalloonCtrl
+lib/virtualbox/VBoxBugReport
+lib/virtualbox/VBoxDD.so
+lib/virtualbox/VBoxDD2.so
+lib/virtualbox/VBoxDDR0.r0
+lib/virtualbox/VBoxDDRC.rc
+lib/virtualbox/VBoxDDU.so
+%%QT%%lib/virtualbox/VBoxDbg.so
+%%QT%%lib/virtualbox/VBoxDragAndDropSvc.so
+lib/virtualbox/VBoxEFI32.fd
+lib/virtualbox/VBoxEFI64.fd
+lib/virtualbox/VBoxExtPackHelperApp
+lib/virtualbox/VBoxGuestControlSvc.so
+lib/virtualbox/VBoxGuestPropSvc.so
+@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxHeadless
+lib/virtualbox/VBoxHeadless.so
+lib/virtualbox/VBoxHostChannel.so
+%%X11%%lib/virtualbox/VBoxKeyboard.so
+lib/virtualbox/VBoxManage
+@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxNetAdpCtl
+@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxNetDHCP
+lib/virtualbox/VBoxNetDHCP.so
+@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxNetNAT
+lib/virtualbox/VBoxNetNAT.so
+%%PYTHON%%lib/virtualbox/VBoxPython.so
+%%PYTHON%%lib/virtualbox/VBoxPython%%PYTHON_VERU%%.so
+lib/virtualbox/VBoxREM.so
+%%I386%%lib/virtualbox/VBoxREM32.so
+%%I386%%lib/virtualbox/VBoxREM64.so
+lib/virtualbox/VBoxRT.so
+%%X11%%@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxSDL
+%%X11%%lib/virtualbox/VBoxSDL.so
+lib/virtualbox/VBoxSVC
+%%X11%%lib/virtualbox/VBoxSharedClipboard.so
+%%X11%%lib/virtualbox/VBoxSharedCrOpenGL.so
+lib/virtualbox/VBoxSharedFolders.so
+%%QT%%lib/virtualbox/VBoxTestOGL
+lib/virtualbox/VBoxVMM.so
+lib/virtualbox/VBoxVMMPreload.so
+lib/virtualbox/VBoxXPCOM.so
+lib/virtualbox/VBoxXPCOMC.so
+lib/virtualbox/VBoxXPCOMIPCD
+lib/virtualbox/VMMR0.r0
+lib/virtualbox/VMMRC.rc
+%%QT%%@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VirtualBox
+%%QT%%lib/virtualbox/VirtualBox.so
+%%SDK%%lib/virtualbox/sdk
+%%WEBSERVICE%%lib/virtualbox/vboxwebsrv
+%%WEBSERVICE%%lib/virtualbox/webtest
+%%VNC%%lib/virtualbox/ExtensionPacks/VNC/ExtPack-license.html
+%%VNC%%lib/virtualbox/ExtensionPacks/VNC/ExtPack-license.rtf
+%%VNC%%lib/virtualbox/ExtensionPacks/VNC/ExtPack-license.txt
+%%VNC%%lib/virtualbox/ExtensionPacks/VNC/ExtPack.xml
+%%VNC%%lib/virtualbox/ExtensionPacks/VNC/%%ARCH%%/VBoxVNC.so
+%%VNC%%lib/virtualbox/ExtensionPacks/VNC/%%ARCH%%/VBoxVNCMain.so
+%%GUESTADDITIONS%%lib/virtualbox/additions/VBoxGuestAdditions.iso
+%%GUESTADDITIONS%%lib/virtualbox/additions/VBoxGuestAdditions_%%GUEST_VER%%.iso
+lib/virtualbox/components/VBoxC.so
+lib/virtualbox/components/VBoxSVCM.so
+lib/virtualbox/components/VBoxXPCOMBase.xpt
+lib/virtualbox/components/VBoxXPCOMIPCC.so
+lib/virtualbox/components/VirtualBox_XPCOM.xpt
+%%QT%%share/applications/virtualbox.desktop
+%%MANUAL%%%%DOCSDIR%%/UserManual.pdf
+%%QT%%share/pixmaps/VBox.png
+%%DATADIR%%/idl/VirtualBox_XPCOM.idl
+%%DATADIR%%/idl/ipcIClientObserver.idl
+%%DATADIR%%/idl/ipcIDConnectService.idl
+%%DATADIR%%/idl/ipcILockService.idl
+%%DATADIR%%/idl/ipcIMessageObserver.idl
+%%DATADIR%%/idl/ipcIService.idl
+%%DATADIR%%/idl/ipcITransactionObserver.idl
+%%DATADIR%%/idl/ipcITransactionService.idl
+%%DATADIR%%/idl/nsIArray.idl
+%%DATADIR%%/idl/nsIAsyncInputStream.idl
+%%DATADIR%%/idl/nsIAsyncOutputStream.idl
+%%DATADIR%%/idl/nsIAtom.idl
+%%DATADIR%%/idl/nsIAtomService.idl
+%%DATADIR%%/idl/nsIBinaryInputStream.idl
+%%DATADIR%%/idl/nsIBinaryOutputStream.idl
+%%DATADIR%%/idl/nsIByteArrayInputStream.idl
+%%DATADIR%%/idl/nsICategoryManager.idl
+%%DATADIR%%/idl/nsIClassInfo.idl
+%%DATADIR%%/idl/nsICollection.idl
+%%DATADIR%%/idl/nsIComponentLoader.idl
+%%DATADIR%%/idl/nsIComponentLoaderManager.idl
+%%DATADIR%%/idl/nsIComponentManager.idl
+%%DATADIR%%/idl/nsIComponentManagerObsolete.idl
+%%DATADIR%%/idl/nsIComponentRegistrar.idl
+%%DATADIR%%/idl/nsIConsoleListener.idl
+%%DATADIR%%/idl/nsIConsoleMessage.idl
+%%DATADIR%%/idl/nsIConsoleService.idl
+%%DATADIR%%/idl/nsIDebug.idl
+%%DATADIR%%/idl/nsIDirectoryEnumerator.idl
+%%DATADIR%%/idl/nsIDirectoryService.idl
+%%DATADIR%%/idl/nsIEnumerator.idl
+%%DATADIR%%/idl/nsIEnvironment.idl
+%%DATADIR%%/idl/nsIErrorService.idl
+%%DATADIR%%/idl/nsIEventQueue.idl
+%%DATADIR%%/idl/nsIEventQueueService.idl
+%%DATADIR%%/idl/nsIEventTarget.idl
+%%DATADIR%%/idl/nsIException.idl
+%%DATADIR%%/idl/nsIExceptionService.idl
+%%DATADIR%%/idl/nsIFactory.idl
+%%DATADIR%%/idl/nsIFastLoadFileControl.idl
+%%DATADIR%%/idl/nsIFastLoadService.idl
+%%DATADIR%%/idl/nsIFile.idl
+%%DATADIR%%/idl/nsIHashable.idl
+%%DATADIR%%/idl/nsIInputStream.idl
+%%DATADIR%%/idl/nsIInputStreamTee.idl
+%%DATADIR%%/idl/nsIInterfaceInfo.idl
+%%DATADIR%%/idl/nsIInterfaceInfoManager.idl
+%%DATADIR%%/idl/nsIInterfaceRequestor.idl
+%%DATADIR%%/idl/nsILineInputStream.idl
+%%DATADIR%%/idl/nsILocalFile.idl
+%%DATADIR%%/idl/nsILocalFileMac.idl
+%%DATADIR%%/idl/nsIMemory.idl
+%%DATADIR%%/idl/nsIModule.idl
+%%DATADIR%%/idl/nsIMultiplexInputStream.idl
+%%DATADIR%%/idl/nsINativeComponentLoader.idl
+%%DATADIR%%/idl/nsIObjectInputStream.idl
+%%DATADIR%%/idl/nsIObjectOutputStream.idl
+%%DATADIR%%/idl/nsIObserver.idl
+%%DATADIR%%/idl/nsIObserverService.idl
+%%DATADIR%%/idl/nsIOutputStream.idl
+%%DATADIR%%/idl/nsIPersistentProperties2.idl
+%%DATADIR%%/idl/nsIPipe.idl
+%%DATADIR%%/idl/nsIProcess.idl
+%%DATADIR%%/idl/nsIProgrammingLanguage.idl
+%%DATADIR%%/idl/nsIProperties.idl
+%%DATADIR%%/idl/nsIPropertyBag.idl
+%%DATADIR%%/idl/nsIProxyObjectManager.idl
+%%DATADIR%%/idl/nsIRecyclingAllocator.idl
+%%DATADIR%%/idl/nsIRunnable.idl
+%%DATADIR%%/idl/nsIScriptableInputStream.idl
+%%DATADIR%%/idl/nsISeekableStream.idl
+%%DATADIR%%/idl/nsISerializable.idl
+%%DATADIR%%/idl/nsIServiceManager.idl
+%%DATADIR%%/idl/nsISimpleEnumerator.idl
+%%DATADIR%%/idl/nsIStorageStream.idl
+%%DATADIR%%/idl/nsIStreamBufferAccess.idl
+%%DATADIR%%/idl/nsIStringEnumerator.idl
+%%DATADIR%%/idl/nsIStringStream.idl
+%%DATADIR%%/idl/nsISupports.idl
+%%DATADIR%%/idl/nsISupportsArray.idl
+%%DATADIR%%/idl/nsISupportsIterators.idl
+%%DATADIR%%/idl/nsISupportsPrimitives.idl
+%%DATADIR%%/idl/nsIThread.idl
+%%DATADIR%%/idl/nsITimelineService.idl
+%%DATADIR%%/idl/nsITimer.idl
+%%DATADIR%%/idl/nsITimerInternal.idl
+%%DATADIR%%/idl/nsITimerManager.idl
+%%DATADIR%%/idl/nsITraceRefcnt.idl
+%%DATADIR%%/idl/nsIVariant.idl
+%%DATADIR%%/idl/nsIWeakReference.idl
+%%DATADIR%%/idl/nsIXPTLoader.idl
+%%DATADIR%%/idl/nsrootidl.idl
+%%NLS%%%%DATADIR%%/nls/VirtualBox_bg.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_ca.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_ca_VA.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_cs.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_da.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_de.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_el.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_en.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_es.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_eu.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_fa.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_fi.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_fr.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_gl.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_he.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_hr_HR.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_hu.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_id.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_it.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_ja.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_km_KH.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_ko.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_lt.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_nl.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_pl.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_pt.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_pt_BR.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_ro.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_ru.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_sk.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_sl.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_sr.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_sv.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_th.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_tr.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_uk.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_zh_CN.qm
+%%NLS%%%%DATADIR%%/nls/VirtualBox_zh_TW.qm
+%%NLS%%%%DATADIR%%/nls/qt_bg.qm
+%%NLS%%%%DATADIR%%/nls/qt_ca.qm
+%%NLS%%%%DATADIR%%/nls/qt_ca_VA.qm
+%%NLS%%%%DATADIR%%/nls/qt_cs.qm
+%%NLS%%%%DATADIR%%/nls/qt_da.qm
+%%NLS%%%%DATADIR%%/nls/qt_de.qm
+%%NLS%%%%DATADIR%%/nls/qt_el.qm
+%%NLS%%%%DATADIR%%/nls/qt_en.qm
+%%NLS%%%%DATADIR%%/nls/qt_es.qm
+%%NLS%%%%DATADIR%%/nls/qt_eu.qm
+%%NLS%%%%DATADIR%%/nls/qt_fa.qm
+%%NLS%%%%DATADIR%%/nls/qt_fi.qm
+%%NLS%%%%DATADIR%%/nls/qt_fr.qm
+%%NLS%%%%DATADIR%%/nls/qt_gl.qm
+%%NLS%%%%DATADIR%%/nls/qt_he.qm
+%%NLS%%%%DATADIR%%/nls/qt_hr_HR.qm
+%%NLS%%%%DATADIR%%/nls/qt_hu.qm
+%%NLS%%%%DATADIR%%/nls/qt_id.qm
+%%NLS%%%%DATADIR%%/nls/qt_it.qm
+%%NLS%%%%DATADIR%%/nls/qt_ja.qm
+%%NLS%%%%DATADIR%%/nls/qt_km_KH.qm
+%%NLS%%%%DATADIR%%/nls/qt_ko.qm
+%%NLS%%%%DATADIR%%/nls/qt_lt.qm
+%%NLS%%%%DATADIR%%/nls/qt_nl.qm
+%%NLS%%%%DATADIR%%/nls/qt_pl.qm
+%%NLS%%%%DATADIR%%/nls/qt_pt.qm
+%%NLS%%%%DATADIR%%/nls/qt_pt_BR.qm
+%%NLS%%%%DATADIR%%/nls/qt_ro.qm
+%%NLS%%%%DATADIR%%/nls/qt_ru.qm
+%%NLS%%%%DATADIR%%/nls/qt_sk.qm
+%%NLS%%%%DATADIR%%/nls/qt_sl.qm
+%%NLS%%%%DATADIR%%/nls/qt_sr.qm
+%%NLS%%%%DATADIR%%/nls/qt_sv.qm
+%%NLS%%%%DATADIR%%/nls/qt_th.qm
+%%NLS%%%%DATADIR%%/nls/qt_tr.qm
+%%NLS%%%%DATADIR%%/nls/qt_uk.qm
+%%NLS%%%%DATADIR%%/nls/qt_zh_CN.qm
+%%NLS%%%%DATADIR%%/nls/qt_zh_TW.qm
+%%DATADIR%%/samples/Makefile
+%%DATADIR%%/samples/tstVBoxAPIXPCOM.cpp
+%%WEBSERVICE%%%%DATADIR%%/sdk/bindings/webservice/vboxweb.wsdl
+%%PYTHON%%%%DATADIR%%/sdk/bindings/xpcom/python/xpcom
diff --git a/emulators/virtualbox-ose-nox11-legacy/Makefile b/emulators/virtualbox-ose-nox11-legacy/Makefile
new file mode 100644
index 000000000000..e641ebe6bd34
--- /dev/null
+++ b/emulators/virtualbox-ose-nox11-legacy/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PKGNAMESUFFIX= -nox11-legacy
+
+OPTIONS_EXCLUDE= ALSA DBUS DEBUG GUESTADDITIONS MANUAL NLS PULSEAUDIO
+OPTIONS_EXCLUDE+= QT5 VPX X11
+
+MASTERDIR= ${.CURDIR}/../virtualbox-ose-legacy
+
+.include "${MASTERDIR}/Makefile"
diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile
index 129c92ec1995..2a929438a8ac 100644
--- a/emulators/virtualbox-ose/Makefile
+++ b/emulators/virtualbox-ose/Makefile
@@ -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}/
DISTFILES= VirtualBox-${PORTVERSION}${EXTRACT_SUFX} ${GUESTADDITIONS}
EXTRACT_ONLY= VirtualBox-${PORTVERSION}${EXTRACT_SUFX}
@@ -15,7 +14,6 @@ COMMENT= General-purpose full virtualizer for x86 hardware
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/COPYING
-PATCH_DEPENDS+= ${LOCALBASE}/share/kBuild/tools/GXX3.kmk:devel/kBuild
BUILD_DEPENDS= yasm:devel/yasm \
xsltproc:textproc/libxslt \
kmk:devel/kBuild \
@@ -29,7 +27,7 @@ CPE_VENDOR= oracle
CPE_PRODUCT= vm_virtualbox
WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION}
-ONLY_FOR_ARCHS= i386 amd64
+ONLY_FOR_ARCHS= amd64
USES= compiler:c++14-lang cpe gnome iconv pkgconfig ssl tar:bzip2
USE_GNOME= libidl libxml2
@@ -42,8 +40,6 @@ CONFLICTS_INSTALL= virtualbox-ose-additions-* \
virtualbox-ose-legacy-[0-9]* \
virtualbox-ose-lite-[0-9]*
-LDFLAGS= -lpthread
-
VBOXUSER?= vboxusers
VBOXWSUSER?= vboxusers
VBOXGROUP?= vboxusers
@@ -57,7 +53,7 @@ VBOX_PROGS= VBoxAutostart VBoxBalloonCtrl VBoxBugReport VBoxHeadless \
VBOX_UTILS= VBoxExtPackHelperApp VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT \
VBoxSVC VBoxXPCOMIPCD
-OPTIONS_DEFINE= ALSA DBUS DEBUG GUESTADDITIONS MANUAL NLS PULSEAUDIO \
+OPTIONS_DEFINE= ALSA DBUS DEBUG GUESTADDITIONS MANUAL NLS OPUS PULSEAUDIO \
PYTHON QT5 R0LOGGING UDPTUNNEL VDE VNC WEBSERVICE VPX X11
OPTIONS_DEFAULT= DBUS QT5 UDPTUNNEL VNC WEBSERVICE X11
OPTIONS_SUB= yes
@@ -66,6 +62,7 @@ DEBUG_DESC= Debug symbols, additional logs and assertions
GUESTADDITIONS_DESC= Build with Guest Additions
MANUAL_DESC= Build with user manual
NLS_DESC= Native language support (requires QT5)
+OPUS_DESC= Use libvpx for audio recording (requires VPX)
QT5_DESC= Build with QT5 frontend (requires X11)
R0LOGGING_DESC= Enable R0 logging (requires DEBUG)
UDPTUNNEL_DESC= Build with UDP tunnel support
@@ -82,6 +79,9 @@ DEBUG_CONFIGURE_ON= --build-debug
MANUAL_BUILD_DEPENDS= ${LOCALBASE}/share/xml/docbook/4.4/docbookx.dtd:textproc/docbook-xml
MANUAL_CONFIGURE_OFF= --disable-docs
NLS_IMPLIES= QT5
+OPUS_CONFIGURE_OFF= --disable-libopus
+OPUS_LIB_DEPENDS= libopus.so:audio/opus
+OPUS_IMPLIES= VPX
PULSEAUDIO_CONFIGURE_OFF= --disable-pulse
PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio
PYTHON_CONFIGURE_OFF= --disable-python
@@ -124,6 +124,7 @@ _ELF32!= kldstat -q -m elf32 && echo yes || echo no
.if ${PORT_OPTIONS:MDEBUG}
KMK_BUILDTYPE= debug
KMK_FLAGS+= BUILD_TYPE=debug
+WITH_DEBUG= yes
.else
KMK_BUILDTYPE= release
.endif
@@ -158,7 +159,7 @@ USE_QT= buildtools_build core dbus gui linguisttools_build opengl
USE_QT+= printsupport widgets x11extras
USE_XORG= xcb
INSTALLS_ICONS= yes
-VBOX_PROGS+= VirtualBox
+VBOX_PROGS+= VirtualBox VirtualBoxVM
VBOX_UTILS+= VBoxTestOGL
VBOX_WITH_QT= 1
.else
@@ -174,7 +175,7 @@ VBOX_UTILS+= vboxwebsrv webtest
.endif
.if ${PORT_OPTIONS:MX11}
-USES+= sdl
+USES+= sdl xorg
USE_SDL= sdl
USE_XORG+= xorgproto x11 xcursor xext xinerama xmu xt
VBOX_PROGS+= VBoxSDL
@@ -202,6 +203,19 @@ KMK_FLAGS+= -j${MAKE_JOBS_NUMBER}
.include <bsd.port.pre.mk>
+.if ${CHOSEN_COMPILER_TYPE} == clang
+# llvm10 in FreeBSD before r364284 miscompiles virtualbox 6.1 causing errors.
+# force llvm11 from ports
+.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1300109
+BUILD_DEPENDS+= clang11:devel/llvm${VBOX_LLVM_VER}
+CC= ${LOCALBASE}/bin/clang${VBOX_LLVM_VER}
+CXX= ${LOCALBASE}/bin/clang++${VBOX_LLVM_VER}
+VBOX_LLVM_VER?= 11
+.endif
+PATCH_DEPENDS+= ${LOCALBASE}/share/kBuild/tools/GXX3.kmk:devel/kBuild
+EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk
+.endif
+
.if ${PYTHON_MAJOR_VER} >= 3
PLIST_SUB+= PYTHON_PYCDIR=/__pycache__/ \
PYTHON_PYCEXT=.cpython-${PYTHON_SUFFIX}.pyc
@@ -274,19 +288,20 @@ post-patch:
${WRKSRC}/LocalConfig.kmk
@${ECHO_CMD} 'VBOX_GCC_PEDANTIC_CXX = -Wshadow $$(VBOX_GCC_WARN) -Wno-long-long' >> \
${WRKSRC}/LocalConfig.kmk
- @${REINPLACE_CMD} -E -e '/soap_socket_errno\(/s/(soap_socket_errno)(\([^)]+\))/\1/' \
- ${WRKSRC}/src/VBox/Main/webservice/vboxweb.cpp
.endif
+.if empty(PORT_OPTIONS:MX11)
+ @${ECHO} 'VBOX_WITH_VMSVGA3D =' >> ${WRKSRC}/LocalConfig.kmk
+.endif
+.if ${CHOSEN_COMPILER_TYPE} == clang
@${REINPLACE_CMD} -e 's| -finline-limit=8000||' \
- -e 's| -mpreferred-stack-boundary=2||' \
- -e 's|%%PYTHON_VERSION%%|${PYTHON_VERSION}|' \
- ${WRKSRC}/Config.kmk
+ -e 's| -mpreferred-stack-boundary=2||' ${WRKSRC}/Config.kmk
@${REINPLACE_CMD} -e 's| -fpermissive||' ${WRKSRC}/Config.kmk \
${WRKSRC}/src/VBox/Main/webservice/Makefile.kmk
@${ECHO_CMD} 'TOOL_VBoxGccFreeBSD_LD = ${CXX}' >> ${WRKSRC}/LocalConfig.kmk
@${SED} -e 's|GXX3|VBoxGccFreeBSD|g' \
${LOCALBASE}/share/kBuild/tools/GXX3.kmk > \
${WRKSRC}/tools/kBuildTools/VBoxGccFreeBSD.kmk
+.endif
@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
${WRKSRC}/Config.kmk ${WRKSRC}/configure \
${WRKSRC}/kBuild/header.kmk ${WRKSRC}/kBuild/units/qt4.kmk \
@@ -329,7 +344,7 @@ do-install:
${MKDIR} ${STAGEDIR}${VBOX_DIR}
cd ${KMK_BUILDDIR}/bin && ${COPYTREE_SHARE} \
- "*.fd *.r0 *.rc *.so components" ${STAGEDIR}${VBOX_DIR}
+ "*.fd *.r0 *.so components" ${STAGEDIR}${VBOX_DIR}
.if ${PORT_OPTIONS:MPYTHON} || ${PORT_OPTIONS:MWEBSERVICE}
${RLN} ${STAGEDIR}${DATADIR}/sdk ${STAGEDIR}${VBOX_DIR}
.endif
diff --git a/emulators/virtualbox-ose/distinfo b/emulators/virtualbox-ose/distinfo
index ac8004bf0188..966401a69196 100644
--- a/emulators/virtualbox-ose/distinfo
+++ b/emulators/virtualbox-ose/distinfo
@@ -1,5 +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
+TIMESTAMP = 1613863264
+SHA256 (VirtualBox-6.1.18.tar.bz2) = 108d42b9b391b7a332a33df1662cf7b0e9d9a80f3079d16288d8b9487f427d40
+SIZE (VirtualBox-6.1.18.tar.bz2) = 165507486
+SHA256 (VBoxGuestAdditions_6.1.18.iso) = 904432eb331d7ae517afaa4e4304e6492b7947b46ecb8267de7ef792c4921b4c
+SIZE (VBoxGuestAdditions_6.1.18.iso) = 61157376
diff --git a/emulators/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk b/emulators/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk
new file mode 100644
index 000000000000..c2a39f402b18
--- /dev/null
+++ b/emulators/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk
@@ -0,0 +1,11 @@
+--- src/VBox/Devices/PC/ipxe/Makefile.kmk.orig 2013-11-29 14:23:32.000000000 -0500
++++ src/VBox/Devices/PC/ipxe/Makefile.kmk 2013-12-13 15:06:45.000000000 -0500
+@@ -35,7 +35,7 @@
+ iPxeBiosBin_CLEAN = \
+ $(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c \
+
+-if1of ($(KBUILD_TARGET), darwin os2 solaris win)
++if1of ($(KBUILD_TARGET), darwin freebsd os2 solaris win)
+ $$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c: $(PATH_SUB_CURRENT)/iPxeBiosBin.rom $(VBOX_BIN2C) | $$(dir $$@)
+ $(call MSG_TOOL,bin2c,iPxeBiosBin,$<,$@)
+ $(QUIET)$(VBOX_BIN2C) -min 32 -max 56 -mask 0x1ff -export NetBiosBinary $< $@
diff --git a/emulators/virtualbox-ose/files/patch-Config.kmk b/emulators/virtualbox-ose/files/patch-Config.kmk
index 784ec4295655..119926c9e025 100644
--- a/emulators/virtualbox-ose/files/patch-Config.kmk
+++ b/emulators/virtualbox-ose/files/patch-Config.kmk
@@ -1,6 +1,6 @@
---- Config.kmk.orig 2020-07-09 16:49:46 UTC
+--- Config.kmk.orig 2021-01-07 15:31:21 UTC
+++ Config.kmk
-@@ -445,11 +445,11 @@ ifn1of ($(KBUILD_TARGET), win darwin)
+@@ -469,11 +469,11 @@ ifn1of ($(KBUILD_TARGET), win darwin)
# Enable OSS audio support.
VBOX_WITH_AUDIO_OSS = 1
endif
@@ -14,9 +14,9 @@
# 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
+@@ -489,11 +489,11 @@ VBOX_WITH_AUDIO_MMNOTIFICATION_CLIENT = 1
+ # (disabled with 6.1, since it's not complete/useful enough)
+ VBOX_WITH_PCI_PASSTHROUGH =
# Enable statically linked dbus support.
-if1of ($(KBUILD_TARGET), linux solaris)
+if1of ($(KBUILD_TARGET), freebsd linux solaris)
@@ -28,16 +28,25 @@
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)
+@@ -501,7 +501,7 @@ VBOX_WITH_INTERNAL_NETWORKING = 1
+ # Enable vmsvga (svga2) graphics device variant, 2D part
+ VBOX_WITH_VMSVGA = 1
+ # Enable vmsvga (svga2) graphics device variant, 3D part
+-if1of ($(KBUILD_TARGET), darwin linux win)
++if1of ($(KBUILD_TARGET), darwin freebsd linux win)
+ VBOX_WITH_VMSVGA3D = 1
+ endif
+ # Enable the generic 3D settings support if at least one 3D capable solution is enabled
+@@ -647,7 +647,7 @@ VBOX_WITH_MAIN_USB_ID_DATABASE = 1
+ #endif
+ # Set this to prefix all C symbols in XPCOM, to avoid dynamic linking problems
+ # caused by our XPCOM library polluting the symbol namespace for system libs.
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+ VBOX_WITH_XPCOM_NAMESPACE_CLEANUP = 1
+ endif
+ # The webservices api.
+@@ -1064,10 +1064,6 @@ ifeq ($(KBUILD_TARGET),darwin)
VBOX_WITH_VBOXSDL=
endif
@@ -48,7 +57,7 @@
ifeq ($(KBUILD_TARGET),haiku)
# Don't bother with SDL ttf for now.
VBOX_WITH_SECURELABEL=
-@@ -1155,7 +1151,7 @@ ifdef VBOX_OSE
+@@ -1228,7 +1224,7 @@ ifdef VBOX_OSE
VBOX_WITH_KCHMVIEWER=
VBOX_WITH_PLUGIN_CRYPT=
VBOX_WITH_DRAG_AND_DROP_PROMISES=
@@ -57,93 +66,24 @@
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
+@@ -4928,7 +4924,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
++ ld $(flags) -Bshareable -znotext -o $(out) $(outbase).kld
endef
endif # x86
-@@ -5016,10 +5019,18 @@ TEMPLATE_VBOXR3EXE_LIBPATH += \
+@@ -5205,6 +5201,7 @@ TEMPLATE_VBOXR3EXE_LDFLAGS.x86 = -m32
+ TEMPLATE_VBOXR3EXE_LDFLAGS.amd64 = -m64
+ TEMPLATE_VBOXR3EXE_LDFLAGS.sparc32 = -m32
+ TEMPLATE_VBOXR3EXE_LDFLAGS.sparc64 = -m64
++TEMPLATE_VBOXR3EXE_LDFLAGS.freebsd = -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
+ TEMPLATE_VBOXR3EXE_LDFLAGS.linux = -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
+ TEMPLATE_VBOXR3EXE_LDFLAGS.solaris = -Wl,-z,ignore # same as VBOX_LD_as_needed
+ TEMPLATE_VBOXR3EXE_LDFLAGS.debug = $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS)
+@@ -5238,10 +5235,18 @@ TEMPLATE_VBOXR3EXE_LIBPATH += \
TEMPLATE_VBOXR3EXE_CFLAGS += -fno-pic
TEMPLATE_VBOXR3EXE_CXXFLAGS += -fno-pic
TEMPLATE_VBOXR3EXE_LDFLAGS += -fno-pic
@@ -163,16 +103,48 @@
/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)
+@@ -5273,6 +5278,7 @@ TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = $(TEMPLATE_VB
+ TEMPLATE_VBOXR3EXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
+ endif
+ ifdef VBOX_WITH_ORIGIN
++ TEMPLATE_VBOXR3EXE_LDFLAGS.freebsd += $(VBOX_GCC_ORIGIN_OPT)
+ TEMPLATE_VBOXR3EXE_LDFLAGS.linux += $(VBOX_GCC_ORIGIN_OPT)
+ endif
+ endif
+@@ -5412,7 +5418,7 @@ ifeq ($(KBUILD_TARGET),win)
+ $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
+ $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
+ $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/oldnames.lib
+-else ifn1of ($(KBUILD_TARGET), darwin linux solaris)
++else ifn1of ($(KBUILD_TARGET), darwin freebsd linux solaris)
+ # The gcc guys sans darwin, linux and solaris (don't depend on statically compiled system libs there)
+ TEMPLATE_VBOXR3STATIC_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) -static
+ TEMPLATE_VBOXR3STATIC_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -static
+@@ -5557,6 +5563,7 @@ ifeq ($(KBUILD_TARGET),win) # No CRT!
+ else ifn1of ($(KBUILD_TARGET), 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_VBoxR3HardenedTstDll_LDFLAGS.freebsd = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBoxR3TstDll_LDFLAGS.freebsd))
TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.linux))
-@@ -5837,10 +5848,18 @@ TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTI
+ endif
+
+@@ -5584,6 +5591,7 @@ TEMPLATE_VBoxR3HardenedTstDll_INST = $(INST_TESTCASE)
+ TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS.win = $(TEMPLATE_VBoxR3TstDll_LDFLAGS.win) -IntegrityCheck
+ ifn1of ($(KBUILD_TARGET), win os2)
+ TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBoxR3TstDll_LDFLAGS))
++ TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS.freebsd = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBoxR3TstDll_LDFLAGS.freebsd))
+ TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBoxR3TstDll_LDFLAGS.linux))
+ endif
+
+@@ -5606,6 +5614,7 @@ ifndef VBOX_WITH_HARDENING
+ TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
+ endif
+ ifdef VBOX_WITH_ORIGIN
++ TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS.freebsd += $(VBOX_GCC_ORIGIN_OPT)
+ TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS.linux += $(VBOX_GCC_ORIGIN_OPT)
+ endif
+ endif
+@@ -6132,10 +6141,19 @@ TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTI
else ifeq ($(KBUILD_TARGET),haiku)
TEMPLATE_VBOXMAINEXE_TOOL = GXX3
TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME) network stdc++ supc++
@@ -180,6 +152,7 @@
+ else ifeq ($(KBUILD_TARGET),freebsd)
TEMPLATE_VBOXMAINEXE_TOOL = GXX3
TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
++TEMPLATE_VBOXMAINEXE_LDFLAGS.freebsd = -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
+TEMPLATE_VBOXMAINEXE_LDFLAGS.freebsd.x86 = -Wl,-z,notext
TEMPLATE_VBOXMAINEXE_INCS += \
+ /usr/local/include
@@ -192,10 +165,19 @@
/usr/include \
/usr/X11R6/include \
/usr/local/include
-@@ -6382,13 +6401,10 @@ ifdef VBOX_WITH_QTGUI
+@@ -6167,6 +6185,7 @@ TEMPLATE_VBOXMAINEXE_LDFLAGS += '$(VBOX_GCC
+ TEMPLATE_VBOXMAINEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
+ endif
+ ifdef VBOX_WITH_ORIGIN
++TEMPLATE_VBOXMAINEXE_LDFLAGS.freebsd += $(VBOX_GCC_ORIGIN_OPT)
+ TEMPLATE_VBOXMAINEXE_LDFLAGS.linux += $(VBOX_GCC_ORIGIN_OPT)
+ endif
+
+@@ -6735,13 +6754,11 @@ ifdef VBOX_WITH_QTGUI
TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
$(VBOX_LIBPATH_X11)
ifeq ($(KBUILD_TARGET),freebsd)
++ TEMPLATE_VBOXQTGUIEXE_LDFLAGS += -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
+ TEMPLATE_VBOXQTGUIEXE_LDFLAGS.freebsd.x86 = -Wl,-z,notext
TEMPLATE_VBOXQTGUIEXE_INCS += \
- /usr/include \
@@ -207,33 +189,46 @@
/usr/local/lib
endif
ifeq ($(KBUILD_TARGET),solaris)
-@@ -6617,12 +6633,8 @@ TEMPLATE_VBoxBldProg_LIBPATH += \
+@@ -6988,10 +7005,17 @@ TEMPLATE_VBoxBldProg_TOOL = GXX3
+ TEMPLATE_VBoxBldProg_LIBS = network iconv
+ TEMPLATE_VBoxBldProg_LIBPATH += \
+ /boot/common/lib
+- else if1of ($(KBUILD_HOST), freebsd openbsd)
++ else ifeq ($(KBUILD_HOST),freebsd)
TEMPLATE_VBoxBldProg_TOOL = GXX3
TEMPLATE_VBoxBldProg_LIBS = pthread
TEMPLATE_VBoxBldProg_INCS += \
-- /usr/include \
-- /usr/X11R6/include \
++ /usr/local/include
++TEMPLATE_VBoxBldProg_LIBPATH += \
++ /usr/local/lib
++ else ifeq ($(KBUILD_HOST),openbsd)
++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 @@
+@@ -7115,6 +7139,7 @@ else # the gcc guys
+ # Do not inherit sanitizer flags from VBOXR3EXE in guest executables. Deal with them separately.
+ TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.debug = $(NO_SUCH_VARIABLE)
+ TEMPLATE_VBOXGUESTR3EXE_CFLAGS.debug = $(NO_SUCH_VARIABLE)
++ TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.freebsd = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.freebsd))
+ TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.linux))
+ TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.debug = $(NO_SUCH_VARIABLE)
+ TEMPLATE_VBOXGUESTR3EXE_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBOXR3EXE_LDFLAGS))
+@@ -7138,6 +7163,7 @@ TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.linux = \
+ $(VBOX_GCC_fno-stack-protector)
+ TEMPLATE_VBOXGUESTR3EXE_CFLAGS.linux = $(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.linux)
+ # The GNU_HASH ELF tag is not supported by older systems.
++TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.freebsd += $(VBOX_LD_hash_style_sysv)
+ TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.linux += $(VBOX_LD_hash_style_sysv)
+
#
- 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
+@@ -7345,6 +7371,7 @@ TEMPLATE_VBOXGUESTR3XF86MOD_LIBS.$(KBUILD_TYPE) =
+ TEMPLATE_VBOXGUESTR3XF86MOD_LIBS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
+ TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
+ # The GNU_HASH ELF tag is not supported by older glibc dynamic linkers.
++TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.freebsd = $(subst -Wl$(COMMA),,$(VBOX_LD_hash_style_sysv))
+ TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.linux = $(subst -Wl$(COMMA),,$(VBOX_LD_hash_style_sysv))
+ TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
+ TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS = -r
diff --git a/emulators/virtualbox-ose/files/patch-configure b/emulators/virtualbox-ose/files/patch-configure
index 31d4bd082fe3..1312d17cacc2 100644
--- a/emulators/virtualbox-ose/files/patch-configure
+++ b/emulators/virtualbox-ose/files/patch-configure
@@ -1,6 +1,6 @@
---- configure.orig 2020-05-13 19:36:41 UTC
+--- configure.orig 2021-01-07 15:31:21 UTC
+++ configure
-@@ -138,10 +138,14 @@ CXX_FLAGS=""
+@@ -140,10 +140,14 @@ CXX_FLAGS=""
if [ "$OS" = "freebsd" ]; then
INCCURL="-I/usr/local/include"
LIBCURL="-L/usr/local/lib -lcurl"
@@ -15,17 +15,7 @@
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)
+@@ -1258,7 +1262,7 @@ extern "C" int main(void)
#endif
}
EOF
@@ -34,17 +24,18 @@
test_execute
fi
}
-@@ -1508,8 +1515,7 @@ EOF
+@@ -1563,9 +1567,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"`
+- INCQT5=`strip_I "$FLGQT5"`
++ 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()
+ LIBQT5="-L$LIBDIR5 $LIBQT5"
+@@ -1703,7 +1705,7 @@ check_libopus()
fi
cat > $ODIR.tmp_src.cc << EOF
#include <cstdio>
@@ -53,7 +44,7 @@
extern "C" int main(void)
{
OpusEncoder *test;
-@@ -1980,8 +1986,8 @@ EOF
+@@ -2035,8 +2037,8 @@ EOF
echo "compiling the following source file:" >> $LOG
cat $ODIR.tmp_src.cc >> $LOG
echo "using the following command line:" >> $LOG
@@ -64,7 +55,7 @@
if [ $? -eq 0 ]; then
found=1
break
-@@ -2453,7 +2459,7 @@ for option in "$@"; do
+@@ -2512,7 +2514,7 @@ for option in "$@"; do
--with-openssl-dir=*)
OPENSSLDIR=`echo $option | cut -d'=' -f2`
INCCRYPTO="-I${OPENSSLDIR}/include"
@@ -73,38 +64,39 @@
;;
--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
+@@ -2856,14 +2858,23 @@ 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_PULSE -eq 1 ]; then
+- check_pulse
+- elif [ $WITH_PULSE -eq 0 ]; then # Force disabling PulseAudio.
+- cnf_append "VBOX_WITH_AUDIO_PULSE" ""
+- elif [ $WITH_PULSE -eq 2 ]; then # --enable-pulse was passed, force PulseAudio.
+- cnf_append "VBOX_WITH_AUDIO_PULSE" "1"
+- fi
++ 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_PULSE -eq 1 ]; then
++ check_pulse
++ elif [ $WITH_PULSE -eq 0 ]; then # Force disabling PulseAudio.
++ cnf_append "VBOX_WITH_AUDIO_PULSE" ""
++ elif [ $WITH_PULSE -eq 2 ]; then # --enable-pulse was passed, force PulseAudio.
++ cnf_append "VBOX_WITH_AUDIO_PULSE" "1"
++ fi
+ if [ $WITH_DBUS -eq 0 ]; then
+ cnf_append "VBOX_WITH_DBUS" ""
+ fi
- fi
++ fi
fi
-@@ -2810,14 +2823,6 @@ if [ "$OS" = "linux" ]; then
+ # Linux-specific
+@@ -2878,14 +2889,6 @@ if [ "$OS" = "linux" ]; then
cnf_append "VBOX_WITHOUT_LINUX_TEST_BUILDS" "1"
fi
if [ $ONLY_ADDITIONS -eq 0 ]; then
diff --git a/emulators/virtualbox-ose/files/patch-include-iprt-x86.h b/emulators/virtualbox-ose/files/patch-include-iprt-x86.h
index 9a1001296bc9..9a66249e045e 100644
--- a/emulators/virtualbox-ose/files/patch-include-iprt-x86.h
+++ b/emulators/virtualbox-ose/files/patch-include-iprt-x86.h
@@ -1,6 +1,6 @@
---- include/iprt/x86.h.orig 2020-05-13 19:36:52 UTC
+--- include/iprt/x86.h.orig 2021-01-07 15:31:34 UTC
+++ include/iprt/x86.h
-@@ -35,6 +35,16 @@
+@@ -38,6 +38,16 @@
# pragma D depends_on library vbox-types.d
#endif
diff --git a/emulators/virtualbox-ose/files/patch-include_VBox_com_array.h b/emulators/virtualbox-ose/files/patch-include_VBox_com_array.h
index ad8071687bbf..9d65058e6b50 100644
--- a/emulators/virtualbox-ose/files/patch-include_VBox_com_array.h
+++ b/emulators/virtualbox-ose/files/patch-include_VBox_com_array.h
@@ -1,6 +1,6 @@
---- include/VBox/com/array.h.orig 2019-04-12 15:47:42 UTC
+--- include/VBox/com/array.h.orig 2021-01-07 15:31:25 UTC
+++ include/VBox/com/array.h
-@@ -168,7 +168,7 @@
+@@ -171,7 +171,7 @@
#include "VBox/com/defs.h"
@@ -9,28 +9,28 @@
/** @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)
+@@ -960,12 +960,12 @@ class SafeArray : public Traits (public)
{
-- AssertReturn(m.arr != NULL, *((T *)NULL));
-- AssertReturn(aIdx < size(), *((T *)NULL));
+ /** @todo r=klaus should do this as a AssertCompile, but cannot find a way which works. */
+ Assert(sizeof(T) <= sizeof(Zeroes));
+- AssertReturn(m.arr != NULL, *(T *)&Zeroes[0]);
+- AssertReturn(aIdx < size(), *(T *)&Zeroes[0]);
+ 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 *)&Zeroes[0]);
+ AssertReturn(m.raw != NULL, *((T *)1));
return m.raw[aIdx];
#endif
}
-@@ -960,7 +960,7 @@ class SafeArray : public Traits (public)
+@@ -980,7 +980,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));
+- AssertReturn(m.raw != NULL, *(const T *)&Zeroes[0]);
++ AssertReturn(m.raw != NULL, *((T *)1));
return m.raw[aIdx];
#endif
}
diff --git a/emulators/virtualbox-ose/files/patch-include_iprt_string.h b/emulators/virtualbox-ose/files/patch-include_iprt_string.h
index d2792545c97e..95119057d1ca 100644
--- a/emulators/virtualbox-ose/files/patch-include_iprt_string.h
+++ b/emulators/virtualbox-ose/files/patch-include_iprt_string.h
@@ -1,6 +1,6 @@
---- include/iprt/string.h.orig 2018-06-29 13:08:03 UTC
+--- include/iprt/string.h.orig 2021-01-07 15:31:33 UTC
+++ include/iprt/string.h
-@@ -43,6 +43,11 @@
+@@ -46,6 +46,11 @@
#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
RT_C_DECLS_BEGIN
# include <sys/libkern.h>
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
index c6eda2f9587d..3e664127c272 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
@@ -1,6 +1,22 @@
---- src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c.orig 2020-05-13 19:37:01 UTC
+--- src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c.orig 2019-01-25 18:12:28 UTC
+++ src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c
-@@ -102,8 +102,6 @@ struct VBoxGuestDeviceState
+@@ -45,6 +45,7 @@
+ #include <sys/uio.h>
+ #include <sys/bus.h>
+ #include <sys/poll.h>
++#include <sys/proc.h>
+ #include <sys/selinfo.h>
+ #include <sys/queue.h>
+ #include <sys/lock.h>
+@@ -61,6 +62,7 @@
+ #include <VBox/version.h>
+ #include <VBox/log.h>
+ #include <iprt/assert.h>
++#include <iprt/err.h>
+ #include <iprt/initterm.h>
+ #include <iprt/process.h>
+ #include <iprt/string.h>
+@@ -102,8 +104,6 @@ struct VBoxGuestDeviceState
struct resource *pIrqRes;
/** Pointer to the IRQ handler. */
void *pfnIrqHandler;
@@ -9,7 +25,7 @@
};
-@@ -113,8 +111,7 @@ struct VBoxGuestDeviceState
+@@ -113,8 +113,7 @@ struct VBoxGuestDeviceState
/*
* Character device file handlers.
*/
@@ -19,7 +35,7 @@
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 =
+@@ -145,8 +144,7 @@ static struct cdevsw g_vgdrvFreeBSDChrDevSW =
{
.d_version = D_VERSION,
.d_flags = D_TRACKCLOSE | D_NEEDMINOR,
@@ -29,7 +45,7 @@
.d_ioctl = vgdrvFreeBSDIOCtl,
.d_read = vgdrvFreeBSDRead,
.d_write = vgdrvFreeBSDWrite,
-@@ -154,81 +150,28 @@ static struct cdevsw g_vgdrvFreeBSDChrDevSW =
+@@ -154,81 +152,28 @@ static struct cdevsw g_vgdrvFreeBSDChrDevSW =
.d_name = "vboxguest"
};
@@ -118,7 +134,7 @@
{
int rc;
PVBOXGUESTSESSION pSession;
-@@ -236,25 +179,18 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
+@@ -240,12 +185,6 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
LogFlow(("vgdrvFreeBSDOpen:\n"));
/*
@@ -130,7 +146,9 @@
- /*
* Create a new session.
*/
- rc = VGDrvCommonCreateUserSession(&g_DevExt, &pSession);
+ fRequestor = VMMDEV_REQUESTOR_USERMODE | VMMDEV_REQUESTOR_TRUST_NOT_GIVEN;
+@@ -262,14 +201,13 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
+ rc = VGDrvCommonCreateUserSession(&g_DevExt, fRequestor, &pSession);
if (RT_SUCCESS(rc))
{
- if (ASMAtomicCmpXchgPtr(&pDev->si_drv1, pSession, (void *)0x42))
@@ -150,7 +168,7 @@
}
LogRel(("vgdrvFreeBSDOpen: failed. rc=%d\n", rc));
-@@ -262,33 +198,6 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
+@@ -277,33 +215,6 @@ static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOp
}
/**
@@ -184,7 +202,7 @@
* I/O control request.
*
* @returns depends...
-@@ -301,8 +210,12 @@ static int vgdrvFreeBSDClose(struct cdev *pDev, int fF
+@@ -316,8 +227,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;
@@ -198,7 +216,7 @@
/*
* Deal with the fast ioctl path first.
*/
-@@ -497,12 +410,14 @@ int VBOXCALL VBoxGuestIDC(void *pvSession, uintptr_t u
+@@ -512,12 +427,14 @@ int VBOXCALL VBoxGuestIDC(void *pvSession, uintptr_t u
static int vgdrvFreeBSDPoll(struct cdev *pDev, int fEvents, struct thread *td)
{
@@ -216,7 +234,7 @@
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)
+@@ -558,11 +475,8 @@ static int vgdrvFreeBSDDetach(device_t pDevice)
/*
* Reverse what we did in vgdrvFreeBSDAttach.
*/
@@ -229,9 +247,9 @@
vgdrvFreeBSDRemoveIRQ(pDevice, pState);
if (pState->pVMMDevMemRes)
-@@ -698,18 +610,21 @@ static int vgdrvFreeBSDAttach(device_t pDevice)
- if (RT_SUCCESS(rc))
- {
+@@ -727,18 +641,21 @@ static int vgdrvFreeBSDAttach(device_t pDevice)
+ VGDrvCommonProcessOptionsFromHost(&g_DevExt);
+
/*
- * Configure device cloning.
+ * Configure device.
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
index a2f9863c8f3b..476346a59b13 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
@@ -1,5 +1,14 @@
---- src/VBox/Additions/common/VBoxGuest/freebsd/Makefile.orig 2020-05-13 19:37:01 UTC
+--- src/VBox/Additions/common/VBoxGuest/freebsd/Makefile.orig 2019-04-16 10:09:09 UTC
+++ src/VBox/Additions/common/VBoxGuest/freebsd/Makefile
+@@ -25,7 +25,7 @@
+ #
+ KMOD = vboxguest
+
+-CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DVBOX_WITH_64_BITS_GUESTS
++CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DVBOX_WITH_64_BITS_GUESTS
+
+ .if (${MACHINE_ARCH} == "i386")
+ CFLAGS += -DRT_ARCH_X86
@@ -80,6 +80,7 @@ SRCS += \
handletable.c \
handletablectx.c \
@@ -8,7 +17,7 @@
thread.c
.PATH: ${.CURDIR}/common/string
-@@ -139,6 +140,7 @@ SRCS += \
+@@ -147,6 +148,7 @@ SRCS += \
.PATH: ${.CURDIR}/r0drv
SRCS += \
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
index 48db97765cf7..faecf870532b 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
@@ -1,6 +1,14 @@
---- src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest.orig 2020-05-13 19:37:01 UTC
+--- src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest.orig 2019-01-25 18:12:28 UTC
+++ src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest
-@@ -109,6 +109,7 @@ FILES_VBOXGUEST_NOBIN=" \
+@@ -63,6 +63,7 @@ FILES_VBOXGUEST_NOBIN=" \
+ ${PATH_ROOT}/include/iprt/time.h=>include/iprt/time.h \
+ ${PATH_ROOT}/include/iprt/timer.h=>include/iprt/timer.h \
+ ${PATH_ROOT}/include/iprt/types.h=>include/iprt/types.h \
++ ${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/crc.h=>include/iprt/crc.h \
+@@ -111,6 +112,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 \
@@ -8,7 +16,7 @@
${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=" \
+@@ -181,6 +183,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 \
@@ -16,7 +24,7 @@
${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=" \
+@@ -207,6 +210,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 \
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
index 01fd1fc9b586..74325b5a9279 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
@@ -1,18 +1,17 @@
---- src/VBox/Additions/x11/Installer/98vboxadd-xclient.orig 2020-05-13 19:37:09 UTC
+--- src/VBox/Additions/x11/Installer/98vboxadd-xclient.orig 2021-01-07 15:34:29 UTC
+++ src/VBox/Additions/x11/Installer/98vboxadd-xclient
-@@ -30,10 +30,10 @@ elif test -z "${SSH_CONNECTION}"; then
+@@ -30,9 +30,9 @@ 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/bin/VBoxClient --vmsvga # In case VMSVGA emulation is enabled
+ /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
++ /usr/local/bin/VBoxClient --vmsvga # In case VMSVGA emulation is enabled
fi
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
index 8633e8a2269a..331bb4462b63 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
@@ -1,4 +1,4 @@
---- src/VBox/HostDrivers/Support/freebsd/Makefile.orig 2020-05-13 19:43:53 UTC
+--- src/VBox/HostDrivers/Support/freebsd/Makefile.orig 2019-01-25 18:19:55 UTC
+++ src/VBox/HostDrivers/Support/freebsd/Makefile
@@ -82,6 +82,7 @@ SRCS += \
assert.c \
@@ -8,12 +8,13 @@
once.c \
term.c \
thread.c
-@@ -94,13 +95,14 @@ SRCS += \
+@@ -94,14 +95,15 @@ SRCS += \
RTStrCopy.c \
RTStrCopyEx.c \
RTStrCopyP.c \
+ memchr.c \
strformat.c \
+ strformatnum.c \
strformatrt.c \
strformattype.c \
+ stringalloc.c \
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
index 82fc839a0267..3c805d5ee92b 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
@@ -1,6 +1,6 @@
---- src/VBox/HostDrivers/Support/freebsd/files_vboxdrv.orig 2020-05-13 19:43:53 UTC
+--- src/VBox/HostDrivers/Support/freebsd/files_vboxdrv.orig 2019-01-25 18:19:55 UTC
+++ src/VBox/HostDrivers/Support/freebsd/files_vboxdrv
-@@ -118,6 +118,7 @@ FILES_VBOXDRV_NOBIN=" \
+@@ -119,6 +119,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 \
@@ -8,12 +8,13 @@
${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=" \
+@@ -128,14 +129,15 @@ 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/strformatnum.cpp=>common/string/strformatnum.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 \
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
index c141ba29fb6c..5b96ab56a61b 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
@@ -1,25 +1,20 @@
-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.orig 2019-05-13 13:33:07 UTC
+++ src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk
-@@ -203,12 +203,15 @@ $$(VBoxNetAdp-src_0_OUTDIR)/Makefile: \
+@@ -206,10 +206,14 @@ $$(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 $@ $<
+- $(QUIET)$(SED) -e "s;VBOX_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
--
++ $(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
++ $(QUIET)$(MV) -f $@.tmp $@
+ endif
- include $(FILE_KBUILD_SUB_FOOTER)
+ endif # freebsd
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
index 4c0df373227c..a6a337231417 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
@@ -1,4 +1,4 @@
---- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c.orig 2018-10-15 14:30:58 UTC
+--- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c.orig 2019-04-16 10:16:39 UTC
+++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c
@@ -52,6 +52,7 @@
#include <net/if_dl.h>
@@ -16,31 +16,7 @@
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
+@@ -436,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;
@@ -49,7 +25,7 @@
PINTNETSG pSG;
VBOXCURVNET_SET(ifp->if_vnet);
-@@ -440,6 +452,19 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend
+@@ -448,6 +452,19 @@ static void vboxNetFltFreeBSDinput(void *arg, int pend
if (m == NULL)
break;
@@ -69,7 +45,7 @@
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
+@@ -462,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);
@@ -97,7 +73,7 @@
if (fDropIt)
m_freem(m);
else
-@@ -513,6 +559,7 @@ static void vboxNetFltFreeBSDoutput(void *arg, int pen
+@@ -521,6 +559,7 @@ static void vboxNetFltFreeBSDoutput(void *arg, int pen
*/
int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *pvIfData, PINTNETSG pSG, uint32_t fDst)
{
@@ -105,7 +81,7 @@
NOREF(pvIfData);
void (*input_f)(struct ifnet *, struct mbuf *);
-@@ -529,10 +576,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
+@@ -537,10 +576,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
{
m = vboxNetFltFreeBSDSGMBufFromSG(pThis, pSG);
if (m == NULL)
@@ -122,7 +98,7 @@
m->m_flags |= M_PKTHDR;
ether_output_frame(ifp, m);
-@@ -542,10 +595,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
+@@ -550,10 +595,16 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
{
m = vboxNetFltFreeBSDSGMBufFromSG(pThis, pSG);
if (m == NULL)
@@ -139,7 +115,7 @@
/*
* 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
+@@ -564,6 +615,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
if (mtag == NULL)
{
m_freem(m);
@@ -147,7 +123,7 @@
return VERR_NO_MEMORY;
}
-@@ -566,6 +626,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
+@@ -574,6 +626,7 @@ int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *p
ifp->if_input(ifp, m);
}
VBOXCURVNET_RESTORE();
@@ -155,7 +131,7 @@
return VINF_SUCCESS;
}
-@@ -578,6 +639,7 @@ static bool vboxNetFltFreeBsdIsPromiscuous(PVBOXNETFLT
+@@ -586,6 +639,7 @@ static bool vboxNetFltFreeBsdIsPromiscuous(PVBOXNETFLT
int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext)
{
@@ -163,7 +139,7 @@
char nam[NG_NODESIZ];
struct ifnet *ifp;
node_p node;
-@@ -586,7 +648,10 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi
+@@ -594,7 +648,10 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi
NOREF(pvContext);
ifp = ifunit(pThis->szName);
if (ifp == NULL)
@@ -174,7 +150,7 @@
/* 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
+@@ -638,12 +695,14 @@ int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, voi
vboxNetFltRelease(pThis, true /*fBusy*/);
}
VBOXCURVNET_RESTORE();
@@ -189,7 +165,7 @@
struct ifnet *ifp, *ifp0;
ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
-@@ -652,6 +719,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi
+@@ -660,6 +719,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi
pThis->u.s.node = NULL;
}
VBOXCURVNET_RESTORE();
@@ -197,7 +173,7 @@
if (ifp0 != NULL)
{
-@@ -664,6 +732,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi
+@@ -672,6 +732,7 @@ bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThi
void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
{
@@ -205,7 +181,7 @@
taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin);
taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout);
-@@ -676,6 +745,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
+@@ -684,6 +745,7 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
ng_rmnode_self(pThis->u.s.node);
VBOXCURVNET_RESTORE();
pThis->u.s.node = NULL;
@@ -213,7 +189,7 @@
}
int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)
-@@ -689,6 +759,7 @@ int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)
+@@ -697,6 +759,7 @@ int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)
void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive)
{
@@ -221,7 +197,7 @@
struct ifnet *ifp;
struct ifreq ifreq;
int error;
-@@ -722,7 +793,10 @@ void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, b
+@@ -730,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)
@@ -232,7 +208,7 @@
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
+@@ -744,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)
@@ -243,7 +219,7 @@
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
+@@ -767,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)
@@ -254,7 +230,7 @@
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
+@@ -778,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)
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt
index c6b681245e91..eb3b623f7299 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-files_vboxnetflt
@@ -1,6 +1,6 @@
---- src/VBox/HostDrivers/VBoxNetFlt/freebsd/files_vboxnetflt.orig 2018-10-15 14:30:58 UTC
+--- src/VBox/HostDrivers/VBoxNetFlt/freebsd/files_vboxnetflt.orig 2021-01-07 15:41:28 UTC
+++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/files_vboxnetflt
-@@ -61,6 +61,7 @@ VBOX_VBOXNETFLT_SOURCES=" \
+@@ -62,6 +62,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 \
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh b/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh
index cebabd64d010..deb51288deb1 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh
@@ -1,6 +1,6 @@
--- src/VBox/Installer/freebsd/VBox.sh.orig 2016-08-27 05:10:34 UTC
+++ src/VBox/Installer/freebsd/VBox.sh
-@@ -0,0 +1,64 @@
+@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# Oracle VM VirtualBox startup script, FreeBSD hosts.
@@ -38,6 +38,9 @@
+ VirtualBox|virtualbox)
+ exec "$INSTALL_DIR/VirtualBox" "$@"
+ ;;
++ VirtualBoxVM|virtualboxvm)
++ exec "$INSTALL_DIR/VirtualBoxVM" "$@"
++ ;;
+ VBoxManage|vboxmanage)
+ exec "$INSTALL_DIR/VBoxManage" "$@"
+ ;;
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
index a908f2c17a51..4cd8b7492ed9 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
@@ -1,6 +1,6 @@
---- src/VBox/Main/src-server/VirtualBoxImpl.cpp.orig 2020-05-13 19:44:10 UTC
+--- src/VBox/Main/src-server/VirtualBoxImpl.cpp.orig 2021-01-07 15:41:43 UTC
+++ src/VBox/Main/src-server/VirtualBoxImpl.cpp
-@@ -2251,7 +2251,7 @@ int VirtualBox::i_encryptSettingBytes(const uint8_t *a
+@@ -2663,7 +2663,7 @@ int VirtualBox::i_encryptSettingBytes(const uint8_t *a
if (aCiphertextSize < 32)
return VERR_INVALID_PARAMETER;
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Main-webservice-Makefile.kmk b/emulators/virtualbox-ose/files/patch-src-VBox-Main-webservice-Makefile.kmk
index a5485e8aee1d..6725f67e1923 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Main-webservice-Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Main-webservice-Makefile.kmk
@@ -1,4 +1,4 @@
---- src/VBox/Main/webservice/Makefile.kmk.orig 2020-05-13 19:44:11 UTC
+--- src/VBox/Main/webservice/Makefile.kmk.orig 2021-01-07 15:41:45 UTC
+++ src/VBox/Main/webservice/Makefile.kmk
@@ -158,7 +158,6 @@ VBOX_PATH_IDL := $(abspath $(PATH_SUB_
RECOMPILE_ON_MAKEFILE_CURRENT := $(MAKEFILE_CURRENT)
@@ -8,7 +8,7 @@
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 $$@)
+@@ -565,8 +564,6 @@ $$(VBOX_JWSSRC_JAR): $$(VBOX_JWS_JAR) | $$(dir $$@)
$(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts \
$(wildcard $(PATH_TARGET_SOAPDEMOXML)/*) \
$(PATH_TARGET_SOAPDEMOXML)/dummy_file \
@@ -17,7 +17,7 @@
$(wildcard $(PATH_TARGET_SOAPDEMONSMAPS)/*) \
$(PATH_TARGET_SOAPDEMONSMAPS)/dummy_file
-@@ -774,17 +771,14 @@ endif
+@@ -786,17 +783,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 $@
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-Makefile.kmk b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-Makefile.kmk
index 915f57ae49b0..f13be222ea9a 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-Makefile.kmk
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/Makefile.kmk.orig 2020-07-09 16:57:23 UTC
+--- src/VBox/Runtime/Makefile.kmk.orig 2021-01-07 15:41:50 UTC
+++ src/VBox/Runtime/Makefile.kmk
-@@ -173,6 +173,11 @@ $(IPRT_OUT_DIR)/oiddb.h.ts +| $(IPRT_OUT_DIR)/oiddb.h:
+@@ -177,6 +177,11 @@ $(IPRT_OUT_DIR)/oiddb.h.ts +| $(IPRT_OUT_DIR)/oiddb.h:
#
@@ -12,12 +12,3 @@
# 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))
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
index 8c4376c342e7..e647f328a36d 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
@@ -7,9 +7,9 @@ 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.orig 2021-01-07 15:42:09 UTC
+++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h
-@@ -82,6 +82,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0
+@@ -84,6 +84,8 @@ DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0
uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
if (cTicks >= INT_MAX)
return RTSEMWAIT_FLAGS_INDEFINITE;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
index 8f6810a5bc82..70b459e94da7 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
@@ -1,6 +1,6 @@
---- src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp.orig 2017-03-08 17:15:20 UTC
+--- src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp.orig 2021-01-07 15:34:20 UTC
+++ src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
-@@ -71,8 +71,8 @@
+@@ -67,8 +67,8 @@
# include <net/if.h>
# include <pwd.h> /* getpwuid */
# include <unistd.h>
@@ -11,7 +11,7 @@
# endif
# ifdef RT_OS_OS2
# include <net/if_dl.h>
-@@ -531,7 +531,7 @@ static void vgsvcVMInfoWriteFixedPropert
+@@ -528,7 +528,7 @@ static void vgsvcVMInfoWriteFixedProperties(void)
}
@@ -20,9 +20,9 @@
/*
* Simple wrapper to work around compiler-specific va_list madness.
*/
-@@ -562,12 +562,6 @@ static int vgsvcVMInfoWriteUsers(void)
- rc = VERR_NOT_IMPLEMENTED;
- # endif
+@@ -555,12 +555,6 @@ static int vgsvcVMInfoWriteUsers(void)
+ #ifdef RT_OS_WINDOWS
+ rc = VGSvcVMInfoWinWriteUsers(&g_VMInfoPropCache, &pszUserList, &cUsersInList);
-#elif defined(RT_OS_FREEBSD)
- /** @todo FreeBSD: Port logged on user info retrieval.
@@ -33,7 +33,7 @@
#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)
+@@ -586,7 +580,7 @@ static int vgsvcVMInfoWriteUsers(void)
while ( (ut_user = getutxent())
&& RT_SUCCESS(rc))
{
@@ -42,7 +42,7 @@
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)
+@@ -621,7 +615,7 @@ static int vgsvcVMInfoWriteUsers(void)
}
# ifdef VBOX_WITH_DBUS
@@ -51,7 +51,7 @@
DBusError dbErr;
DBusConnection *pConnection = NULL;
int rc2 = RTDBusLoadLib();
-@@ -837,7 +831,7 @@ static int vgsvcVMInfoWriteUsers(void)
+@@ -830,7 +824,7 @@ static int vgsvcVMInfoWriteUsers(void)
if ( fHaveLibDbus
&& dbus_error_is_set(&dbErr))
dbus_error_free(&dbErr);
@@ -60,7 +60,7 @@
# endif /* VBOX_WITH_DBUS */
/** @todo Fedora/others: Handle systemd-loginctl. */
-@@ -874,7 +868,7 @@ static int vgsvcVMInfoWriteUsers(void)
+@@ -867,7 +861,7 @@ static int vgsvcVMInfoWriteUsers(void)
RTMemFree(papszUsers);
endutxent(); /* Close utmpx file. */
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp
index 47111c1ded45..bd667880358f 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_common_pam_pam__vbox.cpp
@@ -1,6 +1,6 @@
---- src/VBox/Additions/common/pam/pam_vbox.cpp.orig 2020-05-13 19:37:05 UTC
+--- src/VBox/Additions/common/pam/pam_vbox.cpp.orig 2021-01-07 15:34:21 UTC
+++ src/VBox/Additions/common/pam/pam_vbox.cpp
-@@ -105,7 +105,7 @@ static void pam_vbox_writesyslog(char *pszBuf)
+@@ -104,7 +104,7 @@ static void pam_vbox_writesyslog(char *pszBuf)
openlog("pam_vbox", LOG_PID, LOG_AUTHPRIV);
syslog(LOG_ERR, "%s", pszBuf);
closelog();
@@ -9,7 +9,7 @@
syslog(LOG_ERR, "pam_vbox: %s\n", pszBuf);
#endif
}
-@@ -184,7 +184,7 @@ static int vbox_set_msg(pam_handle_t *hPAM, int iStyle
+@@ -183,7 +183,7 @@ static int vbox_set_msg(pam_handle_t *hPAM, int iStyle
pam_message msg;
msg.msg_style = iStyle;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_Makefile.kmk
index fce921705363..f9d19d679e4a 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_Makefile.kmk
@@ -1,4 +1,4 @@
---- src/VBox/Additions/freebsd/Makefile.kmk.orig 2019-07-12 08:42:35 UTC
+--- src/VBox/Additions/freebsd/Makefile.kmk.orig 2021-01-07 15:34:22 UTC
+++ src/VBox/Additions/freebsd/Makefile.kmk
@@ -23,8 +23,9 @@ $(error "The FreeBSD guest additions installer can onl
endif
@@ -12,11 +12,12 @@
#
# Globals
-@@ -67,11 +68,13 @@ VBOX_FBSD_ADD_STRIP_BIN = \
+@@ -66,11 +67,14 @@ VBOX_FBSD_ADD_STRIP_BIN = \
+ vboxvideo_drv_14.so \
vboxvideo_drv_15.so \
vboxvideo_drv_16.so \
- vboxvideo_drv_17.so \
-- VBoxOGL.so
+- vboxvideo_drv_17.so
++ vboxvideo_drv_17.so \
+ $(if $(VBOX_WITH_PAM),pam_vbox.so,) \
+ VBoxOGL.so \
+ mount_vboxvfs
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk
index 4522bc83e422..9494bd970456 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_Makefile.kmk
@@ -1,10 +1,11 @@
---- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk.orig 2020-05-13 19:37:06 UTC
+--- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk.orig 2021-01-07 15:34:22 UTC
+++ src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk
-@@ -33,32 +33,36 @@ vboxvfs_INCS = \
+@@ -33,32 +33,37 @@ vboxvfs_INCS = \
$(vboxvfs_0_OUTDIR)
vboxvfs_SOURCES = \
vboxvfs_vfsops.c \
- vboxvfs_vnops.c
++ bcmp.c \
+ vboxvfs_vnops.c \
+ vboxvfs_prov.c
vboxvfs_LIBS = \
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_bcmp.c b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_bcmp.c
new file mode 100644
index 000000000000..fb4d7fac8c06
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_bcmp.c
@@ -0,0 +1,12 @@
+--- src/VBox/Additions/freebsd/vboxvfs/bcmp.c.orig 2021-02-21 19:09:22 UTC
++++ src/VBox/Additions/freebsd/vboxvfs/bcmp.c
+@@ -0,0 +1,9 @@
++#include <sys/types.h>
++
++int bcmp(const void *b1, const void *b2, size_t len);
++
++int
++bcmp(const void *b1, const void *b2, size_t len)
++{
++ return __builtin_memcmp((b1), (b2), (len));
++}
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h
index 09bb8575898e..a4f94f92e148 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h
@@ -1,4 +1,4 @@
---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h.orig 2018-06-29 13:08:17 UTC
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h.orig 2021-01-07 15:34:22 UTC
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h
@@ -1,8 +1,3 @@
-/* $Id: vboxvfs.h $ */
@@ -7,9 +7,9 @@
- */
-
/*
- * Copyright (C) 2010-2017 Oracle Corporation
+ * Copyright (C) 2010-2020 Oracle Corporation
*
-@@ -21,72 +16,413 @@
+@@ -24,72 +19,371 @@
#define VBOXVFS_VFSNAME "vboxvfs"
#define VBOXVFS_VERSION 1
@@ -78,28 +78,6 @@
+#include "../../../../../include/iprt/err.h"
+#include "../../../../../include/iprt/fs.h"
+#include "../../../../../include/iprt/log.h"
-+#include "../../../../../include/iprt/mangling.h"
-+#include "../../../../../include/iprt/mem.h"
-+#include "../../../../../include/iprt/param.h"
-+#include "../../../../../include/iprt/path.h"
-+#include "../../../../../include/iprt/semaphore.h"
-+#include "../../../../../include/iprt/stdarg.h"
-+#include "../../../../../include/iprt/stdint.h"
-+#include "../../../../../include/iprt/string.h"
-+#include "../../../../../include/iprt/time.h"
-+#include "../../../../../include/iprt/types.h"
-+#include "../../../../../include/iprt/uni.h"
-+#include "../../../../../include/iprt/nocrt/limits.h"
-+#include "../../../../../include/iprt/alloc.h"
-+#include "../../../../../include/iprt/asm.h"
-+#include "../../../../../include/iprt/asm-amd64-x86.h"
-+#include "../../../../../include/iprt/asm-math.h"
-+#include "../../../../../include/iprt/assert.h"
-+#include "../../../../../include/iprt/cdefs.h"
-+#include "../../../../../include/iprt/err.h"
-+#include "../../../../../include/iprt/fs.h"
-+#include "../../../../../include/iprt/log.h"
-+#include "../../../../../include/iprt/mangling.h"
+#include "../../../../../include/iprt/mem.h"
+#include "../../../../../include/iprt/param.h"
+#include "../../../../../include/iprt/path.h"
@@ -134,26 +112,6 @@
+#include "iprt/time.h"
+#include "iprt/types.h"
+#include "iprt/uni.h"
-+#include "iprt/nocrt/limits.h"
-+#include "iprt/alloc.h"
-+#include "iprt/asm.h"
-+#include "iprt/asm-amd64-x86.h"
-+#include "iprt/asm-math.h"
-+#include "iprt/assert.h"
-+#include "iprt/cdefs.h"
-+#include "iprt/err.h"
-+#include "iprt/fs.h"
-+#include "iprt/log.h"
-+#include "iprt/mem.h"
-+#include "iprt/param.h"
-+#include "iprt/path.h"
-+#include "iprt/semaphore.h"
-+#include "iprt/stdarg.h"
-+#include "iprt/stdint.h"
-+#include "iprt/string.h"
-+#include "iprt/time.h"
-+#include "iprt/types.h"
-+#include "iprt/uni.h"
+
+#include "common/VBoxGuestLib/SysHlp.h"
+
@@ -459,5 +417,5 @@
+
#endif /* KERNEL */
- #endif /* !___VBOXVFS_H___ */
+ #endif /* !GA_INCLUDED_SRC_freebsd_vboxvfs_vboxvfs_h */
-
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c
index 128085de6cb9..5d21a89925de 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vfsops.c
@@ -1,4 +1,4 @@
---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c.orig 2020-07-09 16:50:11 UTC
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c.orig 2021-01-07 15:34:22 UTC
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c
@@ -1,8 +1,3 @@
-/* $Id: vboxvfs_vfsops.c $ */
@@ -7,7 +7,7 @@
- */
-
/*
- * Copyright (C) 2008-2017 Oracle Corporation
+ * Copyright (C) 2008-2020 Oracle Corporation
*
@@ -14,245 +9,478 @@
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
index bc42812105e4..471b3ac76714 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
@@ -1,18 +1,6 @@
---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig 2020-07-09 16:50:11 UTC
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig 2021-01-07 15:34:22 UTC
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c
-@@ -1,10 +1,6 @@
--/* $Id: vboxvfs_vnops.c $ */
--/** @file
-- * Description.
-- */
--
- /*
- * Copyright (C) 2008-2017 Oracle Corporation
-+ * Copyright (C) 2017 Mahdi Mokhtari
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
-@@ -14,228 +10,1347 @@
+@@ -14,228 +14,1347 @@
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_VBoxClient_logging.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_VBoxClient_logging.cpp
new file mode 100644
index 000000000000..ad756a686569
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_VBoxClient_logging.cpp
@@ -0,0 +1,10 @@
+--- src/VBox/Additions/x11/VBoxClient/logging.cpp.orig 2021-01-07 15:34:30 UTC
++++ src/VBox/Additions/x11/VBoxClient/logging.cpp
+@@ -17,6 +17,7 @@
+
+
+ #include <stdlib.h>
++#include <sys/wait.h>
+ #include <iprt/buildconfig.h>
+ #include <iprt/file.h>
+ #include <iprt/process.h>
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_x11include_xproto-7.0.18_X11_Xfuncproto.h b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_x11include_xproto-7.0.18_X11_Xfuncproto.h
new file mode 100644
index 000000000000..ee9a615ab5c8
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_x11_x11include_xproto-7.0.18_X11_Xfuncproto.h
@@ -0,0 +1,230 @@
+--- src/VBox/Additions/x11/x11include/xproto-7.0.18/X11/Xfuncproto.h.orig 2021-01-07 15:37:10 UTC
++++ src/VBox/Additions/x11/x11include/xproto-7.0.18/X11/Xfuncproto.h
+@@ -48,6 +48,227 @@ in this Software without prior written authorization f
+ #endif /* _Xconst */
+
+ /* Function prototype configuration (see configure for more info) */
++#if !defined(NARROWPROTO) && \
++ (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
++#define NARROWPROTO
++#endif
++#ifndef FUNCPROTO
++#define FUNCPROTO 15
++#endif
++
++#ifndef NeedWidePrototypes
++#ifdef NARROWPROTO
++#define NeedWidePrototypes 0
++#else
++#define NeedWidePrototypes 1 /* default to make interropt. easier */
++#endif
++#endif /* NeedWidePrototypes */
++
++#endif /* NeedFunctionPrototypes */
++
++#ifndef _XFUNCPROTOBEGIN
++#if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
++#define _XFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
++#define _XFUNCPROTOEND }
++#else
++#define _XFUNCPROTOBEGIN
++#define _XFUNCPROTOEND
++#endif
++#endif /* _XFUNCPROTOBEGIN */
++
++/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */
++#ifndef __has_attribute
++# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
++#endif
++#ifndef __has_feature
++# define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
++#endif
++#ifndef __has_extension
++# define __has_extension(x) 0 /* Compatibility with non-clang compilers. */
++#endif
++
++/* Added in X11R6.9, so available in any version of modular xproto */
++#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))
++# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
++#else
++# define _X_SENTINEL(x)
++#endif /* GNUC >= 4 */
++
++/* Added in X11R6.9, so available in any version of modular xproto */
++#if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \
++ && !defined(__CYGWIN__) && !defined(__MINGW32__)
++# define _X_EXPORT __attribute__((visibility("default")))
++# define _X_HIDDEN __attribute__((visibility("hidden")))
++# define _X_INTERNAL __attribute__((visibility("internal")))
++#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
++# define _X_EXPORT __global
++# define _X_HIDDEN __hidden
++# define _X_INTERNAL __hidden
++#else /* not gcc >= 4 and not Sun Studio >= 8 */
++# define _X_EXPORT
++# define _X_HIDDEN
++# define _X_INTERNAL
++#endif /* GNUC >= 4 */
++
++/* Branch prediction hints for individual conditionals */
++/* requires xproto >= 7.0.9 */
++#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
++# define _X_LIKELY(x) __builtin_expect(!!(x), 1)
++# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)
++#else /* not gcc >= 3.3 */
++# define _X_LIKELY(x) (x)
++# define _X_UNLIKELY(x) (x)
++#endif
++
++/* Bulk branch prediction hints via marking error path functions as "cold" */
++/* requires xproto >= 7.0.25 */
++#if __has_attribute(__cold__) || \
++ (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */
++# define _X_COLD __attribute__((__cold__))
++#else
++# define _X_COLD /* nothing */
++#endif
++
++/* Added in X11R6.9, so available in any version of modular xproto */
++#if __has_attribute(deprecated) \
++ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \
++ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130))
++# define _X_DEPRECATED __attribute__((deprecated))
++#else /* not gcc >= 3.1 */
++# define _X_DEPRECATED
++#endif
++
++/* requires xproto >= 7.0.30 */
++#if __has_extension(attribute_deprecated_with_message) || \
++ (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
++# define _X_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg)))
++#else
++# define _X_DEPRECATED_MSG(_msg) _X_DEPRECATED
++#endif
++
++/* requires xproto >= 7.0.17 */
++#if __has_attribute(noreturn) \
++ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
++ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
++# define _X_NORETURN __attribute((noreturn))
++#else
++# define _X_NORETURN
++#endif /* GNUC */
++
++/* Added in X11R6.9, so available in any version of modular xproto */
++#if __has_attribute(__format__) \
++ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
++# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
++#else /* not gcc >= 2.3 */
++# define _X_ATTRIBUTE_PRINTF(x,y)
++#endif
++
++/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable
++ argument macros, must be only used inside #ifdef _X_NONNULL guards, as
++ many legacy X clients are compiled in C89 mode still. */
++#if __has_attribute(nonnull) \
++ && defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
++#define _X_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
++#elif __has_attribute(nonnull) \
++ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
++#define _X_NONNULL(args...) __attribute__((nonnull(args)))
++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
++#define _X_NONNULL(...) /* */
++#endif
++
++/* requires xproto >= 7.0.22 */
++#if __has_attribute(__unused__) \
++ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
++#define _X_UNUSED __attribute__((__unused__))
++#else
++#define _X_UNUSED /* */
++#endif
++
++/* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */
++/* requires xproto >= 7.0.9
++ (introduced in 7.0.8 but didn't support all compilers until 7.0.9) */
++#if defined(inline) /* assume autoconf set it correctly */ || \
++ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \
++ (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))
++# define _X_INLINE inline
++#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
++# define _X_INLINE __inline__
++#else
++# define _X_INLINE
++#endif
++
++/* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */
++/* requires xproto >= 7.0.21 */
++#ifndef _X_RESTRICT_KYWD
++# if defined(restrict) /* assume autoconf set it correctly */ || \
++ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \
++ && !defined(__cplusplus)) /* Workaround g++ issue on Solaris */
++# define _X_RESTRICT_KYWD restrict
++# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
++# define _X_RESTRICT_KYWD __restrict__
++# else
++# define _X_RESTRICT_KYWD
++# endif
++#endif
++
++/* requires xproto >= 7.0.30 */
++#if __has_attribute(no_sanitize_thread)
++# define _X_NOTSAN __attribute__((no_sanitize_thread))
++#else
++# define _X_NOTSAN
++#endif
++
++#endif /* _XFUNCPROTO_H_ */
++/*
++ *
++Copyright 1989, 1991, 1998 The Open Group
++
++Permission to use, copy, modify, distribute, and sell this software and its
++documentation for any purpose is hereby granted without fee, provided that
++the above copyright notice appear in all copies and that both that
++copyright notice and this permission notice appear in supporting
++documentation.
++
++The above copyright notice and this permission notice shall be included in
++all copies or substantial portions of the Software.
++
++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++Except as contained in this notice, the name of The Open Group shall not be
++used in advertising or otherwise to promote the sale, use or other dealings
++in this Software without prior written authorization from The Open Group.
++ *
++ */
++
++/* Definitions to make function prototypes manageable */
++
++#ifndef _XFUNCPROTO_H_
++#define _XFUNCPROTO_H_
++
++#ifndef NeedFunctionPrototypes
++#define NeedFunctionPrototypes 1
++#endif /* NeedFunctionPrototypes */
++
++#ifndef NeedVarargsPrototypes
++#define NeedVarargsPrototypes 1
++#endif /* NeedVarargsPrototypes */
++
++#if NeedFunctionPrototypes
++
++#ifndef NeedNestedPrototypes
++#define NeedNestedPrototypes 1
++#endif /* NeedNestedPrototypes */
++
++#ifndef _Xconst
++#define _Xconst const
++#endif /* _Xconst */
++
++/* Function prototype configuration (see configure for more info) */
+ #ifndef NARROWPROTO
+ #undef NARROWPROTO
+ #endif
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Debugger_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Debugger_Makefile.kmk
index 9edb9747e085..11d20783bf83 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Debugger_Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Debugger_Makefile.kmk
@@ -1,6 +1,6 @@
---- src/VBox/Debugger/Makefile.kmk.orig 2020-05-13 19:39:41 UTC
+--- src/VBox/Debugger/Makefile.kmk.orig 2021-01-07 15:37:12 UTC
+++ src/VBox/Debugger/Makefile.kmk
-@@ -113,6 +113,7 @@ VBoxDbg_SOURCES = \
+@@ -110,6 +110,7 @@ VBoxDbg_SOURCES = \
VBoxDbgBase.cpp \
VBoxDbgConsole.cpp \
VBoxDbgStatsQt.cpp
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp
index 5362e4029517..3d4a63920b68 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostALSAAudio.cpp
@@ -1,6 +1,6 @@
---- src/VBox/Devices/Audio/DrvHostALSAAudio.cpp.orig 2020-05-13 19:39:41 UTC
+--- src/VBox/Devices/Audio/DrvHostALSAAudio.cpp.orig 2021-01-07 15:37:12 UTC
+++ src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
-@@ -819,6 +819,7 @@ static DECLCALLBACK(int) drvHostALSAAudioStreamPlay(PP
+@@ -820,6 +820,7 @@ static DECLCALLBACK(int) drvHostAlsaAudioHA_StreamPlay
continue;
}
@@ -8,7 +8,7 @@
case -ESTRPIPE:
{
/* Stream was suspended and waiting for a recovery. */
-@@ -832,6 +833,7 @@ static DECLCALLBACK(int) drvHostALSAAudioStreamPlay(PP
+@@ -833,6 +834,7 @@ static DECLCALLBACK(int) drvHostAlsaAudioHA_StreamPlay
LogFlowFunc(("Resumed suspended output stream\n"));
continue;
}
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostOSSAudio.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostOSSAudio.cpp
new file mode 100644
index 000000000000..67d2319623ee
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Audio_DrvHostOSSAudio.cpp
@@ -0,0 +1,31 @@
+--- src/VBox/Devices/Audio/DrvHostOSSAudio.cpp.orig 2021-01-07 15:37:12 UTC
++++ src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
+@@ -253,10 +253,11 @@ static int ossStreamOpen(const char *pszDev, int fOpen
+
+ default:
+ rc = VERR_AUDIO_STREAM_COULD_NOT_CREATE;
++ iFormat = -1;
+ break;
+ }
+
+- if (RT_FAILURE(rc))
++ if (RT_UNLIKELY(iFormat == -1))
+ break;
+
+ if (ioctl(fdFile, SNDCTL_DSP_SAMPLESIZE, &iFormat))
+@@ -664,6 +665,7 @@ static int ossCreateStreamIn(POSSAUDIOSTREAM pStreamOS
+
+ pCfgAcq->Backend.cFramesPeriod = PDMAUDIOSTREAMCFG_B2F(pCfgAcq, ossAcq.cbFragmentSize);
+ pCfgAcq->Backend.cFramesBufferSize = pCfgAcq->Backend.cFramesPeriod * 2; /* Use "double buffering". */
++ pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesBufferSize;
+ /** @todo Pre-buffering required? */
+ }
+ }
+@@ -782,6 +784,7 @@ static int ossCreateStreamOut(POSSAUDIOSTREAM pStreamO
+ #endif
+ pCfgAcq->Backend.cFramesPeriod = PDMAUDIOSTREAMCFG_B2F(pCfgAcq, obtStream.cbFragmentSize);
+ pCfgAcq->Backend.cFramesBufferSize = pCfgAcq->Backend.cFramesPeriod * 2; /* Use "double buffering" */
++ pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesBufferSize;
+ }
+
+ } while (0);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.cpp
new file mode 100644
index 000000000000..c9574654562d
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.cpp
@@ -0,0 +1,29 @@
+--- src/VBox/Devices/Graphics/DevVGA-SVGA3d-glLdr.cpp.orig 2021-01-07 15:39:16 UTC
++++ src/VBox/Devices/Graphics/DevVGA-SVGA3d-glLdr.cpp
+@@ -186,7 +186,7 @@ int glLdrInit(PPDMDEVINS pDevIns)
+ pfn_wglDeleteContext = 0;
+ pfn_wglMakeCurrent = 0;
+ pfn_wglShareLists = 0;
+-#elif defined(RT_OS_LINUX)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ pfn_XConfigureWindow = 0;
+ pfn_XCloseDisplay = 0;
+ pfn_XCreateColormap = 0;
+@@ -296,7 +296,7 @@ int glLdrInit(PPDMDEVINS pDevIns)
+ GLGETPROC_(wglDeleteContext, "");
+ GLGETPROC_(wglMakeCurrent, "");
+ GLGETPROC_(wglShareLists, "");
+-#elif defined(RT_OS_LINUX)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ X11GETPROC_(XConfigureWindow);
+ X11GETPROC_(XCloseDisplay);
+ X11GETPROC_(XCreateColormap);
+@@ -397,7 +397,7 @@ int glLdrInit(PPDMDEVINS pDevIns)
+ GLGETPROC_(glVertexPointer, "");
+ GLGETPROC_(glViewport, "");
+
+-#ifdef RT_OS_LINUX
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ XInitThreads();
+ #endif
+ return VINF_SUCCESS;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.h b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.h
new file mode 100644
index 000000000000..3069950947cd
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-glLdr.h
@@ -0,0 +1,11 @@
+--- src/VBox/Devices/Graphics/DevVGA-SVGA3d-glLdr.h.orig 2021-01-07 15:39:17 UTC
++++ src/VBox/Devices/Graphics/DevVGA-SVGA3d-glLdr.h
+@@ -338,7 +338,7 @@ GLPFN BOOL (WINAPI *pfn_wglMakeCurrent)(HDC, HGLRC);
+ GLPFN BOOL (WINAPI *pfn_wglShareLists)(HGLRC, HGLRC);
+ #define wglShareLists pfn_wglShareLists
+
+-#elif defined(RT_OS_LINUX)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ /*
+ * GLX
+ */
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-ogl.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-ogl.cpp
new file mode 100644
index 000000000000..96058e78ff1f
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Graphics_DevVGA-SVGA3d-ogl.cpp
@@ -0,0 +1,38 @@
+--- src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp.orig 2021-01-07 15:39:17 UTC
++++ src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
+@@ -1189,7 +1189,7 @@ int vmsvga3dTerminate(PVGASTATECC pThisCC)
+ RTSemEventDestroy(pState->WndRequestSem);
+ #elif defined(RT_OS_DARWIN)
+
+-#elif defined(RT_OS_LINUX)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ /* signal to the thread that it is supposed to exit */
+ pState->bTerminate = true;
+ /* wait for it to terminate */
+@@ -3194,7 +3194,7 @@ int vmsvga3dGenerateMipmaps(PVGASTATECC pThisCC, uint3
+ }
+
+
+-#ifdef RT_OS_LINUX
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ /**
+ * X11 event handling thread.
+ *
+@@ -3224,7 +3224,7 @@ DECLCALLBACK(int) vmsvga3dXEventThread(RTTHREAD hThrea
+ }
+ return VINF_SUCCESS;
+ }
+-#endif // RT_OS_LINUX
++#endif // RT_OS_FREEBSD || RT_OS_LINUX
+
+
+ /**
+@@ -4052,7 +4052,7 @@ static int vmsvga3dContextDestroyOgl(PVGASTATECC pThis
+ AssertRC(rc);
+ #elif defined(RT_OS_DARWIN)
+ vmsvga3dCocoaDestroyViewAndContext(pContext->cocoaView, pContext->cocoaContext);
+-#elif defined(RT_OS_LINUX)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
+ glXMakeCurrent(pState->display, None, NULL);
+ glXDestroyContext(pState->display, pContext->glxContext);
+ XDestroyWindow(pState->display, pContext->window);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Makefile.kmk
new file mode 100644
index 000000000000..257e61da679d
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_Makefile.kmk
@@ -0,0 +1,44 @@
+--- src/VBox/Devices/Makefile.kmk.orig 2021-01-07 15:39:35 UTC
++++ src/VBox/Devices/Makefile.kmk
+@@ -112,6 +112,7 @@ if !defined(VBOX_ONLY_EXTPACKS)
+ VBoxDDU_LDFLAGS.darwin += -framework IOKit
+ endif
+
++ VBoxDDU_LDFLAGS.freebsd = $(VBOX_GCC_NO_UNDEFINED)
+ VBoxDDU_LDFLAGS.linux = $(VBOX_GCC_NO_UNDEFINED)
+ $(call VBOX_SET_VER_INFO_DLL,VBoxDDU,VirtualBox VMM Devices and Drivers Utilities)
+
+@@ -245,6 +246,7 @@ if !defined(VBOX_ONLY_EXTPACKS) && "$(intersects $(KBU
+ -framework SystemConfiguration \
+ -framework AVFoundation \
+ -framework Foundation
++ VBoxDD_LDFLAGS.freebsd = $(VBOX_GCC_NO_UNDEFINED)
+ VBoxDD_LDFLAGS.linux = $(VBOX_GCC_NO_UNDEFINED)
+
+ # --- Tracing bits. ---
+@@ -287,7 +289,7 @@ if !defined(VBOX_ONLY_EXTPACKS) && "$(intersects $(KBU
+ VBoxDD_SOURCES += Graphics/DevVGA-SVGA.cpp
+ endif
+ ifdef VBOX_WITH_VMSVGA3D
+- if1of ($(KBUILD_TARGET), linux win)
++ if1of ($(KBUILD_TARGET), freebsd linux win)
+ # Dynamically load 3D library (opengl32, libGL).
+ # This is a temporary solution. In future the 3D backend will be in a separate library.
+ VBOX_WITH_VMSVGA3D_DYNAMIC_LOAD = 1
+@@ -329,6 +331,7 @@ VBOX_WITH_VMSVGA3D_DYNAMIC_LOAD = 1
+ VBoxDD_SOURCES += \
+ Graphics/DevVGA-SVGA3d-glLdr.cpp
+ else
++ VBoxDD_LIBS.freebsd += X11 GL
+ VBoxDD_LIBS.linux += X11 GL
+ VBoxDD_LIBS.win += $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Opengl32.lib
+ endif
+@@ -1526,6 +1529,8 @@ if defined(VBOX_WITH_VMSVGA3D) && !defined(VBOX_ONLY_E
+ VBoxSVGA3D_INCS = $(VBOX_GRAPHICS_INCS)
+ VBoxSVGA3D_INCS.win := \
+ Graphics/shaderlib/libWineStub/include
++ VBoxSVGA3D_INCS.freebsd := \
++ Graphics/shaderlib/wine/include
+ VBoxSVGA3D_INCS.linux := \
+ Graphics/shaderlib/wine/include
+ VBoxSVGA3D_INCS.darwin := \
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_ipxe_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_ipxe_Makefile.kmk
new file mode 100644
index 000000000000..5d6e9ee0f2f2
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Devices_PC_ipxe_Makefile.kmk
@@ -0,0 +1,20 @@
+--- src/VBox/Devices/PC/ipxe/Makefile.kmk.orig 2021-01-07 15:39:44 UTC
++++ src/VBox/Devices/PC/ipxe/Makefile.kmk
+@@ -121,7 +121,7 @@ endif
+ -falign-loops=1 \
+ -Os \
+ -falign-functions=1 \
+- -mpreferred-stack-boundary=2 \
++ -mstack-alignment=2 \
+ -mregparm=3 \
+ -mrtd \
+ -freg-struct-return \
+@@ -144,7 +144,7 @@ endif
+ -falign-jumps=1 \
+ -falign-loops=1 \
+ -falign-functions=1 \
+- -mpreferred-stack-boundary=2 \
++ -mstack-alignment=2 \
+ -mregparm=3 \
+ -mrtd \
+ -freg-struct-return \
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
index b3ba3993fe3d..925c6ca2157d 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
@@ -1,6 +1,15 @@
---- src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp.orig 2020-05-13 19:43:27 UTC
+--- src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp.orig 2021-01-07 15:40:48 UTC
+++ src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
-@@ -622,7 +622,7 @@ void printUsage(USAGECATEGORY fCategory, uint32_t fSub
+@@ -646,7 +646,7 @@ void printUsage(USAGECATEGORY enmCommand, uint64_t fSu
+ " file <file>|\n"
+ " <devicename>]\n"
+ " [--uarttype<1-N> 16450|16550A|16750]\n"
+-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
+ " [--lpt<1-N> off|<I/O base> <IRQ>]\n"
+ " [--lptmode<1-N> <devicename>]\n"
+ #endif
+@@ -661,7 +661,7 @@ void printUsage(USAGECATEGORY enmCommand, uint64_t fSu
RTStrmPrintf(pStrm, "|dsound");
#endif
}
@@ -9,7 +18,7 @@
{
RTStrmPrintf(pStrm, ""
#ifdef VBOX_WITH_AUDIO_OSS
-@@ -635,22 +635,6 @@ void printUsage(USAGECATEGORY fCategory, uint32_t fSub
+@@ -674,22 +674,6 @@ void printUsage(USAGECATEGORY enmCommand, uint64_t fSu
"|pulse"
#endif
);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp
new file mode 100644
index 000000000000..adc5217b88f3
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp
@@ -0,0 +1,29 @@
+--- src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp.orig 2021-01-07 15:40:49 UTC
++++ src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
+@@ -153,7 +153,7 @@ enum
+ MODIFYVM_UARTMODE,
+ MODIFYVM_UARTTYPE,
+ MODIFYVM_UART,
+-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
+ MODIFYVM_LPTMODE,
+ MODIFYVM_LPT,
+ #endif
+@@ -348,7 +348,7 @@ static const RTGETOPTDEF g_aModifyVMOptions[] =
+ { "--uartmode", MODIFYVM_UARTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
+ { "--uarttype", MODIFYVM_UARTTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
+ { "--uart", MODIFYVM_UART, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
+-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
+ { "--lptmode", MODIFYVM_LPTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
+ { "--lpt", MODIFYVM_LPT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
+ #endif
+@@ -2278,7 +2278,7 @@ RTEXITCODE handleModifyVM(HandlerArg *a)
+ break;
+ }
+
+-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
+ case MODIFYVM_LPTMODE:
+ {
+ ComPtr<IParallelPort> lpt;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
index ee9bc539d71f..c339a8b87443 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
@@ -1,14 +1,14 @@
---- src/VBox/Frontends/VirtualBox/Makefile.kmk.orig 2020-05-13 19:43:28 UTC
+--- src/VBox/Frontends/VirtualBox/Makefile.kmk.orig 2021-01-07 15:40:49 UTC
+++ src/VBox/Frontends/VirtualBox/Makefile.kmk
-@@ -897,6 +897,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_GUI
- VirtualBox_SOURCES += \
+@@ -1186,6 +1186,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_GUI
+ src/VBox2DHelpers.cpp \
src/VBoxFBOverlay.cpp \
src/VBoxGLSupportInfo.cpp
+ VirtualBox_CXXFLAGS.freebsd += -std=c++11
endif
- #
-@@ -1220,6 +1221,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL)
+ $(call VBOX_SET_VER_INFO_EXE,VirtualBox,VirtualBox Manager,$(VBOX_WINDOWS_ICON_FILE))
+@@ -1862,6 +1863,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL)
VBoxOGL2D_SOURCES = \
src/VBoxGLSupportInfo.cpp
VBoxOGL2D_INCS = include
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
index 11c13584a97b..e34783734251 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
@@ -4,8 +4,8 @@
/** @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)
+-#if (defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)) && !defined(VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV)
++#if (defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)) && !defined(VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV)
# define SUPDRV_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
# define SUPDRV_CHECK_SMAP_CHECK(a_pDevExt, a_BadExpr) \
do { \
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
index 68e5920ecdbc..7376ad6fbddd 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
@@ -1,6 +1,6 @@
---- src/VBox/HostDrivers/Support/SUPDrvInternal.h.orig 2020-05-13 19:43:52 UTC
+--- src/VBox/HostDrivers/Support/SUPDrvInternal.h.orig 2021-01-07 15:41:25 UTC
+++ src/VBox/HostDrivers/Support/SUPDrvInternal.h
-@@ -208,7 +208,7 @@
+@@ -217,7 +217,7 @@
# define SUPDRV_WITHOUT_MSR_PROBER
#endif
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c
index 63e8769ce7c2..6afc3a695bc9 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c
@@ -1,14 +1,17 @@
---- src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c.orig 2020-05-13 19:43:53 UTC
+--- src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c.orig 2021-01-07 15:41:26 UTC
+++ src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
-@@ -46,6 +46,7 @@
+@@ -44,8 +44,10 @@
+ #include <sys/fcntl.h>
+ #include <sys/conf.h>
#include <sys/uio.h>
++#include <sys/mutex.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 @@
+@@ -57,7 +59,14 @@
#include <iprt/alloc.h>
#include <iprt/err.h>
#include <iprt/asm.h>
@@ -23,7 +26,7 @@
#ifdef VBOX_WITH_HARDENING
# define VBOXDRV_PERM 0600
#else
-@@ -76,7 +84,9 @@ static d_open_t VBoxDrvFreeBSDOpenUsr;
+@@ -76,7 +85,9 @@ static d_open_t VBoxDrvFreeBSDOpenUsr;
static d_open_t VBoxDrvFreeBSDOpenSys;
static void vboxdrvFreeBSDDtr(void *pvData);
static d_ioctl_t VBoxDrvFreeBSDIOCtl;
@@ -33,7 +36,7 @@
/*********************************************************************************************************************************
-@@ -182,6 +192,13 @@ static int VBoxDrvFreeBSDLoad(void)
+@@ -182,6 +193,13 @@ static int VBoxDrvFreeBSDLoad(void)
rc = supdrvInitDevExt(&g_VBoxDrvFreeBSDDevExt, sizeof(SUPDRVSESSION));
if (RT_SUCCESS(rc))
{
@@ -47,29 +50,7 @@
/*
* 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
+@@ -324,6 +342,45 @@ static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_lo
/**
@@ -115,7 +96,7 @@
* 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
+@@ -372,11 +429,10 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
*/
SUPREQHDR Hdr;
pvUser = *(void **)pvData;
@@ -130,7 +111,7 @@
}
if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
{
-@@ -402,13 +471,12 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
+@@ -401,13 +457,12 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: failed to allocate buffer of %d bytes; ulCmd=%#lx\n", cbReq, ulCmd));
return ENOMEM;
}
@@ -148,7 +129,7 @@
}
if (Hdr.cbIn < cbReq)
RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn);
-@@ -436,9 +504,8 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
+@@ -435,9 +490,8 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes
OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbOut, cbReq, ulCmd));
cbOut = cbReq;
}
@@ -160,7 +141,7 @@
Log(("VBoxDrvFreeBSDIOCtlSlow: returns %d / %d ulCmd=%lx\n", 0, pHdr->rc, ulCmd));
-@@ -541,8 +608,7 @@ bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDE
+@@ -540,8 +594,7 @@ bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDE
bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void)
{
@@ -170,7 +151,7 @@
}
-@@ -625,11 +691,25 @@ int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu,
+@@ -624,11 +677,25 @@ int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu,
#endif /* SUPDRV_WITH_MSR_PROBER */
@@ -196,7 +177,7 @@
va_start(va, pszFormat);
cch = RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, va);
-@@ -637,12 +717,19 @@ SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...)
+@@ -636,12 +703,19 @@ SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...)
printf("%s", szMsg);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetAdp_freebsd_Makefile b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetAdp_freebsd_Makefile
new file mode 100644
index 000000000000..e94dc6f85e27
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetAdp_freebsd_Makefile
@@ -0,0 +1,11 @@
+--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/Makefile.orig 2019-05-13 13:33:07 UTC
++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/Makefile
+@@ -26,7 +26,7 @@
+
+ KMOD = vboxnetadp
+
+-CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVIMAGE
++CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS -DVIMAGE -Iinclude -I. -Ir0drv -w
+
+ .if (${MACHINE_ARCH} == "i386")
+ CFLAGS += -DRT_ARCH_X86
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk
new file mode 100644
index 000000000000..9c7ab624c52a
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk
@@ -0,0 +1,11 @@
+--- src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk.orig 2019-05-13 13:33:07 UTC
++++ src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk
+@@ -565,7 +565,7 @@ $(PATH_OUT)/opt_netgraph.h:
+ $(QUIET)$(RM) -f -- $@
+ $(QUIET)$(CP) -f $< $@
+ ifndef VBOX_WITH_HARDENING
+- $(QUIET)$(SED) -e "s;VBOX_WITH_HARDENING;;g" --output $@.tmp $@
++ $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@.tmp $@
+ ${QUIET}$(MV) -f $@.tmp $@
+ endif
+ ifndef VBOX_WITH_NETFLT_VIMAGE
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_Makefile b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_Makefile
new file mode 100644
index 000000000000..e819561ab9a8
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_VBoxNetFlt_freebsd_Makefile
@@ -0,0 +1,11 @@
+--- src/VBox/HostDrivers/VBoxNetFlt/freebsd/Makefile.orig 2019-05-13 13:33:07 UTC
++++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/Makefile
+@@ -26,7 +26,7 @@
+
+ KMOD = vboxnetflt
+
+-CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVIMAGE
++CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS -DVIMAGE -Iinclude -I. -Ir0drv -w
+
+ .if (${MACHINE_ARCH} == "i386")
+ CFLAGS += -DRT_ARCH_X86
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Main_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_VBox_Main_Makefile.kmk
index 154ce9130b56..173a896547a1 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Main_Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Main_Makefile.kmk
@@ -1,6 +1,6 @@
---- src/VBox/Main/Makefile.kmk.orig 2020-05-13 19:44:04 UTC
+--- src/VBox/Main/Makefile.kmk.orig 2021-01-07 15:41:36 UTC
+++ src/VBox/Main/Makefile.kmk
-@@ -526,6 +526,7 @@ VBoxSVC_SOURCES.os2 = \
+@@ -646,6 +646,7 @@ VBoxSVC_SOURCES.os2 = \
VBoxSVC_SOURCES.freebsd = \
src-server/freebsd/HostHardwareFreeBSD.cpp \
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Main_include_HostPower.h b/emulators/virtualbox-ose/files/patch-src_VBox_Main_include_HostPower.h
index 4c6a36061a8d..5718fe987ce4 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Main_include_HostPower.h
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Main_include_HostPower.h
@@ -1,6 +1,6 @@
---- src/VBox/Main/include/HostPower.h.orig 2017-10-18 07:12:54 UTC
+--- src/VBox/Main/include/HostPower.h.orig 2021-01-07 15:41:38 UTC
+++ src/VBox/Main/include/HostPower.h
-@@ -28,7 +28,7 @@
+@@ -31,7 +31,7 @@
#include <vector>
@@ -9,7 +9,7 @@
# include <VBox/dbus.h>
#endif
-@@ -64,7 +64,7 @@ class HostPowerServiceWin : public HostPowerService (p
+@@ -67,7 +67,7 @@ class HostPowerServiceWin : public HostPowerService (p
RTTHREAD mThread;
};
# endif
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_HostImpl.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_HostImpl.cpp
index c7807331a213..d4c018b2fc23 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_HostImpl.cpp
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Main_src-server_HostImpl.cpp
@@ -1,6 +1,6 @@
---- src/VBox/Main/src-server/HostImpl.cpp.orig 2020-05-13 19:44:09 UTC
+--- src/VBox/Main/src-server/HostImpl.cpp.orig 2021-01-07 15:41:42 UTC
+++ src/VBox/Main/src-server/HostImpl.cpp
-@@ -284,7 +284,7 @@ HRESULT Host::init(VirtualBox *aParent)
+@@ -286,7 +286,7 @@ HRESULT Host::init(VirtualBox *aParent)
#if defined(RT_OS_WINDOWS)
m->pHostPowerService = new HostPowerServiceWin(m->pParent);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_NetworkServices_Dhcpd_VBoxNetDhcpd.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_NetworkServices_Dhcpd_VBoxNetDhcpd.cpp
new file mode 100644
index 000000000000..fb84e7344504
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_NetworkServices_Dhcpd_VBoxNetDhcpd.cpp
@@ -0,0 +1,11 @@
+--- src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp.orig 2021-01-07 15:41:46 UTC
++++ src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
+@@ -394,7 +394,7 @@ void VBoxNetDhcpd::ifPump()
+ WaitReq.Hdr.cbReq = sizeof(WaitReq);
+ WaitReq.pSession = m_pSession;
+ WaitReq.hIf = m_hIf;
+- WaitReq.cMillies = RT_INDEFINITE_WAIT;
++ WaitReq.cMillies = 2000;
+ int rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_WAIT, WaitReq);
+
+ /*
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c
index b82ec16c3ccc..9424293d8fb6 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_alloc-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- 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.orig 2021-01-07 15:42:08 UTC
+++ src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
-@@ -54,6 +54,7 @@ MALLOC_DEFINE(M_IPRTCONT, "iprtcont", "IPRT - contiguo
+@@ -78,6 +78,7 @@ MALLOC_DEFINE(M_IPRTCONT, "iprtcont", "IPRT - contiguo
DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
{
@@ -8,7 +8,7 @@
size_t cbAllocated = cb;
PRTMEMHDR pHdr = NULL;
-@@ -76,8 +77,10 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
+@@ -100,8 +101,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);
@@ -20,7 +20,7 @@
/* 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
+@@ -138,6 +141,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
fFlags & RTMEMHDR_FLAG_ZEROED ? M_NOWAIT | M_ZERO : M_NOWAIT);
}
@@ -29,7 +29,7 @@
if (RT_UNLIKELY(!pHdr))
return VERR_NO_MEMORY;
-@@ -129,6 +134,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
+@@ -153,6 +158,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
{
@@ -38,7 +38,7 @@
pHdr->u32Magic += 1;
#ifdef RT_ARCH_AMD64
-@@ -141,11 +148,14 @@ DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
+@@ -165,11 +172,14 @@ DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
else
#endif
free(pHdr, M_IPRTHEAP);
@@ -53,7 +53,7 @@
void *pv;
/*
-@@ -170,6 +180,7 @@ RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_
+@@ -194,6 +204,7 @@ RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_
*pPhys = vtophys(pv);
Assert(!(*pPhys & PAGE_OFFSET_MASK));
}
@@ -61,7 +61,7 @@
return pv;
}
-@@ -179,7 +190,9 @@ RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
+@@ -203,7 +214,9 @@ RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
if (pv)
{
AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c
index 4ad72bc7dd59..4c628cbe47a5 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_assert-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- 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.orig 2021-01-07 15:42:08 UTC
+++ src/VBox/Runtime/r0drv/freebsd/assert-r0drv-freebsd.c
-@@ -44,15 +44,18 @@
+@@ -68,15 +68,18 @@
DECLHIDDEN(void) rtR0AssertNativeMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
{
@@ -19,7 +19,7 @@
char szMsg[256];
RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
-@@ -60,6 +63,7 @@ DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial,
+@@ -84,6 +87,7 @@ DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial,
printf("%s", szMsg);
NOREF(fInitial);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c
index 51111ee95102..069b50bb877a 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_memobj-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig 2020-07-09 16:57:38 UTC
+--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig 2020-10-16 16:38:10 UTC
+++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
-@@ -105,6 +105,7 @@ static vm_map_t rtR0MemObjFreeBSDGetMap(PRTR0MEMOBJINT
+@@ -129,6 +129,7 @@ static vm_map_t rtR0MemObjFreeBSDGetMap(PRTR0MEMOBJINT
DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
{
@@ -8,7 +8,7 @@
PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)pMem;
int rc;
-@@ -121,16 +122,15 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
+@@ -145,16 +146,15 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
case RTR0MEMOBJTYPE_LOCK:
{
@@ -30,7 +30,7 @@
break;
}
-@@ -194,6 +194,7 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
+@@ -210,6 +210,7 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
return VERR_INTERNAL_ERROR;
}
@@ -38,93 +38,17 @@
return VINF_SUCCESS;
}
-@@ -224,18 +225,23 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelpe
- #else
- VM_OBJECT_UNLOCK(pObject);
- #endif
-- if (pPages)
-+ if (pPages || cTries >= 1)
- break;
-+#if __FreeBSD_version >= 1100092
-+ if (!vm_page_reclaim_contig(fFlags, cPages, 0, VmPhysAddrHigh, uAlignment, 0))
-+ break;
-+#elif __FreeBSD_version >= 1000015
- vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
-+#else
-+ vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
-+#endif
- cTries++;
- }
--
-- return pPages;
- #else
-- while (cTries <= 1)
-+ while (1)
- {
- pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
-- if (pPages)
-+ if (pPages || cTries >= 1)
- break;
- vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
- cTries++;
-@@ -243,11 +249,8 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelpe
-
- if (!pPages)
- return pPages;
--#if __FreeBSD_version >= 1000030
-- VM_OBJECT_WLOCK(pObject);
--#else
-+
- VM_OBJECT_LOCK(pObject);
--#endif
- for (vm_pindex_t iPage = 0; iPage < cPages; iPage++)
- {
- vm_page_t pPage = pPages + iPage;
-@@ -259,13 +262,9 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelpe
- atomic_add_int(&cnt.v_wire_count, 1);
- }
- }
--#if __FreeBSD_version >= 1000030
-- VM_OBJECT_WUNLOCK(pObject);
--#else
- VM_OBJECT_UNLOCK(pObject);
- #endif
- return pPages;
--#endif
- }
-
- static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
-@@ -292,16 +291,17 @@ static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_
- #else
- VM_OBJECT_LOCK(pObject);
- #endif
-+
- while (iPage-- > 0)
- {
- pPage = vm_page_lookup(pObject, iPage);
--#if __FreeBSD_version < 1000000
-+#if __FreeBSD_version < 900000
- vm_page_lock_queues();
- #endif
- if (fWire)
- vm_page_unwire(pPage, 0);
- vm_page_free(pPage);
--#if __FreeBSD_version < 1000000
-+#if __FreeBSD_version < 900000
- vm_page_unlock_queues();
- #endif
- }
-@@ -323,7 +323,8 @@ static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFRE
+@@ -320,7 +321,8 @@ static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFRE
size_t cPages = atop(pMemFreeBSD->Core.cb);
int rc;
- pMemFreeBSD->pObject = vm_object_allocate(OBJT_PHYS, cPages);
+ pMemFreeBSD->pObject = vm_pager_allocate(OBJT_PHYS, NULL,
-+ pMemFreeBSD->Core.cb, VM_PROT_ALL, 0, curthread->td_ucred);
++ pMemFreeBSD->Core.cb, VM_PROT_ALL, 0, curthread->td_ucred);
/* No additional object reference for auto-deallocation upon unmapping. */
#if __FreeBSD_version >= 1000055
-@@ -364,58 +365,77 @@ static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFRE
+@@ -361,58 +363,77 @@ static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFRE
}
DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
{
@@ -202,7 +126,7 @@
return rc;
}
-@@ -425,6 +445,7 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
+@@ -422,6 +443,7 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
RTHCPHYS PhysHighest, size_t uAlignment,
bool fContiguous, int rcNoMem)
{
@@ -210,7 +134,7 @@
uint32_t cPages = atop(cb);
vm_paddr_t VmPhysAddrHigh;
-@@ -432,9 +453,13 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
+@@ -429,9 +451,13 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD),
enmType, NULL, cb);
if (!pMemFreeBSD)
@@ -221,11 +145,11 @@
- pMemFreeBSD->pObject = vm_object_allocate(OBJT_PHYS, atop(cb));
+ pMemFreeBSD->pObject = vm_pager_allocate(OBJT_PHYS, NULL,
-+ pMemFreeBSD->Core.cb, VM_PROT_ALL, 0, curthread->td_ucred);
++ pMemFreeBSD->Core.cb, VM_PROT_ALL, 0, curthread->td_ucred);
if (PhysHighest != NIL_RTHCPHYS)
VmPhysAddrHigh = PhysHighest;
-@@ -470,6 +495,7 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
+@@ -459,6 +485,7 @@ static int rtR0MemObjFreeBSDAllocPhysPages(PPRTR0MEMOB
rtR0MemObjDelete(&pMemFreeBSD->Core);
}
@@ -233,7 +157,7 @@
return rc;
}
-@@ -489,17 +515,22 @@ DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMO
+@@ -478,17 +505,22 @@ DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMO
DECLHIDDEN(int) rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
{
AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_SUPPORTED);
@@ -256,7 +180,7 @@
return VINF_SUCCESS;
}
-@@ -511,6 +542,7 @@ static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTER
+@@ -500,6 +532,7 @@ static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTER
vm_offset_t AddrStart, size_t cb, uint32_t fAccess,
RTR0PROCESS R0Process, int fFlags)
{
@@ -264,7 +188,7 @@
int rc;
NOREF(fAccess);
-@@ -519,21 +551,28 @@ static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTER
+@@ -508,21 +541,28 @@ static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTER
if (!pMemFreeBSD)
return VERR_NO_MEMORY;
@@ -301,7 +225,7 @@
return VERR_NO_MEMORY;/** @todo fix mach -> vbox error conversion for freebsd. */
}
-@@ -569,6 +608,7 @@ DECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOB
+@@ -558,6 +598,7 @@ DECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOB
*/
static int rtR0MemObjNativeReserveInMap(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process, vm_map_t pMap)
{
@@ -309,7 +233,7 @@
int rc;
/*
-@@ -626,11 +666,13 @@ static int rtR0MemObjNativeReserveInMap(PPRTR0MEMOBJIN
+@@ -615,11 +656,13 @@ static int rtR0MemObjNativeReserveInMap(PPRTR0MEMOBJIN
pMemFreeBSD->Core.pv = (void *)MapAddress;
pMemFreeBSD->Core.u.ResVirt.R0Process = R0Process;
*ppMem = &pMemFreeBSD->Core;
@@ -323,7 +247,7 @@
return rc;
}
-@@ -652,6 +694,8 @@ DECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMO
+@@ -641,6 +684,8 @@ DECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMO
DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
unsigned fProt, size_t offSub, size_t cbSub)
{
@@ -332,7 +256,7 @@
// AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
-@@ -707,6 +751,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
+@@ -697,6 +742,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
Assert((vm_offset_t)pMemFreeBSD->Core.pv == Addr);
pMemFreeBSD->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;
*ppMem = &pMemFreeBSD->Core;
@@ -340,7 +264,7 @@
return VINF_SUCCESS;
}
rc = vm_map_remove(kernel_map, Addr, Addr + cbSub);
-@@ -715,6 +760,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
+@@ -705,6 +751,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
else
vm_object_deallocate(pMemToMapFreeBSD->pObject);
@@ -348,43 +272,39 @@
return VERR_NO_MEMORY;
}
-@@ -722,6 +768,8 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
+@@ -712,6 +759,8 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJ
DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
- unsigned fProt, RTR0PROCESS R0Process)
+ unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
{
+ IPRT_FREEBSD_SAVE_EFL_AC();
+
/*
* Check for unsupported stuff.
*/
-@@ -751,7 +799,12 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
- {
- /** @todo is this needed?. */
- PROC_LOCK(pProc);
-- AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr + lim_max(pProc, RLIMIT_DATA));
-+ AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr +
-+#if __FreeBSD_version >= 1100077
-+ lim_max_proc(pProc, RLIMIT_DATA));
-+#else
-+ lim_max(pProc, RLIMIT_DATA));
-+#endif
- PROC_UNLOCK(pProc);
- }
- else
-@@ -774,10 +827,9 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+@@ -768,47 +817,53 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
0); /* copy-on-write and similar flags */
if (rc == KERN_SUCCESS)
-- {
- rc = vm_map_wire(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
-- AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
--
++ rc = vm_map_wire(pProcMap, AddrR3, AddrR3 + cbSub, VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
+ if (rc == KERN_SUCCESS)
-+ {
- rc = vm_map_inherit(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_INHERIT_SHARE);
+ {
+- rc = vm_map_wire(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
++ rc = vm_map_inherit(pProcMap, AddrR3, AddrR3 + cbSub, VM_INHERIT_SHARE);
AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
-@@ -793,6 +845,7 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+- rc = vm_map_inherit(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_INHERIT_SHARE);
+- AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
+-
+ /*
+ * Create a mapping object for it.
+ */
+ PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(RTR0MEMOBJFREEBSD),
+ RTR0MEMOBJTYPE_MAPPING,
+ (void *)AddrR3,
+- pMemToMap->cb);
++ cbSub);
+ if (pMemFreeBSD)
+ {
Assert((vm_offset_t)pMemFreeBSD->Core.pv == AddrR3);
pMemFreeBSD->Core.u.Mapping.R0Process = R0Process;
*ppMem = &pMemFreeBSD->Core;
@@ -392,7 +312,10 @@
return VINF_SUCCESS;
}
-@@ -802,19 +855,25 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJIN
+- rc = vm_map_remove(pProcMap, AddrR3, AddrR3 + pMemToMap->cb);
++ rc = vm_map_remove(pProcMap, AddrR3, AddrR3 + cbSub /* XXX pMemToMap->cb*/ );
+ AssertMsg(rc == KERN_SUCCESS, ("Deleting mapping failed\n"));
+ }
else
vm_object_deallocate(pMemToMapFreeBSD->pObject);
@@ -418,7 +341,7 @@
if ((fProt & RTMEM_PROT_NONE) == RTMEM_PROT_NONE)
ProtectionFlags = VM_PROT_NONE;
-@@ -825,7 +884,12 @@ DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINT
+@@ -819,7 +874,12 @@ DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINT
if ((fProt & RTMEM_PROT_EXEC) == RTMEM_PROT_EXEC)
ProtectionFlags |= VM_PROT_EXECUTE;
@@ -431,7 +354,7 @@
if (krc == KERN_SUCCESS)
return VINF_SUCCESS;
-@@ -850,11 +914,19 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
+@@ -844,11 +904,19 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
vm_offset_t pb = (vm_offset_t)pMemFreeBSD->Core.pv + ptoa(iPage);
@@ -455,7 +378,7 @@
}
case RTR0MEMOBJTYPE_MAPPING:
-@@ -863,11 +935,15 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
+@@ -857,11 +925,15 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
if (pMemFreeBSD->Core.u.Mapping.R0Process != NIL_RTR0PROCESS)
{
@@ -472,18 +395,14 @@
}
return vtophys(pb);
}
-@@ -877,6 +953,7 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
- case RTR0MEMOBJTYPE_PHYS_NC:
+@@ -872,9 +944,11 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
{
RTHCPHYS addr;
+
+ IPRT_FREEBSD_SAVE_EFL_AC();
- #if __FreeBSD_version >= 1000030
VM_OBJECT_WLOCK(pMemFreeBSD->pObject);
- #else
-@@ -888,6 +965,7 @@ DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(P
- #else
- VM_OBJECT_UNLOCK(pMemFreeBSD->pObject);
- #endif
+ addr = VM_PAGE_TO_PHYS(vm_page_lookup(pMemFreeBSD->pObject, iPage));
+ VM_OBJECT_WUNLOCK(pMemFreeBSD->pObject);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return addr;
}
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c
index 1de5b95f38b0..8c68cae63a34 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_mp-r0drv-freebsd.c
@@ -1,22 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c.orig 2019-04-16 10:17:21 UTC
+++ src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c
-@@ -36,6 +36,15 @@
- #include <iprt/cpuset.h>
- #include "r0drv/mp-r0drv.h"
-
-+#if __FreeBSD_version >= 700000 && __FreeBSD_version < 900000
-+#define cpuset_t cpumask_t
-+#define all_cpus (~(cpumask_t)0)
-+#define CPU_CLR(n, p) do { *(p) &= ~((cpumask_t)1 << (n)); } while (0)
-+#define CPU_SETOF(n, p) do { *(p) = (cpumask_t)1 << (n); } while (0)
-+#endif
-+#if __FreeBSD_version < 1200028
-+#define smp_no_rendezvous_barrier smp_no_rendevous_barrier
-+#endif
-
- RTDECL(RTCPUID) RTMpCpuId(void)
- {
-@@ -143,7 +152,9 @@ RTDECL(RTCPUID) RTMpGetOnlineCount(void)
+@@ -147,7 +147,9 @@ RTDECL(RTCPUID) RTMpGetOnlineCount(void)
static void rtmpOnAllFreeBSDWrapper(void *pvArg)
{
PRTMPARGS pArgs = (PRTMPARGS)pvArg;
@@ -26,18 +10,17 @@
}
-@@ -155,7 +166,9 @@ RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *p
+@@ -159,7 +161,9 @@ RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *p
Args.pvUser2 = pvUser2;
Args.idCpu = NIL_RTCPUID;
Args.cHits = 0;
-- smp_rendezvous(NULL, rtmpOnAllFreeBSDWrapper, smp_no_rendevous_barrier, &Args);
+ IPRT_FREEBSD_SAVE_EFL_AC();
-+ smp_rendezvous(NULL, rtmpOnAllFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
+ smp_rendezvous(NULL, rtmpOnAllFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VINF_SUCCESS;
}
-@@ -171,7 +184,11 @@ static void rtmpOnOthersFreeBSDWrapper(void *pvArg)
+@@ -175,7 +179,11 @@ static void rtmpOnOthersFreeBSDWrapper(void *pvArg)
PRTMPARGS pArgs = (PRTMPARGS)pvArg;
RTCPUID idCpu = curcpu;
if (pArgs->idCpu != idCpu)
@@ -49,35 +32,15 @@
}
-@@ -180,10 +197,8 @@ RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void
- /* Will panic if no rendezvousing cpus, so check up front. */
- if (RTMpGetOnlineCount() > 1)
- {
--#if __FreeBSD_version >= 900000
-- cpuset_t Mask;
--#elif __FreeBSD_version >= 700000
-- cpumask_t Mask;
-+#if __FreeBSD_version >= 700000
-+ cpuset_t Cpus;
- #endif
- RTMPARGS Args;
-
-@@ -192,17 +207,15 @@ RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void
+@@ -196,6 +204,7 @@ RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void
Args.pvUser2 = pvUser2;
Args.idCpu = RTMpCpuId();
Args.cHits = 0;
+ IPRT_FREEBSD_SAVE_EFL_AC();
#if __FreeBSD_version >= 700000
--# if __FreeBSD_version >= 900000
-- Mask = all_cpus;
-- CPU_CLR(curcpu, &Mask);
--# else
-- Mask = ~(cpumask_t)curcpu;
--# endif
-- smp_rendezvous_cpus(Mask, NULL, rtmpOnOthersFreeBSDWrapper, smp_no_rendevous_barrier, &Args);
-+ Cpus = all_cpus;
-+ CPU_CLR(curcpu, &Cpus);
-+ smp_rendezvous_cpus(Cpus, NULL, rtmpOnOthersFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
+ # if __FreeBSD_version >= 900000
+ Mask = all_cpus;
+@@ -207,6 +216,7 @@ RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void
#else
smp_rendezvous(NULL, rtmpOnOthersFreeBSDWrapper, NULL, &Args);
#endif
@@ -85,7 +48,7 @@
}
return VINF_SUCCESS;
}
-@@ -220,18 +233,18 @@ static void rtmpOnSpecificFreeBSDWrapper(void *pvArg)
+@@ -224,8 +234,10 @@ static void rtmpOnSpecificFreeBSDWrapper(void *pvArg)
RTCPUID idCpu = curcpu;
if (pArgs->idCpu == idCpu)
{
@@ -96,32 +59,15 @@
}
}
-
- RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
- {
--#if __FreeBSD_version >= 900000
-- cpuset_t Mask;
--#elif __FreeBSD_version >= 700000
-- cpumask_t Mask;
-+#if __FreeBSD_version >= 700000
-+ cpuset_t Cpus;
- #endif
- RTMPARGS Args;
-
-@@ -244,16 +257,14 @@ RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKE
+@@ -248,6 +260,7 @@ RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKE
Args.pvUser2 = pvUser2;
Args.idCpu = idCpu;
Args.cHits = 0;
+ IPRT_FREEBSD_SAVE_EFL_AC();
#if __FreeBSD_version >= 700000
--# if __FreeBSD_version >= 900000
-- CPU_SETOF(idCpu, &Mask);
--# else
-- Mask = (cpumask_t)1 << idCpu;
--# endif
-- smp_rendezvous_cpus(Mask, NULL, rtmpOnSpecificFreeBSDWrapper, smp_no_rendevous_barrier, &Args);
-+ CPU_SETOF(idCpu, &Cpus);
-+ smp_rendezvous_cpus(Cpus, NULL, rtmpOnSpecificFreeBSDWrapper, smp_no_rendezvous_barrier, &Args);
+ # if __FreeBSD_version >= 900000
+ CPU_SETOF(idCpu, &Mask);
+@@ -258,6 +271,7 @@ RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKE
#else
smp_rendezvous(NULL, rtmpOnSpecificFreeBSDWrapper, NULL, &Args);
#endif
@@ -129,30 +75,17 @@
return Args.cHits == 1
? VINF_SUCCESS
: VERR_CPU_NOT_FOUND;
-@@ -273,22 +284,16 @@ static void rtmpFreeBSDPokeCallback(void *pvArg)
-
- RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
- {
--#if __FreeBSD_version >= 900000
-- cpuset_t Mask;
--#elif __FreeBSD_version >= 700000
-- cpumask_t Mask;
--#endif
-+ cpuset_t Cpus;
-
- /* Will panic if no rendezvousing cpus, so make sure the cpu is online. */
+@@ -287,12 +301,14 @@ RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
if (!RTMpIsCpuOnline(idCpu))
return VERR_CPU_NOT_FOUND;
--# if __FreeBSD_version >= 900000
-- CPU_SETOF(idCpu, &Mask);
--# else
-- Mask = (cpumask_t)1 << idCpu;
--# endif
-- smp_rendezvous_cpus(Mask, NULL, rtmpFreeBSDPokeCallback, smp_no_rendevous_barrier, NULL);
+ IPRT_FREEBSD_SAVE_EFL_AC();
-+ CPU_SETOF(idCpu, &Cpus);
-+ smp_rendezvous_cpus(Cpus, NULL, rtmpFreeBSDPokeCallback, smp_no_rendezvous_barrier, NULL);
+ # if __FreeBSD_version >= 900000
+ CPU_SETOF(idCpu, &Mask);
+ # else
+ Mask = (cpumask_t)1 << idCpu;
+ # endif
+ smp_rendezvous_cpus(Mask, NULL, rtmpFreeBSDPokeCallback, smp_no_rendezvous_barrier, NULL);
+ IPRT_FREEBSD_RESTORE_EFL_AC();
return VINF_SUCCESS;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c
index c570caf8f51b..c84313e2f5e2 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semevent-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/semevent-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/semevent-r0drv-freebsd.c.orig 2021-01-07 15:42:08 UTC
+++ src/VBox/Runtime/r0drv/freebsd/semevent-r0drv-freebsd.c
-@@ -77,7 +77,9 @@ RTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem
+@@ -101,7 +101,9 @@ RTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem
Assert(!(fFlags & RTSEMEVENT_FLAGS_BOOTSTRAP_HACK) || (fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL));
AssertPtrReturn(phEventSem, VERR_INVALID_POINTER);
@@ -10,7 +10,7 @@
if (!pThis)
return VERR_NO_MEMORY;
-@@ -128,10 +130,12 @@ RTDECL(int) RTSemEventDestroy(RTSEMEVENT hEventSem)
+@@ -152,10 +154,12 @@ RTDECL(int) RTSemEventDestroy(RTSEMEVENT hEventSem)
/*
* Invalidate it and signal the object just in case.
*/
@@ -23,7 +23,7 @@
return VINF_SUCCESS;
}
-@@ -149,9 +153,11 @@ RTDECL(int) RTSemEventSignal(RTSEMEVENT hEventSem)
+@@ -173,9 +177,11 @@ RTDECL(int) RTSemEventSignal(RTSEMEVENT hEventSem)
/*
* Signal the event object.
*/
@@ -35,7 +35,7 @@
return VINF_SUCCESS;
}
-@@ -175,6 +181,7 @@ static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis,
+@@ -199,6 +205,7 @@ static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis,
AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);
@@ -43,7 +43,7 @@
rtR0SemEventBsdRetain(pThis);
/*
-@@ -224,6 +231,7 @@ static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis,
+@@ -248,6 +255,7 @@ static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis,
}
rtR0SemEventBsdRelease(pThis);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c
index af139a58f91c..d3571a937b1f 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semeventmulti-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/semeventmulti-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/semeventmulti-r0drv-freebsd.c.orig 2021-01-07 15:42:08 UTC
+++ src/VBox/Runtime/r0drv/freebsd/semeventmulti-r0drv-freebsd.c
-@@ -96,7 +96,9 @@ RTDECL(int) RTSemEventMultiCreateEx(PRTSEMEVENTMULTI
+@@ -120,7 +120,9 @@ RTDECL(int) RTSemEventMultiCreateEx(PRTSEMEVENTMULTI
PRTSEMEVENTMULTIINTERNAL pThis;
AssertReturn(!(fFlags & ~RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
@@ -10,7 +10,7 @@
if (pThis)
{
pThis->u32Magic = RTSEMEVENTMULTI_MAGIC;
-@@ -152,10 +154,12 @@ RTDECL(int) RTSemEventMultiDestroy(RTSEMEVENTMULTI hE
+@@ -176,10 +178,12 @@ RTDECL(int) RTSemEventMultiDestroy(RTSEMEVENTMULTI hE
/*
* Invalidate it and signal the object just in case.
*/
@@ -23,7 +23,7 @@
return VINF_SUCCESS;
}
-@@ -164,6 +168,7 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEv
+@@ -188,6 +192,7 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEv
{
uint32_t fNew;
uint32_t fOld;
@@ -31,7 +31,7 @@
/*
* Validate input.
-@@ -190,12 +195,15 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEv
+@@ -214,12 +219,15 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI hEv
rtR0SemBsdBroadcast(pThis);
rtR0SemEventMultiBsdRelease(pThis);
@@ -47,7 +47,7 @@
/*
* Validate input.
*/
-@@ -212,6 +220,7 @@ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEve
+@@ -236,6 +244,7 @@ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEve
ASMAtomicAndU32(&pThis->fStateAndGen, ~RTSEMEVENTMULTIBSD_STATE_MASK);
rtR0SemEventMultiBsdRelease(pThis);
@@ -55,7 +55,7 @@
return VINF_SUCCESS;
}
-@@ -228,6 +237,7 @@ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEve
+@@ -252,6 +261,7 @@ RTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI hEve
static int rtR0SemEventMultiBsdWait(PRTSEMEVENTMULTIINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,
PCRTLOCKVALSRCPOS pSrcPos)
{
@@ -63,7 +63,7 @@
uint32_t fOrgStateAndGen;
int rc;
-@@ -287,6 +297,7 @@ static int rtR0SemEventMultiBsdWait(PRTSEMEVENTMULTIIN
+@@ -311,6 +321,7 @@ static int rtR0SemEventMultiBsdWait(PRTSEMEVENTMULTIIN
}
rtR0SemEventMultiBsdRelease(pThis);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c
index 78ecef4a393d..aeab0a76e37c 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_semfastmutex-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/semfastmutex-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/semfastmutex-r0drv-freebsd.c.orig 2021-01-07 15:42:08 UTC
+++ src/VBox/Runtime/r0drv/freebsd/semfastmutex-r0drv-freebsd.c
-@@ -62,6 +62,7 @@ RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFa
+@@ -86,6 +86,7 @@ RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFa
{
AssertCompile(sizeof(RTSEMFASTMUTEXINTERNAL) > sizeof(void *));
AssertPtrReturn(phFastMtx, VERR_INVALID_POINTER);
@@ -8,7 +8,7 @@
PRTSEMFASTMUTEXINTERNAL pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
if (pThis)
-@@ -70,8 +71,10 @@ RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFa
+@@ -94,8 +95,10 @@ RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFa
sx_init_flags(&pThis->SxLock, "IPRT Fast Mutex Semaphore", SX_DUPOK);
*phFastMtx = pThis;
@@ -19,7 +19,7 @@
return VERR_NO_MEMORY;
}
-@@ -83,11 +86,13 @@ RTDECL(int) RTSemFastMutexDestroy(RTSEMFASTMUTEX hFas
+@@ -107,11 +110,13 @@ RTDECL(int) RTSemFastMutexDestroy(RTSEMFASTMUTEX hFas
return VINF_SUCCESS;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
@@ -33,7 +33,7 @@
return VINF_SUCCESS;
}
-@@ -97,8 +102,11 @@ RTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX hFas
+@@ -121,8 +126,11 @@ RTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX hFas
PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
@@ -45,7 +45,7 @@
return VINF_SUCCESS;
}
-@@ -108,8 +116,11 @@ RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX hFas
+@@ -132,8 +140,11 @@ RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX hFas
PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c
index e76621407cea..4a86a2e38eb2 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_spinlock-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/spinlock-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/spinlock-r0drv-freebsd.c.orig 2021-01-07 15:42:09 UTC
+++ src/VBox/Runtime/r0drv/freebsd/spinlock-r0drv-freebsd.c
-@@ -82,7 +82,9 @@ RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, u
+@@ -106,7 +106,9 @@ RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, u
* Allocate.
*/
AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
@@ -10,7 +10,7 @@
if (!pThis)
return VERR_NO_MEMORY;
-@@ -116,7 +118,9 @@ RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock)
+@@ -140,7 +142,9 @@ RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock)
* Make the lock invalid and release the memory.
*/
ASMAtomicIncU32(&pThis->u32Magic);
@@ -20,7 +20,7 @@
return VINF_SUCCESS;
}
-@@ -142,6 +146,7 @@ RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
+@@ -166,6 +170,7 @@ RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
{
RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
pThis->fIntSaved = fIntSaved;
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h
index 47b7121abc8e..53ab44e2bde6 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_the-freebsd-kernel.h
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h.orig 2020-07-09 16:57:38 UTC
+--- src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h.orig 2021-01-07 15:42:09 UTC
+++ src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h
-@@ -60,6 +60,7 @@
+@@ -87,6 +87,7 @@
#include <sys/smp.h>
#include <sys/sleepqueue.h>
#include <sys/sx.h>
@@ -8,7 +8,7 @@
#include <vm/vm.h>
#include <vm/pmap.h> /* for vtophys */
#include <vm/vm_map.h>
-@@ -67,10 +68,10 @@
+@@ -94,10 +95,10 @@
#include <vm/vm_kern.h>
#include <vm/vm_param.h> /* KERN_SUCCESS ++ */
#include <vm/vm_page.h>
@@ -20,7 +20,7 @@
#include <sys/resourcevar.h>
#include <machine/cpu.h>
-@@ -114,6 +115,24 @@
+@@ -155,6 +156,24 @@
*/
#if 0 /** @todo Not available yet. */
# define USE_KMEM_ALLOC_PROT
@@ -44,4 +44,4 @@
+# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC_EX(f) do { } while (0)
#endif
- #endif
+ #endif /* !IPRT_INCLUDED_SRC_r0drv_freebsd_the_freebsd_kernel_h */
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c
index c2defe1768b9..c9cd05c42397 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_thread2-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c.orig 2021-01-07 15:42:09 UTC
+++ src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c
-@@ -70,6 +70,8 @@ DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT
+@@ -94,6 +94,8 @@ DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT
return VERR_INVALID_PARAMETER;
}
@@ -9,7 +9,7 @@
#if __FreeBSD_version < 700000
/* Do like they're doing in subr_ntoskrnl.c... */
mtx_lock_spin(&sched_lock);
-@@ -86,6 +88,7 @@ DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT
+@@ -110,6 +112,7 @@ DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT
thread_unlock(curthread);
#endif
@@ -17,7 +17,7 @@
return VINF_SUCCESS;
}
-@@ -135,6 +138,7 @@ static void rtThreadNativeMain(void *pvThreadInt)
+@@ -159,6 +162,7 @@ static void rtThreadNativeMain(void *pvThreadInt)
DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
{
@@ -25,7 +25,7 @@
int rc;
struct proc *pProc;
-@@ -150,6 +154,7 @@ DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThr
+@@ -174,6 +178,7 @@ DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThr
}
else
rc = RTErrConvertFromErrno(rc);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c
index c54138933db1..399328e16faa 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_time-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/time-r0drv-freebsd.c.orig 2016-07-18 11:56:55 UTC
+--- src/VBox/Runtime/r0drv/freebsd/time-r0drv-freebsd.c.orig 2021-01-07 15:42:09 UTC
+++ src/VBox/Runtime/r0drv/freebsd/time-r0drv-freebsd.c
-@@ -40,16 +40,23 @@
+@@ -64,16 +64,23 @@
RTDECL(uint64_t) RTTimeNanoTS(void)
{
@@ -29,7 +29,7 @@
}
-@@ -67,8 +74,7 @@ RTDECL(uint64_t) RTTimeSystemMilliTS(voi
+@@ -91,8 +98,7 @@ RTDECL(uint64_t) RTTimeSystemMilliTS(void)
RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
{
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c
index 9dc293692223..ee5b90f13c51 100644
--- a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r0drv_freebsd_timer-r0drv-freebsd.c
@@ -1,6 +1,6 @@
---- src/VBox/Runtime/r0drv/freebsd/timer-r0drv-freebsd.c.orig 2018-10-15 14:31:31 UTC
+--- src/VBox/Runtime/r0drv/freebsd/timer-r0drv-freebsd.c.orig 2021-01-07 15:42:09 UTC
+++ src/VBox/Runtime/r0drv/freebsd/timer-r0drv-freebsd.c
-@@ -92,6 +92,7 @@ static void rtTimerFreeBSDCallback(void *pvTimer);
+@@ -116,6 +116,7 @@ static void rtTimerFreeBSDCallback(void *pvTimer);
RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_t fFlags, PFNRTTIMER pfnTimer, void *pvUser)
{
*ppTimer = NULL;
@@ -8,7 +8,7 @@
/*
* Validate flags.
-@@ -121,6 +122,7 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_
+@@ -145,6 +146,7 @@ RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_
callout_init(&pTimer->Callout, CALLOUT_MPSAFE);
*ppTimer = pTimer;
@@ -16,7 +16,7 @@
return VINF_SUCCESS;
}
-@@ -141,6 +143,8 @@ DECLINLINE(bool) rtTimerIsValid(PRTTIMER pTimer)
+@@ -165,6 +167,8 @@ DECLINLINE(bool) rtTimerIsValid(PRTTIMER pTimer)
RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
{
@@ -25,7 +25,7 @@
/* It's ok to pass NULL pointer. */
if (pTimer == /*NIL_RTTIMER*/ NULL)
return VINF_SUCCESS;
-@@ -153,6 +157,8 @@ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
+@@ -177,6 +181,8 @@ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
pTimer->u32Magic++;
callout_stop(&pTimer->Callout);
RTMemFree(pTimer);
@@ -34,7 +34,7 @@
return VINF_SUCCESS;
}
-@@ -160,6 +166,7 @@ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
+@@ -184,6 +190,7 @@ RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
{
struct timeval tv;
@@ -42,7 +42,7 @@
if (!rtTimerIsValid(pTimer))
return VERR_INVALID_HANDLE;
-@@ -183,12 +190,15 @@ RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64
+@@ -207,12 +214,15 @@ RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64
tv.tv_usec = (u64First % 1000000000) / 1000;
callout_reset(&pTimer->Callout, tvtohz(&tv), rtTimerFreeBSDCallback, pTimer);
@@ -58,7 +58,7 @@
if (!rtTimerIsValid(pTimer))
return VERR_INVALID_HANDLE;
if (pTimer->fSuspended)
-@@ -200,6 +210,7 @@ RTDECL(int) RTTimerStop(PRTTIMER pTimer)
+@@ -224,6 +234,7 @@ RTDECL(int) RTTimerStop(PRTTIMER pTimer)
pTimer->fSuspended = true;
callout_stop(&pTimer->Callout);
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_posix_process-creation-posix.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_posix_process-creation-posix.cpp
new file mode 100644
index 000000000000..e455ae88ccef
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_posix_process-creation-posix.cpp
@@ -0,0 +1,29 @@
+--- src/VBox/Runtime/r3/posix/process-creation-posix.cpp.orig 2021-01-07 15:42:15 UTC
++++ src/VBox/Runtime/r3/posix/process-creation-posix.cpp
+@@ -30,7 +30,7 @@
+ *********************************************************************************************************************************/
+ #define LOG_GROUP RTLOGGROUP_PROCESS
+ #include <iprt/cdefs.h>
+-#ifdef RT_OS_LINUX
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
+ # define IPRT_WITH_DYNAMIC_CRYPT_R
+ #endif
+ #if (defined(RT_OS_LINUX) || defined(RT_OS_OS2)) && !defined(_GNU_SOURCE)
+@@ -64,7 +64,7 @@
+ # include <shadow.h>
+ #endif
+
+-#if defined(RT_OS_LINUX) || defined(RT_OS_OS2)
++#if defined(RT_OS_LINUX) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
+ /* While Solaris has posix_spawn() of course we don't want to use it as
+ * we need to have the child in a different process contract, no matter
+ * whether it is started detached or not. */
+@@ -372,7 +372,7 @@ static int rtCheckCredentials(const char *pszUser, con
+ if (pPwd->pw_passwd && *pPwd->pw_passwd)
+ # endif
+ {
+-# if defined(RT_OS_LINUX) || defined(RT_OS_OS2)
++# if defined(RT_OS_LINUX) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
+ # ifdef IPRT_WITH_DYNAMIC_CRYPT_R
+ size_t const cbCryptData = RT_MAX(sizeof(struct crypt_data) * 2, _256K);
+ # else
diff --git a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_Makefile.kmk b/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_Makefile.kmk
index 2ff4313cda89..c87ba535edb0 100644
--- a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_Makefile.kmk
+++ b/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_Makefile.kmk
@@ -1,6 +1,6 @@
---- src/libs/xpcom18a4/Makefile.kmk.orig 2019-01-25 18:32:58 UTC
+--- src/libs/xpcom18a4/Makefile.kmk.orig 2021-01-07 15:44:04 UTC
+++ src/libs/xpcom18a4/Makefile.kmk
-@@ -980,6 +980,8 @@ VBoxXPCOM_LIBS = \
+@@ -985,6 +985,8 @@ VBoxXPCOM_LIBS = \
$(VBox-xpcom-proxy_1_TARGET) \
$(VBox-xpcom-nspr_1_TARGET) \
$(VBoxXPCOMGlue_s_1_TARGET)
diff --git a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c b/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c
index 971c86938f5e..83cccd4ddde5 100644
--- a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c
+++ b/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c
@@ -1,4 +1,4 @@
---- src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c.orig 2020-05-13 19:46:23 UTC
+--- src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c.orig 2019-04-16 10:18:41 UTC
+++ src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c
@@ -49,6 +49,9 @@
#include <string.h>
@@ -10,13 +10,11 @@
static pthread_mutexattr_t _pt_mattr;
static pthread_condattr_t _pt_cvar_attr;
-@@ -798,7 +801,8 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *
+@@ -798,6 +801,7 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *
* From the semctl(2) man page in glibc 2.0
*/
#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \
-- || defined(FREEBSD) || defined(OPENBSD) || defined(BSDI)
+ || (defined(FREEBSD) && __FreeBSD_version < 1200059) \
-+ || defined(OPENBSD) || defined(BSDI)
+ || defined(OPENBSD) || defined(BSDI)
/* union semun is defined by including <sys/sem.h> */
#else
- /* according to X/OPEN we have to define it ourselves */
diff --git a/emulators/virtualbox-ose/pkg-plist b/emulators/virtualbox-ose/pkg-plist
index 9f2ed04af928..898d797d0cba 100644
--- a/emulators/virtualbox-ose/pkg-plist
+++ b/emulators/virtualbox-ose/pkg-plist
@@ -6,6 +6,7 @@ bin/VBoxManage
%%X11%%bin/VBoxSDL
bin/VBoxVRDP
%%QT%%bin/VirtualBox
+%%QT%%bin/VirtualBoxVM
bin/vboxautostart
bin/vboxballoonctrl
bin/vboxbugreport
@@ -14,6 +15,7 @@ bin/vboxmanage
%%X11%%bin/vboxsdl
%%WEBSERVICE%%bin/vboxwebsrv
%%QT%%bin/virtualbox
+%%QT%%bin/virtualboxvm
include/virtualbox/VirtualBox_XPCOM.h
include/virtualbox/ipcIClientObserver.h
include/virtualbox/ipcIDConnectService.h
@@ -378,8 +380,8 @@ lib/virtualbox/VBoxBugReport
lib/virtualbox/VBoxDD.so
lib/virtualbox/VBoxDD2.so
lib/virtualbox/VBoxDDR0.r0
-lib/virtualbox/VBoxDDRC.rc
lib/virtualbox/VBoxDDU.so
+%%QT%%lib/virtualbox/UICommon.so
%%QT%%lib/virtualbox/VBoxDbg.so
%%QT%%lib/virtualbox/VBoxDragAndDropSvc.so
lib/virtualbox/VBoxEFI32.fd
@@ -397,17 +399,14 @@ lib/virtualbox/VBoxManage
lib/virtualbox/VBoxNetDHCP.so
@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxNetNAT
lib/virtualbox/VBoxNetNAT.so
-%%PYTHON%%lib/virtualbox/VBoxPython.so
-%%PYTHON%%lib/virtualbox/VBoxPython%%PYTHON_VERU%%.so
-lib/virtualbox/VBoxREM.so
%%I386%%lib/virtualbox/VBoxREM32.so
%%I386%%lib/virtualbox/VBoxREM64.so
lib/virtualbox/VBoxRT.so
%%X11%%@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VBoxSDL
%%X11%%lib/virtualbox/VBoxSDL.so
lib/virtualbox/VBoxSVC
+%%X11%%lib/virtualbox/VBoxSVGA3D.so
%%X11%%lib/virtualbox/VBoxSharedClipboard.so
-%%X11%%lib/virtualbox/VBoxSharedCrOpenGL.so
lib/virtualbox/VBoxSharedFolders.so
%%QT%%lib/virtualbox/VBoxTestOGL
lib/virtualbox/VBoxVMM.so
@@ -416,9 +415,9 @@ lib/virtualbox/VBoxXPCOM.so
lib/virtualbox/VBoxXPCOMC.so
lib/virtualbox/VBoxXPCOMIPCD
lib/virtualbox/VMMR0.r0
-lib/virtualbox/VMMRC.rc
-%%QT%%@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VirtualBox
-%%QT%%lib/virtualbox/VirtualBox.so
+%%QT%%lib/virtualbox/VirtualBox
+%%QT%%@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VirtualBoxVM
+%%QT%%lib/virtualbox/VirtualBoxVM.so
%%SDK%%lib/virtualbox/sdk
%%WEBSERVICE%%lib/virtualbox/vboxwebsrv
%%WEBSERVICE%%lib/virtualbox/webtest