From patchwork Wed Apr 12 19:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 82640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp548232vqo; Wed, 12 Apr 2023 12:11:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YdC75jofKLNJVMbFL7dETJd0pP5t1HpOjzHaawuNue9M1AqmsmG+VjLiLn31g7m7+JsgAv X-Received: by 2002:a05:6a20:b706:b0:d9:f6ee:3b8f with SMTP id fg6-20020a056a20b70600b000d9f6ee3b8fmr3479801pzb.17.1681326715786; Wed, 12 Apr 2023 12:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681326715; cv=none; d=google.com; s=arc-20160816; b=xAZsgdZfezOyJZf1Ui76msREq49Fe2avvAPODjXyTGFuYzPY2SSgsGyLNekfDXXM57 KQQZMy9ajCPCdncY1C4Veqz1+NHARQzoUJCsBHxX5wQsVaShzoR/ts/q7ZJVtNb6c42D k7LF+TppmmT94HMQQkUel6+OZb1jBPR3toH9CGJckq/rDdfXuWld6jKSUcFdZJBg55C0 fd52N+kytH/Uzxa0qV3i00Lectdc0c3Z8jEvlIyIweS7x1zFpCXHj9KbLr281tHajsCa OApT8TjPNPQsW5mMSl1kS1XF/fK7qMyavoeUHd0FctPFt/7cUmJm8hWJRwuqWMiD9giE E0Uw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i71-20020a63874a000000b0051972e42719si9590160pge.66.2023.04.12.12.11.42; Wed, 12 Apr 2023 12:11:55 -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 S229974AbjDLTDx (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762998842233519191?= X-GMAIL-MSGID: =?utf-8?q?1762998842233519191?= 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, ...) \