[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxaiDk0md4hURL9E@bombadil.infradead.org>
Date: Mon, 21 Oct 2024 11:48:46 -0700
From: Luis Chamberlain <mcgrof@...nel.org>
To: Matthew Maurer <mmaurer@...gle.com>
Cc: masahiroy@...nel.org, ndesaulniers@...gle.com, ojeda@...nel.org,
gary@...yguo.net, Alex Gaynor <alex.gaynor@...il.com>,
rust-for-linux@...r.kernel.org, linux-kbuild@...r.kernel.org,
linux-kernel@...r.kernel.org, neal@...pa.dev, marcan@...can.st,
j@...nau.net, asahi@...ts.linux.dev, linux-modules@...r.kernel.org,
samitolvanen@...gle.com, Petr Pavlu <petr.pavlu@...e.com>,
Daniel Gomez <da.gomez@...sung.com>,
Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas@...sle.eu>,
Boqun Feng <boqun.feng@...il.com>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>
Subject: Re: [PATCH v6 4/5] modpost: Produce extended MODVERSIONS information
On Tue, Oct 15, 2024 at 11:18:59PM +0000, Matthew Maurer wrote:
> Generate both the existing modversions format and the new extended one
> when running modpost. Presence of this metadata in the final .ko is
> guarded by CONFIG_EXTENDED_MODVERSIONS.
>
> We no longer generate an error on long symbols in modpost if
> CONFIG_EXTENDED_MODVERSIONS is set, as they can now be appropriately
> encoded in the extended section. These symbols will be skipped in the
> previous encoding. An error will still be generated if
> CONFIG_EXTENDED_MODVERSIONS is not set.
>
> Signed-off-by: Matthew Maurer <mmaurer@...gle.com>
> ---
> kernel/module/Kconfig | 8 ++++++++
> scripts/mod/modpost.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
> index 7c6588148d42..a5de2b7f2758 100644
> --- a/kernel/module/Kconfig
> +++ b/kernel/module/Kconfig
> @@ -177,6 +177,14 @@ config ASM_MODVERSIONS
> assembly. This can be enabled only when the target architecture
> supports it.
>
> +config EXTENDED_MODVERSIONS
> + bool "Extended Module Versioning Support"
> + depends on MODVERSIONS
> + help
> + This enables extended MODVERSIONs support, allowing long symbol
> + names to be versioned. The most likely reasons you would enable
> + this are for Rust usage or aggressive LTO configurations.
What is "aggressive LTO configurations" please elaborate. Can we infer
on that through configuration?
> +
> config MODULE_SRCVERSION_ALL
> bool "Source checksum for all modules"
> help
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 107393a8c48a..d18ff8a1109a 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1840,15 +1840,56 @@ static void add_versions(struct buffer *b, struct module *mod)
> continue;
> }
> if (strlen(s->name) >= MODULE_NAME_LEN) {
> +#ifdef CONFIG_EXTENDED_MODVERSIONS
> + /* this symbol will only be in the extended info */
> + continue;
> +#else
> error("too long symbol \"%s\" [%s.ko]\n",
> s->name, mod->name);
> break;
> +#endif
> }
Using #ifdefs on a loop like this seems fragile, even if its more code
make the code clearer and use separate routines for both worlds. Make
the code easy to review and maintain.
> buf_printf(b, "\t{ %#8x, \"%s\" },\n",
> s->crc, s->name);
> }
>
> buf_printf(b, "};\n");
> +
> + buf_printf(b, "#ifdef CONFIG_EXTENDED_MODVERSIONS\n");
Why not *in-code* rather than the output? And if possible why not
two routines as above.
Luis
Powered by blists - more mailing lists