From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.mainlining.org (mail.mainlining.org [5.75.144.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C111446AEF2; Sat, 3 Oct 2026 16:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=5.75.144.95 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791043438; cv=none; b=gBP9iYaBZKYyI14sHlMaFWVHtghvt3578Kjz3gieCpWWLf6rhTX3EZgnT9yll67QS/I8oB6xzfyOsSuBUXBRlCc1HEckePwmMsS0HBzKi9pt0YiTn4cGOvaWl8P8Yp45n/t7mfyU4cEFPokQFZnmfwezYCbDx6aJTyjnCNRfd88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791043438; c=relaxed/simple; bh=raScNH55YyHKO9o6R9zNWW+p8fAddrS2wh/1QF52HVQ=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=aPpxUEbsyeIOz8O6u3bTMl8Tkju1J1A7nLRQvTI/RUlZ3v4v2xiBWMjIoZHP8kpBlBG6NE5DWDA6V70GSrL8i+/bG3aINcXx92tL4GLiqKOQubK8tvtrFsyRZwFWSYZ0LLgpptuV0li/bRlIKEZkXIUgQEcQfNxsgWgjAFTFKPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mainlining.org; spf=pass smtp.helo=mail.mainlining.org; arc=none smtp.client-ip=5.75.144.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mainlining.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.helo=mail.mainlining.org Date: Sat, 03 Oct 2026 17:03:08 +0100 From: Bradley Morgan To: Karl Mehltretter , Russell King , Miguel Ojeda CC: Boqun Feng , Gary Guo , =?ISO-8859-1?Q?Bj=F6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?ISO-8859-1?Q?Onur_=D6zkan?= , Arnd Bergmann , Linus Walleij , Christian Schrefl , "Paul E . McKenney" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , 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: Re: [PATCH 0/2] ARM: rust: Enable Rust support for ARMv5TE In-Reply-To: <20261003093827.77857-1-kmehltretter@gmail.com> References: <20261003093827.77857-1-kmehltretter@gmail.com> Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 3 October 2026 10:38:25 BST, Karl Mehltretter wrote: >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 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. On purpose! It'll be dead code after one of ards changes > >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 > --- Thanks! https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/