Page MenuHomeFreeBSD

Add a routine to dump the boot metadata
ClosedPublic

Authored by mhorne on Oct 5 2020, 8:05 PM.

Details

Summary

The boot metadata (also referred to as modinfo, or preload metadata)
provides information about the size and location of the kernel,
pre-loaded modules, and other metadata (e.g. the EFI framebuffer) to be
consumed during by the kernel during early boot. It is encoded as a
series of type-length-value entries and is usually constructed by
loader(8) and passed to the kernel. It is also faked on some
architectures when booted by other means.

Although much of the module information is available via kldstat(8),
there is no easy way to debug the metadata in its entirety. Add some
routines to parse this data and allow it to be printed to the console
during early boot or output via a sysctl.

Since the output can be lengthly, printing to the console is gated
behind the debug.dump_modinfo_at_boot environment variable as well as
the BOOTVERBOSE flag. The sysctl to print the metadata is named
debug.dump_modinfo.

Test Plan

Sample output of an amd64 kernel with two preloaded modules: P433

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mhorne requested review of this revision.Oct 5 2020, 8:05 PM
mhorne created this revision.
mhorne retitled this revision from Add routines to dump the boot metadata to Add a routine to dump the boot metadata.Oct 5 2020, 8:23 PM
sys/kern/subr_module.c
343 ↗(On Diff #77913)

It would be better to output something like "unknown modinfo attribute"

418 ↗(On Diff #77913)

it would be better to output something like "unknown modinfo metadata type"

Clarify message for unrecognized types. Update copyright header.

sys/kern/subr_module.c
418 ↗(On Diff #77913)

The output will appear something like:

 0xffffffff8299a068:
	        type:   (0x9004) MODINFO_METADATA | unrecognized metadata type
This revision is now accepted and ready to land.Oct 6 2020, 2:16 PM

Fix compilation on 32-bit platforms. Add calls to preload_dump() to more architectures.

This revision now requires review to proceed.Oct 7 2020, 3:47 PM
This revision is now accepted and ready to land.Oct 8 2020, 4:38 AM
This revision was automatically updated to reflect the committed changes.