Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4696875imw; Tue, 12 Jul 2022 12:37:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tiihbRafqadhqcVANSqZ3rSWCRKl+Wo5dXxRW6NxNmUvXfYlubaNJMePV4HCXZAjSeIEn0 X-Received: by 2002:a17:907:72d1:b0:72b:6da5:9bb with SMTP id du17-20020a17090772d100b0072b6da509bbmr7705848ejc.681.1657654659734; Tue, 12 Jul 2022 12:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657654659; cv=none; d=google.com; s=arc-20160816; b=wkD6FRqevEepFmx2uiXR3cJYtaPu6WDKiTRhIMc2VpzhHi9RK9KDVFup4M7GJdI67L tVcxb7U0zOnuMGlppIbqgfd8se2LRfZFQjWgz4QP8vdUYKMjMjzuKf4PHYX8pstGHtek xg7a+B2e5txSIvMI6klahBQ6V8enCTRlfZsSC1N1xLiNOy536tqqTU2lELj7IgR699+F 2iS79Q5+f29puDlmbzvRaNUu5LsxV6Fp25vFTho26KNz/emWetxloRbw6Os5q9uZvvZl mtGmS2QCKkXAPxbjYK6fCT4fUVsF+rYCM02XBSgBM6LI14YRzL+G/WyvA96HKXlf9HID 0iLg== 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=hrt4356mOejIhVzImz6dJg6FZRqTqJX2OZWNHtj7eFc=; b=i+3eJFJcFKi67EvrJk3uiM1o11Oud0u5LS3FE9bQANhGt95zvGZCPNAj8jtkHUKrgx rKvPf46W1NinI/qP1eqK4Se/I4unudycmFRlsoGm9/kJ6kdpVbWwL35oOXVcZ/dHz8Nr 1WZHwLWBA4umjJoXCdwezxxGoRjp1bvRnp/JLTQh7tGZ1nrXVfZEWpCJX+3RPR7pnAtL 9NybK1PXGZUKhos3ce1TmdDM8BZzX9PJT2aPp+jOB7rMzKqlkITAT7alsKLCSx27wOrm 3pxYG05si2VoGvcKgGHaZeLf9R8+TtvG/hdNQJ5vbaMJoYigViL6QEtlZTm8qiO8jnSK qOKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j7s7M7OA; 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 z2-20020a056402274200b004396b724878si2311872edd.441.2022.07.12.12.37.14; Tue, 12 Jul 2022 12:37:39 -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=j7s7M7OA; 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 S234879AbiGLSzI (ORCPT + 99 others); Tue, 12 Jul 2022 14:55:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234189AbiGLSy2 (ORCPT ); Tue, 12 Jul 2022 14:54:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18FACE95E6; Tue, 12 Jul 2022 11:45:57 -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 52EDBB81BB9; Tue, 12 Jul 2022 18:45:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B269AC3411E; Tue, 12 Jul 2022 18:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651553; bh=U/+eLCYI4YDKjT6BcIXjKCgdRxC0oXdMaxjk/f6TANk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7s7M7OABmPu4uzyUCB29OjRS8xmZHvzmtFhm4XDD9dxWnJAnq9a389dLall06rGX uG4uuX5sm6hcy/9yD8KjnDLlKhiwWP/bpu/eqlS8yodpbayS/vdmfl0hwFhuOoPN0S cAF0FjckdesNEXvOxRyPL1upAiGdkDyg8aFeywig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Borislav Petkov , Josh Poimboeuf , Thadeu Lima de Souza Cascardo , Ben Hutchings Subject: [PATCH 5.10 081/130] x86/retpoline: Swizzle retpoline thunk Date: Tue, 12 Jul 2022 20:38:47 +0200 Message-Id: <20220712183250.196932918@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183246.394947160@linuxfoundation.org> References: <20220712183246.394947160@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.7 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,T_SCC_BODY_TEXT_LINE 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 00e1533325fd1fb5459229fe37f235462649f668 upstream. Put the actual retpoline thunk as the original code so that it can become more complicated. Specifically, it allows RET to be a JMP, which can't be .altinstr_replacement since that doesn't do relocations (except for the very first instruction). Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Borislav Petkov Reviewed-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/lib/retpoline.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -32,9 +32,9 @@ SYM_INNER_LABEL(__x86_indirect_thunk_\reg, SYM_L_GLOBAL) UNWIND_HINT_EMPTY - ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), \ - __stringify(RETPOLINE \reg), X86_FEATURE_RETPOLINE, \ - __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; jmp *%\reg; int3), X86_FEATURE_RETPOLINE_LFENCE + ALTERNATIVE_2 __stringify(RETPOLINE \reg), \ + __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; jmp *%\reg; int3), X86_FEATURE_RETPOLINE_LFENCE, \ + __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), ALT_NOT(X86_FEATURE_RETPOLINE) .endm