Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1398729rwl; Wed, 12 Apr 2023 12:11:19 -0700 (PDT) X-Google-Smtp-Source: AKy350ZiHNDwRfM81m9Hca1cABsOaBEJP4AMGF0/doPYnZmTim7hyNnQ1vVMyFY2LqGVBgxv8dUF X-Received: by 2002:a05:6a20:1dd:b0:ec:26cf:fb86 with SMTP id 29-20020a056a2001dd00b000ec26cffb86mr199436pzz.21.1681326679443; Wed, 12 Apr 2023 12:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681326679; cv=none; d=google.com; s=arc-20160816; b=M+g6cnRYoEOt/r6NSnLO4vza0o+kVfGImMSF6Qn/BxkHXO81vYXbrLMlWvEFqRtIWv yrrjxEjIHouwVNSsnkpMj9vzUy9M5l78zsmU8hcAhDipf0uhWFVFgqgEdCxzKrUMqk2m P4lFSY7CT5ykS0/tH8KjVkitP+9oEeEdkruHP7H3xStTks+kvwN9r7yedPOKNFYpFBuN n1DylanXy0kq7XFuCc64mdb1cR4JYBf0H+JUeck8iVwHLgAEQYgnJ6R3HHi1qmi5KCbs zrvo9FrKlw2NFZqLd/WqY0YiWmRHCIsMLWZ2lQsbyDhmHeKNnM+K858Dc3iiazhhTLfK h4og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k/SHGCZ5QfgNIedwRUZCV0fpgow+nDheJaJwZ/wSJh4=; b=yBgZl2ICyJ/W+t9ODGKdYXHVOjSU9VTftIdU2m5DnTxCQVjmK5egG+5FtXjdAhGvua SGrrHNMKluuGMI6tZUraPafrM92uzXX7TJV7fM0ArLmVKmm6q4UttDc7u2QnsCS0OqQj kg36c1Yxu4rB9xC6TbQiAP9H98OWOW+MN1JYwUnAIirc/DyoeK7FiGGAE4DQDitK2rra InmWsyGIku0Ew7+np8RYuM36IjW2CkAUHCl9QQEoVXtfV0i/DGLXqHykf8PS064yBU6V cfPPQPZAZTdsFTSiDADCFiE/GWzNQs41VX9OoJc3XQH5Pqwzl8Yct9F12uBgD1v9+qoR uIlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QWt5t1kV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f186-20020a6251c3000000b005941ff7940dsi16703972pfb.203.2023.04.12.12.11.04; Wed, 12 Apr 2023 12:11:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QWt5t1kV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjDLTDx (ORCPT + 99 others); Wed, 12 Apr 2023 15:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjDLTDs (ORCPT ); Wed, 12 Apr 2023 15:03:48 -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 7693830C8 for ; Wed, 12 Apr 2023 12:03:47 -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 100566386B for ; Wed, 12 Apr 2023 19:03:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44606C433D2; Wed, 12 Apr 2023 19:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681326226; bh=os7uY3nMTCWb+jG1PKMR9S3yUK1VjSJJlj7joM5hI9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QWt5t1kVr9C1RDqVU4+9Zo/cjruM2zWe+BLhm+LRCAl1RaCMobV8Gu2Mdwx6cvPcI w1xXBL0pHHtKfsI+8jpBAa5bdj3/ibHeDsx2ZAOGY7RGwZ5vk3LHm6nAWoDfydjvQZ 2Y9zerupDngDJFU2DsoSt6FxRvqq8l+6veIWlRtFHWr644unF8dlcgeuoLwN4mzeTL pV+DDprL7Vu2f6S7jXTdKbqbM9qBFCQh/Krf3Rm2F0qW5jFXVUmdA9jKaz0g63Yld6 HjeK8y+C5X3zDC7yXvlXLWNqJzCXjBlzn2/L/tO5JIL+7WHxSNvTiAgb/x8W3Hg4uX kRceCXII2Gqvw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes Subject: [PATCH v2 3/9] objtool: Limit unreachable warnings to once per function Date: Wed, 12 Apr 2023 12:03:18 -0700 Message-Id: <81ed0b8e5218ac6ecae49af901bf5e0fb3687cef.1681325924.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e85440db7a5f..de0d0234527d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4509,6 +4509,7 @@ static int validate_sls(struct objtool_file *file) static int validate_reachable_instructions(struct objtool_file *file) { struct instruction *insn; + int warnings = 0; if (file->ignore_unreachables) return 0; @@ -4518,10 +4519,10 @@ static int validate_reachable_instructions(struct objtool_file *file) continue; WARN_INSN(insn, "unreachable instruction"); - return 1; + warnings++; } - return 0; + return warnings; } int check(struct objtool_file *file) diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index ad0024da262b..a668173a5869 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/objtool/warn.h index b1c920dc9516..4ef9b278e5fd 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -55,7 +55,10 @@ static inline char *offstr(struct section *sec, unsigned long offset) #define WARN_INSN(insn, format, ...) \ ({ \ - WARN_FUNC(format, insn->sec, insn->offset, ##__VA_ARGS__); \ + if (!insn->sym || !insn->sym->warned) \ + WARN_FUNC(format, insn->sec, insn->offset, ##__VA_ARGS__);\ + if (insn->sym) \ + insn->sym->warned = 1; \ }) #define BT_FUNC(format, insn, ...) \ -- 2.39.2