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 38EB4C43334 for ; Wed, 20 Jul 2022 01:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241335AbiGTBRq (ORCPT ); Tue, 19 Jul 2022 21:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241264AbiGTBRR (ORCPT ); Tue, 19 Jul 2022 21:17:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8125F6B27C; Tue, 19 Jul 2022 18:14:09 -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 1E1EC6176E; Wed, 20 Jul 2022 01:14:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36ECDC341D0; Wed, 20 Jul 2022 01:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658279648; bh=WXdrFZOXceROsZm8n4HSd8OiAlCYb1jd9+1Sqz04V6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XtXeSkJBl+eu8EruuleZ3sgkBr06/CRvmKu4cyZbq2ilW29Fg6JyIMsRZ3joIXsgV ygizXJlwWPxajPoaRK48HlC5M2ObT0Jk4AB+Vp1G4X9ldu24ENZw5mpOMmufGEkjVd bC2/UQ0VBDP+mcEmy9Gmja75txiaJc9bPXMU+am+2TkbJ8PsxwzGY+4FLim15hd+9X x+hS5VYYR00ydCQ0u1a6Ak1SAw7Kgw9N5UwfqSOvv84gvMLePigp17pO3PhzeGWI+O Tz42NjuaqUCYvO8i5/6CkMD2QKkqNgQh5tLIEqgCIdyXvOPITYVRItqWG56zHUpfbf RUa2ciuccnWAw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kim Phillips , Peter Zijlstra , Borislav Petkov , Josh Poimboeuf , Sasha Levin , dave.hansen@linux.intel.com, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org Subject: [PATCH AUTOSEL 5.15 07/42] x86/sev: Avoid using __x86_return_thunk Date: Tue, 19 Jul 2022 21:13:15 -0400 Message-Id: <20220720011350.1024134-7-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720011350.1024134-1-sashal@kernel.org> References: <20220720011350.1024134-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: Kim Phillips [ Upstream commit 0ee9073000e8791f8b134a8ded31bcc767f7f232 ] Specifically, it's because __enc_copy() encrypts the kernel after being relocated outside the kernel in sme_encrypt_execute(), and the RET macro's jmp offset isn't amended prior to execution. Signed-off-by: Kim Phillips Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Signed-off-by: Sasha Levin --- arch/x86/mm/mem_encrypt_boot.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/mem_encrypt_boot.S b/arch/x86/mm/mem_encrypt_boot.S index 3d1dba05fce4..d94dea450fa6 100644 --- a/arch/x86/mm/mem_encrypt_boot.S +++ b/arch/x86/mm/mem_encrypt_boot.S @@ -65,7 +65,9 @@ SYM_FUNC_START(sme_encrypt_execute) movq %rbp, %rsp /* Restore original stack pointer */ pop %rbp - RET + /* Offset to __x86_return_thunk would be wrong here */ + ret + int3 SYM_FUNC_END(sme_encrypt_execute) SYM_FUNC_START(__enc_copy) @@ -151,6 +153,8 @@ SYM_FUNC_START(__enc_copy) pop %r12 pop %r15 - RET + /* Offset to __x86_return_thunk would be wrong here */ + ret + int3 .L__enc_copy_end: SYM_FUNC_END(__enc_copy) -- 2.35.1