Page MenuHomeFreeBSD

Add /boot/kernel to module_path in stand/defaults/loader.rc
Needs ReviewPublic

Authored by fernape on Fri, May 22, 5:18 PM.

Details

Reviewers
kevans
Summary

According to the handbook and loader(8) man page, we should be able to to things
like this:

unload
load kernel.old

and

load kernel
load splash_bmp
load -t splash_image_data /boot/chuckrulez.bmp
autoboot 5

However, this is what happens (tested in 13-CURRENT on VM and ZFS and on 12.1 physical machine wiht UFS)

In the first case:

OK unload
OK load kernel.old
can't find 'kernel.old'

In the second case:

OK load kernel.old
can't find 'kernel.old' 
OK load splash_bmp
can't find 'splash_bmp'

loader(8) man page states the following:

module_path
Sets the list of directories which will be searched for modules
named in a load command or implicitly required by
a dependency.
The default value for this variable is "/boot/kernel;/boot/modules".

But loader(8) looks for files as follows:

if module_path is empty, default_searchpath (stand/common/modules.c) becomes
/boot/kernel;/boot/modules and maybe something more in addition (depending on
the case). However, because loader(8) reads /boot/defaults/loader.rc it
never applies the default since in that file we set the variable like this:

module_path="/boot/modules;/boot/dtb;/boot/dtb/overlays

Notice that we don't include /boot/kernel and hence we can not load kernels
or modules (the ones that come with the kernel by default) using non fully
qualified paths.

Test Plan
  1. Escape to loader prompt from menu
  2. show module_path (in my case /boot/modules;/boot/dtb;/boot/dtb/overlays)
  3. ls /boot/kernel/kernel (it is there)
  4. ls /boot/kernel/aac.ko (it is there)
  5. load kernel (can't find 'kernel')
  6. load aac (can't find 'aac')
  7. set module_path=/boot/kernel;/boot/modules;/boot/dtb;/boot/dtb/overlays
  8. load kernel (loads fine)
  9. load aac (loads fine)

To be aligned with the man page and handbook, our default loader.conf should
include /boot/kernel in module_path

Since /boot/defaults/loader.rc is read always, I think this should be MFC'ed
to avoid POLA violations.

If this gets committed, I plan to send a patch for the Handbook too since
it doesn't mention module_path.

Diff Detail

Repository
rS FreeBSD src repository
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 31238
Build 28887: arc lint + arc unit

Event Timeline

fernape created this revision.Fri, May 22, 5:18 PM
fernape requested review of this revision.Fri, May 22, 5:18 PM
fernape edited the summary of this revision. (Show Details)Fri, May 22, 5:19 PM
fernape edited the summary of this revision. (Show Details)

We shouldn't be adding /boot/kernel to the default module_path because that's not necessarily the correct path and this the responsibility of the interpreter scripts later when loader's triggered to commence the boot process (e.g. selecting a boot option in the menu, leaving the menu).

The first example cannot work in the current world, and the documentation above it even describes it as such:

load [-t type] filename	Loads the kernel, kernel module, or file of the type given, with the specified filename. Any arguments after filename are passed to the file. If filename is not qualified, it will be searched under /boot/kernel and /boot/modules.

Note that when you have a kernel.old, we won't place it in /boot/kernel but at /boot/kernel.old, which isn't specified to work by any documentation. I believe at some point this was different, but it hasn't been laid out like that in the years that I've been involved at least.

I can't quite see why load splash_bmp didn't work, you just went to the loader menu and escaped to a prompt to try this stuff with a stock installation, right?

fernape added a comment.EditedFri, May 22, 5:43 PM

We shouldn't be adding /boot/kernel to the default module_path because that's not necessarily the correct path and this the responsibility of the interpreter scripts later when loader's triggered to commence the boot process (e.g. selecting a boot option in the menu, leaving the menu).

The first example cannot work in the current world, and the documentation above it even describes it as such:

load [-t type] filename	Loads the kernel, kernel module, or file of the type given, with the specified filename. Any arguments after filename are passed to the file. If filename is not qualified, it will be searched under /boot/kernel and /boot/modules.

Note that when you have a kernel.old, we won't place it in /boot/kernel but at /boot/kernel.old, which isn't specified to work by any documentation. I believe at some point this was different, but it hasn't been laid out like that in the years that I've been involved at least.

I can't quite see why load splash_bmp didn't work, you just went to the loader menu and escaped to a prompt to try this stuff with a stock installation, right?

Yes, I did.

I assume it is because it is in /boot/kernel, not in /boot/modules and not int modules_path:

ls /boot/kernel/splash_bmp.ko 
/boot/kernel/splash_bmp.ko*

In my 13 (stock installation) I dont' have anything in /boot/modules. All modules from the default kernel are in /boot/kernel.

In my 12.1 it is the same except for:

ls /boot/modules/
linker.hints       nvidia-modeset.ko* nvidia.ko*         vboxdrv.ko*        vboxnetadp.ko*     vboxnetflt.ko*

that I happen to build from ports.

Ah, I see- I was wrong, in that escaping the menu itself doesn't trigger loadelf, so you would've had to do a boot-conf in order for the module_path to get corrected for splash_bmp to load.

I'll need to double-check 4th semantics here for whether we should be amending module_path earlier or loading upon exit of the menu.