From: Easwar Hariharan <[email protected]> Sent: Wednesday, August 5, 2026 10:28 AM > > On 8/5/2026 07:24, Michael Kelley wrote: > > The VMBus module initialization function, hv_acpi_init(), currently > > does nothing when running in the root partition and root is not nested > > in another VM. But the initialization function reports success, so the > > VMBus module is indeed loaded. VMBus functionality is not actually > > needed, but the VMBus module must be loaded so that hv_vmbus_exists() > > can answer correctly. Furthermore, the mshv_root dependency on the > > VMBus module is needed as described in the commit message for > > 840b740a35bf ("mshv: Add conditional VMBus dependency"). > > > > Loading the VMBus module without actually initializing it causes > > failures if the module should later be unloaded. The module unload code > > tries to clean up things that were never initialized, resulting in > > memory faults and a panic. > > > > Fix this by having VMBus module exit function perform the same > > check for non-nested root partition, and do nothing in such a > > case, just like hv_acpi_init(). > > > > In the long run, the code that manages the Hyper-V provided SynIC > > should be refactored to better coordinate the requirements of > > root partition scenarios and normal VM scenarios, and to hopefully > > remove the hv_vmbus_exists() dependnecy between mshv_root and > > VMBus modules. Preventing the current unload failure scenario is > > an expediency until such a refactoring is done. > > > > Reported-by: Sashiko <[email protected]> > > Closes: > > https://lore.kernel.org/linux-hyperv/[email protected]/ > > Fixes: 7e279d78664aa ("Drivers: hv: vmbus: skip VMBus initialization if > > Linux is root") > > Signed-off-by: Michael Kelley <[email protected]> > > --- > > v1: > > https://lore.kernel.org/linux-hyperv/[email protected]/ > > > > Changes in v2: > > * Use a different solution: Allow the VMBus module to load but have the > > unload function do nothing for non-nested root > > * Change the patch Subject and commit message to reflect the new approach > > > > drivers/hv/vmbus_drv.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > > index e19ec73b0187..f837153427f4 100644 > > --- a/drivers/hv/vmbus_drv.c > > +++ b/drivers/hv/vmbus_drv.c > > @@ -3024,6 +3024,9 @@ static void __exit vmbus_exit(void) > > { > > int cpu; > > > > + if (hv_root_partition() && !hv_nested) > > + return; > > + > > Do you think it'd be useful to have a comment here either saying something to > the effect of > "nothing was initialized, so let's skip the teardown", or alternatively > pointing to the paired > check in hv_acpi_init()?
I generally lean toward adding comments for anything that is non-obvious, so yes. Actually, a comment is really needed in hv_acpi_init() to explain why the code intentionally allows the module to be loaded even though no initialization is done. Then a comment here can refer back to that. I'll spin a v3. Michael

