From: Karl Mehltretter <kmehltretter@gmail.com>
To: Russell King <linux@armlinux.org.uk>, Miguel Ojeda <ojeda@kernel.org>
Cc: "Karl Mehltretter" <kmehltretter@gmail.com>,
"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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Arnd Bergmann" <arnd@arndb.de>,
"Linus Walleij" <linusw@kernel.org>,
"Christian Schrefl" <chrisi.schrefl@gmail.com>,
"Bradley Morgan" <brads@mainlining.org>,
"Paul E . McKenney" <paulmck@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
linux-arm-kernel@lists.infradead.org,
rust-for-linux@vger.kernel.org, llvm@lists.linux.dev,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] ARM: rust: Enable Rust support for ARMv5TE
Date: Sat, 3 Oct 2026 11:38:25 +0200 [thread overview]
Message-ID: <20261003093827.77857-1-kmehltretter@gmail.com> (raw)
Rust is currently limited to ARMv7 on 32-bit ARM. This series extends
it to ARMv5TE.
Linus Walleij asked for older ARM cores during review of the ARMv7
support [1]. Christian Schrefl tried ARMv5 with the armv5te-none-eabi
target at the time [2]. He hit missing core atomics, missing
__aeabi_mem* symbols and a floating-point helper reached from
pr_info!() formatting. None of these show up anymore. The kernel crate
now implements atomics through the C helpers, and the
armv5te-unknown-linux-gnueabi target used here keeps the Linux EABI.
The only remaining problem was a link error. Pre-ARMv6 __arch_xchg()
has no 2-byte case, which the Rust Atomic<i16> helpers need. Patch 1
adds it the way the other pre-ARMv6 atomics work, with interrupts
disabled. Patch 2 enables Rust for ARMv5TE.
Bradley Morgan's two-byte cmpxchg() emulation series [3] does not
overlap with this. Its ARMv6 part was dropped in v2 and it never
covered xchg() or pre-ARMv6.
Tested on v7.3-rc1 with clang 22.1.8, rustc 1.99.0 and bindgen 0.73.2.
- QEMU versatilepb (ARM926EJ-S). The Rust samples, all Rust KUnit
suites and 355 doctests pass.
- Microchip SAM9X75 Curiosity board (ARM926EJ-S), at91_dt_defconfig
without the ARMv4T AT91RM9200. The samples, all Rust KUnit suites and
356 doctests pass. The Rust sample modules (rust_minimal, rust_print,
rust_misc_device, rust_driver_faux) load and unload cleanly.
- Build test with every Rust driver, abstraction and sample that can be
selected on ARMv5TE (rnull, binder, the two PHY drivers, cpufreq-dt,
the DRM panic QR code). PWM_TH1520 is the exception. It uses a native
u64 division, which does not link on 32-bit ARM.
As a further test I ported the Atmel PWM driver to Rust and ran it next
to the C driver on the SAM9X75 board. The port is not part of this
series. The comparison found a prescaler bug in the C driver for
periods of 2^32 clock cycles or more [4].
I plan to get a Raspberry Pi 1 Model B+ and then add ARMv6K support as
a separate patch.
The ARMv7 enablement went in through Russell's patch system as
"ARM: 9441/1". Unless someone prefers another route I would submit
this series there after review.
[1] https://lore.kernel.org/rust-for-linux/CACRpkdYF0sVB2-qgy=GzETSR3+2sagVQPGdunDQDJrn8KqJorA@mail.gmail.com/
[2] https://lore.kernel.org/rust-for-linux/b13d37bd-ec68-4713-94e5-e9ed4d6a6354@gmail.com/
[3] https://lore.kernel.org/lkml/20260922173354.14404-1-brads@mainlining.org/
[4] https://lore.kernel.org/linux-pwm/20261003083036.21584-1-kmehltretter@gmail.com/
Karl Mehltretter (2):
ARM: cmpxchg: support 2-byte xchg() on pre-ARMv6 CPUs
ARM: rust: Enable Rust support for ARMv5TE
Documentation/rust/arch-support.rst | 2 +-
arch/arm/Kconfig | 2 +-
arch/arm/Makefile | 4 ++++
arch/arm/include/asm/cmpxchg.h | 14 +++++++++++---
4 files changed, 17 insertions(+), 5 deletions(-)
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.39.5 (Apple Git-154)
next reply other threads:[~2026-10-03 9:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 9:38 Karl Mehltretter [this message]
2026-10-03 9:38 ` [PATCH 1/2] ARM: cmpxchg: support 2-byte xchg() on pre-ARMv6 CPUs Karl Mehltretter
2026-10-03 10:12 ` Arnd Bergmann
2026-10-06 10:32 ` Linus Walleij
2026-10-06 14:48 ` Bradley Morgan
2026-10-03 9:38 ` [PATCH 2/2] ARM: rust: Enable Rust support for ARMv5TE Karl Mehltretter
2026-10-03 10:24 ` Miguel Ojeda
2026-10-04 18:56 ` Karl Mehltretter
2026-10-03 10:45 ` Arnd Bergmann
2026-10-03 17:07 ` Karl Mehltretter
2026-10-03 20:54 ` Arnd Bergmann
2026-10-05 4:20 ` Karl Mehltretter
2026-10-03 16:03 ` [PATCH 0/2] " Bradley Morgan
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=20261003093827.77857-1-kmehltretter@gmail.com \
--to=kmehltretter@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=arnd@arndb.de \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brads@mainlining.org \
--cc=chrisi.schrefl@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=justinstitt@google.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=llvm@lists.linux.dev \
--cc=lossin@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=paulmck@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.