OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe
When a guest OS does not support unaccepted memory, the unaccepted memory must be accepted before returning a memory map to the caller. EfiMemoryAcceptProtocol is defined in MdePkg and is implemented / Installed in AmdSevDxe for AMD SEV-SNP memory acceptance. Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Acked-by: Jiewen Yao <Jiewen.yao@intel.com> Signed-off-by: Dionna Glaze <dionnaglaze@google.com> Message-Id: <20221108164616.3251967-2-dionnaglaze@google.com>
This commit is contained in:
committed by
mergify[bot]
parent
e5ec3ba409
commit
59aa48bb7d
@@ -14,6 +14,7 @@
|
||||
#include <Library/MemEncryptSevLib.h>
|
||||
|
||||
#include "SnpPageStateChange.h"
|
||||
#include "VirtualMemory.h"
|
||||
|
||||
/**
|
||||
Pre-validate the system RAM when SEV-SNP is enabled in the guest VM.
|
||||
@@ -29,12 +30,27 @@ MemEncryptSevSnpPreValidateSystemRam (
|
||||
IN UINTN NumPages
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (!MemEncryptSevSnpIsEnabled ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// All the pre-validation must be completed in the PEI phase.
|
||||
//
|
||||
ASSERT (FALSE);
|
||||
// DXE pre-validation may happen with the memory accept protocol.
|
||||
// The protocol should only be called outside the prevalidated ranges
|
||||
// that the PEI stage code explicitly skips. Specifically, only memory
|
||||
// ranges that are classified as unaccepted.
|
||||
if (BaseAddress >= SIZE_4GB) {
|
||||
Status = InternalMemEncryptSevCreateIdentityMap1G (
|
||||
0,
|
||||
BaseAddress,
|
||||
EFI_PAGES_TO_SIZE (NumPages)
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
}
|
||||
|
||||
InternalSetPageState (BaseAddress, NumPages, SevSnpPagePrivate, TRUE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user