From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.79]) by mx.groups.io with SMTP id smtpd.web10.62902.1595875444492914188 for ; Mon, 27 Jul 2020 11:44:04 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=ypcKLN1v; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.244.79, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+AZsvITNYdibkLapVICuPCPAFCiOoqfXpvAZ3fXh/WU0pA1pA0WGUigBfydE4MT53Lrh561PtzLwFK4UEyPDROeLAShTQuX4Mw0RhGjxoPhN95aWKRJ3GqJ83FImcVVqf7lFKiDDTiTe92Gav3YEPc2eom3pkTex6HppjdMjD9YyMuanoWLzxSrWZ3MixFW7/ye4gE0SmiLEk/6r67O/pRIjfLHkc3KND+khKh+zb5/tYzt/95KdHiSjPTfv/VQjv2Lu2rp9qCXszG1O6iK2cHlxKXemyU10cWYcjTPsA+lqmjJeH0/74VDKoCCd77WuoPT0hUFbvbeHNNtcPgVsQ== 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=WSCxNM2JLS/ot0Fo9ASNbyJPedXlaR0+XAw++ONGBg29+tHPe8lk3Zh0Mq5ormqHo6OaKWkTCpIAoHubYn82mNv1LkKmPXG/lceywHCAH0M6mHe5KFxEn3b96XZVgnwf6Yp1znqUn5aNNtt7SRXus2sjc0hCEJuoIb7RI0nAlxbssauZYcWW4eS06MvodfwCxrP7kJvg0coxY/wKpoO7wbM5pop6sDYH1eeLyQLspkdttYhAlPD+nfpC6sIp79tAEe2+Cs6CofgjXeqgxmZWsU1z4OBdxUfWYrzW8nzTVdsbX3p6uBVb3jkE14nmRMIjXs2zTkSLZMmWopeOZGFPiQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cly63GpVgtcX7Qni9pbo9m94/AhxXLuSc1r4QOxC/u8=; b=ypcKLN1vupG5K1fC4WNfMLbSqR4pBljvNMXQT7EH7cU8lcx9wgjMj5DTuuH5MTLu2VOlL5hq8wSv7Cc+EgzywaJuTcYHkG98+5Cm5a0lgVyeMIY7M3noNK7B5D+8XjeFphw42GGn8Hl/Rwt8T/668+d+pwtpo7kOlpSnpxRgWAU= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1257.namprd12.prod.outlook.com (2603:10b6:3:74::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.24; Mon, 27 Jul 2020 18:44:03 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0%8]) with mapi id 15.20.3216.031; Mon, 27 Jul 2020 18:44:03 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Subject: [PATCH v12 43/46] OvmfPkg: Use the SEV-ES work area for the SEV-ES AP reset vector Date: Mon, 27 Jul 2020 13:43:28 -0500 Message-ID: <66c37d51131b034a9006bfecfc4f1b37f9213c27.1595863587.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR13CA0055.namprd13.prod.outlook.com (2603:10b6:3:117::17) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR13CA0055.namprd13.prod.outlook.com (2603:10b6:3:117::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.9 via Frontend Transport; Mon, 27 Jul 2020 18:44:02 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dc87b205-9cfa-41ac-07a1-08d8325d0899 X-MS-TrafficTypeDiagnostic: DM5PR12MB1257: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZOdEpKVcabvmR5+3ByX4+6GYGProlvOp/FmbWtNHI9EhwLp0zaZ8cFccE3ZyZw5MmWAFDIuZtFhOs4cTTSjEUmU9SOojzp9n1e0uQgqd+B9vh+WP75XiD/mk1DBEAnIvHv0jp9vtbtkhgr4oAX1iEYn5XhUl3qTrMers3PRMq8Xg3aHDe0j+TF3nericOn6sdJEdYdmhYNFRddqKxcILT8UY7JH2jxuLo/gjwRAQ8luNgyLAC5bkZAkJNp+dxNzYlUXbzreNR85SIaNIB/367WAzjLojPkC3a6ce9Zm/soDJWRyqZ6sgSbH1doQzNOuMr0VLvqxBv9WEJ4ACrZYMrTIgJDrz9nCk0guO2SMDoFGhTRrcj+RktMMWC6zNU+gMAg7Vzr3JXCozNeKIJy8AWFHwTEr/cjG55P6hl8CgYRWmWzvvp1IQjHiQ1bLPtArLBiwFxeLJZVwK1Q9Cy421Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(136003)(346002)(396003)(376002)(39860400002)(5660300002)(66476007)(66556008)(36756003)(8936002)(66946007)(6666004)(478600001)(186003)(16526019)(19627235002)(83380400001)(2906002)(26005)(52116002)(7696005)(2616005)(956004)(6486002)(86362001)(6916009)(8676002)(966005)(316002)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hhVkIqHARb6+MPRNv8CbgbIgsBv3uRCmx5vhdT8/uEWIlfVbjkX5ySUQNEqIEa1adOmBjMhQ7fe7f/F5+HLH/MAlY7kRoQFREJY4NBF9HzHe5ZYMOMXRLfmzgTMqzpAm2xyVeYo19Zy0ZetgEoV4wivelHbS4AYDGpg7altoQFjwdQpigsgwFaAbe9aW8FybWFWq0mCiT1lZKsx/OYRLMf6+6xrTveFrmA5Yb/7VtLPMc4nlAZmdFS4imbrJ7METzeoFqwbMewjYEskk9T5Xg4cmHDO0z/uz9mFV3owMdd7rdLljxnh9hHqZAR/izgDuuN6qpsW1BcjavCtUEdxJG4O4DFOdP2ij1BIqEmF3tTLDjo4HKfF0BYLVjztJzYk49K3QjofklukyQ3ILieTJst5VIaNDBe8iZktZL/GGui3Ff9h3ik37MPDBgrkhqxEhHv+TmhNyGEH1HT8Kvgy9uOeHHuvudE9dZFoesTAQsao= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc87b205-9cfa-41ac-07a1-08d8325d0899 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2020 18:44:03.2428 (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: 1dvcPyTSKF9taE3ncsARQHWe7h02LmSjhYkAvY4CAjsHTnFMbaxshUCbh0VLglLGSeDtudxTz0WcPWMOyjy6+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1257 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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