rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Ojeda <ojeda@kernel.org>
To: gary@garyguo.net
Cc: a.hindborg@samsung.com, alex.gaynor@gmail.com,
	aliceryhl@google.com, benno.lossin@proton.me,
	bjorn3_gh@protonmail.com, boqun.feng@gmail.com, bp@alien8.de,
	dave.hansen@linux.intel.com, hpa@zytor.com, jpoimboe@kernel.org,
	linux-kernel@vger.kernel.org, masahiroy@kernel.org,
	mingo@redhat.com, nathan@kernel.org, nicolas@fjasle.eu,
	ojeda@kernel.org, patches@lists.linux.dev, peterz@infradead.org,
	rust-for-linux@vger.kernel.org, tglx@linutronix.de,
	wedsonaf@gmail.com, x86@kernel.org
Subject: Re: Re: [PATCH v2 1/6] rust: module: add static pointer to `{init,cleanup}_module()`
Date: Thu, 25 Jul 2024 19:44:49 +0200	[thread overview]
Message-ID: <20240725174449.102724-1-ojeda@kernel.org> (raw)
In-Reply-To: <20240724204649.7de3ffed.gary@garyguo.net>

On Wed, 24 Jul 2024 20:46:49 +0100 Gary Guo <gary@garyguo.net> wrote:
>
> On Wed, 24 Jul 2024 18:14:54 +0200
> Miguel Ojeda <ojeda@kernel.org> wrote:
>
> > Add the equivalent of the `___ADDRESSABLE()` annotation in the
> > `module_{init,exit}` macros to the Rust `module!` macro.
> >
> > Without this, `objtool` would complain if enabled for Rust, e.g.:
> >
> >     samples/rust/rust_print.o: warning: objtool: cleanup_module(): not an indirect call target
> >     samples/rust/rust_print.o: warning: objtool: init_module(): not an indirect call target
> >
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> > ---
> >  rust/macros/module.rs | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/rust/macros/module.rs b/rust/macros/module.rs
> > index 411dc103d82e..571ffa2e189c 100644
> > --- a/rust/macros/module.rs
> > +++ b/rust/macros/module.rs
> > @@ -256,6 +256,12 @@ mod __module_init {{
> >                          unsafe {{ __init() }}
> >                      }}
> >
> > +                    #[cfg(MODULE)]
> > +                    #[doc(hidden)]
> > +                    #[used]
> > +                    #[link_section = \".init.data\"]
>
> Should this be in section `.discard.addressable` instead?
>
> > +                    static __UNIQUE_ID___addressable_init_module: unsafe extern \"C\" fn() -> i32 = init_module;
> > +
> >                      #[cfg(MODULE)]
> >                      #[doc(hidden)]
> >                      #[no_mangle]
> > @@ -269,6 +275,12 @@ mod __module_init {{
> >                          unsafe {{ __exit() }}
> >                      }}
> >
> > +                    #[cfg(MODULE)]
> > +                    #[doc(hidden)]
> > +                    #[used]
> > +                    #[link_section = \".exit.data\"]
> > +                    static __UNIQUE_ID___addressable_cleanup_module: extern \"C\" fn() = cleanup_module;
> > +
> >                      // Built-in modules are initialized through an initcall pointer
> >                      // and the identifiers need to be unique.
> >                      #[cfg(not(MODULE))]

Boot-tested under QEMU for Rust:

Tested-by: Miguel Ojeda <ojeda@kernel.org>

Thanks!

Cheers,
Miguel

  reply	other threads:[~2024-07-25 17:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 16:14 [PATCH v2 0/6] Rust: support `CPU_MITIGATIONS` and enable `objtool` Miguel Ojeda
2024-07-24 16:14 ` [PATCH v2 1/6] rust: module: add static pointer to `{init,cleanup}_module()` Miguel Ojeda
2024-07-24 19:46   ` Gary Guo
2024-07-25 17:44     ` Miguel Ojeda [this message]
2024-07-25 17:46       ` Miguel Ojeda
2024-07-25 17:47     ` Miguel Ojeda
2024-07-30 11:18       ` Gary Guo
2024-07-24 16:14 ` [PATCH v2 2/6] x86/rust: support MITIGATION_RETPOLINE Miguel Ojeda
2024-07-24 19:38   ` Gary Guo
2024-07-24 16:14 ` [PATCH v2 3/6] x86/rust: support MITIGATION_RETHUNK Miguel Ojeda
2024-07-24 19:40   ` Gary Guo
2024-07-24 16:14 ` [PATCH v2 4/6] x86/rust: support MITIGATION_SLS Miguel Ojeda
2024-07-24 19:42   ` Gary Guo
2024-07-24 16:14 ` [PATCH v2 5/6] objtool: list `noreturn` Rust functions Miguel Ojeda
2024-07-24 19:35   ` Gary Guo
2024-07-25  8:33     ` Peter Zijlstra
2024-08-21 15:28       ` Gary Guo
2024-07-24 16:14 ` [PATCH v2 6/6] objtool/kbuild/rust: enable objtool for Rust Miguel Ojeda
2024-07-24 21:51 ` [PATCH v2 0/6] Rust: support `CPU_MITIGATIONS` and enable `objtool` Benno Lossin
2024-07-25  8:38 ` Peter Zijlstra
2024-07-25  9:53   ` Miguel Ojeda
2024-07-25  9:43 ` Alice Ryhl

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=20240725174449.102724-1-ojeda@kernel.org \
    --to=ojeda@kernel.org \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gary@garyguo.net \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=patches@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wedsonaf@gmail.com \
    --cc=x86@kernel.org \
    /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).