From: Alice Ryhl <aliceryhl@google.com>
To: Benno Lossin <benno.lossin@proton.me>
Cc: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"Christian Schrefl" <chrisi.schrefl@gmail.com>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Russ Weight" <russ.weight@linux.dev>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] rust: fix building firmware abstraction on 32bit arm
Date: Mon, 14 Apr 2025 14:05:58 +0000 [thread overview]
Message-ID: <Z_0WRohxxMYqKxM5@google.com> (raw)
In-Reply-To: <D94KNIHTJOWU.1EHA7217LSC4S@proton.me>
On Sat, Apr 12, 2025 at 10:01:22AM +0000, Benno Lossin wrote:
> On Fri Apr 11, 2025 at 4:15 PM CEST, Miguel Ojeda wrote:
> > On Fri, Apr 11, 2025 at 2:46 PM Benno Lossin <benno.lossin@proton.me> wrote:
> >>
> >> Ah I overlooked this, you should be using `kernel::ffi` (or
> >> `crate::ffi`) instead of `core`. (for `c_char` it doesn't matter, but we
> >> shouldn't be using `core::ffi`, since we have our own mappings).
> >
> > In 6.6, C `char` changed to unsigned, but `core::ffi::c_char` is
> > signed (in x86_64 at least).
> >
> > We should just never use `core::ffi` (except in `rust/ffi.rs`, of
> > course) -- I think we should just add the C types to the prelude
> > (which we discussed in the past) so that it is easy to avoid the
> > mistake (something like the patch attached as the end result, but
> > tested and across a kernel cycle or two) and mention it in the Coding
> > Guidelines. Thoughts?
>
> Yeah sounds like a good idea.
>
> > I tried to use Clippy's `disallowed-types` too:
> >
> > disallowed-types = [
> > { path = "core::ffi::c_void", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_char", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_schar", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_uchar", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_short", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_ushort", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_int", reason = "the `kernel::ffi` types
> > should be used instead" },
> > { path = "core::ffi::c_uint", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_long", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_ulong", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_longlong", reason = "the `kernel::ffi`
> > types should be used instead" },
> > { path = "core::ffi::c_ulonglong", reason = "the `kernel::ffi`
> > types should be used instead" },
> > ]
> >
> > But it goes across aliases.
>
> We could make the types in `ffi` be transparent newtypes. But not sure
> if that could interfere with kCFI or other stuff.
Transparent newtypes for all integers would be super inconvenient.
Alice
next prev parent reply other threads:[~2025-04-14 14:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 7:14 [PATCH] rust: fix building firmware abstraction on 32bit arm Christian Schrefl
2025-04-11 8:37 ` Benno Lossin
2025-04-11 10:35 ` Danilo Krummrich
2025-04-11 13:47 ` Christian Schrefl
2025-04-11 14:17 ` Danilo Krummrich
2025-04-11 12:45 ` Benno Lossin
2025-04-11 14:15 ` Miguel Ojeda
2025-04-11 14:18 ` Miguel Ojeda
2025-04-12 10:01 ` Benno Lossin
2025-04-14 14:05 ` Alice Ryhl [this message]
2025-04-14 14:52 ` Benno Lossin
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=Z_0WRohxxMYqKxM5@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=chrisi.schrefl@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=russ.weight@linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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