From: Alice Ryhl <aliceryhl@google•com>
To: Link Mauve <linkmauve@linkmauve•fr>
Cc: rust-for-linux@vger•kernel.org, "Miguel Ojeda" <ojeda@kernel•org>,
"Boqun Feng" <boqun@kernel•org>, "Gary Guo" <gary@garyguo•net>,
"Björn Roy Baron" <bjorn3_gh@protonmail•com>,
"Benno Lossin" <lossin@kernel•org>,
"Andreas Hindborg" <a.hindborg@kernel•org>,
"Trevor Gross" <tmgross@umich•edu>,
"Danilo Krummrich" <dakr@kernel•org>,
"Jonathan Corbet" <corbet@lwn•net>,
"Madhavan Srinivasan" <maddy@linux•ibm.com>,
"Michael Ellerman" <mpe@ellerman•id.au>,
"Nicholas Piggin" <npiggin@gmail•com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel•org>,
"Peter Zijlstra" <peterz@infradead•org>,
"Josh Poimboeuf" <jpoimboe@kernel•org>,
"Jason Baron" <jbaron@akamai•com>,
"Steven Rostedt" <rostedt@goodmis•org>,
"Ard Biesheuvel" <ardb@kernel•org>,
"Nathan Chancellor" <nathan@kernel•org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail•com>,
"Bill Wendling" <morbo@google•com>,
"Justin Stitt" <justinstitt@google•com>,
linux-doc@vger•kernel.org, linux-kernel@vger•kernel.org,
linuxppc-dev@lists•ozlabs.org, llvm@lists•linux.dev,
officialTechflashYT@gmail•com, "Ash Logan" <ash@heyquark•com>,
"Roberto Van Eeden" <rw-r-r-0644@protonmail•com>,
"Jonathan Neuschäfer" <j.neuschaefer@gmx•net>
Subject: Re: [PATCH] rust: Add PowerPC support
Date: Wed, 4 Feb 2026 10:41:33 +0000 [thread overview]
Message-ID: <aYMiXcy33YEVkgYM@google.com> (raw)
In-Reply-To: <20260204030507.8203-1-linkmauve@linkmauve.fr>
On Wed, Feb 04, 2026 at 04:05:04AM +0100, Link Mauve wrote:
> For now only Big Endian 32-bit PowerPC is supported, as that is the only
> hardware I have. This has been tested on the Nintendo Wii so far, but I
> plan on also using it on the GameCube, Wii U and Apple G4.
Super cool!
> These changes aren’t the only ones required to get the kernel to compile
> and link on PowerPC, libcore will also have to be changed to not use
> integer division to format u64, u128 and core::time::Duration, otherwise
> __udivdi3() and __umoddi3() will have to be added. I have tested this
> change by replacing the three implementations with unimplemented!() and
> it linked just fine.
Uh oh this seems tricky. How is this not a problem on arm32 too?
Perhaps we should just be providing __udivdi3() and __umoddi3() in
general?
> diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> index d4eaba459a0e..238f0f625a36 100644
> --- a/arch/powerpc/include/asm/jump_label.h
> +++ b/arch/powerpc/include/asm/jump_label.h
> @@ -15,14 +15,18 @@
> #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
> #define JUMP_LABEL_NOP_SIZE 4
>
> +/* This macro is also expanded on the Rust side. */
> +#define ARCH_STATIC_BRANCH_ASM(key, label) \
> + "1:\n\t" \
> + "nop # arch_static_branch\n\t" \
> + ".pushsection __jump_table, \"aw\"\n\t" \
> + ".long 1b - ., " label " - .\n\t" \
> + JUMP_ENTRY_TYPE key " - .\n\t" \
> + ".popsection \n\t"
> +
> static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
> {
> - asm goto("1:\n\t"
> - "nop # arch_static_branch\n\t"
> - ".pushsection __jump_table, \"aw\"\n\t"
> - ".long 1b - ., %l[l_yes] - .\n\t"
> - JUMP_ENTRY_TYPE "%c0 - .\n\t"
> - ".popsection \n\t"
> + asm goto(ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
> : : "i" (&((char *)key)[branch]) : : l_yes);
In case this patch takes a long time to land, it may make sense to split
this part out in a separate patch that can land now.
Also, consider pre-emptively updating arch_static_branch_jump too. We
probably need it at some point in the future.
> diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> index 38b3416bb979..0054880ba0ea 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -188,6 +188,16 @@ fn main() {
> panic!("arm uses the builtin rustc target");
> } else if cfg.has("ARM64") {
> panic!("arm64 uses the builtin rustc aarch64-unknown-none target");
> + } else if cfg.has("PPC32") {
> + ts.push("arch", "powerpc");
> + ts.push("data-layout", "E-m:e-p:32:32-Fn32-i64:64-n32");
> + ts.push("features", "+soft-float");
> + ts.push("llvm-target", "powerpc-unknown-eabi");
> + if cfg.rustc_version_atleast(1, 91, 0) {
> + ts.push("target-pointer-width", 32);
> + } else {
> + ts.push("target-pointer-width", "32");
> + }
Is there no built-in target we can use? I think we want to avoid adding
new targets if at all possible.
Alice
next prev parent reply other threads:[~2026-02-04 11:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 3:05 [PATCH] rust: Add PowerPC support Link Mauve
2026-02-04 10:41 ` Alice Ryhl [this message]
2026-02-04 12:36 ` Gary Guo
2026-02-04 12:55 ` Alice Ryhl
2026-02-04 13:06 ` Peter Zijlstra
2026-02-04 13:36 ` Alice Ryhl
2026-02-04 17:19 ` Christophe Leroy (CS GROUP)
2026-02-04 17:33 ` Mukesh Kumar Chaurasiya
2026-02-04 19:42 ` Christophe Leroy (CS GROUP)
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=aYMiXcy33YEVkgYM@google.com \
--to=aliceryhl@google$(echo .)com \
--cc=a.hindborg@kernel$(echo .)org \
--cc=ardb@kernel$(echo .)org \
--cc=ash@heyquark$(echo .)com \
--cc=bjorn3_gh@protonmail$(echo .)com \
--cc=boqun@kernel$(echo .)org \
--cc=chleroy@kernel$(echo .)org \
--cc=corbet@lwn$(echo .)net \
--cc=dakr@kernel$(echo .)org \
--cc=gary@garyguo$(echo .)net \
--cc=j.neuschaefer@gmx$(echo .)net \
--cc=jbaron@akamai$(echo .)com \
--cc=jpoimboe@kernel$(echo .)org \
--cc=justinstitt@google$(echo .)com \
--cc=linkmauve@linkmauve$(echo .)fr \
--cc=linux-doc@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=llvm@lists$(echo .)linux.dev \
--cc=lossin@kernel$(echo .)org \
--cc=maddy@linux$(echo .)ibm.com \
--cc=morbo@google$(echo .)com \
--cc=mpe@ellerman$(echo .)id.au \
--cc=nathan@kernel$(echo .)org \
--cc=nick.desaulniers+lkml@gmail$(echo .)com \
--cc=npiggin@gmail$(echo .)com \
--cc=officialTechflashYT@gmail$(echo .)com \
--cc=ojeda@kernel$(echo .)org \
--cc=peterz@infradead$(echo .)org \
--cc=rostedt@goodmis$(echo .)org \
--cc=rust-for-linux@vger$(echo .)kernel.org \
--cc=rw-r-r-0644@protonmail$(echo .)com \
--cc=tmgross@umich$(echo .)edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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