OvmfPkg: Add PeilessStartupLib

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429

PeilessStarupLib provides a function (PeilessStartup) which brings
up both Legacy and Tdx guest from SEC phase to DXE phase. PEI phase
is skipped so that the attack surfaces are reduced as much as possible.

PeilessStartup() does below tasks:
1. Contruct the FW hoblist.
   Since PEI is skipped, we must find a memory region which is the
   largest one below 4GB. Then this memory region will be used as the
   firmware hoblist.
2. Initialize the platform.
3. Build various Hobs, such as SecFv Hob, DxeFv Hob, Stack Hob, etc.
4. At last DXE Core is located / loaded and transfer control to it.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
This commit is contained in:
Min Xu
2021-11-28 19:50:51 +08:00
committed by mergify[bot]
parent 75942a52ae
commit 4fe2678411
9 changed files with 1896 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
#/** @file
# Component description file for TDX Pre PI Library
#
# LIbrary helps you build a platform that skips PEI and loads DXE Core
# directly. Helps building HOBs, reading data from the FV, and doing
# decompression.
#
# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PeilessStartupLib
FILE_GUID = 8FA74135-F841-40A4-86C8-69C923D2E85F
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = PeilessStartupLib|SEC
#
# VALID_ARCHITECTURES = X64
#
[Sources]
PeilessStartup.c
Hob.c
DxeLoad.c
[Sources.X64]
X64/VirtualMemory.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
OvmfPkg/OvmfPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
[LibraryClasses]
BaseLib
DebugLib
BaseMemoryLib
PcdLib
UefiCpuLib
DebugAgentLib
IoLib
LocalApicLib
SynchronizationLib
HobLib
TdxLib
MemoryAllocationLib
PrePiLib
QemuFwCfgLib
PlatformInitLib
[Guids]
gEfiHobMemoryAllocModuleGuid
gEfiHobMemoryAllocStackGuid
gUefiOvmfPkgPlatformInfoGuid
gEfiMemoryTypeInformationGuid
gPcdDataBaseHobGuid
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdCfvBase
gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataOffset
gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize
gUefiOvmfPkgTokenSpaceGuid.PcdBfvBase
gUefiOvmfPkgTokenSpaceGuid.PcdBfvRawDataOffset
gUefiOvmfPkgTokenSpaceGuid.PcdBfvRawDataSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBase
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize