rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Timur Tabi <ttabi@nvidia.com>
To: "andrewjballance@gmail.com" <andrewjballance@gmail.com>,
	Joel Fernandes <joelagnelf@nvidia.com>
Cc: Alistair Popple <apopple@nvidia.com>,
	Alexandre Courbot <acourbot@nvidia.com>,
	"ojeda@kernel.org" <ojeda@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>,
	John Hubbard <jhubbard@nvidia.com>
Subject: Re: Printing with overflow checks can cause modpost errors
Date: Wed, 17 Sep 2025 23:18:11 +0000	[thread overview]
Message-ID: <feb67ee04fde382ae071f84a439f60939e16100d.camel@nvidia.com> (raw)
In-Reply-To: <20250916185253.GA1765622@joelbox2>

On Tue, 2025-09-16 at 14:52 -0400, Joel Fernandes wrote:
> From: Joel Fernandes <joelagnelf@nvidia.com>
> Subject: [PATCH] rust: print: Fix issue with rust_build_error
> 
> When printing just before calling io.write32(), modpost fails. The issue
> seems to be that, the printk arguments are used in an unsafe block, thus Rust
> cannot trust its value. This can be fixed by simply creating a variable alias
> for each variable.
> 
> Fix it in an even simpler way by just call printk in a closure. Rust captures
> the arguments into the closure's arguments thus breaking the dependencies.
> Tested with the following snippet and it builds with patch:
> 
>   let offset = 0;
>   pr_err!("{}", offset);
>   io.write32(base, offset);
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>

Tested-by: Timur Tabi <ttabi@nvidia.com>

This fixes an issue I had with pr_err!() and io.write32() and causing rust_build_error.

      reply	other threads:[~2025-09-17 23:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 21:31 Printing with overflow checks can cause modpost errors Joel Fernandes
2025-09-12  0:27 ` Andrew Ballance
2025-09-12  2:53   ` Joel Fernandes
2025-09-12  4:08     ` Andrew Ballance
2025-09-12  8:27       ` Miguel Ojeda
2025-09-12  9:45         ` Alice Ryhl
2025-09-12 10:08           ` Miguel Ojeda
2025-09-16 10:32       ` Joel Fernandes
2025-09-16 10:48         ` Joel Fernandes
2025-09-16 18:52           ` Joel Fernandes
2025-09-17 23:18             ` Timur Tabi [this message]

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=feb67ee04fde382ae071f84a439f60939e16100d.camel@nvidia.com \
    --to=ttabi@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=andrewjballance@gmail.com \
    --cc=apopple@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.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).