From nobody Sat Feb 7 11:38:08 2026 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E450E32FA2D for ; Mon, 5 Jan 2026 10:44:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767609859; cv=none; b=tFj/N8faPuTQrWXEiLvXzHJQPu1R1EAdsuQVccFJtXX5awg0uV5QgHLPO9ye7amIESztKssCuwNEa8PAl7BbCJYw4SsNiJ9ZH/OdT6da4megBIhStfGW7Rlz7Wr2OfhFsL567QzGy9AAwH1u8UlxooXNAP+I3eE/ioojh+v/s4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767609859; c=relaxed/simple; bh=1QO3DLk2yhnxowskNNFKMDzfjU/42K8tKMfyiZUya8Q=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=PE26ykCU4D8cC6SbwRyjbcN4l4mzlBCj8gEL3x+9oz17VnHfaqb1nU5fUBF1HanYd8SVMPHZVdcLGQRJA/oyqy4T2ZZJ9e+Gm130aSUSVHUvqPtVn/E2cUiREOGq+9I4HXlVmkyUo+CfIWqOGWzleeg2xspzQX3baD843BqRlH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fPgltwW4; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fPgltwW4" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-43284f60a8aso4134205f8f.3 for ; Mon, 05 Jan 2026 02:44:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767609855; x=1768214655; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=iB7YE0l+vq3WW+DIqr0TlHXqLvKI5geObaEQMVL3pYo=; b=fPgltwW4iCduJR3FWFeUUZpJ+s00mFsCgGgyd+LfAHDNL8FmTJduhW7/NSpR4bU1Y7 x6pwveZHRtSwmlR0Vvrnmg4Ed3nqJET7hOVhioJsDCtJPClOdbfmaCfdShrYH8Hna+HD nqhKikKXdD/F3UwUWROtG16pQuZaeuiKbCdSc1LD1OKdP0fC7YRrclONAGB/ahLU1Bz/ mi2aRa2edyzYC7HDn0y2Ng4kax95T1jbGG8SCcrVr6VBBa4PbkMfDsyCTojQujcO5VR8 YW6BdJApQiFOuDZXPHVdo7F1H1UxOFHx8NsBs0vc0SSVoSI5kdHp76ytkmhE17hCzmLx BcEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767609855; x=1768214655; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iB7YE0l+vq3WW+DIqr0TlHXqLvKI5geObaEQMVL3pYo=; b=H1QQdQpk1S4AVrbq9RdGyQknnXtIYlL0Y2dMzF3CWSqJ2NoNkbfWbP/M1wIuYHuesx xlioMYIshmPMe0hff0FDCo++1jnVQvgae5THOn79+jl1tXlP4IwamzEexCFWlRo2Wg/p ZAyZx35xPERIjR2Sd7Gbq/oqLwjHaY6T4HJqer++1T6lmHzTbTe2fEwGCLx82t+ZytSj xVMFLpBXeBWMIxjm5T1cvBwoE6ulsnSUDEAwp5wRuBIQzhf1hFPHW0SHaEcnpuzzOfCk QlaRs8+Ep17QL86XgHKrH9ol28sbdUwts/9xe53srSun6U3XWW0DlNmV7mRc+gdIqGSu 2bXw== X-Forwarded-Encrypted: i=1; AJvYcCVtmt8a5YZODDm3aAsaaHddLrwX7Adc1PxfHIk6lNueckrq65Tmaxs7jQ5g2D6R68DfOalKs/2ciEr+EXs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9PX0/gJZLG4ryn2w6dF1wCBNH4A/VKr+mx9i+R5tYrFySq7Xw 9TXD88l6H18PJPFC6QkFbRZ8dPJKL4DWWJCHeBkJ42udHo/9OX0bSu3DHwLB/fZKJqcLfQVU7yO dVd7l3ICtvTYV3RM4xw== X-Google-Smtp-Source: AGHT+IGQ34WZFKVilT6HOUlgUQJo4didZl8RM/l4vnBrj2WM6URpfu7K3BIidVdMwnPvK5FgGd8Acedl+UGGZKU= X-Received: from wrbck15.prod.google.com ([2002:a5d:5e8f:0:b0:42f:bb38:35d1]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:609:b0:431:342:ad41 with SMTP id ffacd0b85a97d-4324e6fa1a7mr65299971f8f.61.1767609855242; Mon, 05 Jan 2026 02:44:15 -0800 (PST) Date: Mon, 05 Jan 2026 10:44:06 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAPWVW2kC/32NQQqDMBBFryKz7pQkEkO76j2KC2PGZMAmkoi0i Hdv6gG6fA/++zsUykwF7s0OmTYunGIFdWlgDEP0hOwqgxJKSyVatLympeDE0WGgeaGMSpOT1g5 khIA6XDJN/D6jz75y4LKm/Dk/Nvmzf3ObRIla3lpHVhvTdQ+fkp/pOqYX9MdxfAFq2A2QtQAAA A== X-Change-Id: 20251203-bitops-find-helper-25ed1bbae700 X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=4818; i=aliceryhl@google.com; h=from:subject:message-id; bh=1QO3DLk2yhnxowskNNFKMDzfjU/42K8tKMfyiZUya8Q=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBpW5X480DtzvVuRhPhMmNpQuoBcHD6YBnm8rwY9 3CueU5yKtmJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCaVuV+AAKCRAEWL7uWMY5 RkIzEACet0+jmd3Fl7BK5lRdHUdojAeqaBxBt6BMkPlNfqaCrPurZiMy/2V/U6SCifYE4SKRXej UrP4wVCTZTWPjSedUUiJBdzVYMRpjoe+phjyjA1Hx0ovJ19aIm5ON0Vr8ImLOlMb2PgQSVC0EfB rozcRQquqabh9wC8r2WaI+iCc5LGHd3inCeh/+7QuXxODJNPFwwQlIUA/qhh5DHB8s8u2aCklNC gQsUaeds3Wim6XzAejMAu+oWeu1hktOJuKQLUJk20C3pJl1eFKqR2yyQVL5BP/2a0R9jQVVHvNt Ybf3jCOTNtM3FZXEa7bRYQ/wXE5caHxek3cBYCt5Mt5Tow7WCVJQUhhkFYREyIwsZfn/f4oIT7/ uXfRrNZROsKKcBXXwuNvMh5w1ko7JRmlJloZTbY9p+lCYaYPJ/Otn1QaEPbDTuV1r86oiI41Hde BtL++DuSh3d/1T+OjOLxldLean7QdU1dMFqTZ/+hd9oZdBGsJiggBeXQGeV2+G3ZpN8qIiZqOP/ brBnnD+1fcbUFRIuWkqkFf2BMIUp+ZeW87ak4c+Sqpr0kozAfVSAa/XVBHem/qrmVn2iUtkLoRw sOAQnP8Ktu6LxruX8IUiDGti9Gze6oQTYjG5DlIeCZMg2aoMdnwygeMVJhehf/fxu04H3qhxuSE JlK5Z1tfvRcksCw== X-Mailer: b4 0.14.2 Message-ID: <20260105-bitops-find-helper-v2-1-ae70b4fc9ecc@google.com> Subject: [PATCH v2] rust: bitops: fix missing _find_* functions on 32-bit ARM From: Alice Ryhl To: Yury Norov , Burak Emir , Andreas Hindborg Cc: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Trevor Gross , Danilo Krummrich , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Alice Ryhl Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On 32-bit ARM, you may encounter linker errors such as this one: ld.lld: error: undefined symbol: _find_next_zero_bit >>> referenced by rust_binder_main.43196037ba7bcee1-cgu.0 >>> drivers/android/binder/rust_binder_main.o:(::insert_or_update_handle) in archive vmlinux.a >>> referenced by rust_binder_main.43196037ba7bcee1-cgu.0 >>> drivers/android/binder/rust_binder_main.o:(::insert_or_update_handle) in archive vmlinux.a This error occurs because even though the functions are declared by include/linux/find.h, the definition is #ifdef'd out on 32-bit ARM. This is because arch/arm/include/asm/bitops.h contains: #define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) #define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) #define find_first_bit(p,sz) _find_first_bit_le(p,sz) #define find_next_bit(p,sz,off) _find_next_bit_le(p,sz,off) And the underscore-prefixed function is conditional on #ifndef of the non-underscore-prefixed name, but the declaration in find.h is *not* conditional on that #ifndef. To fix the linker error, we ensure that the symbols in question exist when compiling Rust code. We do this by definining them in rust/helpers/ whenever the normal definition is #ifndef'd out. Note that these helpers are somewhat unusual in that they do not have the rust_helper_ prefix that most helpers have. Adding the rust_helper_ prefix does not compile, as 'bindings::_find_next_zero_bit()' will result in a call to a symbol called _find_next_zero_bit as defined by include/linux/find.h rather than a symbol with the rust_helper_ prefix. This is because when a symbol is present in both include/ and rust/helpers/, the one from include/ wins under the assumption that the current configuration is one where that helper is unnecessary. This heuristic fails for _find_next_zero_bit() because the header file always declares it even if the symbol does not exist. The functions still use the __rust_helper annotation. This lets the wrapper function be inlined into Rust code even if full kernel LTO is not used once the patch series for that feature lands. Cc: stable@vger.kernel.org Fixes: 6cf93a9ed39e ("rust: add bindings for bitops.h") Reported-by: Andreas Hindborg Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/x/topic/x/near= /561677301 Signed-off-by: Alice Ryhl Reviewed-by: Dirk Behme Tested-by: Andreas Hindborg --- Changes in v2: - Remove rust_helper_ prefix from helpers. - Improve commit message. - The set of functions for which a helper is added is changed so that it matches arch/arm/include/asm/bitops.h - Link to v1: https://lore.kernel.org/r/20251203-bitops-find-helper-v1-1-51= 93deb57766@google.com --- rust/helpers/bitops.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/rust/helpers/bitops.c b/rust/helpers/bitops.c index 5d0861d29d3f0d705a014ae4601685828405f33b..e79ef9e6d98f969e2a0a2a6f62d= 9fcec3ef0fd72 100644 --- a/rust/helpers/bitops.c +++ b/rust/helpers/bitops.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 =20 #include +#include =20 void rust_helper___set_bit(unsigned long nr, unsigned long *addr) { @@ -21,3 +22,44 @@ void rust_helper_clear_bit(unsigned long nr, volatile un= signed long *addr) { clear_bit(nr, addr); } + +/* + * The rust_helper_ prefix is intentionally omitted below so that the + * declarations in include/linux/find.h are compatible with these helpers. + * + * Note that the below #ifdefs mean that the helper is only created if C d= oes + * not provide a definition. + */ +#ifdef find_first_zero_bit +__rust_helper +unsigned long _find_first_zero_bit(const unsigned long *p, unsigned long s= ize) +{ + return find_first_zero_bit(p, size); +} +#endif /* find_first_zero_bit */ + +#ifdef find_next_zero_bit +__rust_helper +unsigned long _find_next_zero_bit(const unsigned long *addr, + unsigned long size, unsigned long offset) +{ + return find_next_zero_bit(addr, size, offset); +} +#endif /* find_next_zero_bit */ + +#ifdef find_first_bit +__rust_helper +unsigned long _find_first_bit(const unsigned long *addr, unsigned long siz= e) +{ + return find_first_bit(addr, size); +} +#endif /* find_first_bit */ + +#ifdef find_next_bit +__rust_helper +unsigned long _find_next_bit(const unsigned long *addr, unsigned long size, + unsigned long offset) +{ + return find_next_bit(addr, size, offset); +} +#endif /* find_next_bit */ --- base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 change-id: 20251203-bitops-find-helper-25ed1bbae700 Best regards, --=20 Alice Ryhl