Compare commits
16 Commits
edk2-stabl
...
edk2-stabl
Author | SHA1 | Date | |
---|---|---|---|
16779ede2d | |||
07c0c2eb0a | |||
9c733f0b90 | |||
a21a3438f7 | |||
a72d552f19 | |||
1f026ababf | |||
a7d3d4e7c4 | |||
a69eac7578 | |||
524a15c1fa | |||
8db39c60cd | |||
4dbebc2d10 | |||
60b519456c | |||
0903042b66 | |||
2189c71026 | |||
7b126978e1 | |||
2d1138a1a8 |
@ -17,6 +17,6 @@ steps:
|
||||
#checkLatest: false # Optional
|
||||
condition: and(gt(variables.pkg_count, 0), succeeded())
|
||||
|
||||
- script: npm install -g cspell
|
||||
- script: npm install -g cspell@5.20.0
|
||||
displayName: 'Install cspell npm'
|
||||
condition: and(gt(variables.pkg_count, 0), succeeded())
|
||||
|
@ -21,7 +21,7 @@
|
||||
"*.jpg"
|
||||
],
|
||||
"minWordLength": 5,
|
||||
"allowCompoundWords": false,
|
||||
"allowCompoundWords": true,
|
||||
"maxNumberOfProblems": 200,
|
||||
"maxDuplicateProblems": 200,
|
||||
"ignoreWords": [
|
||||
@ -178,6 +178,117 @@
|
||||
"vcruntimed",
|
||||
"ucrtd",
|
||||
"msvcrtd",
|
||||
"XIPFLAGS"
|
||||
"XIPFLAGS",
|
||||
"bootflow",
|
||||
"bootup",
|
||||
"cacheability",
|
||||
"cachetype",
|
||||
"conout",
|
||||
"deadloop",
|
||||
"devicepath",
|
||||
"hisilicon",
|
||||
"littleendian",
|
||||
"nonsecure",
|
||||
"pagetable",
|
||||
"postmem",
|
||||
"premem",
|
||||
"reglist",
|
||||
"semihalf",
|
||||
"subvendor",
|
||||
"subhierarchy",
|
||||
"targetlist",
|
||||
"tmpname",
|
||||
"watchdogtimer",
|
||||
"writeback",
|
||||
"langcode",
|
||||
"langcodes",
|
||||
"autoreload",
|
||||
"bootable",
|
||||
"endiannness",
|
||||
"fvmain",
|
||||
"prefetchable",
|
||||
"multiboot",
|
||||
"ramdisk",
|
||||
"unbootable",
|
||||
"setjump",
|
||||
"bytecodes",
|
||||
"bytelist",
|
||||
"bytestream",
|
||||
"countof",
|
||||
"deregistering",
|
||||
"devicetree",
|
||||
"mainpage",
|
||||
"mismanipulation",
|
||||
"pytool",
|
||||
"wbinvd",
|
||||
"armltd",
|
||||
"datacache",
|
||||
"lastattemptstatus",
|
||||
"lastattemptversion",
|
||||
"lowestsupportedversion",
|
||||
"updateable",
|
||||
"pecoff",
|
||||
"autodetect",
|
||||
"harddisk",
|
||||
"toctou",
|
||||
"bugbug",
|
||||
"depexes",
|
||||
"fwvol",
|
||||
"hoblist",
|
||||
"imagehandle",
|
||||
"schedulable",
|
||||
"StandaloneMMCore",
|
||||
"systemtable",
|
||||
"uncacheable",
|
||||
"devpath",
|
||||
"testsuites",
|
||||
"testcase",
|
||||
"pxmldoc",
|
||||
"pcxml",
|
||||
"pclutf",
|
||||
"pcunicode",
|
||||
"ntxmltransformcharacter",
|
||||
"ntxmlcomparestrings",
|
||||
"pcxmldoc",
|
||||
"ntxmlfetchcharacterdecoder",
|
||||
"ntxml",
|
||||
"ntxmlspecialstringcompare",
|
||||
"rtlxmlcallback",
|
||||
"xmlef",
|
||||
"osruntime",
|
||||
"readytoboot",
|
||||
"hwerrrec",
|
||||
"xformed",
|
||||
"xform",
|
||||
"undock",
|
||||
"qrencoder",
|
||||
"selawik",
|
||||
"ntxmlrawnextcharacter",
|
||||
"undocked",
|
||||
"reprompt",
|
||||
"yesno",
|
||||
"okcancel",
|
||||
"qrencoding",
|
||||
"qrlevel",
|
||||
"shiftn",
|
||||
"unenroll",
|
||||
"pcxmlstructure",
|
||||
"pxmlstructure",
|
||||
"pcencoder",
|
||||
"pcvoid",
|
||||
"nofailure",
|
||||
"blockio",
|
||||
"lockv",
|
||||
"uefishelldebug",
|
||||
"mtrrcap",
|
||||
"drhds",
|
||||
"rmrrs",
|
||||
"creatorid",
|
||||
"dxeipl",
|
||||
"swmdialogs",
|
||||
"unrecovered",
|
||||
"cmocka",
|
||||
"unenrolling",
|
||||
"unconfigure"
|
||||
]
|
||||
}
|
||||
|
@ -176,6 +176,7 @@
|
||||
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
|
||||
!endif
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
|
||||
|
@ -122,6 +122,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
|
||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
|
||||
|
111
MdeModulePkg/Include/Guid/VariableFlashInfo.h
Normal file
111
MdeModulePkg/Include/Guid/VariableFlashInfo.h
Normal file
@ -0,0 +1,111 @@
|
||||
/** @file
|
||||
This file defines the GUID and data structure used to pass information about
|
||||
a variable store mapped on flash (i.e. a MMIO firmware volume) to the modules
|
||||
that consume that information such as the DXE and MM UEFI variable drivers.
|
||||
|
||||
The HOB described in this file is currently optional. It is primarily provided
|
||||
to allow a platform to dynamically describe the flash information to environments
|
||||
such as Standalone MM that cannot access the prior method using dynamic PCDs.
|
||||
|
||||
Even for platforms that use Standalone MM, if the information is only stored
|
||||
statically such as with FixedAtBuild PCDs, the HOB is not required.
|
||||
|
||||
Every point of consumption in this package that uses the PCDs will first check
|
||||
for the HOB and use its value if present.
|
||||
|
||||
Early modules such as the PEI UEFI variable driver might also consume this
|
||||
information. For modules such as these, that execute early in the boot flow,
|
||||
at least two approaches are possible depending on platform design.
|
||||
|
||||
1. If the information in the HOB exactly matches the information in the PCDs,
|
||||
(i.e. the HOB values are set using the PCD values), let the driver read
|
||||
the information from the PCD and produce the HOB later in boot.
|
||||
|
||||
2. Produce the HOB very early in boot. For example, the earliest point the HOB
|
||||
is currently consumed is in FaultTolerantWritePei. Note that FaultTolerantWritePei
|
||||
produces gEdkiiFaultTolerantWriteGuid which is a dependency for VariablePei.
|
||||
|
||||
Therefore, attaching a NULL class library to FaultTolerantWritePei with a
|
||||
constructor that produces the HOB will guarantee it is produced before the first
|
||||
point of consumption as the constructor is executed before the module entry point.
|
||||
|
||||
Copyright (c) Microsoft Corporation.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef VARIABLE_FLASH_INFO_H_
|
||||
#define VARIABLE_FLASH_INFO_H_
|
||||
|
||||
#define VARIABLE_FLASH_INFO_HOB_GUID \
|
||||
{ 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 0xfb, 0xa2, 0x89, 0x20, 0xfc, 0x90 }}
|
||||
|
||||
#define VARIABLE_FLASH_INFO_HOB_VERSION 1
|
||||
|
||||
extern EFI_GUID gVariableFlashInfoHobGuid;
|
||||
|
||||
#pragma pack (push, 1)
|
||||
|
||||
///
|
||||
/// This structure can be used to describe UEFI variable
|
||||
/// flash information.
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// Version of this structure.
|
||||
///
|
||||
/// Increment the value when the structure is modified.
|
||||
///
|
||||
UINT32 Version;
|
||||
///
|
||||
/// Reserved field.
|
||||
///
|
||||
/// Currently reserved for natural alignment.
|
||||
///
|
||||
UINT32 Reserved;
|
||||
///
|
||||
/// Base address of the non-volatile variable range in the flash device.
|
||||
///
|
||||
/// Note that this address should align with the block size requirements of the flash device.
|
||||
///
|
||||
EFI_PHYSICAL_ADDRESS NvVariableBaseAddress;
|
||||
///
|
||||
/// Size of the non-volatile variable range in the flash device.
|
||||
///
|
||||
/// Note that this value should be less than or equal to FtwSpareLength to support reclaim of
|
||||
/// entire variable store area.
|
||||
/// Note that this address should align with the block size requirements of the flash device.
|
||||
///
|
||||
UINT64 NvVariableLength;
|
||||
///
|
||||
/// Base address of the FTW spare block range in the flash device.
|
||||
///
|
||||
/// Note that this address should align with the block size requirements of the flash device.
|
||||
///
|
||||
EFI_PHYSICAL_ADDRESS FtwSpareBaseAddress;
|
||||
///
|
||||
/// Size of the FTW spare block range in the flash device.
|
||||
///
|
||||
/// Note that this value should be greater than or equal to NvVariableLength.
|
||||
/// Note that this address should align with the block size requirements of the flash device.
|
||||
///
|
||||
UINT64 FtwSpareLength;
|
||||
///
|
||||
/// Base address of the FTW working block range in the flash device.
|
||||
///
|
||||
/// Note that if FtwWorkingLength is larger than on block size, this value should be block size aligned.
|
||||
///
|
||||
EFI_PHYSICAL_ADDRESS FtwWorkingBaseAddress;
|
||||
///
|
||||
/// Size of the FTW working block range in the flash device.
|
||||
///
|
||||
/// Note that if the value is less than on block size, the range should not span blocks.
|
||||
/// Note that if the value is larger than one block size, this value should be block size aligned.
|
||||
///
|
||||
UINT64 FtwWorkingLength;
|
||||
} VARIABLE_FLASH_INFO;
|
||||
|
||||
#pragma pack (pop)
|
||||
|
||||
#endif
|
68
MdeModulePkg/Include/Library/VariableFlashInfoLib.h
Normal file
68
MdeModulePkg/Include/Library/VariableFlashInfoLib.h
Normal file
@ -0,0 +1,68 @@
|
||||
/** @file
|
||||
Variable Flash Information Library
|
||||
|
||||
Copyright (c) Microsoft Corporation<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef VARIABLE_FLASH_INFO_LIB_H_
|
||||
#define VARIABLE_FLASH_INFO_LIB_H_
|
||||
|
||||
/**
|
||||
Get the base address and size for the NV storage area used for UEFI variable storage.
|
||||
|
||||
@param[out] BaseAddress The NV storage base address.
|
||||
@param[out] Length The NV storage length in bytes.
|
||||
|
||||
@retval EFI_SUCCESS NV storage information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
|
||||
@retval EFI_NOT_FOUND NV storage information could not be found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetVariableFlashNvStorageInfo (
|
||||
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||
OUT UINT64 *Length
|
||||
);
|
||||
|
||||
/**
|
||||
Get the base address and size for the fault tolerant write (FTW) spare
|
||||
area used for UEFI variable storage.
|
||||
|
||||
@param[out] BaseAddress The FTW spare base address.
|
||||
@param[out] Length The FTW spare length in bytes.
|
||||
|
||||
@retval EFI_SUCCESS FTW spare information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
|
||||
@retval EFI_NOT_FOUND FTW spare information could not be found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetVariableFlashFtwSpareInfo (
|
||||
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||
OUT UINT64 *Length
|
||||
);
|
||||
|
||||
/**
|
||||
Get the base address and size for the fault tolerant write (FTW) working
|
||||
area used for UEFI variable storage.
|
||||
|
||||
@param[out] BaseAddress The FTW working area base address.
|
||||
@param[out] Length The FTW working area length in bytes.
|
||||
|
||||
@retval EFI_SUCCESS FTW working information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
|
||||
@retval EFI_NOT_FOUND FTW working information could not be found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetVariableFlashFtwWorkingInfo (
|
||||
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||
OUT UINT64 *Length
|
||||
);
|
||||
|
||||
#endif
|
@ -0,0 +1,179 @@
|
||||
/** @file
|
||||
Variable Flash Information Library
|
||||
|
||||
Copyright (c) Microsoft Corporation<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Pi/PiMultiPhase.h>
|
||||
#include <Guid/VariableFlashInfo.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/VariableFlashInfoLib.h>
|
||||
|
||||
/**
|
||||
Get the HOB that contains variable flash information.
|
||||
|
||||
@param[out] VariableFlashInfo Pointer to a pointer to set to the variable flash information structure.
|
||||
|
||||
@retval EFI_SUCCESS Variable flash information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER The VariableFlashInfo pointer given is NULL.
|
||||
@retval EFI_NOT_FOUND Variable flash information could not be found.
|
||||
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
GetVariableFlashInfoFromHob (
|
||||
OUT VARIABLE_FLASH_INFO **VariableFlashInfo
|
||||
)
|
||||
{
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
|
||||
if (VariableFlashInfo == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
GuidHob = GetFirstGuidHob (&gVariableFlashInfoHobGuid);
|
||||
if (GuidHob == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*VariableFlashInfo = GET_GUID_HOB_DATA (GuidHob);
|
||||
|
||||
//
|
||||
// Assert if more than one variable flash information HOB is present.
|
||||
//
|
||||
DEBUG_CODE (
|
||||
if ((GetNextGuidHob (&gVariableFlashInfoHobGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {
|
||||
DEBUG ((DEBUG_ERROR, "ERROR: Found two variable flash information HOBs\n"));
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the base address and size for the NV storage area used for UEFI variable storage.
|
||||
|
||||
@param[out] BaseAddress The NV storage base address.
|
||||
@param[out] Length The NV storage length in bytes.
|
||||
|
||||
@retval EFI_SUCCESS NV storage information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetVariableFlashNvStorageInfo (
|
||||
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||
OUT UINT64 *Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VARIABLE_FLASH_INFO *VariableFlashInfo;
|
||||
|
||||
if ((BaseAddress == NULL) || (Length == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = GetVariableFlashInfoFromHob (&VariableFlashInfo);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*BaseAddress = VariableFlashInfo->NvVariableBaseAddress;
|
||||
*Length = VariableFlashInfo->NvVariableLength;
|
||||
} else {
|
||||
*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ?
|
||||
PcdGet64 (PcdFlashNvStorageVariableBase64) :
|
||||
PcdGet32 (PcdFlashNvStorageVariableBase)
|
||||
);
|
||||
*Length = (UINT64)PcdGet32 (PcdFlashNvStorageVariableSize);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the base address and size for the fault tolerant write (FTW) spare
|
||||
area used for UEFI variable storage.
|
||||
|
||||
@param[out] BaseAddress The FTW spare base address.
|
||||
@param[out] Length The FTW spare length in bytes.
|
||||
|
||||
@retval EFI_SUCCESS FTW spare information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
|
||||
@retval EFI_NOT_FOUND FTW spare information could not be found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetVariableFlashFtwSpareInfo (
|
||||
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||
OUT UINT64 *Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VARIABLE_FLASH_INFO *VariableFlashInfo;
|
||||
|
||||
if ((BaseAddress == NULL) || (Length == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = GetVariableFlashInfoFromHob (&VariableFlashInfo);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*BaseAddress = VariableFlashInfo->FtwSpareBaseAddress;
|
||||
*Length = VariableFlashInfo->FtwSpareLength;
|
||||
} else {
|
||||
*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageFtwSpareBase64) != 0 ?
|
||||
PcdGet64 (PcdFlashNvStorageFtwSpareBase64) :
|
||||
PcdGet32 (PcdFlashNvStorageFtwSpareBase)
|
||||
);
|
||||
*Length = (UINT64)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the base address and size for the fault tolerant write (FTW) working
|
||||
area used for UEFI variable storage.
|
||||
|
||||
@param[out] BaseAddress The FTW working area base address.
|
||||
@param[out] Length The FTW working area length in bytes.
|
||||
|
||||
@retval EFI_SUCCESS FTW working information was found successfully.
|
||||
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
|
||||
@retval EFI_NOT_FOUND FTW working information could not be found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetVariableFlashFtwWorkingInfo (
|
||||
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||
OUT UINT64 *Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VARIABLE_FLASH_INFO *VariableFlashInfo;
|
||||
|
||||
if ((BaseAddress == NULL) || (Length == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = GetVariableFlashInfoFromHob (&VariableFlashInfo);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*BaseAddress = VariableFlashInfo->FtwWorkingBaseAddress;
|
||||
*Length = VariableFlashInfo->FtwWorkingLength;
|
||||
} else {
|
||||
*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) != 0 ?
|
||||
PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) :
|
||||
PcdGet32 (PcdFlashNvStorageFtwWorkingBase)
|
||||
);
|
||||
*Length = (UINT64)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
## @file
|
||||
# Variable Flash Information Library
|
||||
#
|
||||
# Provides services to access UEFI variable flash information.
|
||||
#
|
||||
# Copyright (c) Microsoft Corporation<BR>
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = BaseVariableFlashInfoLib
|
||||
MODULE_UNI_FILE = BaseVariableFlashInfoLib.uni
|
||||
FILE_GUID = DEC426C9-C92E-4BAD-8E93-3F61C261118B
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = VariableFlashInfoLib
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = ANY
|
||||
#
|
||||
|
||||
[Sources]
|
||||
BaseVariableFlashInfoLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
HobLib
|
||||
|
||||
[Guids]
|
||||
gVariableFlashInfoHobGuid ## CONSUMES ## HOB
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## SOMETIMES_CONSUMES
|
@ -0,0 +1,12 @@
|
||||
// /** @file
|
||||
// Variable Flash Information Library
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "UEFI variable flash information library"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "Provides services to access UEFI variable flash information."
|
@ -154,6 +154,10 @@
|
||||
#
|
||||
VariablePolicyHelperLib|Include/Library/VariablePolicyHelperLib.h
|
||||
|
||||
## @libraryclass Provides services to access UEFI variable flash information.
|
||||
#
|
||||
VariableFlashInfoLib|Include/Library/VariableFlashInfoLib.h
|
||||
|
||||
[Guids]
|
||||
## MdeModule package token space guid
|
||||
# Include/Guid/MdeModulePkgTokenSpace.h
|
||||
@ -226,6 +230,10 @@
|
||||
# Include/Guid/SmmVariableCommon.h
|
||||
gSmmVariableWriteGuid = { 0x93ba1826, 0xdffb, 0x45dd, { 0x82, 0xa7, 0xe7, 0xdc, 0xaa, 0x3b, 0xbd, 0xf3 }}
|
||||
|
||||
## Guid of the variable flash information HOB.
|
||||
# Include/Guid/VariableFlashInfo.h
|
||||
gVariableFlashInfoHobGuid = { 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 0xfb, 0xa2, 0x89, 0x20, 0xfc, 0x90 }}
|
||||
|
||||
## Performance protocol guid that also acts as the performance HOB guid and performance variable GUID
|
||||
# Include/Guid/Performance.h
|
||||
gPerformanceProtocolGuid = { 0x76B6BDFA, 0x2ACD, 0x4462, { 0x9E, 0x3F, 0xCB, 0x58, 0xC9, 0x69, 0xD9, 0x37 } }
|
||||
|
@ -103,6 +103,7 @@
|
||||
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
[LibraryClasses.EBC.PEIM]
|
||||
IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
|
||||
@ -440,6 +441,7 @@
|
||||
MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.inf
|
||||
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
|
||||
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
|
||||
MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
[Components.IA32, Components.X64, Components.AARCH64]
|
||||
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
|
@ -26,6 +26,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/SafeIntLib.h>
|
||||
#include <Library/VariableFlashInfoLib.h>
|
||||
|
||||
//
|
||||
// Flash erase polarity is 1
|
||||
@ -708,10 +710,13 @@ InitFtwProtocol (
|
||||
|
||||
Since Signature and WriteQueueSize have been known, Crc can be calculated out,
|
||||
then the work space header will be fixed.
|
||||
|
||||
@param[in] WorkSpaceLength Length in bytes of the FTW workspace area.
|
||||
|
||||
**/
|
||||
VOID
|
||||
InitializeLocalWorkSpaceHeader (
|
||||
VOID
|
||||
IN UINTN WorkSpaceLength
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -46,6 +46,8 @@
|
||||
UefiLib
|
||||
PcdLib
|
||||
ReportStatusCodeLib
|
||||
SafeIntLib
|
||||
VariableFlashInfoLib
|
||||
|
||||
[Guids]
|
||||
#
|
||||
@ -65,14 +67,6 @@
|
||||
[FeaturePcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
||||
|
||||
#
|
||||
# gBS->CalculateCrc32() is consumed in EntryPoint.
|
||||
# PI spec said: When the DXE Foundation is notified that the EFI_RUNTIME_ARCH_PROTOCOL
|
||||
|
@ -52,6 +52,8 @@
|
||||
ReportStatusCodeLib
|
||||
SmmMemLib
|
||||
BaseLib
|
||||
SafeIntLib
|
||||
VariableFlashInfoLib
|
||||
|
||||
[Guids]
|
||||
#
|
||||
@ -74,14 +76,6 @@
|
||||
[FeaturePcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
||||
|
||||
#
|
||||
# gBS->CalculateCrc32() is consumed in EntryPoint.
|
||||
# PI spec said: When the DXE Foundation is notified that the EFI_RUNTIME_ARCH_PROTOCOL
|
||||
|
@ -50,7 +50,9 @@
|
||||
MmServicesTableLib
|
||||
PcdLib
|
||||
ReportStatusCodeLib
|
||||
SafeIntLib
|
||||
StandaloneMmDriverEntryPoint
|
||||
VariableFlashInfoLib
|
||||
|
||||
[Guids]
|
||||
#
|
||||
@ -73,13 +75,5 @@
|
||||
[FeaturePcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
|
@ -987,22 +987,43 @@ InitFtwDevice (
|
||||
OUT EFI_FTW_DEVICE **FtwData
|
||||
)
|
||||
{
|
||||
EFI_FTW_DEVICE *FtwDevice;
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS WorkSpaceAddress;
|
||||
UINT64 Size;
|
||||
UINTN FtwWorkingSize;
|
||||
EFI_FTW_DEVICE *FtwDevice;
|
||||
|
||||
FtwWorkingSize = 0;
|
||||
|
||||
Status = GetVariableFlashFtwWorkingInfo (&WorkSpaceAddress, &Size);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUintn (Size, &FtwWorkingSize);
|
||||
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Allocate private data of this driver,
|
||||
// Including the FtwWorkSpace[FTW_WORK_SPACE_SIZE].
|
||||
//
|
||||
FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize));
|
||||
FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + FtwWorkingSize);
|
||||
if (FtwDevice == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
FtwDevice->WorkSpaceAddress = WorkSpaceAddress;
|
||||
FtwDevice->WorkSpaceLength = FtwWorkingSize;
|
||||
|
||||
Status = GetVariableFlashFtwSpareInfo (&FtwDevice->SpareAreaAddress, &Size);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUintn (Size, &FtwDevice->SpareAreaLength);
|
||||
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE.
|
||||
//
|
||||
FtwDevice->WorkSpaceLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||
FtwDevice->SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
if ((FtwDevice->WorkSpaceLength == 0) || (FtwDevice->SpareAreaLength == 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "Ftw: Workspace or Spare block does not exist!\n"));
|
||||
FreePool (FtwDevice);
|
||||
@ -1015,16 +1036,6 @@ InitFtwDevice (
|
||||
FtwDevice->FtwWorkSpaceLba = (EFI_LBA)(-1);
|
||||
FtwDevice->FtwSpareLba = (EFI_LBA)(-1);
|
||||
|
||||
FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwWorkingBase64);
|
||||
if (FtwDevice->WorkSpaceAddress == 0) {
|
||||
FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
|
||||
}
|
||||
|
||||
FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwSpareBase64);
|
||||
if (FtwDevice->SpareAreaAddress == 0) {
|
||||
FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwSpareBase);
|
||||
}
|
||||
|
||||
*FtwData = FtwDevice;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1277,7 +1288,7 @@ InitFtwProtocol (
|
||||
FtwDevice->FtwLastWriteHeader = NULL;
|
||||
FtwDevice->FtwLastWriteRecord = NULL;
|
||||
|
||||
InitializeLocalWorkSpaceHeader ();
|
||||
InitializeLocalWorkSpaceHeader (FtwDevice->WorkSpaceLength);
|
||||
|
||||
//
|
||||
// Refresh the working space data from working block
|
||||
|
@ -16,10 +16,13 @@ EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER mWorkingBlockHeader = { ZERO_GUID, 0, 0
|
||||
|
||||
Since Signature and WriteQueueSize have been known, Crc can be calculated out,
|
||||
then the work space header will be fixed.
|
||||
|
||||
@param[in] WorkSpaceLength Length in bytes of the FTW workspace area.
|
||||
|
||||
**/
|
||||
VOID
|
||||
InitializeLocalWorkSpaceHeader (
|
||||
VOID
|
||||
IN UINTN WorkSpaceLength
|
||||
)
|
||||
{
|
||||
//
|
||||
@ -46,7 +49,7 @@ InitializeLocalWorkSpaceHeader (
|
||||
&gEdkiiWorkingBlockSignatureGuid,
|
||||
sizeof (EFI_GUID)
|
||||
);
|
||||
mWorkingBlockHeader.WriteQueueSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);
|
||||
mWorkingBlockHeader.WriteQueueSize = WorkSpaceLength - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);
|
||||
|
||||
//
|
||||
// Crc is calculated with all the fields except Crc and STATE, so leave them as FTW_ERASED_BYTE.
|
||||
|
@ -16,6 +16,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/SafeIntLib.h>
|
||||
#include <Library/VariableFlashInfoLib.h>
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
|
||||
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||
@ -212,25 +214,31 @@ PeimFaultTolerantWriteInitialize (
|
||||
EFI_PHYSICAL_ADDRESS SpareAreaAddress;
|
||||
UINTN SpareAreaLength;
|
||||
EFI_PHYSICAL_ADDRESS WorkSpaceInSpareArea;
|
||||
UINT64 Size;
|
||||
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA FtwLastWrite;
|
||||
|
||||
FtwWorkingBlockHeader = NULL;
|
||||
FtwLastWriteHeader = NULL;
|
||||
FtwLastWriteRecord = NULL;
|
||||
|
||||
WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwWorkingBase64);
|
||||
if (WorkSpaceAddress == 0) {
|
||||
WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
|
||||
}
|
||||
SpareAreaAddress = 0;
|
||||
SpareAreaLength = 0;
|
||||
WorkSpaceAddress = 0;
|
||||
WorkSpaceLength = 0;
|
||||
|
||||
WorkSpaceLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||
Status = GetVariableFlashFtwWorkingInfo (&WorkSpaceAddress, &Size);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwSpareBase64);
|
||||
if (SpareAreaAddress == 0) {
|
||||
SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwSpareBase);
|
||||
}
|
||||
Status = SafeUint64ToUintn (Size, &WorkSpaceLength);
|
||||
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
Status = GetVariableFlashFtwSpareInfo (&SpareAreaAddress, &Size);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUintn (Size, &SpareAreaLength);
|
||||
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// The address of FTW working base and spare base must not be 0.
|
||||
|
@ -39,6 +39,8 @@
|
||||
HobLib
|
||||
BaseMemoryLib
|
||||
PcdLib
|
||||
SafeIntLib
|
||||
VariableFlashInfoLib
|
||||
|
||||
[Guids]
|
||||
## SOMETIMES_PRODUCES ## HOB
|
||||
@ -47,14 +49,6 @@
|
||||
gEdkiiWorkingBlockSignatureGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiSystemNvDataFvGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
|
||||
|
@ -567,11 +567,13 @@ GetVariableStore (
|
||||
OUT VARIABLE_STORE_INFO *StoreInfo
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
||||
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
||||
EFI_PHYSICAL_ADDRESS NvStorageBase;
|
||||
UINT32 NvStorageSize;
|
||||
UINT64 NvStorageSize64;
|
||||
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData;
|
||||
UINT32 BackUpOffset;
|
||||
|
||||
@ -591,11 +593,13 @@ GetVariableStore (
|
||||
// Emulated non-volatile variable mode is not enabled.
|
||||
//
|
||||
|
||||
NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
|
||||
NvStorageBase = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ?
|
||||
PcdGet64 (PcdFlashNvStorageVariableBase64) :
|
||||
PcdGet32 (PcdFlashNvStorageVariableBase)
|
||||
);
|
||||
Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize);
|
||||
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
ASSERT (NvStorageBase != 0);
|
||||
|
||||
//
|
||||
|
@ -20,6 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/SafeIntLib.h>
|
||||
#include <Library/VariableFlashInfoLib.h>
|
||||
|
||||
#include <Guid/VariableFormat.h>
|
||||
#include <Guid/VariableIndexTable.h>
|
||||
|
@ -39,6 +39,8 @@
|
||||
DebugLib
|
||||
PeiServicesTablePointerLib
|
||||
PeiServicesLib
|
||||
SafeIntLib
|
||||
VariableFlashInfoLib
|
||||
|
||||
[Guids]
|
||||
## CONSUMES ## GUID # Variable store header
|
||||
@ -59,9 +61,6 @@
|
||||
gEfiPeiReadOnlyVariable2PpiGuid ## PRODUCES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable ## SOMETIMES_CONSUMES
|
||||
|
||||
[Depex]
|
||||
|
@ -31,6 +31,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/AuthVariableLib.h>
|
||||
#include <Library/VarCheckLib.h>
|
||||
#include <Library/VariableFlashInfoLib.h>
|
||||
#include <Library/SafeIntLib.h>
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/VariableFormat.h>
|
||||
@ -40,11 +42,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PrivilegePolymorphic.h"
|
||||
|
||||
#define NV_STORAGE_VARIABLE_BASE (EFI_PHYSICAL_ADDRESS)\
|
||||
(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \
|
||||
PcdGet64 (PcdFlashNvStorageVariableBase64) : \
|
||||
PcdGet32 (PcdFlashNvStorageVariableBase))
|
||||
|
||||
#define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE |\
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
|
||||
EFI_VARIABLE_RUNTIME_ACCESS | \
|
||||
|
@ -423,6 +423,8 @@ FtwNotificationEvent (
|
||||
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
||||
UINT64 VariableStoreLength;
|
||||
UINTN FtwMaxBlockSize;
|
||||
UINT32 NvStorageVariableSize;
|
||||
UINT64 NvStorageVariableSize64;
|
||||
|
||||
//
|
||||
// Ensure FTW protocol is installed.
|
||||
@ -432,14 +434,20 @@ FtwNotificationEvent (
|
||||
return;
|
||||
}
|
||||
|
||||
Status = GetVariableFlashNvStorageInfo (&NvStorageVariableBase, &NvStorageVariableSize64);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUint32 (NvStorageVariableSize64, &NvStorageVariableSize);
|
||||
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
||||
|
||||
Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
||||
ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);
|
||||
}
|
||||
|
||||
NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
|
||||
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
||||
|
||||
//
|
||||
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
|
||||
//
|
||||
|
@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore (
|
||||
EFI_PHYSICAL_ADDRESS NvStorageBase;
|
||||
UINT8 *NvStorageData;
|
||||
UINT32 NvStorageSize;
|
||||
UINT64 NvStorageSize64;
|
||||
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData;
|
||||
UINT32 BackUpOffset;
|
||||
UINT32 BackUpSize;
|
||||
@ -153,19 +154,24 @@ InitRealNonVolatileVariableStore (
|
||||
|
||||
mVariableModuleGlobal->FvbInstance = NULL;
|
||||
|
||||
Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize);
|
||||
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
ASSERT (NvStorageBase != 0);
|
||||
|
||||
//
|
||||
// Allocate runtime memory used for a memory copy of the FLASH region.
|
||||
// Keep the memory and the FLASH in sync as updates occur.
|
||||
//
|
||||
NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
|
||||
NvStorageData = AllocateRuntimeZeroPool (NvStorageSize);
|
||||
if (NvStorageData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
NvStorageBase = NV_STORAGE_VARIABLE_BASE;
|
||||
ASSERT (NvStorageBase != 0);
|
||||
|
||||
//
|
||||
// Copy NV storage data to the memory buffer.
|
||||
//
|
||||
|
@ -71,8 +71,10 @@
|
||||
TpmMeasurementLib
|
||||
AuthVariableLib
|
||||
VarCheckLib
|
||||
VariableFlashInfoLib
|
||||
VariablePolicyLib
|
||||
VariablePolicyHelperLib
|
||||
SafeIntLib
|
||||
|
||||
[Protocols]
|
||||
gEfiFirmwareVolumeBlockProtocolGuid ## CONSUMES
|
||||
@ -125,9 +127,6 @@
|
||||
gEfiImageSecurityDatabaseGuid
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES
|
||||
|
@ -1084,6 +1084,8 @@ SmmFtwNotificationEvent (
|
||||
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
||||
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
||||
UINTN FtwMaxBlockSize;
|
||||
UINT32 NvStorageVariableSize;
|
||||
UINT64 NvStorageVariableSize64;
|
||||
|
||||
if (mVariableModuleGlobal->FvbInstance != NULL) {
|
||||
return EFI_SUCCESS;
|
||||
@ -1097,14 +1099,21 @@ SmmFtwNotificationEvent (
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = GetVariableFlashNvStorageInfo (&NvStorageVariableBase, &NvStorageVariableSize64);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SafeUint64ToUint32 (NvStorageVariableSize64, &NvStorageVariableSize);
|
||||
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
ASSERT (NvStorageVariableBase != 0);
|
||||
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
||||
|
||||
Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
||||
ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);
|
||||
}
|
||||
|
||||
NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
|
||||
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
||||
|
||||
//
|
||||
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
|
||||
//
|
||||
|
@ -80,8 +80,10 @@
|
||||
AuthVariableLib
|
||||
VarCheckLib
|
||||
UefiBootServicesTableLib
|
||||
VariableFlashInfoLib
|
||||
VariablePolicyLib
|
||||
VariablePolicyHelperLib
|
||||
SafeIntLib
|
||||
|
||||
[Protocols]
|
||||
gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
|
||||
@ -127,9 +129,6 @@
|
||||
gEdkiiVarErrorFlagGuid
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES
|
||||
|
@ -73,9 +73,11 @@
|
||||
HobLib
|
||||
MemoryAllocationLib
|
||||
MmServicesTableLib
|
||||
SafeIntLib
|
||||
StandaloneMmDriverEntryPoint
|
||||
SynchronizationLib
|
||||
VarCheckLib
|
||||
VariableFlashInfoLib
|
||||
VariablePolicyLib
|
||||
VariablePolicyHelperLib
|
||||
|
||||
@ -120,9 +122,6 @@
|
||||
gEdkiiVarErrorFlagGuid
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES
|
||||
|
@ -196,6 +196,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
!if $(BUILD_SHELL) == TRUE
|
||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||
@ -577,7 +578,7 @@
|
||||
|
||||
!include OvmfPkg/OvmfTpmPcds.dsc.inc
|
||||
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
|
||||
|
||||
[PcdsDynamicHii]
|
||||
!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
|
||||
|
@ -206,6 +206,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
#
|
||||
# Network libraries
|
||||
|
@ -217,6 +217,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
|
||||
#
|
||||
|
@ -190,6 +190,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||
ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
|
||||
@ -510,7 +511,7 @@
|
||||
# Set ConfidentialComputing defaults
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
|
||||
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
|
||||
|
||||
################################################################################
|
||||
#
|
||||
|
@ -207,6 +207,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
|
||||
#
|
||||
|
@ -214,6 +214,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
|
||||
#
|
||||
@ -650,7 +651,7 @@
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
|
||||
|
||||
!if $(CSM_ENABLE) == FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
|
||||
!endif
|
||||
|
||||
[PcdsDynamicHii]
|
||||
|
@ -76,6 +76,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.
|
||||
0x007000|0x001000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
|
||||
|
||||
0x008000|0x001000
|
||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize
|
||||
|
||||
0x010000|0x010000
|
||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
|
||||
|
||||
@ -87,6 +90,14 @@ FV = PEIFV
|
||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
|
||||
FV = DXEFV
|
||||
|
||||
##########################################################################################
|
||||
# Set the SEV-ES specific work area PCDs (used for all forms of SEV since the
|
||||
# the SEV STATUS MSR is now saved in the work area)
|
||||
#
|
||||
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
|
||||
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
|
||||
##########################################################################################
|
||||
|
||||
################################################################################
|
||||
|
||||
[FV.SECFV]
|
||||
|
@ -218,6 +218,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
|
||||
#
|
||||
@ -658,7 +659,7 @@
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
|
||||
|
||||
!if $(CSM_ENABLE) == FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
|
||||
!endif
|
||||
|
||||
[PcdsDynamicDefault.X64]
|
||||
|
@ -90,6 +90,14 @@ FV = PEIFV
|
||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
|
||||
FV = DXEFV
|
||||
|
||||
##########################################################################################
|
||||
# Set the SEV-ES specific work area PCDs (used for all forms of SEV since the
|
||||
# the SEV STATUS MSR is now saved in the work area)
|
||||
#
|
||||
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
|
||||
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
|
||||
##########################################################################################
|
||||
|
||||
################################################################################
|
||||
|
||||
[FV.SECFV]
|
||||
|
@ -171,7 +171,6 @@
|
||||
PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
|
||||
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
|
||||
PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
|
||||
CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
|
||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
|
||||
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
|
||||
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
|
||||
@ -198,6 +197,9 @@
|
||||
|
||||
!if $(SMM_REQUIRE) == FALSE
|
||||
LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
|
||||
CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
|
||||
!else
|
||||
CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf
|
||||
!endif
|
||||
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
|
||||
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
|
||||
@ -232,6 +234,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
|
||||
#
|
||||
@ -681,7 +684,7 @@
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
|
||||
|
||||
!if $(CSM_ENABLE) == FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
|
||||
!endif
|
||||
|
||||
[PcdsDynamicHii]
|
||||
|
@ -106,7 +106,8 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvm
|
||||
FV = DXEFV
|
||||
|
||||
##########################################################################################
|
||||
# Set the SEV-ES specific work area PCDs
|
||||
# Set the SEV-ES specific work area PCDs (used for all forms of SEV since the
|
||||
# the SEV STATUS MSR is now saved in the work area)
|
||||
#
|
||||
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
|
||||
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
|
||||
|
@ -196,6 +196,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
|
||||
|
||||
#
|
||||
|
@ -150,6 +150,8 @@ BITS 32
|
||||
SevEsUnexpectedRespTerminate:
|
||||
TerminateVmgExit TERM_UNEXPECTED_RESP_CODE
|
||||
|
||||
%ifdef ARCH_X64
|
||||
|
||||
; If SEV-ES is enabled then initialize and make the GHCB page shared
|
||||
SevClearPageEncMaskForGhcbPage:
|
||||
; Check if SEV is enabled
|
||||
@ -209,6 +211,8 @@ GetSevCBitMaskAbove31:
|
||||
GetSevCBitMaskAbove31Exit:
|
||||
OneTimeCallRet GetSevCBitMaskAbove31
|
||||
|
||||
%endif
|
||||
|
||||
; Check if Secure Encrypted Virtualization (SEV) features are enabled.
|
||||
;
|
||||
; Register usage is tight in this routine, so multiple calls for the
|
||||
|
@ -75,6 +75,12 @@ SearchBfv:
|
||||
|
||||
%ifdef ARCH_IA32
|
||||
|
||||
;
|
||||
; SEV support can be built and run using the Ia32/X64 split environment.
|
||||
; Set the OVMF/SEV work area as appropriate.
|
||||
;
|
||||
OneTimeCall CheckSevFeatures
|
||||
|
||||
;
|
||||
; Restore initial EAX value into the EAX register
|
||||
;
|
||||
|
@ -47,7 +47,36 @@
|
||||
%include "Ia32/SearchForBfvBase.asm"
|
||||
%include "Ia32/SearchForSecEntry.asm"
|
||||
|
||||
%define WORK_AREA_GUEST_TYPE (FixedPcdGet32 (PcdOvmfWorkAreaBase))
|
||||
%define WORK_AREA_GUEST_TYPE (FixedPcdGet32 (PcdOvmfWorkAreaBase))
|
||||
%define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Offset))
|
||||
|
||||
%define GHCB_PT_ADDR (FixedPcdGet32 (PcdOvmfSecGhcbPageTableBase))
|
||||
%define GHCB_BASE (FixedPcdGet32 (PcdOvmfSecGhcbBase))
|
||||
%define GHCB_SIZE (FixedPcdGet32 (PcdOvmfSecGhcbSize))
|
||||
%define SEV_ES_WORK_AREA (FixedPcdGet32 (PcdSevEsWorkAreaBase))
|
||||
%define SEV_ES_WORK_AREA_SIZE 25
|
||||
%define SEV_ES_WORK_AREA_STATUS_MSR (FixedPcdGet32 (PcdSevEsWorkAreaBase))
|
||||
%define SEV_ES_WORK_AREA_RDRAND (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 8)
|
||||
%define SEV_ES_WORK_AREA_ENC_MASK (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 16)
|
||||
%define SEV_ES_WORK_AREA_RECEIVED_VC (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 24)
|
||||
%define SEV_ES_VC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + FixedPcdGet32 (PcdOvmfSecPeiTempRamSize))
|
||||
%define SEV_SNP_SECRETS_BASE (FixedPcdGet32 (PcdOvmfSnpSecretsBase))
|
||||
%define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSize))
|
||||
%define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase))
|
||||
%define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize))
|
||||
%define SNP_SEC_MEM_BASE_DESC_1 (FixedPcdGet32 (PcdOvmfSecPageTablesBase))
|
||||
%define SNP_SEC_MEM_SIZE_DESC_1 (FixedPcdGet32 (PcdOvmfSecGhcbBase) - SNP_SEC_MEM_BASE_DESC_1)
|
||||
;
|
||||
; The PcdOvmfSecGhcbBase reserves two GHCB pages. The first page is used
|
||||
; as GHCB shared page and second is used for bookkeeping to support the
|
||||
; nested GHCB in SEC phase. The bookkeeping page is mapped private. The VMM
|
||||
; does not need to validate the shared page but it need to validate the
|
||||
; bookkeeping page.
|
||||
;
|
||||
%define SNP_SEC_MEM_BASE_DESC_2 (GHCB_BASE + 0x1000)
|
||||
%define SNP_SEC_MEM_SIZE_DESC_2 (SEV_SNP_SECRETS_BASE - SNP_SEC_MEM_BASE_DESC_2)
|
||||
%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE)
|
||||
%define SNP_SEC_MEM_SIZE_DESC_3 (FixedPcdGet32 (PcdOvmfPeiMemFvBase) - SNP_SEC_MEM_BASE_DESC_3)
|
||||
|
||||
%ifdef ARCH_X64
|
||||
#include <AutoGen.h>
|
||||
@ -94,44 +123,15 @@
|
||||
%define TDX_WORK_AREA_PGTBL_READY (FixedPcdGet32 (PcdOvmfWorkAreaBase) + 4)
|
||||
%define TDX_WORK_AREA_GPAW (FixedPcdGet32 (PcdOvmfWorkAreaBase) + 8)
|
||||
|
||||
%define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Offset))
|
||||
|
||||
%define GHCB_PT_ADDR (FixedPcdGet32 (PcdOvmfSecGhcbPageTableBase))
|
||||
%define GHCB_BASE (FixedPcdGet32 (PcdOvmfSecGhcbBase))
|
||||
%define GHCB_SIZE (FixedPcdGet32 (PcdOvmfSecGhcbSize))
|
||||
%define SEV_ES_WORK_AREA (FixedPcdGet32 (PcdSevEsWorkAreaBase))
|
||||
%define SEV_ES_WORK_AREA_SIZE 25
|
||||
%define SEV_ES_WORK_AREA_STATUS_MSR (FixedPcdGet32 (PcdSevEsWorkAreaBase))
|
||||
%define SEV_ES_WORK_AREA_RDRAND (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 8)
|
||||
%define SEV_ES_WORK_AREA_ENC_MASK (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 16)
|
||||
%define SEV_ES_WORK_AREA_RECEIVED_VC (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 24)
|
||||
%define SEV_ES_VC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + FixedPcdGet32 (PcdOvmfSecPeiTempRamSize))
|
||||
%define SEV_SNP_SECRETS_BASE (FixedPcdGet32 (PcdOvmfSnpSecretsBase))
|
||||
%define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSize))
|
||||
%define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase))
|
||||
%define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize))
|
||||
%define SNP_SEC_MEM_BASE_DESC_1 (FixedPcdGet32 (PcdOvmfSecPageTablesBase))
|
||||
%define SNP_SEC_MEM_SIZE_DESC_1 (FixedPcdGet32 (PcdOvmfSecGhcbBase) - SNP_SEC_MEM_BASE_DESC_1)
|
||||
;
|
||||
; The PcdOvmfSecGhcbBase reserves two GHCB pages. The first page is used
|
||||
; as GHCB shared page and second is used for bookkeeping to support the
|
||||
; nested GHCB in SEC phase. The bookkeeping page is mapped private. The VMM
|
||||
; does not need to validate the shared page but it need to validate the
|
||||
; bookkeeping page.
|
||||
;
|
||||
%define SNP_SEC_MEM_BASE_DESC_2 (GHCB_BASE + 0x1000)
|
||||
%define SNP_SEC_MEM_SIZE_DESC_2 (SEV_SNP_SECRETS_BASE - SNP_SEC_MEM_BASE_DESC_2)
|
||||
%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE)
|
||||
%define SNP_SEC_MEM_SIZE_DESC_3 (FixedPcdGet32 (PcdOvmfPeiMemFvBase) - SNP_SEC_MEM_BASE_DESC_3)
|
||||
|
||||
%include "X64/IntelTdxMetadata.asm"
|
||||
%include "Ia32/Flat32ToFlat64.asm"
|
||||
%include "Ia32/AmdSev.asm"
|
||||
%include "Ia32/PageTables64.asm"
|
||||
%include "Ia32/IntelTdx.asm"
|
||||
%include "X64/OvmfSevMetadata.asm"
|
||||
%include "X64/IntelTdxMetadata.asm"
|
||||
%include "Ia32/Flat32ToFlat64.asm"
|
||||
%include "Ia32/PageTables64.asm"
|
||||
%include "Ia32/IntelTdx.asm"
|
||||
%include "X64/OvmfSevMetadata.asm"
|
||||
%endif
|
||||
|
||||
%include "Ia32/AmdSev.asm"
|
||||
|
||||
%include "Ia16/Real16ToFlat32.asm"
|
||||
%include "Ia16/Init16.asm"
|
||||
|
||||
|
@ -69,7 +69,7 @@ MailBoxWakeUp:
|
||||
mov rax, [rbx + WakeupVectorOffset]
|
||||
; OS sends a wakeup command for a given APIC ID, firmware is supposed to reset
|
||||
; the command field back to zero as acknowledgement.
|
||||
mov qword [rbx + WakeupVectorOffset], 0
|
||||
mov qword [rbx + CommandOffset], 0
|
||||
jmp rax
|
||||
MailBoxSleep:
|
||||
jmp $
|
||||
@ -83,7 +83,7 @@ AsmRelocateApMailBoxLoopEnd:
|
||||
;-------------------------------------------------------------------------------------
|
||||
global ASM_PFX(AsmGetRelocationMap)
|
||||
ASM_PFX(AsmGetRelocationMap):
|
||||
lea rax, [ASM_PFX(AsmRelocateApMailBoxLoopStart)]
|
||||
lea rax, [AsmRelocateApMailBoxLoopStart]
|
||||
mov qword [rcx], rax
|
||||
mov qword [rcx + 8h], AsmRelocateApMailBoxLoopEnd - AsmRelocateApMailBoxLoopStart
|
||||
ret
|
||||
|
@ -272,6 +272,7 @@
|
||||
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
|
||||
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
|
||||
|
||||
|
Reference in New Issue
Block a user