Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp456249ybz; Wed, 29 Apr 2020 03:23:30 -0700 (PDT) X-Google-Smtp-Source: APiQypI83Q4SjAyv1TWLTiq+TP9mEtzFlu1w2eiDQ/vw+QCNrbHzSfQlp0bDhof2kiM4DzIyE43s X-Received: by 2002:a17:906:3198:: with SMTP id 24mr1783379ejy.39.1588155809867; Wed, 29 Apr 2020 03:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588155809; cv=none; d=google.com; s=arc-20160816; b=tCN/qyFBKU9Az5z5ydlpk0e4JVqOEzFKt3Omzag1tQNnT6ni4q29Z02m9XrPdt+CeG iEfc9apoKt9GySnDkN1Qye4aCHohE4dzypwR6oMTBCkyQQ0KdhdY2BvQI+BwCuNvfXMu HFv+1HsdBPpCEn1/u517RtA4i88imy0eYiLinJjGgDEHYPRkzmH/dyOoYROsOFxG4KsH assPXwHfKInMm7jD+aaSqBeNV5RJthO9Vak+RNynw9Gs38k1QjQZSSHoVBUNERnpDYpH qeemwlhrE3+11wnT6fgL/TbUrjo9vFU721lD6XL3ySqVW+/uTPsUp2/q60MHcdSnf/uE hY8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Z5HLrL3i5i8JIG6fwC9yLl6toRI1qYlpF8k6Gl2JT8Q=; b=CDI7fF5j1cDAMdyLUU5OmNBDx9/7nQ2cpw8UIpsPvOieTsLulzh94vLUPDthRl81SL HtJ1AMtv4CrKs+xxuwY9YTHUKg7Saq8+wvhaGvC9Jyjzfr/MY2Amds4reB/Iem9yOShv j68od/xKIOPt6DYMx6lPQ2Nr+Sx+MUpWK+DDFjSqqDLpkV2ufZEh02pfN+8dk14B1MjB utzXqm4uQsQrjiHz1ir8anw9bCriq4DsL8Tw23v+HvwaogpI0YpfAk+Q46AOAWtmWJk7 T+Du8TaoWYEDiiC5/+Js81C5o/ik/yDogWkYCFiRnBRpNudzOgNIoKYeuDFevRmIMDsM KjiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="X0VPNF/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si3057612edl.93.2020.04.29.03.23.06; Wed, 29 Apr 2020 03:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="X0VPNF/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbgD2KV2 (ORCPT + 99 others); Wed, 29 Apr 2020 06:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgD2KV2 (ORCPT ); Wed, 29 Apr 2020 06:21:28 -0400 Received: from merlin.infradead.org (unknown [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CFB0C03C1AD for ; Wed, 29 Apr 2020 03:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Z5HLrL3i5i8JIG6fwC9yLl6toRI1qYlpF8k6Gl2JT8Q=; b=X0VPNF/W1alR4AoFIzdkm2Xhe/ AZVuh9xdiE7TAQ6nznqpRGpvoK0pQbN0En6ZMYrat/lLF935iI0OepakqNmXX4Bqi3UBh233rvfrj j+vhhvkUZCArKc2r4NMIH3x79JNZ8bn52mi1ofqWHnbA6Z9MlwYY1mrLuWg6cmnV8hw2CJaJcHRMm wArTP8ab7NYRvr/GGQ/2RWtAYYmuPgQ3btjs4Nisdi/qB/V+P6ihqofvo9Qvz22l0vXpaaB3RIpbV 0u/DgQGnmyVfBPA8T5NG/+AXLOSxqYgbnwHWsnNinSC3GQkyWdHRhR2RPmC+T3UyuoUxb0vRfQ6tc 8cBDLQRg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jTjpv-0001t9-Uz; Wed, 29 Apr 2020 10:21:04 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8140E301224; Wed, 29 Apr 2020 12:21:01 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 71232201F9F0B; Wed, 29 Apr 2020 12:21:01 +0200 (CEST) Date: Wed, 29 Apr 2020 12:21:01 +0200 From: Peter Zijlstra To: jpoimboe@redhat.com, alexandre.chartre@oracle.com Cc: linux-kernel@vger.kernel.org, jthierry@redhat.com, tglx@linutronix.de, x86@kernel.org, mbenes@suse.cz Subject: [PATCH v2.1 01-B/14] objtool: Uniquely identify alternative instruction groups Message-ID: <20200429102101.GK13592@hirez.programming.kicks-ass.net> References: <20200428191101.886208539@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200428191101.886208539@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Subject: objtool: Uniquely identify alternative instruction groups From: Alexandre Chartre Date: Tue, 14 Apr 2020 12:36:11 +0200 From: Alexandre Chartre Assign a unique identifier to every alternative instruction group in order to be able to tell which instructions belong to what alternative. [peterz: extracted from a larger patch] Signed-off-by: Alexandre Chartre Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 26 ++++++++++++++++++++------ tools/objtool/check.h | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -770,7 +770,9 @@ static int handle_group_alt(struct objto struct instruction *orig_insn, struct instruction **new_insn) { + static unsigned int alt_group_next_index = 1; struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL; + unsigned int alt_group = alt_group_next_index++; unsigned long dest_off; last_orig_insn = NULL; @@ -779,7 +781,7 @@ static int handle_group_alt(struct objto if (insn->offset >= special_alt->orig_off + special_alt->orig_len) break; - insn->alt_group = true; + insn->alt_group = alt_group; last_orig_insn = insn; } @@ -813,6 +815,7 @@ static int handle_group_alt(struct objto } last_new_insn = NULL; + alt_group = alt_group_next_index++; insn = *new_insn; sec_for_each_insn_from(file, insn) { if (insn->offset >= special_alt->new_off + special_alt->new_len) @@ -822,6 +825,7 @@ static int handle_group_alt(struct objto insn->ignore = orig_insn->ignore_alts; insn->func = orig_insn->func; + insn->alt_group = alt_group; /* * Since alternative replacement code is copy/pasted by the --- a/tools/objtool/check.h +++ b/tools/objtool/check.h @@ -30,12 +30,13 @@ struct instruction { unsigned int len; enum insn_type type; unsigned long immediate; - bool alt_group, dead_end, ignore, ignore_alts; + bool dead_end, ignore, ignore_alts; bool hint; bool retpoline_safe; s8 instr; u8 visited; u8 ret_offset; + int alt_group; struct symbol *call_dest; struct instruction *jump_dest; struct instruction *first_jump_src;