Skip to content

Commit 2fcad3c

Browse files
authored
cmov: separate in/out in ARM32 ASM (#1346)
Changes the `asm!` block used to implement `masknz32` for ARM32 in the (otherwise) portable backend to separate its inputs and outputs, which should be semantically clearer.
1 parent b3a22ad commit 2fcad3c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmov/src/portable.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ fn masknz64(condition: u64) -> u64 {
138138
/// assembly should guarantee won't happen again in the future (CVE-2026-23519).
139139
#[cfg(target_arch = "arm")]
140140
fn masknz32(condition: u32) -> u32 {
141-
let mut mask = condition;
141+
let mut mask: u32;
142142
unsafe {
143143
core::arch::asm!(
144-
"rsbs {0}, {0}, #0", // Reverse subtract
144+
"rsbs {0}, {1}, #0", // Reverse subtract
145145
"sbcs {0}, {0}, {0}", // Subtract with carry, setting flags
146-
inout(reg) mask,
146+
lateout(reg) mask,
147+
in(reg) condition,
147148
options(nostack, nomem),
148149
);
149150
}

0 commit comments

Comments
 (0)