Re: [PATCH 3/8] ACPI, x86: Extended error log driver for x86 platform

From: Tony Luck
Date: Mon Oct 14 2013 - 12:50:12 EST


On Mon, Oct 14, 2013 at 3:26 AM, Borislav Petkov <bp@xxxxxxxxx> wrote:
> On Sun, Oct 13, 2013 at 11:16:33PM -0400, Chen Gong wrote:
>> But this driver can be loaded as a module. If this module is unloaded,
>> extlog_print is gone. I can't keep such a pointer internally.
>
> Sure you can - you define a weak extlog_print() function in a
> compilation unit which is always builtin. Maybe mce.c or so.

"weak" is a good compile/link time tool to provide a default function
while allowing override with a architecture (or more generally a CONFIG_*)
specific one. But it is no help when loading/unloading modules.

Think about it ... we have a call to this function from some place in the
base kernel (originating from mce.o). Before the module is loaded you
want that to leap to your weak function.

Now load the module with the not-weak definition of the function - the
module loader would have to go do a relocation fix-up in the base kernel
to point to this new function. At module unload it would have to undo
that.

-Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/