From mboxrd@z Thu Jan 1 00:00:00 1970 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 9DE68C433FE for ; Mon, 22 Nov 2021 17:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240088AbhKVRR3 (ORCPT ); Mon, 22 Nov 2021 12:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240069AbhKVRRY (ORCPT ); Mon, 22 Nov 2021 12:17:24 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A0A4C061574 for ; Mon, 22 Nov 2021 09:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=MGsUQZoscnAFq5RhWJPllZ3KY3Zlemip4v9jXuHkL+U=; b=mOJhYDGnOd8Ywz3LHyKFe5tcol YdQ90z3LD5HOtfJD+sZvYwfENdxHw/WPOUCa25OwZwYoLhQtJvKcrus2lsqX5qEkcHUfHWuIQ8T6m 3STCk9wnOeDEDvfKa5TimV3eWOZi8tjEBxsdecn0Ah5/QoDb+nlD4ceEdEAyJyZh0+hft8bdg/Nym xOn8VZ8zt70BMfasQWU0kTbylNqVSc5S/rxWRWb6F8AXz/oKUpDGgO0+kG32jpecMObfG3rODo35z uiPsA4HGkTR5Q0OKYGuVLm/wMKvBqNkuH4hCkJ3urmQMfN/LpF0niH4uXgTuo3FwxRCrILBNLuYZG EZJN5APw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpCtF-00HWQM-ST; Mon, 22 Nov 2021 17:14:02 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1606F300728; Mon, 22 Nov 2021 18:13:59 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 011322C277ADA; Mon, 22 Nov 2021 18:13:58 +0100 (CET) Message-ID: <20211122170805.211049036@infradead.org> User-Agent: quilt/0.66 Date: Mon, 22 Nov 2021 18:03:05 +0100 From: Peter Zijlstra To: x86@kernel.org, joao@overdrivepizza.com, hjl.tools@gmail.com, jpoimboe@redhat.com, andrew.cooper3@citrix.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, ndesaulniers@google.com, keescook@chromium.org, samitolvanen@google.com Subject: [RFC][PATCH 4/6] objtool: Read the _THIS_IP_ hints References: <20211122170301.764232470@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Read the new _THIS_IP_ annotation. While there, attempt to not bloat struct instruction. Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 27 +++++++++++++++++++++++++++ tools/objtool/include/objtool/check.h | 13 ++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1854,6 +1854,29 @@ static int read_unwind_hints(struct objt return 0; } +static int read_this_ip_hints(struct objtool_file *file) +{ + struct section *sec; + struct instruction *insn; + struct reloc *reloc; + + sec = find_section_by_name(file->elf, ".rela.discard.this_ip"); + if (!sec) + return 0; + + list_for_each_entry(reloc, &sec->reloc_list, list) { + insn = find_insn(file, reloc->sym->sec, reloc->sym->offset + reloc->addend); + if (!insn) { + WARN("bad .discard.this_ip entry"); + return -1; + } + + insn->this_ip = 1; + } + + return 0; +} + static int read_retpoline_hints(struct objtool_file *file) { struct section *sec; @@ -2066,6 +2089,10 @@ static int decode_sections(struct objtoo if (ret) return ret; + ret = read_this_ip_hints(file); + if (ret) + return ret; + /* * Must be before add_{jump_call}_destination. */ --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -45,11 +45,18 @@ struct instruction { unsigned int len; enum insn_type type; unsigned long immediate; - bool dead_end, ignore, ignore_alts; - bool hint; - bool retpoline_safe; + + u8 dead_end : 1, + ignore : 1, + ignore_alts : 1, + hint : 1, + retpoline_safe : 1, + this_ip : 1; + /* 2 bit hole */ s8 instr; u8 visited; + /* u8 hole */ + struct alt_group *alt_group; struct symbol *call_dest; struct instruction *jump_dest;