From nobody Tue Jan 7 19:49:51 2025 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YSM8H2XjKz5jrYk; Tue, 07 Jan 2025 19:49:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YSM8H1zBLz3y1Q; Tue, 7 Jan 2025 19:49:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736279391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ckvbs0Hvbqt+4Jo+EWnwu/2lRl2g4q/zhgZBORMCg/M=; b=NnQDywUtuCc4QhhXZ3JY87hf8gVaTsvoSfnWNwZXYfapMoWuBn+PeuMQkzTMQ4/anP9NBK lvgVpB69p3C/MqqoXjKhMP6UErPmqJUj90vGF+pL/njxowWjlMGiSwW9uRpSI4CAhRhRbL 6FJH+pJY5w9RI5ttHWl3EJK0Vfrgisu+5qHggj49P2lz2/6XGv+qerDbb7/V2UXCz1pkYZ FLPgWbgMh1UpRLhm5XKGIPEEWo2LQe3vN9XAbQtDDTWi1O66mpj0l1y5p7yenkntHrwLUq DxmwdR2cqAxBBdwi/yO7iPv538TcK+RmtoFB8dCzKjbVPdRziAG60y8X6j4MSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736279391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ckvbs0Hvbqt+4Jo+EWnwu/2lRl2g4q/zhgZBORMCg/M=; b=s6tE7UEGJl8aeoQ2Iuwn4EetsXfbAzR4Zytejv7gTku05CH1a/v63dZwfE29E36YbzMgQ1 cglG/UpJJiCVuIrMKqxojlDlYEvQ/7VdHTWbHtB5NHMyEKKO0EXkBmkJZjaNu3Dyo6MZrU E6PMHiGAUlUVhrtRCESMGz4zWmI+3kjn4HduIjo2dTc6obOfprcBx3lPBBXwnvCDj3BZJU to0xTfCDUJw2or9BGSssdRzuOzuzn9XS/z/cIa4xrZmAuORJCpYucoIlg95yyl1QX08NQT LISXucECR9TSCIah7qs9yG3ieoJynVxoA2BsAEjaP4eQmK8OChLIb+TXhmt/QQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736279391; a=rsa-sha256; cv=none; b=sdqo073SVasmjq3JENNA2n5yxlJHubvqqP6qX/SBSqIeflEh+HWBZzVcPP6BldYGT/ITes AKggP22RNHSYTnKAankoHaHT89Dt6BdUnGOlBrPxAOCMT/NAmIl8wp2mUoIYoWTRTwi27A 3KdyrycnY7GSlrOzgI283p1ZeqNLpCgPGNALlx0y87QHkAraUP5EWgg4TQ1AImQPCC39ZR D64fhxeJg3tFbLOP3AjzOS1DOKCBRstv469RfrHMeT7tCyIDQ9ILEv0VZo3pah9QJYNB8b ZUTLocXUKUWkAgoRyili2bql8v8cz1te0DfE5ynVtDQTt0lsVBQs5eLUAMkQig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YSM8H1JPDz84M; Tue, 07 Jan 2025 19:49:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 507JnpJn000368; Tue, 7 Jan 2025 19:49:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 507Jnpx7000365; Tue, 7 Jan 2025 19:49:51 GMT (envelope-from git) Date: Tue, 7 Jan 2025 19:49:51 GMT Message-Id: <202501071949.507Jnpx7000365@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org From: Vladimir Druzenko Subject: git: 448dfbb743fa - 2025Q1 - emulators/virtualbox-ose-kmod: Add check for MAXCPU and mp_maxcpus before load vboxdrv.ko List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-all@freebsd.org Sender: owner-dev-commits-ports-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vvd X-Git-Repository: ports X-Git-Refname: refs/heads/2025Q1 X-Git-Reftype: branch X-Git-Commit: 448dfbb743fadbf19299be9b16251108a5e47474 Auto-Submitted: auto-generated The branch 2025Q1 has been updated by vvd: URL: https://cgit.FreeBSD.org/ports/commit/?id=448dfbb743fadbf19299be9b16251108a5e47474 commit 448dfbb743fadbf19299be9b16251108a5e47474 Author: Craig Leres AuthorDate: 2025-01-07 16:10:57 +0000 Commit: Vladimir Druzenko CommitDate: 2025-01-07 19:40:38 +0000 emulators/virtualbox-ose-kmod: Add check for MAXCPU and mp_maxcpus before load vboxdrv.ko If the MAXCPU option is not the default for the running kernel, then 'kldload vboxdrv.ko' will result in a kernel panic. Due to ABI difference (vboxdrv passes cpuset_t parameter (bitfield with CPU_SETSIZE -> MAXCPU bits) into smp_rendezvous_cpus()) kernel panics with "ncpus is 0 with non-zero map" message. PR: 219913 (cherry picked from commit 8d72823b38b779036014938cc250f859b27fb3f7) --- emulators/virtualbox-ose-kmod/Makefile | 1 + ...ox_HostDrivers_Support_freebsd_SUPDrv-freebsd.c | 37 +++++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/emulators/virtualbox-ose-kmod/Makefile b/emulators/virtualbox-ose-kmod/Makefile index b06147d885d1..252ba10585de 100644 --- a/emulators/virtualbox-ose-kmod/Makefile +++ b/emulators/virtualbox-ose-kmod/Makefile @@ -1,5 +1,6 @@ PORTNAME= virtualbox-ose DISTVERSION= 6.1.50 +PORTREVISION= 1 CATEGORIES= emulators MASTER_SITES= https://download.virtualbox.org/virtualbox/${DISTVERSION}/ PKGNAMESUFFIX= -kmod 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 ea9d35bc1c65..7dd580efb0a0 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,17 +1,18 @@ --- src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c.orig 2022-07-19 20:58:42 UTC +++ src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c -@@ -44,8 +44,10 @@ +@@ -44,8 +44,11 @@ #include #include #include +#include ++#include /* mp_maxcpus */ #include "../SUPDrvInternal.h" +#include "freebsd/the-freebsd-kernel.h" #include #include #include -@@ -57,7 +59,14 @@ +@@ -57,7 +60,14 @@ #include #include #include @@ -26,7 +27,7 @@ #ifdef VBOX_WITH_HARDENING # define VBOXDRV_PERM 0600 #else -@@ -76,7 +85,9 @@ static d_ioctl_t VBoxDrvFreeBSDIOCtl; +@@ -76,7 +86,9 @@ static d_ioctl_t VBoxDrvFreeBSDIOCtl; static d_open_t VBoxDrvFreeBSDOpenSys; static void vboxdrvFreeBSDDtr(void *pvData); static d_ioctl_t VBoxDrvFreeBSDIOCtl; @@ -36,7 +37,7 @@ /********************************************************************************************************************************* -@@ -93,7 +104,8 @@ static moduledata_t g_VBoxDrvFreeBSDModule = +@@ -93,7 +105,8 @@ static moduledata_t g_VBoxDrvFreeBSDModule = }; /** Declare the module as a pseudo device. */ @@ -46,7 +47,21 @@ MODULE_VERSION(vboxdrv, 1); /** -@@ -182,6 +194,13 @@ static int VBoxDrvFreeBSDLoad(void) +@@ -140,6 +153,13 @@ static int VBoxDrvFreeBSDModuleEvent(struct module *pM + static int VBoxDrvFreeBSDModuleEvent(struct module *pMod, int enmEventType, void *pvArg) + { + int rc; ++ ++ /* Refuse to load if mp_maxcpus is wrong */ ++ if (MAXCPU != mp_maxcpus) { ++ printf("vboxdrv: MAXCPU != mp_maxcpus (%d != %d)\n", MAXCPU, mp_maxcpus); ++ return EINVAL; ++ } ++ + switch (enmEventType) + { + case MOD_LOAD: +@@ -182,6 +202,13 @@ static int VBoxDrvFreeBSDLoad(void) rc = supdrvInitDevExt(&g_VBoxDrvFreeBSDDevExt, sizeof(SUPDRVSESSION)); if (RT_SUCCESS(rc)) { @@ -60,7 +75,7 @@ /* * Configure character devices. Add symbolic links for compatibility. */ -@@ -324,6 +343,45 @@ static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_lo +@@ -324,6 +351,45 @@ static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_lo /** @@ -106,7 +121,7 @@ * Deal with the 'slow' I/O control requests. * * @returns 0 on success, appropriate errno on failure. -@@ -372,11 +430,10 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes +@@ -372,11 +438,10 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes */ SUPREQHDR Hdr; pvUser = *(void **)pvData; @@ -121,7 +136,7 @@ } if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC)) { -@@ -401,13 +458,12 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes +@@ -401,13 +466,12 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: failed to allocate buffer of %d bytes; ulCmd=%#lx\n", cbReq, ulCmd)); return ENOMEM; } @@ -139,7 +154,7 @@ } if (Hdr.cbIn < cbReq) RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn); -@@ -435,9 +491,8 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes +@@ -435,9 +499,8 @@ static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSes OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbOut, cbReq, ulCmd)); cbOut = cbReq; } @@ -151,7 +166,7 @@ Log(("VBoxDrvFreeBSDIOCtlSlow: returns %d / %d ulCmd=%lx\n", 0, pHdr->rc, ulCmd)); -@@ -540,8 +595,7 @@ bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void) +@@ -540,8 +603,7 @@ bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void) bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void) { @@ -161,7 +176,7 @@ } -@@ -624,20 +678,44 @@ int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, +@@ -624,20 +686,44 @@ int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, #endif /* SUPDRV_WITH_MSR_PROBER */