Bug 219913 - emulators/virtualbox-ose-kmod: if the MAXCPU option is not the default for the running kernel, then 'kldload vboxdrv.ko' will result in a kernel panic
Summary: emulators/virtualbox-ose-kmod: if the MAXCPU option is not the default for th...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Virtualbox Team (Nobody)
URL: https://www.freshports.org/emulators/...
Keywords: crash
Depends on:
Blocks:
 
Reported: 2017-06-10 19:01 UTC by Andriy Voskoboinyk
Modified: 2023-10-17 14:48 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (vbox)


Attachments
patch (2.37 KB, patch)
2018-04-11 03:35 UTC, Craig Leres
no flags Details | Diff
updated patch (5.49 KB, patch)
2023-08-18 21:11 UTC, Craig Leres
leres: maintainer-approval? (vbox)
grahamperrin: maintainer-approval? (emulation)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Voskoboinyk freebsd_committer freebsd_triage 2017-06-10 19:01:31 UTC
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.

Manual "opt_global.h" inclusion from current kernel build into src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c seems to fix this issue when MAXCPU is overridden; kern.smp.maxcpus may be used instead (in case if other 'global' options are not so problematic).
Comment 1 Walter Schwarzenfeld freebsd_triage 2018-02-12 14:59:01 UTC
Feedback please!
Comment 2 Craig Leres freebsd_committer freebsd_triage 2018-04-06 02:55:10 UTC
I just started running 11.1-RELEASE on some of my systems and ran into this. At a minimum I think the driver should refuse to load if mp_maxcpus != MAXCPU.

Is there a way to make a cpuset_t at runtime?
Comment 3 Craig Leres freebsd_committer freebsd_triage 2018-04-11 03:35:18 UTC
Created attachment 192427 [details]
patch

The attached patch adds a check and refuses to load vboxdrv when MAXCPU does not match mp_maxcpus.
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2023-08-18 03:59:03 UTC
(In reply to Craig Leres from comment #3)

Thanks, can someone rebase for 6.1.46_1? 

(Assuming that the bug is still reproducible.)
Comment 5 Craig Leres freebsd_committer freebsd_triage 2023-08-18 21:11:19 UTC
Created attachment 244203 [details]
updated patch

Here's an updated patch. It's been nearly 4 years since I've run virtualbox anywhere so I did not go to the trouble of building a custom kernel with MAXCPU != 256 but I did build virtualbox-ose-kmod and test that vboxdrv still loads with the patch applied.

Really the only reason I ran into this was that I had always bump'ed MAXCPU from its ridiculously low default in the before times and didn't notice when the default changed to the more modern value of 256. At that point I stopped customizing it.
Comment 7 Graham Perrin freebsd_committer freebsd_triage 2023-08-19 05:21:41 UTC
Comment on attachment 244203 [details]
updated patch

Additional eyes on this patch. 

Whilst emulation@ is not the maintainer, it _is_ a specified address for problems; <https://github.com/freebsd/freebsd-ports/commit/afbf09cc33941f6e8015ea2a99665add0df3b03a#diff-64c4a683499abbf4275fc526621380d5ffa8c2f6c58cd5a2acf0080b6d47f377R17>