Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1402462rwl; Wed, 12 Apr 2023 12:14:49 -0700 (PDT) X-Google-Smtp-Source: AKy350ZqhSVwiwZyfN3ZP1i3AzY5eOj8NAozm7NtrNuJmwQ2DVTpiV+lHcMnZbk8auSW93mfPnoP X-Received: by 2002:a17:902:dad1:b0:1a6:4118:6f9e with SMTP id q17-20020a170902dad100b001a641186f9emr4576762plx.20.1681326889563; Wed, 12 Apr 2023 12:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681326889; cv=none; d=google.com; s=arc-20160816; b=ORcBxNMmw0IjlvMZ2zfX2F+8tO4GUJsAd96Mecihj1nmyWfbmQtXMySiM3dV6xoDFx VRVAzJoPPJjiR2NYZkDAMN2M3lsAf5mp0GmcEejjyLvbdvSOdvhBsNCDTjBxk6yKShJA /9eDSro5DehmqwVH4rtD6u+0muY4PVXmGqlYlwxh/2pPJ/fpXlHTxIVfnPrqOwv2wdFN /+yFx3eQ8FiYbv3cNVz078h09WwrbqkUu9FyPONJ4CiOjCoFPN6IM0fxhMKXBdgW5rTY gNWMnOxPyi6nfAwtsSjSjvcJqCsjFK/tpKGP/IeJwn5L7sgupjZoXGDkZ3E+thDRnVMb PTtA== 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=oFXAdgl27wyf6qAINaorVsXnJnV6Gd/J7677AZuXdH4=; b=vS3GT0+Y9kdMy/34oz0gi53DYIYO9HtWDipOEE8CQdQ2Gww2f6SNDH4nGn9lbzgBvQ qhYHrqt9V5DVtf77/ip1K5BJJBupWFGZCT82q/hNJQ9lGWTqJFisDDEpIUaje9vmEBOl 2fuUiONB04TkBfpNnlb5rFXzEge/+K7iVw9ORjaBsgKTdxczIm49OCkq5aRNqEEFmvjW PEU4oM/eSGR++6oFLHdyOzJwjDpTKtOmg6AJ+/z/oEN8zrmQpe4bXKbD02dE2S3qCFnh I5wwoa3dsiPDQsOvogcrW/L1zX5UHRsiwwLmWR1XEkg6P2DT63SDFo0lHNJEHDEXQu3S 4Z7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aStfXEpT; 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 i30-20020a63585e000000b0051393805cd1si16823916pgm.461.2023.04.12.12.14.37; Wed, 12 Apr 2023 12:14:49 -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=aStfXEpT; 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 S229764AbjDLTEF (ORCPT + 99 others); Wed, 12 Apr 2023 15:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjDLTDt (ORCPT ); Wed, 12 Apr 2023 15:03:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96CBE6F for ; Wed, 12 Apr 2023 12:03:48 -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 11EAC6387F for ; Wed, 12 Apr 2023 19:03:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AD80C433EF; Wed, 12 Apr 2023 19:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681326227; bh=ALLHXWLy6y39aAaEiGHQFmrawumL94Hfe6ZlVC/BQUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aStfXEpTrgz7R5gGwQpVWCMa1e/aFwS0LM8H2J0mdNSdYpbXavmcZtOxgVFbFpU8s vLQT4p9dMG2o903/IMeW3fY17wQh51/QR8X4zc512DYPheoP4Wqtar8Ah7KDTJetKS rqv2mdZJV3/PfYwz2anB86tac0IFJzJZAvgBX6QfpZK+43o/yOe2oIwGtArCUgcYdX jgAgQhD1Lub4/h32jSgH+q6JPUr+KVy8gnFYY/VMPuYYQPSZDZUXnA9hzXqEMKIadw NhMT7HmI7X84gsO9hiuIcRTvn1NAcOFfRqGqsENcQP3Qor9n5rdeJiujmGh3xeqvWC 6h4subfi9ayvw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes Subject: [PATCH v2 6/9] objtool: Include backtrace in verbose mode Date: Wed, 12 Apr 2023 12:03:21 -0700 Message-Id: <6a11522b7d2fdb713ec80a89fe8cb199ddb511b6.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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 bc9dd69c9a45..b9e5e0e9c1ee 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3654,8 +3654,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; } } @@ -3700,8 +3699,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; } } @@ -3799,8 +3797,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; } @@ -3858,8 +3856,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; } } @@ -3885,10 +3882,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; } @@ -3910,8 +3905,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; } /* @@ -4195,8 +4189,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 4ef9b278e5fd..856ea8bc10d7 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -61,12 +61,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