[PATCH] firmware module loading issue

Joe Talbott josepht at cstone.net
Mon May 17 05:14:55 PDT 2010

I've run into an issue while porting if_wpi from FreeBSD.  I am
hitting the KKASSERT at line 441 in sys/kern/link_elf.c.  I've been
using the following hack to work around the issue but want to get
other's input regarding a more robust solution.  So my question is
what do you all think I should do here?

On a side note I have observed but not tracked down a problem with the
firmware API where the module containing the firmware is not
automatically loaded.  This seems to be an issue on my FreeBSD laptop
as well so any solution will be forward to them as well.

I hope to have if_wpi in our tree by the end of the week.  Once that
is done I'll start working on if_rum since I also have that hardware.

diff --git a/sys/conf/files b/sys/conf/files
index 51a2d1f..ea267c8 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -728,7 +728,7 @@ kern/subr_disklabel32.c	standard
 kern/subr_disklabel64.c	standard
 kern/subr_diskslice.c	standard
 kern/subr_eventhandler.c	standard
-kern/subr_firmware.c	standard
+kern/subr_firmware.c	optional firmware
 kern/subr_kcore.c	standard
 kern/subr_kobj.c	standard
 kern/subr_log.c		standard
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index e2716f1..2583472 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -405,6 +405,7 @@ link_elf_load_file(const char* filename, linker_file_t* result)
     struct nlookupdata nd;
     struct thread *td = curthread;	/* XXX */
     struct proc *p = td->td_proc;
+    struct proc p_dummy;
     struct vnode *vp;
     Elf_Ehdr *hdr;
     caddr_t firstpage;
@@ -431,6 +432,12 @@ link_elf_load_file(const char* filename, linker_file_t* result)
     int symcnt;
     int strcnt;
+    /* XXX Hack for wpifw loading where p == NULL */
+    if (p == NULL) {
+	p = &p_dummy;
+        p->p_ucred = nd.nl_cred;
+    }
     KKASSERT(p != NULL);
     if (p->p_ucred == NULL) {
 	kprintf("link_elf_load_file: cannot load '%s' from filesystem"

More information about the Kernel mailing list