On 12/12/19 12:54 AM, Ni, Ray wrote: >> + // Allocate GHCB and per-CPU variable pages. >> + // >> + GhcbPageCount = mMaxCpuCount * 2; >> + GhcbBase = AllocatePages (GhcbPageCount); >> + ASSERT (GhcbBase != NULL); >> + >> + GhcbBasePa = (PHYSICAL_ADDRESS)(UINTN) GhcbBase; >> + >> + DecryptStatus = MemEncryptSevClearPageEncMask ( >> + 0, >> + GhcbBasePa, >> + GhcbPageCount, >> + TRUE >> + ); >> + ASSERT_RETURN_ERROR (DecryptStatus); >> + >> + ZeroMem (GhcbBase, EFI_PAGES_TO_SIZE (GhcbPageCount)); >> + >> + PcdStatus = PcdSet64S (PcdGhcbBase, GhcbBasePa); >> + ASSERT_RETURN_ERROR (PcdStatus); >> + PcdStatus = PcdSet64S (PcdGhcbSize, EFI_PAGES_TO_SIZE (GhcbPageCount)); >> + ASSERT_RETURN_ERROR (PcdStatus); >> + >> + DEBUG ((DEBUG_INFO, >> + "SEV-ES is enabled, %lu GHCB pages allocated starting at 0x%p\n", >> + (UINT64)GhcbPageCount, GhcbBase)); >> + >> + AsmWriteMsr64 (MSR_SEV_ES_GHCB, GhcbBasePa); > > As I said in the comments to PcdGhcbBase/Size, can all PCD consumers read the > GHCB MSR instead? > > Does the GHCB buffer contains size information? If no, how does CPU know the > GHCB buffer size? > I am asking this because I want to see a way to remove the PcdGhcbSize.
The GHCB is one page in size and is a defined structure. The PcdGhcbSize represents the total size of the allocation, which is one GHCB page per CPU and one page per CPU to hold per-CPU data (currently the DR7 value). Thanks, Tom > > Thanks, > Ray > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52180): https://edk2.groups.io/g/devel/message/52180 Mute This Topic: https://groups.io/mt/60973127/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-