29#define EFI_MEMORY_INTERNAL_MASK 0x0700000000000000ULL
33AllocateConfidentialComputingBlob (
34 OUT CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION **CcBlobPtr
38 CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *CcBlob;
40 Status =
gBS->AllocatePool (
42 sizeof (CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION),
45 if (EFI_ERROR (Status)) {
54 CcBlob->Reserved1 = 0;
57 CcBlob->Reserved2 = 0;
107 DEBUG ((DEBUG_INFO,
"Accepting all memory\n"));
113 Status =
gDS->GetMemorySpaceMap (&NumEntries, &AllDescMap);
114 if (EFI_ERROR (Status)) {
118 for (Index = 0; Index < NumEntries; Index++) {
121 Desc = &AllDescMap[Index];
126 Status = AmdSevMemoryAccept (
131 if (EFI_ERROR (Status)) {
135 Status =
gDS->RemoveMemorySpace (Desc->BaseAddress, Desc->Length);
136 if (EFI_ERROR (Status)) {
140 Status =
gDS->AddMemorySpace (
146 Desc->Capabilities & ~(EFI_MEMORY_INTERNAL_MASK | EFI_MEMORY_RUNTIME)
148 if (EFI_ERROR (Status)) {
153 gBS->FreePool (AllDescMap);
154 gBS->CloseEvent (mAcceptAllMemoryEvent);
160ResolveUnacceptedMemory (
167 if (!mAcceptAllMemoryAtEBS) {
171 Status = AcceptAllMemory ();
178AllowUnacceptedMemory (
182 mAcceptAllMemoryAtEBS =
FALSE;
188 mMemoryAcceptanceProtocol = { AllowUnacceptedMemory };
205 CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *SnpBootDxeTable;
211 return EFI_UNSUPPORTED;
221 Status =
gDS->GetMemorySpaceMap (&NumEntries, &AllDescMap);
222 if (!EFI_ERROR (Status)) {
223 for (Index = 0; Index < NumEntries; Index++) {
226 Desc = &AllDescMap[Index];
248 if (
PcdGet16 (PcdOvmfHostBridgePciDevId) == INTEL_Q35_MCH_DEVICE_ID) {
299 if (EFI_ERROR (Status)) {
302 "%a: MemEncryptSevClearPageEncMask(): %r\n",
311 Status = AllocateConfidentialComputingBlob (&SnpBootDxeTable);
312 if (EFI_ERROR (Status)) {
315 "%a: AllocateConfidentialComputingBlob(): %r\n",
328 Status =
gBS->InstallMultipleProtocolInterfaces (
330 &gEdkiiMemoryAcceptProtocolGuid,
331 &mMemoryAcceptProtocol,
332 &gOvmfSevMemoryAcceptanceProtocolGuid,
333 &mMemoryAcceptanceProtocol,
341 Status =
gBS->CreateEventEx (
344 ResolveUnacceptedMemory,
346 &gEfiEventBeforeExitBootServicesGuid,
347 &mAcceptAllMemoryEvent
350 if (EFI_ERROR (Status)) {
351 DEBUG ((DEBUG_ERROR,
"AllowUnacceptedMemory event creation for EventBeforeExitBootServices failed.\n"));
358 return gBS->InstallConfigurationTable (
359 &gConfidentialComputingSevSnpBlobGuid,
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define IS_ALIGNED(Value, Alignment)
#define SIGNATURE_32(A, B, C, D)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
RETURN_STATUS EFIAPI MemEncryptSevClearPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
BOOLEAN EFIAPI MemEncryptSevSnpIsEnabled(VOID)
BOOLEAN EFIAPI MemEncryptSevIsEnabled(VOID)
VOID EFIAPI MemEncryptSevSnpPreValidateSystemRam(IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)
RETURN_STATUS EFIAPI MemEncryptSevClearMmioPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
#define PcdGet16(TokenName)
#define FixedPcdGet32(TokenName)
#define FixedPcdGet64(TokenName)
#define FeaturePcdGet(TokenName)
@ EfiGcdMemoryTypeNonExistent
@ EfiGcdMemoryTypeUnaccepted
@ EfiGcdMemoryTypeSystemMemory
@ EfiGcdMemoryTypeMemoryMappedIo
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)