Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5977263rwe; Tue, 18 Apr 2023 14:45:34 -0700 (PDT) X-Google-Smtp-Source: AKy350YgM5TNTBzPtA2B6cbklixOtjolHXWmBXP4z75rQycqTkxFDm7oPjQMC36KxevnE3zhJrF/ X-Received: by 2002:a05:6a20:748f:b0:ef:c5b6:b6a8 with SMTP id p15-20020a056a20748f00b000efc5b6b6a8mr923270pzd.45.1681854334693; Tue, 18 Apr 2023 14:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681854334; cv=none; d=google.com; s=arc-20160816; b=s94z3k4nlZH4hoyMP5tygi/+bmKSUagx5GYZofHrJGbv8+v689xbdjlA23f1IdHkeH 1mWYJ/CR29hgMgoDbmR4FKft1DuKKmQUCUT0ADrVcMYazp1QoG6R0QBAUXDQZqkD7Fku xV8ON4470hqJe/0pR/vlGPD/sjF5BmxyFJvskASlfzH5y3yu5PP0koqdR6yB8iUzTtTx mywAG/NXFGU8IFllFNSAF3RkybOh/AyyxiS0Vpcy9T85wtpOW/FRLiWWT3RmSDI81w6M BskVNYP3D087965oCrG+GDbuWXN855712eDkAidKQDyhqAFsdSnrRBEj9Yb9yXAjNOyu gmdw== 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=Oc08TwWTUhbnv+KmwT6H/lJOv3XnybKdFYOva+u687k=; b=xBoziNJ11ftJF0c4JwQWgjR3is4A9gr3L0k6Adst7zRYJD3GJ27tVUqpo5IHgojbzX mMZiVtx9gqyGnDexEf+CF4yOuctYbfK234twQ5ROeqwKpSGBs5Ype8dzN+/WKGIakVVS dBO/hm9KTQpmDYeSHt1QMaacTcydAQnLwGZzTjqPYwpUUeS6YtlctJmozrQe0IQjjlnY FbRr0t60N8mDhl92smPsqdtXN8UbWe35VHYLeQ2qzRXhaX3CDpYhNxqURUYYZgQjDgUE ajhxiTBVPNM2/rpqZfIppM4Pv3qI3VkyFWP4siPeB8/fQgoR5dT0hUU8PJAK9p02FMtz IEHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RwW7odxe; 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 h131-20020a636c89000000b00518ebc6f91fsi14178030pgc.851.2023.04.18.14.45.20; Tue, 18 Apr 2023 14:45:34 -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=RwW7odxe; 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 S232993AbjDRV2m (ORCPT + 99 others); Tue, 18 Apr 2023 17:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232997AbjDRV2e (ORCPT ); Tue, 18 Apr 2023 17:28:34 -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 278F31026E for ; Tue, 18 Apr 2023 14:28:12 -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 B6D6D612AE for ; Tue, 18 Apr 2023 21:28:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE361C4339B; 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=1681853281; bh=ij85bIvlI0ug5hahPrm5CUQ/Uj6pydt9FfFsLuqiE1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RwW7odxeNgHigkMNNMw1f88aayUFzwCqtCcmWcCvr+ZBqnoaEexntOjXcgZD2PLf8 VWilc8PbrS+97sWQ5yTo1qLWnrcjD3AKumLAPGjRsydINKg01qS5oUyqjxJiuTPLYN XMKEPDsMDzZTLXtgmKHfktMroK7xaAtrSOuBEYwUTkDVRhu5ln+OfoeGoCe94YIzVq ycgik4QUrMA6gXCr/X/8UvIQrw25D4gYdd1uThwXmtl+iNXz1j9VJ9dg7Mjj8yDIoi Xozdhxx3k2/QJqQS+tgYJUqEiR6LJdHueN3e0ZV5KlyYIVpvyzjbiVgzfFmkm+K33H pqKiNjWgQgZNQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , Nick Desaulniers Subject: [PATCH v3 5/8] objtool: Ignore exc_double_fault() __noreturn warnings Date: Tue, 18 Apr 2023 14:27:51 -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 This is a hack, but it works for now. Problem is, exc_double_fault() may or may not return, depending on whether CONFIG_X86_ESPFIX64 is set. But objtool has no visibility to the kernel config. "Fix" it by silencing the exc_double_fault() __noreturn warning. This removes the following warning: vmlinux.o: warning: objtool: xenpv_exc_double_fault+0xd: exc_double_fault() is missing a __noreturn annotation Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index dd10128ab013..1cace399d32a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4505,6 +4505,35 @@ static int validate_sls(struct objtool_file *file) return warnings; } +static bool ignore_noreturn_call(struct instruction *insn) +{ + struct symbol *call_dest = insn_call_dest(insn); + + /* + * FIXME: hack, we need a real noreturn solution + * + * Problem is, exc_double_fault() may or may not return, depending on + * whether CONFIG_X86_ESPFIX64 is set. But objtool has no visibility + * to the kernel config. + * + * Other potential ways to fix it: + * + * - have compiler communicate __noreturn functions somehow + * - remove CONFIG_X86_ESPFIX64 + * - read the .config file + * - add a cmdline option + * - create a generic objtool annotation format (vs a bunch of custom + * formats) and annotate it + */ + if (!strcmp(call_dest->name, "exc_double_fault")) { + /* prevent further unreachable warnings for the caller */ + insn->sym->warned = 1; + return true; + } + + return false; +} + static int validate_reachable_instructions(struct objtool_file *file) { struct instruction *insn, *prev_insn; @@ -4521,7 +4550,7 @@ static int validate_reachable_instructions(struct objtool_file *file) 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) { + if (call_dest && !ignore_noreturn_call(prev_insn)) { WARN_INSN(insn, "%s() is missing a __noreturn annotation", call_dest->name); warnings++; -- 2.39.2