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 209C03C10BB; Tue, 8 Sep 2026 20:34:35 +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=1788899676; cv=none; b=d4XdjcPMNl5h5Nnfe2K0FS4Du1qU6oBoexPPOrAEky+q3lpeq5J5n2+31RMbA66lqlNgK149bCwaUiwR/9d/XYmtUgfKwF0z2oChY4p5RhtpEb+YpeISuYbvTRBmC87qBXNAbhCNZVVot8xyz1rbSP8JsrdkfycN9JWBiPtW0tE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788899676; c=relaxed/simple; bh=fK6TBedXtp9C8wyXq+gMkA9aCIWbdgW4j1n3EuVwG2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZDHx2MqrAfNjKQDfwOLlphViTcI7leu5gsdDYpAuN5Hg6aYlOHVdK0N4Z89sZA8xY8e2Gcq5VsOm992yUWqXhudkS426IGMaJ9rfCPz52znCzAuFOz8qsBKLyz7fUjkuSU9OZrDKyZC6m5r9RcxbcAsmEg7de1S9+WikkN4R/OI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SaeACdhu; 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="SaeACdhu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A1431F00A3D; Tue, 8 Sep 2026 20:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788899675; bh=/P7niWFbL9FTqnXvHulVblf0RiAm/HsEVfTytuXDkPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SaeACdhu6OJY2qwxudyZOzqsnyef6fUDvSrLCBRNNAAFLJeJ3f99t1v9ua2EcxXb4 JSXrKARGbOilEyLqFPMCYvUq8LHqVR0XQ90xlr5rK7bx52YgZQ3bIg2JAZobYoce7P E9cqCSTCKtvQ+rcMVYOnaWYsLFxxYNaS/Q/IszG5FBXeT2heZqTx914SDh4WJ8GomV hBu8xUP7+CIjeF8QitBEIICKx6HIKtgjbgHHQ9nJfLETu1kfgq6p8Hj7/e7f4GuxS+ DbSdb+5hUVE4rjNTYHS8eDBj3PwMTEjbL5J2VBZRom9A7MhekUM8VZ8sUKHqmDKPPr socNNbxggwOtw== 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 v2 13/27] rust: Annotate the intrinsic stubs as returnable Date: Tue, 8 Sep 2026 13:33:25 -0700 Message-ID: <201df80c0cbc78d6e1b167d48c6432d5773e528b.1788899473.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: rust-for-linux@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 da1a7409d9845..0aa9f298a2757 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -36,6 +36,9 @@ endif obj-$(CONFIG_RUST) += exports.o +always-$(CONFIG_RUST) += intrinsics_annotate_generated.c +obj-$(CONFIG_RUST) += intrinsics_annotate_generated.o + always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs @@ -702,6 +705,20 @@ ifdef CONFIG_PPC32 __udivdi3 __umoddi3 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