mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
The first call to MemEncryptSevGetEncryptionMask() in the Dxe phase will look for the encryption mask for the page table entry by reading the PcdPteMemoryEncryptionAddressOrMask (dynamic PCD) token. The value is then cached for subsequent accesses. But if the first call has interrupts disabled, as is the case in the MmioExit function in the #VC handler then the PcdGet64() will re-enable interrupts unexpectedly. A hypervisor may then inject interrupts into the guest whilst the guest is not expected to be interrupted. This leads to the ovmf image hanging when handling too many nested #VC exceptions. This patch avoids using the PcdPteMemoryEncryptionAddressOrMask token in the MemEncryptSevGetEncryptionMask() function as it cannot be called safely from a context where interrupts are disabled. Instead, we fetch the values from the SEC_SEV_ES_WORK_AREA in the Dxe phase. The work area is already used in the Pei phase, and is available in the Dxe phase as it is marked as either EfiBootServicesData or EfiACPIMemoryNVS. However, the work area will be inaccessible when SetVirtualAddressMap() is called, so we only read the work area in the Dxe phase through a constructor function. Signed-off-by: John Berg <jhnberg@amazon.co.uk> Signed-off-by: Ivan Orlov <iorlov@amazon.co.uk>
59 lines
1.5 KiB
INI
59 lines
1.5 KiB
INI
## @file
|
|
# Library provides the helper functions for SEV guest
|
|
#
|
|
# Copyright (c) 2017 - 2024, Advanced Micro Devices. All rights reserved.<BR>
|
|
#
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
#
|
|
#
|
|
##
|
|
|
|
[Defines]
|
|
INF_VERSION = 1.25
|
|
BASE_NAME = DxeMemEncryptSevLib
|
|
FILE_GUID = c1594631-3888-4be4-949f-9c630dbc842b
|
|
MODULE_TYPE = BASE
|
|
VERSION_STRING = 1.0
|
|
LIBRARY_CLASS = MemEncryptSevLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_DRIVER
|
|
CONSTRUCTOR = DxeMemEncryptSevLibConstructor
|
|
|
|
#
|
|
# The following information is for reference only and not required by the build
|
|
# tools.
|
|
#
|
|
# VALID_ARCHITECTURES = X64
|
|
#
|
|
|
|
[Packages]
|
|
MdeModulePkg/MdeModulePkg.dec
|
|
MdePkg/MdePkg.dec
|
|
OvmfPkg/OvmfPkg.dec
|
|
UefiCpuPkg/UefiCpuPkg.dec
|
|
|
|
[Sources]
|
|
DxeMemEncryptSevLibInternal.c
|
|
PeiDxeMemEncryptSevLibInternal.c
|
|
PeiDxeMemEncryptSevLibInternal.h
|
|
X64/DxeSnpSystemRamValidate.c
|
|
X64/MemEncryptSevLib.c
|
|
X64/PeiDxeVirtualMemory.c
|
|
X64/SnpPageStateChangeInternal.c
|
|
X64/VirtualMemory.c
|
|
X64/VirtualMemory.h
|
|
|
|
[LibraryClasses]
|
|
BaseLib
|
|
CacheMaintenanceLib
|
|
CpuLib
|
|
DebugLib
|
|
MemoryAllocationLib
|
|
PcdLib
|
|
CcExitLib
|
|
AmdSvsmLib
|
|
|
|
[FeaturePcd]
|
|
gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
|
|
|
|
[FixedPcd]
|
|
gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase
|
|
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
|