rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Matthew Maurer <mmaurer@google.com>
Cc: masahiroy@kernel.org, ndesaulniers@google.com, ojeda@kernel.org,
	gary@garyguo.net, "Alex Gaynor" <alex.gaynor@gmail.com>,
	rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org, neal@gompa.dev, marcan@marcan.st,
	j@jannau.net, asahi@lists.linux.dev,
	linux-modules@vger.kernel.org, samitolvanen@google.com,
	"Petr Pavlu" <petr.pavlu@suse.com>,
	"Daniel Gomez" <da.gomez@samsung.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nicolas@fjasle.eu>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>
Subject: Re: [PATCH v6 4/5] modpost: Produce extended MODVERSIONS information
Date: Mon, 21 Oct 2024 11:48:46 -0700	[thread overview]
Message-ID: <ZxaiDk0md4hURL9E@bombadil.infradead.org> (raw)
In-Reply-To: <20241015231925.3854230-5-mmaurer@google.com>

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@google.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 

  parent reply	other threads:[~2024-10-21 18:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15 23:18 [PATCH v6 0/5] Extended MODVERSIONS Support Matthew Maurer
2024-10-15 23:18 ` [PATCH v6 1/5] export_report: Rehabilitate script Matthew Maurer
2024-10-17  0:29   ` Sami Tolvanen
2024-10-21 18:42     ` Luis Chamberlain
2024-10-28 13:13   ` Masahiro Yamada
2024-10-15 23:18 ` [PATCH v6 2/5] modules: Support extended MODVERSIONS info Matthew Maurer
2024-10-21 18:44   ` Luis Chamberlain
2024-10-15 23:18 ` [PATCH v6 3/5] export_report: Tolerate additional `.mod.c` content Matthew Maurer
2024-10-15 23:18 ` [PATCH v6 4/5] modpost: Produce extended MODVERSIONS information Matthew Maurer
2024-10-17  0:25   ` Sami Tolvanen
2024-10-21 18:48   ` Luis Chamberlain [this message]
2024-10-21 18:50   ` Luis Chamberlain
2024-10-15 23:19 ` [PATCH v6 5/5] export_report: Use new version info format Matthew Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZxaiDk0md4hURL9E@bombadil.infradead.org \
    --to=mcgrof@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=asahi@lists.linux.dev \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=da.gomez@samsung.com \
    --cc=gary@garyguo.net \
    --cc=j@jannau.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=masahiroy@kernel.org \
    --cc=mmaurer@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=neal@gompa.dev \
    --cc=nicolas@fjasle.eu \
    --cc=ojeda@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).