Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kernel Module: hrtimer_start "Unknown Symbol in Module"

I'm building a kernel module that uses the hrtimer interface. I have the module compiling successfully, and it's got MODULE_LICENSE("GPL") set:

make -C /lib/modules/3.0.0-23-server/build SUBDIRS=/home/projects/net-modeler modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-23-server'
  CC [M]  /home/projects/net-modeler/nm_injector.o
  CC [M]  /home/projects/net-modeler/nm_scheduler.o
  LD [M]  /home/projects/net-modeler/net-modeler.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/projects/net-modeler/net-modeler.mod.o
  LD [M]  /home/projects/net-modeler/net-modeler.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-23-server'

... but when I try to insmod it, dmesg outputs

[111853.094925] Unknown symbol hrtimer_init (err 0)
[111853.094931] Unknown symbol hrtimer_start (err 0)
[111853.094942] Unknown symbol hrtimer_cancel (err 0)

Those functions are externed inside of <linux/hrtimer.h>, and exported in kernel/hrtimer.c as follows:

/**
 * hrtimer_init - initialize a timer to the given clock
 * @timer:  the timer to be initialized
 * @clock_id: the clock to be used
 * @mode: timer mode abs/rel
 */
void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
      enum hrtimer_mode mode)
{
  debug_init(timer, clock_id, mode);
  __hrtimer_init(timer, clock_id, mode);
}
EXPORT_SYMBOL_GPL(hrtimer_init);

cat /proc/kallsyms | grep <func> for the three functions results in:

0000000000000000 T hrtimer_init
0000000000000000 T hrtimer_cancel
0000000000000000 T hrtimer_start

Can anyone help me figure out what's going on? It seems to me that all of the functions are exported and they should be able to be found, but for some reason they're not. Am I doing something stupid?

like image 574
Chris Avatar asked Aug 08 '12 21:08

Chris


1 Answers

For anyone else trying to solve this problem, MODULE_LICENSE("GPL") must be in all of the module files, not just the main one.

Without that, the file that actually contained the function calls was restricted from accessing them by EXPORT_SYMBOL_GPL.

like image 115
Chris Avatar answered Sep 23 '22 21:09

Chris