diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2005-07-30 09:02:42 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2005-07-30 09:02:42 +0000 |
commit | 05d42812accd5edbfe95a06af05eae531959c220 (patch) | |
tree | b1d2d227bd805153039236ff8b34d8b262c0d401 /sys/dev/hwpmc/hwpmc_mod.c | |
parent | c32a4bcef8c9039472ca54161264c3ffa3289810 (diff) | |
download | FreeBSD-src-05d42812accd5edbfe95a06af05eae531959c220.zip FreeBSD-src-05d42812accd5edbfe95a06af05eae531959c220.tar.gz |
Fail the module loading process if the currently executing kernel
was not compiled with 'options HWPMC_HOOKS' or if the compiled-in
version numbers of the kernel and module are out of sync.
Reported by: cracauer
MFC after: 3 days
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_mod.c')
-rw-r--r-- | sys/dev/hwpmc/hwpmc_mod.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index bb94906..111eccb 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -3917,6 +3917,18 @@ pmc_initialize(void) PMCDBG(MOD,INI,0, "PMC Initialize (version %x)", PMC_VERSION); + /* check kernel version */ + if (pmc_kernel_version != PMC_VERSION) { + if (pmc_kernel_version == 0) + printf("hwpmc: this kernel has not been compiled with " + "'options HWPMC_HOOKS'.\n"); + else + printf("hwpmc: kernel version (0x%x) does not match " + "module version (0x%x).\n", pmc_kernel_version, + PMC_VERSION); + return EPROGMISMATCH; + } + /* * check sysctl parameters */ |