From nobody Tue Jan 7 16:14:28 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 4YSGMn2DjNz5kmn7; Tue, 07 Jan 2025 16:14:29 +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 4YSGMm6dXLz4XL0; Tue, 7 Jan 2025 16:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736266469; 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=o4vp5XlWa4HonmX4A4eVUs7WnHdIMTrmUaNTfdCqscQ=; b=TQAnn6d1Yc287gyQK2o34eprw9plTTbE2t0C0TB7AzKcOQfSwDAOkxrI7TrMMaGk/r3osf PxWFYA3KbS2bAQ6CWZJKPH7m6+qdC+haN6KkqvkfvkcLDKBIsN7ldUEElVAAeC3SXvhXMK bGmZ1Iu1iOTMaWgp4zKVc3bl6KE2Su/SQouhsV4gWp6MHAHFaNdy19bjEnjkIqNLBi5KO/ 3Hg27+swp11Iez9ZKtwDrtyaVyZiH/fEufsrabtkW9dA2F1/ceeXFOWmvDBSXceF5wcz4R PxKQrDVNvdl9Dd+JbUAAuGkYFB7jgWRplzToQZ6NtNX+TC8A+2kNxxIUVsL66w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736266469; 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=o4vp5XlWa4HonmX4A4eVUs7WnHdIMTrmUaNTfdCqscQ=; b=F3l43sicOS2Vady0cMyS5qNFbXzFJVEyN0tzzb/8rSnCF38SxGkgengghXdknzRzcb6VYI 0wcMk3P1ovt3oo0pgSbFZGuk1T1d6i072ukQOBIBXn++tKpYZ7+sdayi+g4P94qGsEC71E ah/WJ845eArYJ+i+PrjsOBCazzDo4a+GObPV9aVrCLtM8BBqtAnu2AgX9NKjVwsyBjaalc nGo4th7dA+ra8K6FDRpD27nkBuJ6K6Uv0QroQHBgLD4+3Yv2LeeKv9p0c+QP3cT6HpQCfM A+Fg+nj1xrU8zFhdwotrVkooL5OgosjwCwTU4/8pECoAhEeGv3ITRGO1m9S4MA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736266469; a=rsa-sha256; cv=none; b=qj+42NvjRbw6P2Vhbfq9WwRBFK38ZKQ6uowUM/J6GQ2fKjdabmLyLIOOUWyDsthIMIx7L4 qCi0jSl/+r755rmq/L/bK1Uqc3suYi1JpfLYJDkfAsG8xDWEZkGJp/byMJoW1+kcPvkGuB AZ0xB2PxDKo2ohDL7BJeQoviw+X6uu0OWGiJ5PXdsSqt2vs2OXO92dwWL26r9XjLFQI2Wv t9drXE7F4MrW3DEPESgDIrXA2viEy+jP0JWXN6+nHfpIuK8BKxfcGgm/MbEgGRODrWwZRk m1QCbMFQjtchad4b7sWrkvhCusIJxXo9dBGzTqqM1VhqqE8VtNmva1hPA9i7Ag== 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 4YSGMm63tlz2cB; Tue, 07 Jan 2025 16:14:28 +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 507GESTN004260; Tue, 7 Jan 2025 16:14:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 507GES3O004257; Tue, 7 Jan 2025 16:14:28 GMT (envelope-from git) Date: Tue, 7 Jan 2025 16:14:28 GMT Message-Id: <202501071614.507GES3O004257@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Vladimir Druzenko Subject: git: 8d72823b38b7 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 8d72823b38b779036014938cc250f859b27fb3f7 Auto-Submitted: auto-generated The branch main has been updated by vvd: URL: https://cgit.FreeBSD.org/ports/commit/?id=8d72823b38b779036014938cc250f859b27fb3f7 commit 8d72823b38b779036014938cc250f859b27fb3f7 Author: Craig Leres AuthorDate: 2025-01-07 16:10:57 +0000 Commit: Vladimir Druzenko CommitDate: 2025-01-07 16:10:57 +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 --- 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 */