\r
#include <Uefi/UefiBaseType.h>\r
#include <Library/BaseLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
#include <Library/MemEncryptSevLib.h>\r
\r
#include "SnpPageStateChange.h"\r
+#include "VirtualMemory.h"\r
\r
typedef struct {\r
UINT64 StartAddress;\r
{\r
PHYSICAL_ADDRESS EndAddress;\r
SNP_PRE_VALIDATED_RANGE OverlapRange;\r
+ EFI_STATUS Status;\r
\r
if (!MemEncryptSevSnpIsEnabled ()) {\r
return;\r
\r
EndAddress = BaseAddress + EFI_PAGES_TO_SIZE (NumPages);\r
\r
+ //\r
+ // The page table used in PEI can address up to 4GB memory. If we are asked to\r
+ // validate a range above the 4GB, then create an identity mapping so that the\r
+ // PVALIDATE instruction can execute correctly. If the page table entry is not\r
+ // present then PVALIDATE will #GP.\r
+ //\r
+ if (BaseAddress >= SIZE_4GB) {\r
+ Status = InternalMemEncryptSevCreateIdentityMap1G (\r
+ 0,\r
+ BaseAddress,\r
+ EFI_PAGES_TO_SIZE (NumPages)\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ASSERT (FALSE);\r
+ CpuDeadLoop ();\r
+ }\r
+ }\r
+\r
while (BaseAddress < EndAddress) {\r
//\r
// Check if the range overlaps with the pre-validated ranges.\r