From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C67653CCFD4; Fri, 28 Aug 2026 04:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892728; cv=none; b=ZdVehNNhuXThLoLWI5YwjUMvRUucUesTTh4Vq7cg2JgYfos6LujIQRKYfhenOKHerr+hzzPLNFPyxNNItF3KtcBOZ2B9OF5Uew5Imx9ZJ7InAmxiOgGDGH+NSP3/+GHnJmO4eZN2webxGZvSyl9qjuo7xY8PDMZ94Fb9TVQemeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892728; c=relaxed/simple; bh=vOtShQW5hqWtQLsF6JJqqLEy9K1H2NwWlw6Q7PKK47w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a0MnyNihhpy+buR66H5mn5RW9a3VerXP30PQuoSIekkWn4npUgz/0NR/Do4qiiyGUTA7AvRMZqKLYa5oh1lxkXO88Oah2zoYH6/11o9NhvEonneeCLVRms/CANW5u4FqCeMQPIIttde2MyFeJq8GVwMnMwNAsVIuGK4urQijp/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AjgD8tBy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AjgD8tBy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AB531F00A3D; Fri, 28 Aug 2026 04:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892726; bh=q4UKoS/KEgRJIb5nCfv+d+0dqJKoVa0rpn2ix/q0LHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AjgD8tBymtQ7msSsHc/RxbIZCDsTlTIMP/HZ06sEyWyfh/RsGspLco1VegYAU8k5n bDH1dq4HoGaaugJalUn3Nqiy16T3WyujJrSxF4mZ3Bv2hMe1JIoOBELNtTkSTCpABM MjGL3tqGsuVd5ZkIgEYt1q1+NAZaRx/jgqgwdeMem38rTNcNgCytaHCHnBCTnS5J58 j0Vkr9O/XG00+XR0rJvse0HOA1Jcjm10HYUZ97ttJgAtauWNUTuTJK7t+w6V7ly+ph ZicE582fmHuePYq01r/EEzogB0CTbODERiBmo+vr1M1V/1BdpwXJ9JC4Ir80V7cFmM iijvS5HksAm7A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 13/27] rust: Annotate the intrinsic stubs as returnable Date: Thu, 27 Aug 2026 21:51:42 -0700 Message-ID: <00f55392e4640b835027a30b0dad79b4b53a56ad.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When building the Rust core library, the compiler emits calls to compiler-rt builtins like __udivti3() for 128-bit arithmetic, which the kernel doesn't want, so objcopy is used to redirect those calls to stubs which just panic. Problem is, their call sites still expect them to return, which confuses objtool. Objtool doesn't report any warnings today because the stubs are weak, which noreturn detection currently ignores. In preparation for removing that restriction, annotate them as returnable. Signed-off-by: Josh Poimboeuf --- rust/.gitignore | 1 + rust/Makefile | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/rust/.gitignore b/rust/.gitignore index d3829ffab80ba..c198d1a52e60e 100644 --- a/rust/.gitignore +++ b/rust/.gitignore @@ -6,5 +6,6 @@ doctests_kernel_generated.rs doctests_kernel_generated_kunit.c uapi_generated.rs exports_*_generated.h +intrinsics_annotate_generated.c doc/ test/ diff --git a/rust/Makefile b/rust/Makefile index 627ed79dc6f50..1cbee6f1ca098 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -33,6 +33,9 @@ endif obj-$(CONFIG_RUST) += exports.o +always-$(CONFIG_RUST) += intrinsics_annotate_generated.c +obj-$(CONFIG_RUST) += intrinsics_annotate_generated.o + always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs @@ -684,6 +687,20 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),) __ashlti3 __lshrti3 endif +# For objtool, annotate the redirect-intrinsics as returnable. Their call +# sites were compiled against the returnable intrinsics, but the redirected +# versions are noreturn. +quiet_cmd_intrinsics_annotate = GEN $@ + cmd_intrinsics_annotate = { \ + echo '/* Generated by rust/Makefile - do not edit */'; \ + echo '\#include '; \ + for s in $(redirect-intrinsics); do \ + echo "ANNOTATE_IGNORE_NORETURN(__rust$$s);"; \ + done; } > $@ + +$(obj)/intrinsics_annotate_generated.c: $(srctree)/rust/Makefile FORCE + $(call if_changed,intrinsics_annotate) + ifdef CONFIG_MODVERSIONS cmd_gendwarfksyms = $(if $(skip_gendwarfksyms),, \ $(call rust_exports,$@,"%s\n") | \ -- 2.55.0