Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1404009rwl; Wed, 12 Apr 2023 12:16:20 -0700 (PDT) X-Google-Smtp-Source: AKy350b4Su0y9G0pDHt7A7zUx3+5UR7SbFDqx2UcVo1zZBcu7qr5KIAEc2ELuOMX3szkq8z2IJ79 X-Received: by 2002:a17:902:d0d4:b0:1a5:2b9b:67f7 with SMTP id n20-20020a170902d0d400b001a52b9b67f7mr3114042pln.46.1681326979798; Wed, 12 Apr 2023 12:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681326979; cv=none; d=google.com; s=arc-20160816; b=DPr6jPZVhEVGqsBvzjMAmAZ3nVjWmsn0vFL3mbBf7xWmV70Awiu4uBRLZqmVq/PgUP MgpwXzDmkqpUq0Wx8u3RHFmMeDqlcrANJ6XLYM2oCPw3OlIesO39HQF7TFyizo6pJ+Ne DSuys/cjy1ApRUZEzlfdDa4dyPHZUh/pYzCA6qV0Xz0mqRUD3jyMTnuRZZwXyyDUhufw x8Effu/cYj4j6o8131wq4SVc3BSuR1P6/eJIkkw6Os4G1RXyVw87/3wbwVGCAIopU8D2 F7/b2ZVS48WRoYXQAL36OfAsuJ6iJ6NB1d4oj9xnu2gmNaDR81ljMoW84WHwJI8sgrbX HUlQ== 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=G0gSiAK9snB1UybVtdSz/1ts4LhS3+3pgXIONcTdHao=; b=bMBOkEGZUJ/HoEJ//DvY4uWRvYa05ohu3jqsXxgrZMIvtsUeRwdJr72OL4FIENLPPP GWp+HLb1CEgRqhw8fA9SxxHiehK3XxVnbLnI1uONxBCjgEJmt4brfweW9wMqJfTHS5SP PMqKs4xhX3naLMmPqNJVOkvGQlCEbAIOJnmzvlfWOuws+B6HnguiQnWTSXPMAtIyXTKy 0a5/fRKiw/S3HS6rFArdsz08K16JXmU+C37Gb0JgV9NjZH8Uvtd9FYwGg6N5xJTPp//A +NWnXnmJhHtXRE3tL0ils/QtVlsJtHkR1QKG+W9A6MKYnGSu90+0LhOXZthiIN5ZMvYx dgOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TGnrh85+; 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 z5-20020a170903018500b001a20c983d21si18965207plg.51.2023.04.12.12.16.05; Wed, 12 Apr 2023 12:16:19 -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=TGnrh85+; 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 S230370AbjDLTEP (ORCPT + 99 others); Wed, 12 Apr 2023 15:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbjDLTDu (ORCPT ); Wed, 12 Apr 2023 15:03:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7F646B9 for ; Wed, 12 Apr 2023 12:03:49 -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 140EA6387D for ; Wed, 12 Apr 2023 19:03:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F03DC4339B; Wed, 12 Apr 2023 19:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681326228; bh=h9r8KJRiCpRGToEG6UzamCIqwFgA/cCcBPojuYwWHP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TGnrh85+l03ixoIvN+Boa5Wsmn1a2TRrdjOGzj9r1U9roeakZMS3e49+rtkhk8d0S W98FJK8H4zyqtSbS4F8UMeq8rO5A8pPOD+QZX/4VCSONkjab6sUPh04OB2hkBuVJjD F6wUHNNQtG6I1ip+cOQMZwiA5Kb+sdsGeNMQ+wRxiSC6mCVxltBaIRlA3c7WmYuq7m KFNqT6cZgPcDpwp7+epsiajuithymXLOa/1eujZFaqu8zqPNjnXUKoM6GACX+HCXZP IhoLQGnFVilG9RmYQ6RoVhcyT7IXDx17q4WWJVUimXZkd8XqlxPzaiI3EpjF/epPAD gqZDpC/Ct7vog== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes Subject: [PATCH v2 9/9] objtool: Ignore exc_double_fault() __noreturn warnings Date: Wed, 12 Apr 2023 12:03:24 -0700 Message-Id: <683214828d8b2ad732dab1a74e858087519d8c8b.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 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 60f2d649f19f..7641e818db7d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4483,6 +4483,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); + + /* + * 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. + * + * Other potential ways to fix it: + * + * - 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 + * - have compiler communicate __noreturn functions somehow + */ + 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; @@ -4499,7 +4528,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