While I encountered this working on support for a RISC-V board, the specific code in question is platform-independent. The mmcsd code (sys/dev/mmc/mmcsd.c) declares a module dependency on a module called g_flashmap. However, this module doesn't exist. So if mmcsd is built as a module, it cannot be loaded, you get an error message about this non-existent module not being found. g_flashmap is actually a prefix used internally in the geom_flashmap code. Turns out that also affects fdt_slicer as well, but the fix is just 4 fixes to refer to the actual module: https://github.com/csgordon/freebsd-starfive2/commit/95e24f536ddd4bde5f3b441c5e3a45a5a0acc49d
Sorry, > platform-independent.
how did the code in geom_flashmap even compile?
I'm relatively new to working in the FreeBSD kernel, so it's quite possible there's a subtlety in missing or some kind of module validation check in not aware of that has broken. But the C code itself doesn't care about the dependency declaration, so geom_flashmap itself is fine, but does declare a module name that's not tied to the *filename* of the final kld, and kld loading assumes the declared dependency name matches the filename, which is what fails. That's why my local fix is to change the module declarations to match the filename. On amd64 it appears that both geom_flashmap and mmcsd are linked directly into the kernel, so the kld loading code doesn't encounter the name mismatch.
I suspect the problem is that you don't have a /boot/kernel/linker.hints file. So when the kernel loads a module which depends on g_flashmap, it doesn't know that that corresponds to geom_flashmap.ko. Your patch changes the module name to geom_flashmap, and linker_hints_lookup() will always try to load <module name>.ko, so it works. Note that in FreeBSD, kernel modules and linker files (.ko files) are not exactly the same. A linker file may contain multiple modules. Assuming my guess is right, your patch just works around one specific consequence of not having a linker.hints. OTOH, almost all of the GEOM modules are named geom_*, so maybe the patch should be committed anyway...
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=2352336ad9b26fd21d9b0013e195e41d6d02b914 commit 2352336ad9b26fd21d9b0013e195e41d6d02b914 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-10-29 15:11:12 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-10-29 15:11:12 +0000 geom_flashmap: Rename the kernel module Absent a linker.hints, if a module dependency exists on disk, the loader will automatically load it. That is, if something depends on module foo, and foo.ko exists, we'll load foo.ko even though the linker hints file is missing. It's a bit of a hack but it's handy. This breaks with geom_flashmap though, since it's geom_flashmap.ko on disk but the module is called g_flashmap. However, pretty much every other GEOM module is given a "geom_" prefix, so for consistency's sake alone, it seems nice to rename the module. PR: 274388 Reviewed by: jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47311 sys/dev/fdt/fdt_slicer.c | 2 +- sys/dev/mmc/mmcsd.c | 2 +- sys/geom/geom_flashmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=26d85a5aba3439092e73dfe33234a5687d5c70b9 commit 26d85a5aba3439092e73dfe33234a5687d5c70b9 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-10-29 15:11:12 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-11-05 00:55:43 +0000 geom_flashmap: Rename the kernel module Absent a linker.hints, if a module dependency exists on disk, the loader will automatically load it. That is, if something depends on module foo, and foo.ko exists, we'll load foo.ko even though the linker hints file is missing. It's a bit of a hack but it's handy. This breaks with geom_flashmap though, since it's geom_flashmap.ko on disk but the module is called g_flashmap. However, pretty much every other GEOM module is given a "geom_" prefix, so for consistency's sake alone, it seems nice to rename the module. PR: 274388 Reviewed by: jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47311 (cherry picked from commit 2352336ad9b26fd21d9b0013e195e41d6d02b914) sys/dev/fdt/fdt_slicer.c | 2 +- sys/dev/mmc/mmcsd.c | 2 +- sys/geom/geom_flashmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)