modules finding order

Mark Johnston markj at FreeBSD.org
Mon Apr 17 19:10:12 UTC 2017


On Mon, Apr 17, 2017 at 08:58:22AM +0200, Gary Jennejohn wrote:
> On Sun, 16 Apr 2017 15:12:49 -0700
> Mark Johnston <markj at FreeBSD.org> wrote:
> > On Sun, Apr 16, 2017 at 10:21:37PM +0200, Baptiste Daroussin wrote:
> > > Hi all,
> > > 
> > > I would like to change in FreeBSD 12 at least the default order the modules are
> > > found/look up.
> > > 
> > > For now the modules are loaded from /boot/kernel first then if not found,
> > > checked from /boot/modules.
> > > 
> > > I think we should revert that to /boot/modules first then /boot/kernel.
> > > 
> The problem I see with this is that the module under
> /boot/modules may have been generated against a /usr/src which is
> newer than what was used to generate the running kernel.  In this
> case kldload should (I hope) fail.

It may or may not; the load will fail if the running kernel's
__FreeBSD_version does not match the value that the module was compiled
with. If the __FreeBSD_version values match, then the module is in
theory compatible with the running kernel and should just work.

> I regularly update /usr/src without making a new world or kernel.
> 
> If kldload automatically falls back to trying /boot/kernel in
> this case then everything would be OK.  If kldload does not or
> cannot retry then I would not consider this change a good idea.

I don't think there's any mechanism to fall back. A
"kldload foo" from the command line will cause the kernel to try and
load the first "foo.ko" found in the paths given by the kern.module_path
sysctl value. If that fails, the kldload fails. I'm not sure how it
works for modules loaded by loader(8).

> 
> There's also the possibility that the module is loaded
> successfully, but at run time it fails due to missing
> functionality in the old kernel.  I'm not sure that this could
> happen.


More information about the freebsd-arch mailing list