From nobody Wed Dec 17 03:27:47 2025 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 7838E1DF271 for ; Fri, 13 Dec 2024 11:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734089510; cv=none; b=bOVuldiwoV4fXhHW+BOVU7xD97Tjb+T7u+gb3ng8tmQH5HsuOmJMk1iCSEnxOgfEFWmnLGDdJzY4nXsMLvYobnq/9LwuIgOLfx16kGFgJd/kaYbuetL+NE2RnatmxYt6x8BXPmOsn62v23JG0ITaTEp/1sAhu8WYAAb3RlnoaGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734089510; c=relaxed/simple; bh=RL2+sa7FqlB5keLFzemHFNSTwj0vyUQXIodq1LlTmxg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=vDnfzhtIfpAK6OgMnJi33gWZ2ZYOqEKYictvYezPFkZMr5vsblJqRqa5zSh88mErJ/r964nYtVujmTo2W7bUDNuPhoCri5aIahNwKNcdz55gqAkdCoUjgfMxReL1DP/iTJ2wNuQisfdfQWTS2ew8KFiP9ld9vby3Seuu281PL58= 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=ciiw3bD+; arc=none smtp.client-ip=209.85.128.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--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="ciiw3bD+" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-43623bf2a83so15325425e9.0 for ; Fri, 13 Dec 2024 03:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734089507; x=1734694307; 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=A/liT58PKYw7HwtStWEUG+08/cDBkM9nfVGzjd6G6SU=; b=ciiw3bD+HUhNW8rAO8St0Zexrb7QFz3QeKpShEz/GzF8uyLrab0p/S0AIuraQEF8mP bVo3TKDKUvkOMAg15dNPWsGbMBcPx75YOBKHIL0H4bYXIx/zq+O2EBL62EWGcSYL6VDK sMTtsh5xkBIiEruINv6X0tf33lEkZFKBuH5/HVCWfQFQRJirsIoDT534/tKLmvmVSENI dl1DEMLZ79qd3W0A9Mgab5iwB7Ej+gsShnP2AOy+gL/eEeiiuH0FFqDV5N/FjcUwRkDa H57XjidmIQbSLnrVdl6m9WjONeCMeayTh8XEz2o+0h5oe/MQI0xzp6kjpneYdWHuzELu PaPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734089507; x=1734694307; 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=A/liT58PKYw7HwtStWEUG+08/cDBkM9nfVGzjd6G6SU=; b=HTH2KUxDky9UbZ1wEI11TOVOfKmX8BHBBv+tlzSWf8SlP6itkUta2isjUeGyk12I6M SSY5aiImmhTsQARCj5ZDuEQYzotTvqFp0teSrJp4zSdMiX5Zbc7/9Rk5Qa8gU3hrLS95 QUumvVtEJjnAQnDBXep0ds4sDQrHqImOKHxH8AQMVoDY0a9BmcvvK1mQzBZtjIyp8v8N 8+mBwnexKxYS+h1IDmTGHagFJVSFcxLG5iEsP6Jo5iPWvHTkH82T7ruUUfvjfce5tu7T 0/bObosUAOEGtf92Pv1z7xZiXHRpXcKKkyJVt+UuFuqI/SkXKgWhcdOkAGZROQyAaZSU Qy4A== X-Gm-Message-State: AOJu0YxHsVYjtS3EQA+NM8n6DJbrAQYPzfqADkiRRk7UDAgNGhBRSx6T 8ZILL9P1ee9YRO0XarN1ASSxalsG393uUZJu945IXFWIvbJzSn4Ywlwk1bFU7Cq7fFIAQ11M8gf LOC6yoc2bqg== X-Google-Smtp-Source: AGHT+IH7cHlQeRy1xZRu5M7RBxGpX53bIPU0Rj1rBgppyxRggT+ne4NlBEvps3MOKD7DTPzL3SAILj1cLz/mhA== X-Received: from wmbd13.prod.google.com ([2002:a05:600c:58cd:b0:434:9dec:7cc5]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:154c:b0:434:ff30:a159 with SMTP id 5b1f17b1804b1-4362a982c34mr20114835e9.0.1734089506939; Fri, 13 Dec 2024 03:31:46 -0800 (PST) Date: Fri, 13 Dec 2024 11:31:30 +0000 In-Reply-To: <20241213-objtool-strict-v1-0-fd388f9d971f@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241213-objtool-strict-v1-0-fd388f9d971f@google.com> X-Mailer: b4 0.15-dev Message-ID: <20241213-objtool-strict-v1-1-fd388f9d971f@google.com> Subject: [PATCH 1/2] objtool: Add --fail-on-warn 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. My use case for this is noinstr validation; so far I've never seen any false warnings here, but it quite often detects real bugs. I'd like my 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..dd70cbb98929b7f558c27766bda= 46ad276c0750d 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, "fail-on-warn", &opts.fail_on_warn, "fail on fatal warning= s"), =20 OPT_END(), }; diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4ce176ad411fb12a10101bbedbb6180275941b4b..266896b46e92c5c4a3244aa73de= b3a355e6d8f8d 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.fail_on_warn && warnings) + return 1; return 0; } diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index fcca6662c8b4b5e0048e54fada8694cc2e6ebc34..f9af81ad9f600044280085cd1a7= 43609ce054a21 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 fail_on_warn; }; =20 extern struct opts opts; --=20 2.47.1.613.gc27f4b7a9f-goog From nobody Wed Dec 17 03:27:47 2025 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 5FAF21DF728 for ; Fri, 13 Dec 2024 11:31:50 +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=1734089512; cv=none; b=ukTJMdknL83jOJ3VgpzMona7+i43d3m23SpTIKg5zrdrgoo6eGgyh6s+eNsvZzzlrRYWYeeU4zr8+S37Y4sxmYAVM9wEhvpT6T7S9LYB9umesVQSWAJmanCSWEN4vPx4qk1q7GxmWqlkeT4xymkasaezcIOJ2VsAKbPbW5EnQok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734089512; c=relaxed/simple; bh=8Z+fkcLpCW50dgG3XgGbc9Y+J6ZITUqaOeKIYboitQ8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FI4emZ+Rt9gWg6BSjNCM3kESZYK4eJhKlnCd4ppJtwLcauLUVARQHhbs0gEWbPfHYM2s9sGsXr9q8YiXtj5O6Ef0k7G9iAWjl02r0v3fPehVJs0kvQkOTaAU9BQ8sC8W3Jil2vhv09eDbauHpOjCUPeNYGpZuN+i8LlN8Y9lD60= 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=e8V4rozR; 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="e8V4rozR" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-43627bb20b5so10416405e9.1 for ; Fri, 13 Dec 2024 03:31:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734089509; x=1734694309; 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=12jc0w/fivkkryMIJsg9WOh7az7NrRYvkDaKh8q38vk=; b=e8V4rozRZDQGgq2bdNP9Nlyfwa9Xh7OHavGBO4y1dBS7KWB5hmAmheJzIpiE8Va8Hy tThS8pUJk+855bCGr1xkxdKgL+hKir2WTVNg7Sc2SyCYixDonXpuRd6r5FlibvVngQcN mwy3BUdGVR30Y4FuGy/8eHAkKHR/oaiv3Zu4Zn3S5cU6OVkiFAUwpKXHM4rEfSaXRXTU 86GA5bMq24zb1IKPkw36n/JZVcyaac3/a4mjNGebq//WyJDnr91JCxT2IheOBCBy4hkW ZhukrohU3vzuLVu+yHxu1pRPoUeggUG3fdP0eCFvVhA4oL/RSlYrjmhnfQpw/WhsAKda Ofvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734089509; x=1734694309; 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=12jc0w/fivkkryMIJsg9WOh7az7NrRYvkDaKh8q38vk=; b=gZZgW9soxzo6AYXGOt6jQ543S6fBLecNpYZGxE0B3YWucpfBoCXPjrinUtpzeIpu2F JpRaQ1m2ehLW1EyY+1ouz8E3utG4Gir8Q8GHfoIFex2MMgu9Xu9GIrF/i/6wKeIZmsYl llsQKwr6O6la4AMGn3sC+O8Z1jAMalwiW3bN2W/p8ip5vb52Vk5MhOQHjuOjMliWOQDI l47EVgQMITF+32na7Yf9J5jWdYtVnK0wI8huq2ewOPgs13EQbY/X+GPyn+80PdbZgaOa B7j2hx/G4V0pUZFRcIgkPmdU+QCXeLzCdaOqUBmY9FnkNkYEuYoNds2NcqeFBnZZXnBC RpQA== X-Gm-Message-State: AOJu0YyL6+GPeZP7xHWUn3gzovFTqSoFeEwcmmX0h75hqQNLk3Stc2yO +QdPrNl04DwLNgqcVEQLQoNToDaSjAQ26qnYymxjjganAYUjUpqzdIr+Yr4dpDBpoJbrWPs4eDX LeeLQV85Ljg== X-Google-Smtp-Source: AGHT+IEZ4eA8bhHHA8R9uWIaOs6w9kxA+a6SSCc9PyYcjPq9AgHQF76/B6v8e4W1chnsdD7KewFoDA8hfeL33Q== X-Received: from wmbdx22.prod.google.com ([2002:a05:600c:63d6:b0:436:3ea:c491]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a14:b0:435:32e:8270 with SMTP id 5b1f17b1804b1-4362aa3bcdcmr19895245e9.14.1734089508870; Fri, 13 Dec 2024 03:31:48 -0800 (PST) Date: Fri, 13 Dec 2024 11:31:31 +0000 In-Reply-To: <20241213-objtool-strict-v1-0-fd388f9d971f@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241213-objtool-strict-v1-0-fd388f9d971f@google.com> X-Mailer: b4 0.15-dev Message-ID: <20241213-objtool-strict-v1-2-fd388f9d971f@google.com> Subject: [PATCH 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, I would like my build to fail when those bugs arise. If we wanted to we could enable this for individual warnings, it seems unlikely there's a use-case for that though. So for now I've just added a global setting for vmlinux. Signed-off-by: Brendan Jackman --- lib/Kconfig.debug | 11 +++++++++++ scripts/Makefile.vmlinux_o | 1 + 2 files changed, 12 insertions(+) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index f3d72370587936fa373129cc9b246f15dac907be..b1f0f8c83b050d4112428e0d8de= ce059ebf8dcd2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -563,6 +563,17 @@ config NOINSTR_VALIDATION select OBJTOOL default y =20 +config VMLINUX_OBJTOOL_STRICT + bool "Strict objtool on vmlinux" + default n + # Conditions when we run objtool on vmlinux + depends on NOINSTR_VALIDATION || LTO_CLANG || X86_KERNEL_IBT + help + Fail the build when objtool produces warnings on vmlinux. + + By default, objtool just prints warnings to the terminal without + causing a build failure. This config changes that for vmlinux. + config VMLINUX_MAP bool "Generate vmlinux.map file when linking" depends on EXPERT diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 0b6e2ebf60dc1bb69d9651d5b7858ccd296e92dd..97b6b262d482e0bac1a4d74f9a2= e7b1867b6ee00 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -39,6 +39,7 @@ vmlinux-objtool-args-$(delay-objtool) +=3D $(objtool-ar= gs-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) +=3D --no-unreachable vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_S= RSO)), --unret) +vmlinux-objtool-args-$(CONFIG_VMLINUX_OBJTOOL_STRICT) +=3D --fail-on-warn =20 objtool-args =3D $(vmlinux-objtool-args-y) --link =20 --=20 2.47.1.613.gc27f4b7a9f-goog