From nobody Wed Dec 17 16:54:37 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB903C77B75 for ; Tue, 18 Apr 2023 21:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232838AbjDRV2R (ORCPT ); Tue, 18 Apr 2023 17:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232707AbjDRV2N (ORCPT ); Tue, 18 Apr 2023 17:28:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83E0AD3D for ; Tue, 18 Apr 2023 14:28:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 551FC63951 for ; Tue, 18 Apr 2023 21:28:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80055C4339E; Tue, 18 Apr 2023 21:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681853279; bh=QLb9CZEh4jbifWcfcjQ/raJsyLVWkp1Ug+utfGGdmOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AAFVT7Th4uWYQ5gVAbR35YJeC/EuGSNAl/6RaCsICHji5Ezk2jCGofZBnr4atJJpy UOompHmTAw/0dhGQ9f6EdBAstltpwdxCpBvvuBQLchl4MbBH6FnZHGX0Te6SzUBEW7 qNL/MXS66dNDLAX0L8Vzd4Xl7qvwfMKolvby59iGOvnyWuHwMtD3fNGN2J2AnoAHAC Jo7PRS/UJkvi59h3ZV1yedBmCN9m00imhM6P76KbnrUyfSY2ykwdbffmvGhBXYnvK7 3rAoqOZAMxAYP++eGZNZpEApbXxOsspLX3MBqWyxoVXeh5SCCN0wKco4CcvMcI/uBB L1uti4KL0mHgA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , Nick Desaulniers Subject: [PATCH v3 1/8] objtool: Limit unreachable warnings to once per function Date: Tue, 18 Apr 2023 14:27:47 -0700 Message-Id: <9d38f881bfc34e031c74e4e90064ccb3e49f599a.1681853186.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Unreachable instruction warnings are limited to once per object file. That no longer makes sense for vmlinux validation, which might have more unreachable instructions lurking in other places. Change it to once per function. Note this affects some other (much rarer) non-fatal warnings as well. In general I think one-warning-per-function makes sense, as related warnings can accumulate quickly and we want to eventually get back to failing the build with -Werror anyway. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 5 +++-- tools/objtool/include/objtool/elf.h | 1 + tools/objtool/include/objtool/warn.h | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 5b600bbf2389..a00931342c7e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4514,6 +4514,7 @@ static int validate_sls(struct objtool_file *file) static int validate_reachable_instructions(struct objtool_file *file) { struct instruction *insn; + int warnings =3D 0; =20 if (file->ignore_unreachables) return 0; @@ -4523,10 +4524,10 @@ static int validate_reachable_instructions(struct o= bjtool_file *file) continue; =20 WARN_INSN(insn, "unreachable instruction"); - return 1; + warnings++; } =20 - return 0; + return warnings; } =20 int check(struct objtool_file *file) diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index e1ca588eb69d..78e2d0fc21ca 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -61,6 +61,7 @@ struct symbol { u8 return_thunk : 1; u8 fentry : 1; u8 profiling_func : 1; + u8 warned : 1; struct list_head pv_target; struct list_head reloc_list; }; diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/o= bjtool/warn.h index b1c920dc9516..f195deab456e 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -55,7 +55,12 @@ static inline char *offstr(struct section *sec, unsigned= long offset) =20 #define WARN_INSN(insn, format, ...) \ ({ \ - WARN_FUNC(format, insn->sec, insn->offset, ##__VA_ARGS__); \ + struct instruction *_insn =3D (insn); \ + if (!_insn->sym || !_insn->sym->warned) \ + WARN_FUNC(format, _insn->sec, _insn->offset, \ + ##__VA_ARGS__); \ + if (_insn->sym) \ + _insn->sym->warned =3D 1; \ }) =20 #define BT_FUNC(format, insn, ...) \ --=20 2.39.2