Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp455090imi; Fri, 22 Jul 2022 02:45:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sfov6JaLxi4BnQo98uow1twlddybaEk4LXguWk/nAECv+PtC9XTfg2aFAbGX3s51z1HJEN X-Received: by 2002:a17:902:ab95:b0:16d:12a8:2af1 with SMTP id f21-20020a170902ab9500b0016d12a82af1mr2595712plr.164.1658483124894; Fri, 22 Jul 2022 02:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483124; cv=none; d=google.com; s=arc-20160816; b=wldvw2MbQg7QD/Z2weADAih4YO1e9XCgbc2Rp9e8hrsWvUFVWbV/ESmmcoL4K7offn yckYTc5y545FGyFiLLAiqFPWh2298HRxak41H/sMMtMMo107S52F0M9kfWiMntVJcy9z oTZ/wuhgZOF6ba6bsR6fGHjKCXpkrdtHsTvemRD2JHvstQF6Zmh3KsvB3Fa4pKMCuELG zK4h1AQ6QCuGdZkdygSjN/ygJr9aApcV+M6Zgf0+jUlhQWqRPyEle7/w95X//d1So0xL 4FauNhHBnw5FMt5vhNnrq6iN+vD7vQ6KakP7gmFWnLGnP/Wg9eW3D3QjNHYcl7FXPvlC sV2A== 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=vhDiPXLaigjZESXtRbzOMnnER6ftjicUy1IRC3gEQeA=; b=ADEDAPNB+/FeKaZ3sQojshnNCDLnbhdX1lljrYLbmYzX9kCbWtf1ARK8aM46YKm8gE DDW/eed9+L3GKxlNCATXMSowTRKenvV1lEDo40xWbDWAc/mw/PFnrKJ6uOWly7jiKegS ZoJJ1jsBrnqNsOjQgeali3WA2MuUfr8xo9zntnxaEClFP+T/dG5JVUNzgm1PXL8b2hhI GBLGFIrFxRLUFKKLCaYMZOjz/Kq+1ijFeRMeOSZhyeGCRdJl8NJNKIlYTZGl6Tx3hcxg 94HZCmLjjVxCJOxX1C0iuQfJlqW3VubqQFuLYQfubXDopIx2qvDLwyPtgvtkWXwQbnU8 onyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e82MLqRB; 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 e16-20020a170902ef5000b0016cd98eebc3si5161568plx.151.2022.07.22.02.45.09; Fri, 22 Jul 2022 02:45:24 -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=e82MLqRB; 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 S234937AbiGVJJQ (ORCPT + 99 others); Fri, 22 Jul 2022 05:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235029AbiGVJI4 (ORCPT ); Fri, 22 Jul 2022 05:08:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F087904CF; Fri, 22 Jul 2022 02:08:48 -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 49B7C61EE6; Fri, 22 Jul 2022 09:08:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54C3EC36AE2; Fri, 22 Jul 2022 09:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658480926; bh=6H9Lyl9oIAdqchAN6Gj+v6lW5keext/SAPl2qXlkcwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e82MLqRBN59QtbdneTc69zW/zDzz9GMoWmT3S1AnVwsVAhfmUWXK3eIZeZ2ZEhREF ukVd7eb8a3XofaKNWOW0jDk9qqfYgTlYn5GuupJHu/par9vj17kv4kghAKqm9s5+Dw TglT03tWqSOTVYS/hUy5WocFg+ojfDGiVfSXCswE= 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 , Thadeu Lima de Souza Cascardo Subject: [PATCH 5.18 19/70] x86/sev: Avoid using __x86_return_thunk Date: Fri, 22 Jul 2022 11:07:14 +0200 Message-Id: <20220722090651.799178181@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722090650.665513668@linuxfoundation.org> References: <20220722090650.665513668@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 commit 0ee9073000e8791f8b134a8ded31bcc767f7f232 upstream. 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: Thadeu Lima de Souza Cascardo Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/mem_encrypt_boot.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- 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)