From d7278928f702800028d2e95767e7dd36bf8dbac2 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Mon, 9 Jun 2025 16:18:21 +0300 Subject: [PATCH 1/2] linux_raw: inline `__NR_getrandom` into ARM assembly --- src/backends/linux_raw.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backends/linux_raw.rs b/src/backends/linux_raw.rs index f199e201..6b6af91e 100644 --- a/src/backends/linux_raw.rs +++ b/src/backends/linux_raw.rs @@ -13,7 +13,6 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize { // Based on `rustix` and `linux-raw-sys` code. cfg_if! { if #[cfg(target_arch = "arm")] { - const __NR_getrandom: u32 = 384; // In thumb-mode, r7 is the frame pointer and is not permitted to be used in // an inline asm operand, so we have to use a different register and copy it // into r7 inside the inline asm. @@ -22,10 +21,10 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize { // bother with it. core::arch::asm!( "mov {tmp}, r7", - "mov r7, {nr}", + // TODO(MSRV-1.82): replace with `nr = const __NR_getrandom,` + "mov r7, #384", "svc 0", "mov r7, {tmp}", - nr = const __NR_getrandom, tmp = out(reg) _, inlateout("r0") buf => r0, in("r1") buflen, From a8556951a1a72156fcee09d75edced8665b310c3 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Mon, 9 Jun 2025 16:21:16 +0300 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f51c2b59..4de0a4b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.3.4] - UNRELEASED +### Changed +- Relax MSRV for the `linux_raw` opt-in backend on ARM targets [#688] + ### Added - `unsupported` opt-in backend [#667] [#667]: https://github.com/rust-random/getrandom/pull/667 +[#688]: https://github.com/rust-random/getrandom/pull/688 ## [0.3.3] - 2025-05-09