From nobody Mon Jun 22 23:59:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFF62C433F5 for ; Tue, 15 Mar 2022 10:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244577AbiCOKpj (ORCPT ); Tue, 15 Mar 2022 06:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347253AbiCOKpF (ORCPT ); Tue, 15 Mar 2022 06:45:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08AD132995; Tue, 15 Mar 2022 03:43:49 -0700 (PDT) Date: Tue, 15 Mar 2022 10:43:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1647341027; 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=1mmzYc9b/LcoRKMAbTkvhuOjQ0e1B3LxaHEakfD1YVg=; b=a3oUOXnvpJTPH/Dd2T+NET0ErmydrbwryYczjxzqK+ROe4ENaHCqVYhLB7Tv5TOUTfZYx+ 3eDprlfLg85giMN5CJLiS2nEVurduwblMK6lamf5I3pGJ0AiqM4OCx0Jai0wArFQsUqiTc G5SHcrvEZwYg+DpshSTN0B4igs6w479feRhr9weHtC+BHw7b5lqXluZT0kwwowBIfcE1Fj um+Nj7gugzCeIigAEM8bPx87lhheksiaLdfMBt+IOY4fjEWat/LhNjvCoqOIqNJTXQFURw IU3ulkspzVfsre300I/maD5fIhcVbqs7zCPctCUNb/mq3N8A6zh5gA1M7pzE6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1647341027; 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=1mmzYc9b/LcoRKMAbTkvhuOjQ0e1B3LxaHEakfD1YVg=; b=kWk4yep0bXJqZltZOXgYAaxCXrEP+uuoSYv1UTxs4VTEslmlZJe1UXAKuVmfWfYqWmmAUl wIwvltU+0HmJnhDg== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] objtool: Rework ASM_REACHABLE Cc: "Peter Zijlstra (Intel)" , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220308154319.410010807@infradead.org> References: <20220308154319.410010807@infradead.org> MIME-Version: 1.0 Message-ID: <164734102649.16921.17671353163928907701.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/core branch of tip: Commit-ID: 0e5b613b4d4be3345dda349fb90dd73d2103302f Gitweb: https://git.kernel.org/tip/0e5b613b4d4be3345dda349fb90dd73d2= 103302f Author: Peter Zijlstra AuthorDate: Tue, 08 Mar 2022 16:30:49 +01:00 Committer: Peter Zijlstra CommitterDate: Tue, 15 Mar 2022 10:32:44 +01:00 objtool: Rework ASM_REACHABLE Currently ASM_REACHABLE only works for UD2 instructions; reorder things to also allow over-riding dead_end_function(). To that end: - Mark INSN_BUG instructions in decode_instructions(), this saves having to iterate all instructions yet again. - Have add_call_destinations() set insn->dead_end for dead_end_function() calls. - Move add_dead_ends() *after* add_call_destinations() such that ASM_REACHABLE can clear the ->dead_end mark. - have validate_branch() only check ->dead_end. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20220308154319.410010807@infradead.org --- tools/objtool/check.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 0c857e7..894c9a7 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -395,6 +395,14 @@ static int decode_instructions(struct objtool_file *fi= le) if (ret) goto err; =20 + /* + * By default, "ud2" is a dead end unless otherwise + * annotated, because GCC 7 inserts it for certain + * divide-by-zero cases. + */ + if (insn->type =3D=3D INSN_BUG) + insn->dead_end =3D true; + hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offse= t)); list_add_tail(&insn->list, &file->insn_list); nr_insns++; @@ -524,14 +532,6 @@ static int add_dead_ends(struct objtool_file *file) struct instruction *insn; =20 /* - * By default, "ud2" is a dead end unless otherwise annotated, because - * GCC 7 inserts it for certain divide-by-zero cases. - */ - for_each_insn(file, insn) - if (insn->type =3D=3D INSN_BUG) - insn->dead_end =3D true; - - /* * Check for manually annotated dead ends. */ sec =3D find_section_by_name(file->elf, ".rela.discard.unreachable"); @@ -1114,6 +1114,9 @@ static void annotate_call_site(struct objtool_file *f= ile, list_add_tail(&insn->call_node, &file->mcount_loc_list); return; } + + if (!sibling && dead_end_function(file, sym)) + insn->dead_end =3D true; } =20 static void add_call_dest(struct objtool_file *file, struct instruction *i= nsn, @@ -2089,10 +2092,6 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; =20 - ret =3D add_dead_ends(file); - if (ret) - return ret; - add_ignores(file); add_uaccess_safe(file); =20 @@ -2131,6 +2130,14 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; =20 + /* + * Must be after add_call_destinations() such that it can override + * dead_end_function() marks. + */ + ret =3D add_dead_ends(file); + if (ret) + return ret; + ret =3D add_jump_table_alts(file); if (ret) return ret; @@ -3138,7 +3145,7 @@ static int validate_branch(struct objtool_file *file,= struct symbol *func, return 1; } =20 - if (dead_end_function(file, insn->call_dest)) + if (insn->dead_end) return 0; =20 break;