Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1369674imi; Sat, 23 Jul 2022 03:56:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uV6y54Brrhk712VDdKfma6DFUwrdeN+i7nY/ya1nuIVnLrRBataHx3M+dLSLGZbLdWobjm X-Received: by 2002:a63:5d0c:0:b0:41a:4856:e08e with SMTP id r12-20020a635d0c000000b0041a4856e08emr3572080pgb.218.1658573794640; Sat, 23 Jul 2022 03:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573794; cv=none; d=google.com; s=arc-20160816; b=qEuAaRqepbfmIWezCp6BRIE8w99BNv6WGeKYLMr7IlCfclZKy06xG3EpF65IdhuoIf VWnsQK2AE2aMxUp82dsg/qOggsLRJ3jWg6mfeRXEiLNWved+Dn7tZRdwjETBVCWwKrNs Cqdr3XFfWBAKDOWJfVp2FVsLQThUmsOT6/N8oY6XQ+0Q5DF88anxAso+09PUJkvCkVwz s8LEjom2pGgBVAdlJkpeO49Ei0+HAF4bDWWk6EvpHeJgLUsfzfayBBmHJ0YOVtus7Tmr wWyJkIjnLWWi8rlgtIAv3hluCqGqHw9MHGoPNRbY8FbimhvGSFZ0PvIyQLfnQ7QRFFnH LrmA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9WebQxCvbSkcyZxL3fkxv9RLm4iVhKs4PwuHmOkYkVY=; b=sCzT4UO8marV8yl4GA98N5If6j22IUDlroV/zCD4DNcKGY4XIuHMZmF9PfnYUikMdJ kieQ0hsjcYe5mQabpRjNg1hwtpPe2DUVGkQ5UW+8AmlBCU9sGuxpQJ47tQsbIere4Hj6 1nPmOaJXy4Gt5PaNmJslQ8wc89qv6lL3zLYtD1wpJ8z7ynV7uUDRPFZsAK2kZGBzeTXB 2F3mmIrTIEv7t7za8JJJvR6zxzxaNBQaOSO2I4TXNoJXax8nhDV2kmGH2fQQGefyZSiZ gTNZZjDJheht2TZJWA2/822XU/fNRiUG2r02SeG0CY2bCQ1ZoUaesX15RHG+I1zTcmGx v8cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J9CUGOij; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay8-20020a1709028b8800b0016c192735f1si7481312plb.220.2022.07.23.03.56.19; Sat, 23 Jul 2022 03:56: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=@linuxfoundation.org header.s=korg header.b=J9CUGOij; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237353AbiGWJ7X (ORCPT + 99 others); Sat, 23 Jul 2022 05:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237610AbiGWJ6p (ORCPT ); Sat, 23 Jul 2022 05:58:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A6F369F0D; Sat, 23 Jul 2022 02:57:38 -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 ams.source.kernel.org (Postfix) with ESMTPS id C5243B82C21; Sat, 23 Jul 2022 09:57:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27074C341C0; Sat, 23 Jul 2022 09:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570255; bh=wGMNTjp6VPYf7orV8ztNuBdmDKJ1DhLEaFQidTOFZH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J9CUGOijz/iAcsS2qR9fd5VB8yYw5N0xDRFJxoUAdcOEHTN9r0mEcuU0fIQbMKiWR AYbJ6wLHZgxvXhH6tGdAtznNUAmBl50k67+Jq43mrcRMzvu3xAu9T9qG8p8/bBL15+ ItokoVG8HMAbsOD0hCsm/0ovkN2J9HGhC5U7u85o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Borislav Petkov , Ingo Molnar , Miroslav Benes , Ben Hutchings Subject: [PATCH 5.10 033/148] objtool: Skip magical retpoline .altinstr_replacement Date: Sat, 23 Jul 2022 11:54:05 +0200 Message-Id: <20220723095233.591415325@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220723095224.302504400@linuxfoundation.org> References: <20220723095224.302504400@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 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 From: Peter Zijlstra commit 50e7b4a1a1b264fc7df0698f2defb93cadf19a7b upstream. When the .altinstr_replacement is a retpoline, skip the alternative. We already special case retpolines anyway. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.259429287@infradead.org Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- tools/objtool/special.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -104,6 +104,14 @@ static int get_alt_entry(struct elf *elf return -1; } + /* + * Skip retpoline .altinstr_replacement... we already rewrite the + * instructions for retpolines anyway, see arch_is_retpoline() + * usage in add_{call,jump}_destinations(). + */ + if (arch_is_retpoline(new_reloc->sym)) + return 1; + alt->new_sec = new_reloc->sym->sec; alt->new_off = (unsigned int)new_reloc->addend; @@ -152,7 +160,9 @@ int special_get_alts(struct elf *elf, st memset(alt, 0, sizeof(*alt)); ret = get_alt_entry(elf, entry, sec, idx, alt); - if (ret) + if (ret > 0) + continue; + if (ret < 0) return ret; list_add_tail(&alt->list, alts);