From nobody Sat Feb 7 17:41:41 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 438631E0DED for ; Wed, 18 Dec 2024 14:59:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533944; cv=none; b=anxo0+lc5htiZEdPNYsmyVAAO7PkYq8CUgcSgbhbTpBIonEpJUhCi/cgaynquQEzlVKJ/2rzdHHE6pepbiqS1yQtrdYULgwZ1P97S1MbBjAWzOIwpMCNuDPV0eMdmjzRduKVulA0SHNKgig0kTJ59l7funvYGofs3ecwS7G7FZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533944; c=relaxed/simple; bh=KCEr2W+5QMJ0aau2ejxlB/jVgNJmqNP817wKzYYGqxE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l/ujZPBLlT86kqxzwhEE2rcXF5n162K5D3utKgW1udoW9S1Nosb4ffFXrmBMMMTKPRtcdpCF2xOCAlbwmd59KhzmK8pQjrC6/13KOzuU3vZQtgmebbxQF4k4vNw7FolIiIR9cjIRgeBNS5RnDLO5rjHip9f9EbUBjGJq1CZ2Pxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M/dHMPox; arc=none smtp.client-ip=209.85.128.73 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--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M/dHMPox" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-436379713baso23739525e9.2 for ; Wed, 18 Dec 2024 06:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734533941; x=1735138741; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=idHXEvLLy2mDizWltND5EhS5SGdeBni13+lqGt1+LxU=; b=M/dHMPoxEmn8OeBTyPmSO+82+nGhO20rlRW+axGvVCQFdSbYjsOT0MVlhXV4DGdUDQ 58MazTE3Jo5Miz3rtkT4Ke/A5BYYB25DCNL3PdHMpqV74JSg3XXaqd406aeBHy0JHw6s 29lMPmwAY7DFwK3pk8XfsA7LAmZswXpDbK+o2rR58maH6I1wFoEyLz26gSVmc3kERAAN ECO4rOEJ1Bnx57BjJOO99OAuG1m1XxFRFI00jvaXt2WPpUebngGeOIcnlWaEbVS5fZKJ Gm4EQ7W/1qfFEPC9E5qcHxMfWBU09f/UfzyrZWYXiSOohXhF4fpKqKyiB78SZe1KFQNS ulBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533941; x=1735138741; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=idHXEvLLy2mDizWltND5EhS5SGdeBni13+lqGt1+LxU=; b=S4VKGqe7tBEmBtnTUVjJDtxMFSUyqIFvm+bPKYQNhLgP5+79kFWq+nUhoFWK5nnV3r 3SBtGAEeP1jiv5nts90PlBNJgbhgWGlyf1U2yzVklG+5HubJQOEdZ6EPv6UEeoOEJr17 aaQ5ACgbNm/SQ2xRYj74JjMSvFf0qE8oUW1ecpJIHQXtHnHFvGsmRlo9a4ZSpF3oSAk4 +bIwzyUQXMv351AhLCEA2Jv9tB8oOkipF2Poitwai7Nk9K0xouOZLbFXyKqpoM/mH/QP XNxX/6er+gIVo7E8cEAph6AmJoZT/e3CG78SzOb0Mf4/9vUr5cbA8owQSkHEo6300jjj WvHw== X-Gm-Message-State: AOJu0YyjYWDDa4iJqept1O4VAs4ptOg98kfqZoOCen6Lmcohdl8HSDIY T+XqNNgHmvEUn0PinuUkf+5GhIyqeHFd3qOZYSN0S1bXjKPfW+vCPhu8eJ4xdXHjl9Mbj3JyE/o 8F/PiET8x+g== X-Google-Smtp-Source: AGHT+IH+9zaQOVFuVfKtcWUDrT45GIKtZMxkPrMnUP9HyJ02nWCkBrRH3WyfgoYhgFwBe/w1jpoWPWajtTkyMg== X-Received: from wmin8.prod.google.com ([2002:a7b:cbc8:0:b0:434:a346:77e5]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3c98:b0:434:9936:c823 with SMTP id 5b1f17b1804b1-43655395610mr28336945e9.18.1734533940792; Wed, 18 Dec 2024 06:59:00 -0800 (PST) Date: Wed, 18 Dec 2024 14:58:55 +0000 In-Reply-To: <20241218-objtool-strict-v2-0-a5297c961434@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241218-objtool-strict-v2-0-a5297c961434@google.com> X-Mailer: b4 0.15-dev Message-ID: <20241218-objtool-strict-v2-1-a5297c961434@google.com> Subject: [PATCH v2 1/2] objtool: Add --Werror From: Brendan Jackman To: Josh Poimboeuf , Peter Zijlstra , Andrew Morton , Masahiro Yamada , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable At present objtool only prints to the terminal when observing "fatal warnings". This option lets you have it produce an error instead. The use case for this is noinstr validation; so far I've never seen any false warnings here, but it quite often detects real bugs. It would be useful for the build to fail when I have those bugs. Signed-off-by: Brendan Jackman --- tools/objtool/builtin-check.c | 6 ++++++ tools/objtool/check.c | 7 ++----- tools/objtool/include/objtool/builtin.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 387d56a7f5fb8da8435d0a3f5c05eeee66932c9b..0b28082df90710ff7127327deb8= 57c0548f378c7 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -94,6 +94,12 @@ static const struct option check_options[] =3D { OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses= in warnings"), OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"), OPT_BOOLEAN('v', "verbose", &opts.verbose, "verbose warnings"), + /* + * For now, don't fail the kernel build on fatal warnings by default. + * These errors are still fairly common due to the growing matrix of + * supported toolchains and their recent pace of change. + */ + OPT_BOOLEAN(0, "Werror", &opts.werror, "fail on fatal warnings"), =20 OPT_END(), }; diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4ce176ad411fb12a10101bbedbb6180275941b4b..7c73517dc11c98cd7163f96dc8f= 4158389d58428 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4941,10 +4941,7 @@ int check(struct objtool_file *file) } =20 out: - /* - * For now, don't fail the kernel build on fatal warnings. These - * errors are still fairly common due to the growing matrix of - * supported toolchains and their recent pace of change. - */ + if (opts.werror && warnings) + return 1; return 0; } diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index fcca6662c8b4b5e0048e54fada8694cc2e6ebc34..97d668010efadfa05bb6e25e196= 7a7d72bf77815 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -38,6 +38,7 @@ struct opts { bool sec_address; bool stats; bool verbose; + bool werror; }; =20 extern struct opts opts; --=20 2.47.1.613.gc27f4b7a9f-goog From nobody Sat Feb 7 17:41:41 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 2C5B71E9B24 for ; Wed, 18 Dec 2024 14:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533945; cv=none; b=fCV654twL42Kgs4OgBX4inyPJdA/IxZvkMf6JjwkTJHRbinKS7yrQPKM95xWVeGvmWZgRjJNNRDCguPls7DIS7+9lDWxgLgZxGdFlbGdrNhn+yM/oSvr/0fldm3Vhu59TwFjBYuU0eloEjtzChJflIQAetLHdNciw7XMSkvIPdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734533945; c=relaxed/simple; bh=vafDbXBf+QfMxG6+rjWXgv88J6vjtPaiFaHXbRrgmRo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WKH5sd+N9AzF1qc18R506XEKPxEOHynW0dFhJXmFOBULTPs7P6kk+dRLNEfZG+RLW07FIWTv/Zquayu5E7IXjx3chZMOlojTc0/edDTycPu9MPTxNbJgo29P9tZ7ojmXDEiApJ/8KalqG5e2+fzASezkc6a5L3WFKuyo1UW1pTQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uLKz8fHM; arc=none smtp.client-ip=209.85.128.73 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--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uLKz8fHM" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4361ac607b6so54818815e9.0 for ; Wed, 18 Dec 2024 06:59:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734533942; x=1735138742; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+fxq85lD6PQT2A+RCvBP9upNyfET7edCFQdJ5Qc6idU=; b=uLKz8fHMvJYDm5qi3QlRmw8prr87P6YS67XLrVdLOirHX6tUYAhlXV3Yd0eD3yy5RX H9JMvvTpU1YStfWTFXl0zrfauWyllSmLaS/ucNiZySUJfeLc/3sSMXh8yf9YhpI70gsa Mf6ORdjKLqb1Ci/qKkdKmsEoYqJTArPamYnP+5I/RPxvDrMRZF2H4Bo8PlR1nzaNkkiF 5aJ4Zw+nrnKQHJvMBlrUtftAG4f5ZU4AEBRolfxmLHXV/45GogNIxVZUz99FIclbZNlc gkMMeiPNebLRHMNcTiZ8XqZR56MM23pEws3fLjWEcSPVRYTFWAjHbrHBNqaTFek9GisV yYDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734533942; x=1735138742; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+fxq85lD6PQT2A+RCvBP9upNyfET7edCFQdJ5Qc6idU=; b=OGM3DQ2rOX+9nsPPvyTBecPIy4seRStHs3Q1iOAmA+TyFIrPClF13mDOcjZtasRxhE ABt7DbwxtG/N0B/8rTTtB5wfJo2tWf59oODpW7qXqrrlV+HFozW5EwqBBB1ypyQhJ1jj QUtU5k5t/U8MHA5wcSYVk/vDpLGn/I4jLbK5LNKQbMoRkPbDdyN2OY7FLEQEYah6xAss CUDh/OB6Ok1TR+gPYg25t4VFs96CNFKt00Z3Hj1FMDx70L6QYr18mcVDVo88vkedQZyh TkrWxQ2UcBgXWBj0kE24sSr3wJCCn2yJeqNWKGXnSsxLZ9je7MQexNimKpk1eldCG693 Hp5g== X-Gm-Message-State: AOJu0Yz5Zn26f5tMGsNCHwbDHpeYqnFzSi+zttSMk8zQpAVEQrhjomxj PZb4wibpSRy/zGFaXbn2KyB3yJuYmu3XtfDzOORuUh0tKeOW98Umnx0cBrpUW/6ILqgvlRO7NmU ygkO8t1xTXw== X-Google-Smtp-Source: AGHT+IH6nFaGWCuLmtEVK7MkT2qc20xbncxkKqUUs/d5E7z2van0Z9iQNOqaZ3mX/Vt8cvgsSyrqh3ATVeu6rw== X-Received: from wmbhn6.prod.google.com ([2002:a05:600c:a386:b0:434:9eee:e503]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:5248:b0:435:14d:f61a with SMTP id 5b1f17b1804b1-436553eb4a4mr23858575e9.25.1734533942686; Wed, 18 Dec 2024 06:59:02 -0800 (PST) Date: Wed, 18 Dec 2024 14:58:56 +0000 In-Reply-To: <20241218-objtool-strict-v2-0-a5297c961434@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241218-objtool-strict-v2-0-a5297c961434@google.com> X-Mailer: b4 0.15-dev Message-ID: <20241218-objtool-strict-v2-2-a5297c961434@google.com> Subject: [PATCH v2 2/2] kbuild: Add option to fail build on vmlinux objtool issues From: Brendan Jackman To: Josh Poimboeuf , Peter Zijlstra , Andrew Morton , Masahiro Yamada , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable NOINSTR_VALIDATION is pretty helpful for detecting bugs, it would be helpful for the build to fail when those bugs arise. If necessary it would be possible to enable this for individual warnings, it seems unlikely there's a use-case for that though. So for now just add a global setting. Signed-off-by: Brendan Jackman --- lib/Kconfig.debug | 10 ++++++++++ scripts/Makefile.lib | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index f3d72370587936fa373129cc9b246f15dac907be..3ee92da4733a3a504991d5dbb4d= 0cee84f519d64 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -545,6 +545,16 @@ config FRAME_POINTER config OBJTOOL bool =20 +config OBJTOOL_WERROR + bool "Run objtool with warnings as errors" + default n + depends on OBJTOOL + help + Fail the build when objtool produces warnings. + + By default, objtool just prints warnings to the terminal without + causing a build failure. This config changes that. + config STACK_VALIDATION bool "Compile-time stack metadata validation" depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7395200538da89a2f6e6d21f8959f3f60d291d79..a53e052ae0532e886fcb2019025= cf7216e484bd2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -277,6 +277,7 @@ objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D --= static-call objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) +=3D --uaccess objtool-args-$(CONFIG_GCOV_KERNEL) +=3D --no-unreachable objtool-args-$(CONFIG_PREFIX_SYMBOLS) +=3D --prefix=3D$(CONFIG_FUNCTION_= PADDING_BYTES) +objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --Werror =20 objtool-args =3D $(objtool-args-y) \ $(if $(delay-objtool), --link) \ --=20 2.47.1.613.gc27f4b7a9f-goog