42 Msr.GhcbPhysicalAddress = 0;
43 Msr.GhcbTerminate.Function = GHCB_INFO_TERMINATE_REQUEST;
44 Msr.GhcbTerminate.ReasonCodeSet = GHCB_TERMINATE_GHCB;
45 Msr.GhcbTerminate.ReasonCode = ReasonCode;
76 if (Msr.Bits.SevSnpBit) {
98 Msr.GhcbPhysicalAddress = Address & ~EFI_PAGE_MASK;
99 Msr.GhcbGpaRegister.Function = GHCB_INFO_GHCB_GPA_REGISTER_REQUEST;
109 if ((Msr.GhcbGpaRegister.Function != GHCB_INFO_GHCB_GPA_REGISTER_RESPONSE) ||
110 ((Msr.GhcbPhysicalAddress & ~EFI_PAGE_MASK) != Address))
132 Msr.GhcbPhysicalAddress = 0;
133 Msr.GhcbHypervisorFeatures.Function = GHCB_HYPERVISOR_FEATURES_REQUEST;
140 Features =
RShiftU64 (Msr.GhcbPhysicalAddress, 12);
142 if ((Msr.GhcbHypervisorFeatures.Function != GHCB_HYPERVISOR_FEATURES_RESPONSE) ||
143 (!(Features & GHCB_HV_FEATURES_SNP)))
170 Msr.GhcbPhysicalAddress = 0;
171 Msr.GhcbInfo.Function = GHCB_INFO_SEV_INFO_GET;
178 if (Msr.GhcbInfo.Function != GHCB_INFO_SEV_INFO) {
182 if (Msr.GhcbProtocol.SevEsProtocolMin > Msr.GhcbProtocol.SevEsProtocolMax) {
186 if ((Msr.GhcbProtocol.SevEsProtocolMin > GHCB_VERSION_MAX) ||
187 (Msr.GhcbProtocol.SevEsProtocolMax < GHCB_VERSION_MIN))
216 Msr.GhcbPhysicalAddress =
FixedPcdGet32 (PcdOvmfSecGhcbBase);
225 Ghcb->ProtocolVersion =
MIN (Msr.GhcbProtocol.SevEsProtocolMax, GHCB_VERSION_MAX);
226 Ghcb->GhcbUsage = GHCB_STANDARD_USAGE;
257 return ((WorkArea !=
NULL) && (WorkArea->Header.GuestType == CcGuestTypeAmdSev));
284 return ((SevEsWorkArea->SevStatusMsrValue & BIT1) != 0);
298 PHYSICAL_ADDRESS Start, End;
322 PHYSICAL_ADDRESS Cr3;
328 RETURN_STATUS Status;
338 MapAttribute.Uint64 = ApicAddress;
339 MapAttribute.Bits.Present = 1;
340 MapAttribute.Bits.ReadWrite = 1;
341 MapMask.Uint64 = MAX_UINT64;
342 BufferSize = SIZE_4KB;
356 DEBUG ((DEBUG_ERROR,
"Failed to map APIC MMIO region as unencrypted: %d\n", Status));
VOID EFIAPI CpuDeadLoop(VOID)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID EFIAPI CpuFlushTlb(VOID)
RETURN_STATUS EFIAPI PageTableMap(IN OUT UINTN *PageTable OPTIONAL, IN PAGING_MODE PagingMode, IN VOID *Buffer, IN OUT UINTN *BufferSize, IN UINT64 LinearAddress, IN UINT64 Length, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask, OUT BOOLEAN *IsModified OPTIONAL)
UINTN EFIAPI AsmReadCr3(VOID)
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
UINT64 EFIAPI AsmWriteMsr64(IN UINT32 Index, IN UINT64 Value)
UINTN EFIAPI GetLocalApicBaseAddress(VOID)
#define RETURN_ERROR(StatusCode)
#define DEBUG(Expression)
VOID EFIAPI MemEncryptSevSnpPreValidateSystemRam(IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
STATIC BOOLEAN HypervisorSnpFeatureCheck(VOID)
VOID SecValidateSystemRam(VOID)
VOID SecMapApicBaseUnencrypted(VOID)
VOID SevEsProtocolCheck(VOID)
BOOLEAN SevSnpIsEnabled(VOID)
STATIC VOID SevSnpGhcbRegister(EFI_PHYSICAL_ADDRESS Address)
BOOLEAN SevEsIsEnabled(VOID)
#define FixedPcdGet32(TokenName)
#define PcdGet32(TokenName)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
UINT32 EFIAPI AsmReadMsr32(IN UINT32 Index)