Skip to content

init: Add Ubuntu support for module loading and entropy initialization#2650

Open
jiechen0826 wants to merge 2 commits intomicrosoft:mainfrom
jiechen0826:ubuntu-support
Open

init: Add Ubuntu support for module loading and entropy initialization#2650
jiechen0826 wants to merge 2 commits intomicrosoft:mainfrom
jiechen0826:ubuntu-support

Conversation

@jiechen0826
Copy link
Contributor

Fix UVM boot failures on Ubuntu-based rootfs where critical kernel modules
(hv_netvsc, hv_sock, bridge, etc.) are loadable (=m) rather than built-in (=y).

Problem

On Ubuntu, unlike Mariner, networking and vsock modules are not compiled into the kernel.
This causes two boot failures:

  1. NIC hot-add timeout: When the host attaches a synthetic NIC to the UVM, no driver
    claims the vmbus device because hv_netvsc isn't loaded, resulting in:
timed out waiting for /sys/bus/vmbus/devices/<guid>/net to exist
  1. Entropy init failure: init_entropy() was called before load_all_modules(),
    so hv_sock (vsock transport) wasn't available yet.

Changes

Commit 1: Move entropy init after module loading

  • Move init_entropy() after load_all_modules() so that hv_sock is available
    for vsock-based entropy seeding.

Commit 2: Preload networking modules + logging improvements

  • Add preload_networking_modules() to load critical modules by name
    (kmod_module_new_from_name) before the general ftw()-based module scan.
    The general scan walks by file path and may not reliably resolve all modules
    on Ubuntu's directory layout.
  • Enable KMOD=1 in the default Makefile.
  • Improve module load logging in load_module() and parse_tree_entry() with
    structured dmesg messages including error codes.

Impact on AzLinux based kernel

No impact. On AzLinux where these modules are built-in (=y):

  • preload_networking_modules() calls kmod_module_probe_insert_module() which
    returns immediately (KMOD_PROBE_IGNORE_LOADED).
  • The entropy reorder is safe — init_entropy() still runs after modules, just
    in a different position in main().

On distros where hv_sock is a loadable module (e.g., Ubuntu), the
vsock transport used by init_entropy is not available until modules
are loaded. Move init_entropy() after load_all_modules().
On Ubuntu, hv_netvsc, hv_sock, bridge, and other networking modules are
loadable (=m) rather than built-in (=y). The existing ftw()-based
load_all_modules() may not resolve them reliably by path alone.

Add preload_networking_modules() to load critical modules by name before
the general module scan. Also enable KMOD=1 in the default Makefile and
improve module load logging with structured messages.

Without hv_netvsc: hot-added NICs timeout waiting for sysfs net interface.
Without hv_sock: vsock-based entropy and GCS communication fail.

Signed-off-by: Jie Chen <jiechen3@microsoft.com>
@jiechen0826 jiechen0826 requested a review from a team as a code owner March 26, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant