[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190813152624.GB26138@kroah.com>
Date: Tue, 13 Aug 2019 17:26:24 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Matthias Maennich <maennich@...gle.com>
Cc: linux-kernel@...r.kernel.org, maco@...roid.com,
kernel-team@...roid.com, arnd@...db.de, geert@...ux-m68k.org,
hpa@...or.com, jeyu@...nel.org, joel@...lfernandes.org,
kstewart@...uxfoundation.org, linux-arch@...r.kernel.org,
linux-kbuild@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
linux-modules@...r.kernel.org, linux-scsi@...r.kernel.org,
linux-usb@...r.kernel.org, lucas.de.marchi@...il.com,
maco@...gle.com, michal.lkml@...kovi.net, mingo@...hat.com,
oneukum@...e.com, pombredanne@...b.com, sam@...nborg.org,
sboyd@...eaurora.org, sspatil@...gle.com,
stern@...land.harvard.edu, tglx@...utronix.de,
usb-storage@...ts.one-eyed-alien.net, x86@...nel.org,
yamada.masahiro@...ionext.com,
Andrew Morton <akpm@...ux-foundation.org>,
Michael Ellerman <mpe@...erman.id.au>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>
Subject: Re: [PATCH v2 03/10] module: add support for symbol namespaces.
On Tue, Aug 13, 2019 at 01:17:00PM +0100, Matthias Maennich wrote:
> The EXPORT_SYMBOL_NS() and EXPORT_SYMBOL_NS_GPL() macros can be used to
> export a symbol to a specific namespace. There are no _GPL_FUTURE and
> _UNUSED variants because these are currently unused, and I'm not sure
> they are necessary.
>
> I didn't add EXPORT_SYMBOL_NS() for ASM exports; this patch sets the
> namespace of ASM exports to NULL by default. In case of relative
> references, it will be relocatable to NULL. If there's a need, this
> should be pretty easy to add.
>
> A module that wants to use a symbol exported to a namespace must add a
> MODULE_IMPORT_NS() statement to their module code; otherwise, modpost
> will complain when building the module, and the kernel module loader
> will emit an error and fail when loading the module.
>
> MODULE_IMPORT_NS() adds a modinfo tag 'import_ns' to the module. That
> tag can be observed by the modinfo command, modpost and kernel/module.c
> at the time of loading the module.
>
> The ELF symbols are renamed to include the namespace with an asm label;
> for example, symbol 'usb_stor_suspend' in namespace USB_STORAGE becomes
> 'usb_stor_suspend.USB_STORAGE'. This allows modpost to do namespace
> checking, without having to go through all the effort of parsing ELF and
> relocation records just to get to the struct kernel_symbols.
>
> On x86_64 I saw no difference in binary size (compression), but at
> runtime this will require a word of memory per export to hold the
> namespace. An alternative could be to store namespaced symbols in their
> own section and use a separate 'struct namespaced_kernel_symbol' for
> that section, at the cost of making the module loader more complex.
>
> Co-developed-by: Martijn Coenen <maco@...roid.com>
> Signed-off-by: Martijn Coenen <maco@...roid.com>
> Signed-off-by: Matthias Maennich <maennich@...gle.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Powered by blists - more mailing lists