Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4469260imw; Tue, 19 Jul 2022 07:12:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6mUtAigtuewOO1MRE2ll4hpYEt8PuuDesqYFMy/sm6EkrhSF1dp+P1jAd/lku8kkkcTzt X-Received: by 2002:a05:6122:c4b:b0:374:bd55:6a24 with SMTP id i11-20020a0561220c4b00b00374bd556a24mr11403715vkr.9.1658239934004; Tue, 19 Jul 2022 07:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658239933; cv=none; d=google.com; s=arc-20160816; b=H/hv9u9yiLBd0/gB2daQUcFDq3KGsipWthtK0u9lqFOpKIM3Q44gRbB/gGPq4Zumk2 jC2pgSmv5Gy+ewPyW8amvVzJ4QZ7bckKD206TN0h8YF7GHE0ZSMIStzJJTMInwY2rdTM tnIheKzXgjpxU/i3vDxVxFDpEJoquQh8Kyuq3llyn+F/3tSWJS1GO7JE+8tb3S6C8JJJ aT36QGluJ93zQ00tTh5EvTKx6EM1Z8a+potn5jGLzDhCmao4FaEd2NgonSIHu984ZyFl SuvECq2qvuSX0qdtr6aqxOo+HGbmd8VHE1a6zuAvGaOgddFZZX1JBlhqOWzvjwR9A8az TT6Q== 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=bo0ciptWVgEucBtcFJB/jKHtRMVTkqmmFw4op0hSBk8=; b=CejJIAy/YEoYYlRG6zxDxpkFxuuhHOFQjNCWwoY2oxuYMOIHeRk/KXT3443Iv5UlDU XCkL4A7l4twKdmcMH8HCNoiCoAOgSigIrAkVJ0Zn3gUbGJz1jVvpBi8ife1z1/2MqK9L QWKRxxrVSynqR1VtlKbtIVKdJe2hhF8WaiaK5uqjnpz9bbuk3JL40xK9jp0pTgba/VJf OuK2rILMVXR6nEBFJNYxMbQl8AZaR1dqYItRzkQdSMhVHwEB13aekWmbXiT/ie/ZS/wG g+/UlckcpPHb2JAYW8QSxbcFFQXpL+81EzesbgKuIE221JGXCAbaC6yeu6KgORcZNnrK AFeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yDXoTNxe; 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 i123-20020a672281000000b003572acffdcbsi2481923vsi.512.2022.07.19.07.11.58; Tue, 19 Jul 2022 07:12:13 -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=yDXoTNxe; 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 S242824AbiGSNC6 (ORCPT + 99 others); Tue, 19 Jul 2022 09:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243079AbiGSNAT (ORCPT ); Tue, 19 Jul 2022 09:00:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34C6E4332D; Tue, 19 Jul 2022 05:25:35 -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 39146B81B21; Tue, 19 Jul 2022 12:25:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BD63C341CA; Tue, 19 Jul 2022 12:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233533; bh=WXdrFZOXceROsZm8n4HSd8OiAlCYb1jd9+1Sqz04V6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yDXoTNxeW5gdWpE+O7scFkpS3Dv8Hm2VttHoRKnYVHjmNwMFIsGc6I6VdfLFXqIqO DdKf/wO4JXRgLasIN13CCTZ9YOFByqhtpG9OF9gFViGfIWzRvkaLmBVpmow5voLNVi 3dowD1xSkGZmu1fNvnnJdrMe1UPpz9Pusi3TLNY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , "Peter Zijlstra (Intel)" , Borislav Petkov , Josh Poimboeuf , Sasha Levin Subject: [PATCH 5.18 146/231] x86/sev: Avoid using __x86_return_thunk Date: Tue, 19 Jul 2022 13:53:51 +0200 Message-Id: <20220719114726.628551296@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114714.247441733@linuxfoundation.org> References: <20220719114714.247441733@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: 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