From nobody Tue Nov 26 00:32:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63885+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63885+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596837275647841.3600362894043; Fri, 7 Aug 2020 14:54:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9EMHYY1788612xHXoPlHwija; Fri, 07 Aug 2020 14:54:35 -0700 X-Received: from NAM04-BN3-obe.outbound.protection.outlook.com (NAM04-BN3-obe.outbound.protection.outlook.com [40.107.68.65]) by mx.groups.io with SMTP id smtpd.web10.6576.1596837274634032456 for ; Fri, 07 Aug 2020 14:54:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ocZM1cO2sBLUhxTyyWbMJIeBHM2FKodbHO2yI4pVFJbcpj6FafCNj3uZhxVv0jn20d55ILpbQklRyN3aO5IC6bpN1QkmlIMsHPP5FH7flSki4+sfC2uDD35g/A8WtMKFZz78m4CQGEsXY0KI0HYzBPLHlm6Nv2IQI4IV71lP6v5F2lmLpaKUsPtGLzVzdObf4Xvnsvbhq+oMbvuLel0qP7w8DtqSOBRR0viTJ4MT/U3XJiNhIQh6llVXb+X3BGANCgS0cqirbbXteYr/1BshqArKnnkgso2CAAx3zW3g7cixEhZ8P/VeSybKtS5pHAcKHEfG2p123eydZaSd/ERShg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cly63GpVgtcX7Qni9pbo9m94/AhxXLuSc1r4QOxC/u8=; b=jPBjEGTdmv6Q7Sxgg81JUeWYfxPCjDw3PqybbLCHtONrSqJ2cJyHE8ARq7FgXsoi/RIMDBU/6l3zFTRWk2bK5KXAf3zBsVN+gilKbYrRqsgfLZHw4rDw1sWgC0/c7HtUbmyZK7SxJecVPcKQJxQpPZMdFUXZ04BD1Dtd5taVGIE6V4P2BQ/yA0ogzLx58zSqO8TS55E1Nq642cwmcNjN+h9Z2108Z1lcj38A7KuQEToK5ZF9Uq+IxLG6Gcb0f4Lx7D435tkgrW07Yhwcv4tDDN5ainYDnPDJ/ujp0ct+tZgJMvFJX0EAcZkDW2G43bUxsJe5gQ9raqND12wkzZDPhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1717.namprd12.prod.outlook.com (2603:10b6:903:11f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20; Fri, 7 Aug 2020 21:54:33 +0000 X-Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b%5]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 21:54:33 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH v14 43/46] OvmfPkg: Use the SEV-ES work area for the SEV-ES AP reset vector Date: Fri, 7 Aug 2020 16:53:56 -0500 Message-ID: <18d1b4fd770e53fd12aa77282dfc3ae1e54c1b4e.1596829170.git.thomas.lendacky@amd.com> In-Reply-To: References: X-ClientProxiedBy: DM5PR12CA0052.namprd12.prod.outlook.com (2603:10b6:3:103::14) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR12CA0052.namprd12.prod.outlook.com (2603:10b6:3:103::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19 via Frontend Transport; Fri, 7 Aug 2020 21:54:32 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c42528a7-cb3a-4483-5eee-08d83b1c77be X-MS-TrafficTypeDiagnostic: CY4PR12MB1717: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: /eRMe2hJpA/jAR0JOpZDQ7YprcN39u3kWqcBnXPBZ0rnAoMAB7Ok71oZB/DAjghdghmF4ImtTKeS7AaW6VH49VMHnW3Ii41Fyfen8oUXaFzl3XqvwGW3+vFwU/kdBgZ+rLzxw9N8qA/sHsUXaCQFk5J+bxqtKD2k5lsQSkpGseugSwi+npBggUkYGASVhsgjzz99B65Zkx/e1Yy47Yc+WXUv+O9i+zKYpWrupuB/KWJglwSjtPOB/UBTZuzBVwwqIBcsjiZwmeGwTxOt1eGM5APYTUaAY3o86lpADe0iNMiMCT4n6QhAhQR0CTgz0daW+aQZOD1VyRCsiwxs56vRq83iQcXS+eLYsaOhyhuKoAu7hCbFZXgcD//1dXOKqKQ7Qcl3juDA/S0VBgrKKId6zVnvD+4sXDG72/0YRzwUT8G174g38D3m12kVjydoSCdzfTd9eGwDqYfoW8fVNu0RiA== X-MS-Exchange-AntiSpam-MessageData: 7MSqnJaEc98fO+fh93HvMYpmeC2DG3y7IetMzIvfgkyRLq1vRjDYGgEltT4hQQ3taYet5/grptnK5BvVjU2rWzBnop83sPi8Lon/FMU5ySx6ed6kjVUhtG+U3A2fvPBd22PFEMVPX0xgqWO1PMpYhjL/vwm2tCNbsDgedEwabOyhsPc4n4LVgXV1Z/EyfngCSsjzKSFZfHp0Q0ZHwoRGXEplO/TA5zdwkuOK4mJLd5Ij9wu3BsTP2zB8woFyzGMTpz8kUkRxxwO/448uEN8hO7YuncvkKd331b9AhNoKmgUi+6gGErg21C1j/FSs9AkwL+AxJakSuVyxv8FKKF/QKycz2I1PoZRIydyx5J158vE46rrGaBW9YlKDR/e3dpbOyCCUMquv2iTTcBNHdGiCV+dOAu/EmVlyKzAkTiqI5oxKqliokkJKz2UC15SRjUJkgDDqAan3xO0H200eRcpkQQZCd7N5T0CG8mA0DUkIXDb/S6mZlSbE5TKz5wxkO54smUOqXxU5OWapgsAvK/x3yqp5diPscZnWY98pjEzTPECcPAg851RcvE4iV9grKS/u2FZOgHuvjHBPxtH9rbw9d6dT6J3ZIbu4qXg2+NMvOGARAWZUuudj+hDGwpshu5m8162r2g0Q4wzlyA8izMnzEw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c42528a7-cb3a-4483-5eee-08d83b1c77be X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 21:54:32.9112 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VZBva3ASPcH4jGa/QuRuleAjKBR2WQIEdxc2hkEEGL2BVz+q9kvbGVQH+NNu1xIHvhYBFQYOmbd5/s0Hubf+Qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1717 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com X-Gm-Message-State: N6JSVZCWnaQObPUxepoAhLQlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596837275; bh=Arivw4cUbO7Sy/r3N6hTUEWgewHnMnwynfRq23rm2YQ=; h=Content-Type:Date:From:Reply-To:Subject:To; b=PFhx/2g/CuWstfsLX0EuD4FuEjnyiJ2fEEfzkWwtEnCFQ/v2+BlUd1AcFZ0g4xZOZpG S3FWr54pVjSwZII2fX6aHivvULdUCxDDBetLbxsNg2Y+Vog46N0d+Bm2fdFX1KFh3IJmc mkqTzG7laxt7RzR4Y4WyYwqSqOCXD+oHc3U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 A hypervisor is not allowed to update an SEV-ES guest's register state, so when booting an SEV-ES guest AP, the hypervisor is not allowed to set the RIP to the guest requested value. Instead an SEV-ES AP must be re-directed from within the guest to the actual requested staring location as specified in the INIT-SIPI-SIPI sequence. Use the SEV-ES work area for the reset vector code that contains support to jump to the desired RIP location after having been started. This is required for only the very first AP reset. This new OVMF source file, ResetVectorVtf0.asm, is used in place of the original file through the use of the include path order set in OvmfPkg/ResetVector/ResetVector.inf under "[BuildOptions]". Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Reviewed-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm | 100 +++++++++++++++++++ OvmfPkg/ResetVector/ResetVector.nasmb | 1 + 2 files changed, 101 insertions(+) create mode 100644 OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm diff --git a/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm b/OvmfPkg/ResetVe= ctor/Ia16/ResetVectorVtf0.asm new file mode 100644 index 000000000000..980e0138e7fe --- /dev/null +++ b/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm @@ -0,0 +1,100 @@ +;-------------------------------------------------------------------------= ----- +; @file +; First code executed by processor after resetting. +; Derived from UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm +; +; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +;-------------------------------------------------------------------------= ----- + +BITS 16 + +ALIGN 16 + +; +; Pad the image size to 4k when page tables are in VTF0 +; +; If the VTF0 image has page tables built in, then we need to make +; sure the end of VTF0 is 4k above where the page tables end. +; +; This is required so the page tables will be 4k aligned when VTF0 is +; located just below 0x100000000 (4GB) in the firmware device. +; +%ifdef ALIGN_TOP_TO_4K_FOR_PAGING + TIMES (0x1000 - ($ - EndOfPageTables) - 0x20) DB 0 +%endif + +; +; SEV-ES Processor Reset support +; +; sevEsResetBlock: +; For the initial boot of an AP under SEV-ES, the "reset" RIP must be +; programmed to the RAM area defined by SEV_ES_AP_RESET_IP. A known offs= et +; and GUID will be used to locate this block in the firmware and extract +; the build time RIP value. The GUID must always be 48 bytes from the +; end of the firmware. +; +; 0xffffffca (-0x36) - IP value +; 0xffffffcc (-0x34) - CS segment base [31:16] +; 0xffffffce (-0x32) - Size of the SEV-ES reset block +; 0xffffffd0 (-0x30) - SEV-ES reset block GUID +; (00f771de-1a7e-4fcb-890e-68c77e2fb44e) +; +; A hypervisor reads the CS segement base and IP value. The CS segment b= ase +; value represents the high order 16-bits of the CS segment base, so the +; hypervisor must left shift the value of the CS segement base by 16 bit= s to +; form the full CS segment base for the CS segment register. It would th= en +; program the EIP register with the IP value as read. +; + +TIMES (32 - (sevEsResetBlockEnd - sevEsResetBlockStart)) DB 0 + +sevEsResetBlockStart: + DD SEV_ES_AP_RESET_IP + DW sevEsResetBlockEnd - sevEsResetBlockStart + DB 0xDE, 0x71, 0xF7, 0x00, 0x7E, 0x1A, 0xCB, 0x4F + DB 0x89, 0x0E, 0x68, 0xC7, 0x7E, 0x2F, 0xB4, 0x4E +sevEsResetBlockEnd: + +ALIGN 16 + +applicationProcessorEntryPoint: +; +; Application Processors entry point +; +; GenFv generates code aligned on a 4k boundary which will jump to this +; location. (0xffffffe0) This allows the Local APIC Startup IPI to be +; used to wake up the application processors. +; + jmp EarlyApInitReal16 + +ALIGN 8 + + DD 0 + +; +; The VTF signature +; +; VTF-0 means that the VTF (Volume Top File) code does not require +; any fixups. +; +vtfSignature: + DB 'V', 'T', 'F', 0 + +ALIGN 16 + +resetVector: +; +; Reset Vector +; +; This is where the processor will begin execution +; + nop + nop + jmp EarlyBspInitReal16 + +ALIGN 16 + +fourGigabytes: + diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/Re= setVector.nasmb index 762661115d50..4913b379a993 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -82,5 +82,6 @@ =20 %include "Main.asm" =20 + %define SEV_ES_AP_RESET_IP FixedPcdGet32 (PcdSevEsWorkAreaBase) %include "Ia16/ResetVectorVtf0.asm" =20 --=20 2.27.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63885): https://edk2.groups.io/g/devel/message/63885 Mute This Topic: https://groups.io/mt/76058842/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-