Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1366072imi; Sat, 23 Jul 2022 03:48:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vsqcntnzDjmafPVSkoCnLDN50tlWfLEVvDRSNIFuHNjxEUv4+Ty+Fp/a1YPNypmTjA9qb8 X-Received: by 2002:a17:907:2724:b0:72b:496c:568a with SMTP id d4-20020a170907272400b0072b496c568amr3163341ejl.305.1658573287551; Sat, 23 Jul 2022 03:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573287; cv=none; d=google.com; s=arc-20160816; b=RmqGbhFYMd3vDH8VwecnacALhcxwzS+QC6HW3OcOVMLMLm4e820YAsABf1OWxbP9W6 J8TcW4o7C/qcZdzwC4fpYgLsEO6bO3NMw6GqKwPwmkDrS1Q/knVSlvuk+xLy2tyQtMCT mbcNVpeyDyXCYgkLZxVacXdlxp/pt01bA318DgbNsf9UWA7xGjxn+nZ2++5udExKOavv JHq0n6nxqNNCAqAFlrkFBT4iDGo4r9q1jNz8nY+UbjIWDHB3WyadoG1iav0RYSk6URFv brUQyqu/ZLxlH8rB9GVuVdHdrlNtSGeWelNXEe+zomXS3ExQxm1f5zqUnMDljSPMLpIV w9bg== 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=jj8JzbFvO0IJpO8ux6ElLvTAgrzrwjPecVaztRlO0u17+BGu67KBl195/zGaS0lA8W dRGYIp3v9ep4G6VOOVqBZIIrFjo31vgw3rBQ/gZvlGvw7N+jokcTWYca1d76aOWJC5Ge P4F38Rs0KNcBRXMfsNzv/vLir4e1AEl40EWUUIJqq0mroX7YVFBidN0CVH+SBk6LwFov 74A43XNlD4CN/ingTet/MbteW2RKkjCKmkCkFphTQ/7d5xzI7n0U8NOdv2n18XUQA5BX Z8L+oI0YkYMqxloXGePahEi0oH3tiy6W6jD8uzXs1Rppdt04sWRFPrfwnAeigJ6HC0gW JZ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PeXvjQjv; 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 he9-20020a1709073d8900b007123952b00dsi9546288ejc.100.2022.07.23.03.47.42; Sat, 23 Jul 2022 03:48:07 -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=PeXvjQjv; 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 S238541AbiGWKGG (ORCPT + 99 others); Sat, 23 Jul 2022 06:06:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238481AbiGWKFl (ORCPT ); Sat, 23 Jul 2022 06:05:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEBF09F07D; Sat, 23 Jul 2022 03:00:29 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6C56661212; Sat, 23 Jul 2022 10:00:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D25FC341C0; Sat, 23 Jul 2022 10:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570421; bh=U/+eLCYI4YDKjT6BcIXjKCgdRxC0oXdMaxjk/f6TANk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PeXvjQjvnc09Lgaf0k/BhTv7lTmXLbVXqrytOCFSiUvP4n+US/HJkNqyoUMLkyYjy R6U7os+ZfnycC6WMtVM+K8vKGc1DaMSgxSi+MKzKQRD5NVW6K7aACLRwsHRbEZPFFQ AGDzm+Rxj92g8RjhLm60Cb8ojAxxuJomiE6/FcZE= 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/148] x86/retpoline: Swizzle retpoline thunk Date: Sat, 23 Jul 2022 11:54:53 +0200 Message-Id: <20220723095247.034926462@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 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