Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5962777rwe; Tue, 18 Apr 2023 14:29:04 -0700 (PDT) X-Google-Smtp-Source: AKy350bFoMCUdzppoHdLEPE2I5hBsKIptVacglyZTLzy2xO9a2vwR7eNu5wnlcpIJ42jw12JTE5V X-Received: by 2002:a17:903:643:b0:19c:d309:4612 with SMTP id kh3-20020a170903064300b0019cd3094612mr3284851plb.6.1681853343834; Tue, 18 Apr 2023 14:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681853343; cv=none; d=google.com; s=arc-20160816; b=gCITVfHSj0ZyVROq0iOG0GIiAGxQGlcMQ2uuHVpfAd6VD4LBqnd9auM+stEIXHPBCz gMomVCwLV2J0k11YCzAcORBq/W+LtILk6jknBphJu++GMM8ALQ9Sg055ptqdD2KfjllZ Q2QIoJGEHzrzc9rzHJ4qW0y6L9J6P3ax1ZQhbZnJ0aXmBJsbDhem7MG0brMUgjRXIiCY d1/ls+xNb3kV+kaTbCmk5z/ToFsWXUE5QIKS7eqC4bY8SoZThbNFFRkZQrsGEuMk04lz T7mF+TPqGYS+1Od5f8e0qjFjwJd3tfg6M/6nxOTMOwk7L0spBOU/0k/lFX3mn4A9i9Qh m5NA== 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=elFHmzVjgw1NQzzaCjSeSa5fyM1DnN5RYpYet6adpRw=; b=WbAm186Bu4fqWsnwpRvqU4CnVI+eYycjvuIfEBwZFXvwqpFH0Pg2U/e5YH5iAwu3rf EamdTCGejyoHzercyesNp3i5Fxq+eVYfFc9JWJTLUIDFjWnn5Cf2aflhDpc2wdEiwLZD q4lhZmTfDCw/GUOdlzXE8We5yfSUB5CuTgeJTgJEePVGFzdP6pgt/2QA4LqgyzGF9d27 wkr4DrPwaEkFMzPS3MI78u2Db7zqIpMtUNd+bdWGVz2su5IGV5pPaMJdvE6YAXMUb570 4OHa48qhvlkMv2fOi9niD3qpqBms0cg1DZyp/fcDyYCuyOs9JA/Q6WtN5CxDKD5PTabD OA7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mG5cYVFR; 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 u6-20020a17090282c600b001a4fc13dfa5si14560789plz.276.2023.04.18.14.28.50; Tue, 18 Apr 2023 14:29:03 -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=mG5cYVFR; 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 S232818AbjDRV2Z (ORCPT + 99 others); Tue, 18 Apr 2023 17:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232753AbjDRV2P (ORCPT ); Tue, 18 Apr 2023 17:28:15 -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 91B62BBB1 for ; Tue, 18 Apr 2023 14:28:01 -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 09E606395A for ; Tue, 18 Apr 2023 21:28:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E4AEC433A0; Tue, 18 Apr 2023 21:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681853280; bh=pBU1V3n8RoeNydoWkCOq7gRDOLCsSaGVqI+g1UM+LHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mG5cYVFRVoVveup0sM4ym0gMevTAZG6FJHEsWSU21tEm7ayDCeF9gOXAR0VM8DZjr 5C14MITk1NDLNM/Ax3aI8n6SmbQHnNTz1tpR3JqM/fVwKUB5JEcWwScT9AQ9zO/zY0 V1TwpLTdaU5F9enIOoKlMdTbPwx1rbwpyKYZOWDlCS0imSE3fdi0Dsd401W/kkHwol 0izRQKppbnRm2/maVb9w6Cr3xQ6XBvQctEelTOU8j+IePma+pdIBNa2pHnB7euNPQ4 PWK8kIF7YPEiIyvdoRk7E6utFwNxEuncCeijR6PmxWB9a0R0jyyTsNqY526UEUvwUz 0HAzKEFGPD6WA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , Nick Desaulniers Subject: [PATCH v3 3/8] objtool: Include backtrace in verbose mode Date: Tue, 18 Apr 2023 14:27:49 -0700 Message-Id: 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,T_SCC_BODY_TEXT_LINE 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 Include backtrace in verbose mode. This makes it easy to gather all the information needed for diagnosing objtool warnings. Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 4 ++-- tools/objtool/check.c | 26 ++++++++++--------------- tools/objtool/include/objtool/warn.h | 14 +++++++------ 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt index 4d6c5acde7a3..5a69c207a10e 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -246,8 +246,8 @@ Objtool warnings NOTE: When requesting help with an objtool warning, please recreate with OBJTOOL_VERBOSE=1 (e.g., "make OBJTOOL_VERBOSE=1") and send the full -output, including any disassembly below the warning, to the objtool -maintainers. +output, including any disassembly or backtrace below the warning, to the +objtool maintainers. For asm files, if you're getting an error which doesn't make sense, first make sure that the affected code follows the above rules. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index c63e0867daca..aa083296af1e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3657,8 +3657,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, ret = validate_branch(file, func, alt->insn, state); if (ret) { - if (opts.backtrace) - BT_FUNC("(alt)", insn); + BT_INSN(insn, "(alt)"); return ret; } } @@ -3703,8 +3702,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, ret = validate_branch(file, func, insn->jump_dest, state); if (ret) { - if (opts.backtrace) - BT_FUNC("(branch)", insn); + BT_INSN(insn, "(branch)"); return ret; } } @@ -3802,8 +3800,8 @@ static int validate_unwind_hint(struct objtool_file *file, { if (insn->hint && !insn->visited && !insn->ignore) { int ret = validate_branch(file, insn_func(insn), insn, *state); - if (ret && opts.backtrace) - BT_FUNC("<=== (hint)", insn); + if (ret) + BT_INSN(insn, "<=== (hint)"); return ret; } @@ -3861,8 +3859,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn) ret = validate_unret(file, alt->insn); if (ret) { - if (opts.backtrace) - BT_FUNC("(alt)", insn); + BT_INSN(insn, "(alt)"); return ret; } } @@ -3888,10 +3885,8 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn) } ret = validate_unret(file, insn->jump_dest); if (ret) { - if (opts.backtrace) { - BT_FUNC("(branch%s)", insn, - insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : ""); - } + BT_INSN(insn, "(branch%s)", + insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : ""); return ret; } @@ -3913,8 +3908,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn) ret = validate_unret(file, dest); if (ret) { - if (opts.backtrace) - BT_FUNC("(call)", insn); + BT_INSN(insn, "(call)"); return ret; } /* @@ -4216,8 +4210,8 @@ static int validate_symbol(struct objtool_file *file, struct section *sec, state->uaccess = sym->uaccess_safe; ret = validate_branch(file, insn_func(insn), insn, *state); - if (ret && opts.backtrace) - BT_FUNC("<=== (sym)", insn); + if (ret) + BT_INSN(insn, "<=== (sym)"); return ret; } diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h index f195deab456e..ac04d3fe4dd9 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -63,12 +63,14 @@ static inline char *offstr(struct section *sec, unsigned long offset) _insn->sym->warned = 1; \ }) -#define BT_FUNC(format, insn, ...) \ -({ \ - struct instruction *_insn = (insn); \ - char *_str = offstr(_insn->sec, _insn->offset); \ - WARN(" %s: " format, _str, ##__VA_ARGS__); \ - free(_str); \ +#define BT_INSN(insn, format, ...) \ +({ \ + if (opts.verbose || opts.backtrace) { \ + struct instruction *_insn = (insn); \ + char *_str = offstr(_insn->sec, _insn->offset); \ + WARN(" %s: " format, _str, ##__VA_ARGS__); \ + free(_str); \ + } \ }) #define WARN_ELF(format, ...) \ -- 2.39.2