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 165F5C43334 for ; Wed, 20 Jul 2022 01:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240576AbiGTBLM (ORCPT ); Tue, 19 Jul 2022 21:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240185AbiGTBLB (ORCPT ); Tue, 19 Jul 2022 21:11:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF3E7545DD; Tue, 19 Jul 2022 18:10:52 -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 E295C61732; Wed, 20 Jul 2022 01:10:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D114C341C6; Wed, 20 Jul 2022 01:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658279451; bh=j9iKzw3Ez6OxwOZqbsC/qV42DywUvZICssT6cBlTxK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t8WWOlF7cYv2rGXpebtao5QNJQFWs4+9RfW+dBmGIJaRwkos02kPpJFhAxdW01iBZ 7srJeYChcMoYIdizmc96oCKmLXH+hwC7U4wtnCWFNiB23uzv2HkvD4EE9ZdmqvogDH lyepYLnI4ZBDjfE6n/WgQv3LgJngyYIl/rDsB6u4BX+ecONCy7WstXd8m1kVAtkRkc 7TzSBvv0bhb/qmLzH7fkM1Tshu7xAoTymEaa1E1DA7HgLvDLDnKbj0umu7ayDLGjYR yDUXucADtPQyG68KRvQQ/KFvMFVYIqrHQBZQqK8n/a5kx4wzKQH8xFtiQs9RQnFNny KyKRqLfhw9gcQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Zijlstra , Borislav Petkov , Josh Poimboeuf , Sasha Levin , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, ndesaulniers@google.com Subject: [PATCH AUTOSEL 5.18 06/54] x86/retpoline: Swizzle retpoline thunk Date: Tue, 19 Jul 2022 21:09:43 -0400 Message-Id: <20220720011031.1023305-6-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720011031.1023305-1-sashal@kernel.org> References: <20220720011031.1023305-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 00e1533325fd1fb5459229fe37f235462649f668 ] 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: Sasha Levin --- arch/x86/lib/retpoline.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index b2b2366885a2..2cdd62499d54 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -33,9 +33,9 @@ SYM_INNER_LABEL(__x86_indirect_thunk_\reg, SYM_L_GLOBAL) UNWIND_HINT_EMPTY ANNOTATE_NOENDBR - 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 -- 2.35.1