From patchwork Thu May 18 11:08:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 95800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp416521vqo; Thu, 18 May 2023 04:28:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CDkeAmAuo/VkMPIJZmbaSdNzc9XsTNXqYMmUfLm+MUK22JvLbzVTBr7m1RAVXoEAj/KBL X-Received: by 2002:a05:6a00:1346:b0:643:6b94:374b with SMTP id k6-20020a056a00134600b006436b94374bmr4411303pfu.1.1684409320923; Thu, 18 May 2023 04:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684409320; cv=none; d=google.com; s=arc-20160816; b=B0HX9aAOpGhAs8p4/0H1NbXcb8KiXy285LIruoacGbuWBmrlkUyJAOc/2H1HbDp3zY U/f8+qJGhj8dQVb1Lj/7JethzBYMf6G/jio9oUIigRG4Y2xdSu5XJFHtwAUaZ2MG8bsr W1cqa0hGn9JOWN1RDSQaooONXud7Nm0kzoLOlu7ZzLmp5mDM7VOlxBonc31cAHytYoud xxFSMD/kWkmIYjrFf9WdQujFXMDlB8It9IW6K5MWcKcamGa1892Sx4hP1AHX3XFwfV0P SlhqTm5QNxujSwChC5N5ulMD6MPrbaHjXakxj9SHNhKmcNP+eCmPy56+8VCCcJ7qu3/e ek+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=QOLKbqZ+WEyAA/7wcsnVMTanilWInv/gKVP1qd2MJ1c=; b=Ld9P40x0yEaeBqKrLvyjw2i0hg6uy9HPpHUwJy8GKyqDROcG0RgbmLfgoqEexVYSY2 FKPQYwEacU0cKvH40VD6OAmY+pXVMc1CXiyR5OJTXVTNXWyPZVOg3d7sSiuDqBzLS63e 7NCOa+9Ej7ddZQlGMEa7dpHjMRBxH/re/c87dkz2oaRNALW2MtEn82z24G6HqipF25+V U3sOMCvJ1kgUmyPDaL2m4qIWMsyK+CQbxd97FzzpdG7qTVD7d8tBV56UrPq4Vy1MoA2s hjgIhRz5e+MW8BbEQ54I0DF5BW0LtS9/eVgAujA7Qhu/oR/rTVDjTqBi550P5ZUGH2KA Jw2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sXqCLz91; dkim=neutral (no key) header.i=@linutronix.de header.b=K+dWE8F0; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a056a00009100b0063b7790fde1si1399112pfj.284.2023.05.18.04.28.29; Thu, 18 May 2023 04:28:40 -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=@linutronix.de header.s=2020 header.b=sXqCLz91; dkim=neutral (no key) header.i=@linutronix.de header.b=K+dWE8F0; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbjERLIh (ORCPT + 99 others); Thu, 18 May 2023 07:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbjERLIa (ORCPT ); Thu, 18 May 2023 07:08:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1381F10EA; Thu, 18 May 2023 04:08:05 -0700 (PDT) Date: Thu, 18 May 2023 11:08:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684408082; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QOLKbqZ+WEyAA/7wcsnVMTanilWInv/gKVP1qd2MJ1c=; b=sXqCLz91X7I8seLlwJprPcBJXo+uwFO2ng5l6DsvF+DiZq9nMJIb20zqV+NI2DGhbdmH2D bpNoxhCPam01WzuviiS6oEUoHdv/YP2AfKHyRSnV1YFGI3DtwxYziRJL16r73dpYuKEeVN Oz2vSlmVnTX496tPz4k0YV/bd1DZWFC6sXG+GWC+fn62CgrCyhXrLti2FjTSXla9clQ+Bs jh/qtYh2OqIeIISnWYQOUQNRRBIFSkiX7YYlD35kfPp4/qz0dt63DgEax5/MO11p3re/qT tgoSaOJO70OThmgxw5wMLNQO2VGremDipRw3+kFMzdIAo1jQZWGpTy2dsgAr3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684408082; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QOLKbqZ+WEyAA/7wcsnVMTanilWInv/gKVP1qd2MJ1c=; b=K+dWE8F0qSlzUzYPx9hMdFGPgFcYhNMIiQSLbwEqNVIiLgkjQSQLSvmCz+Th2HZZSVsBHP dSa7SSUzcPG5VaDA== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Detect missing __noreturn annotations Cc: Miroslav Benes , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <6e2b93d8c65eaed6c4166a358269dc0ef01f890c.1681853186.git.jpoimboe@kernel.org> References: <6e2b93d8c65eaed6c4166a358269dc0ef01f890c.1681853186.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <168440808219.404.11188702829106131273.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763552073473429247?= X-GMAIL-MSGID: =?utf-8?q?1766231187678256381?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: fedb724c3db5490234ddde0103811c28c2fedae0 Gitweb: https://git.kernel.org/tip/fedb724c3db5490234ddde0103811c28c2fedae0 Author: Josh Poimboeuf AuthorDate: Tue, 18 Apr 2023 14:27:50 -07:00 Committer: Josh Poimboeuf CommitterDate: Tue, 16 May 2023 06:31:53 -07:00 objtool: Detect missing __noreturn annotations Most "unreachable instruction" warnings these days seem to actually be the result of a missing __noreturn annotation. Add an explicit check for that. Reviewed-by: Miroslav Benes Link: https://lore.kernel.org/r/6e2b93d8c65eaed6c4166a358269dc0ef01f890c.1681853186.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 6 ++++++ tools/objtool/check.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt index 9ec8cbf..f9345e0 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -303,6 +303,12 @@ the objtool maintainers. If it's not actually in a callable function (e.g. kernel entry code), change ENDPROC to END. +3. file.o: warning: objtool: foo+0x48c: bar() is missing a __noreturn annotation + + The call from foo() to bar() doesn't return, but bar() is missing the + __noreturn annotation. NOTE: In addition to adding the __noreturn + annotation, the function name also needs to be added to + 'global_noreturns' in tools/objtool/check.c. 4. file.o: warning: objtool: func(): can't find starting instruction or diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 71985f3..8d1b422 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4507,7 +4507,8 @@ static int validate_sls(struct objtool_file *file) static int validate_reachable_instructions(struct objtool_file *file) { - struct instruction *insn; + struct instruction *insn, *prev_insn; + struct symbol *call_dest; int warnings = 0; if (file->ignore_unreachables) @@ -4517,6 +4518,17 @@ static int validate_reachable_instructions(struct objtool_file *file) if (insn->visited || ignore_unreachable_insn(file, insn)) continue; + prev_insn = prev_insn_same_sec(file, insn); + if (prev_insn && prev_insn->dead_end) { + call_dest = insn_call_dest(prev_insn); + if (call_dest) { + WARN_INSN(insn, "%s() is missing a __noreturn annotation", + call_dest->name); + warnings++; + continue; + } + } + WARN_INSN(insn, "unreachable instruction"); warnings++; }