mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 08:04:07 +02:00
OvmfPkg/BaseMemEncryptSevLib: Calculate memory size for Page State Change
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4654 Calculate the amount of memory that can be use to build the Page State Change data (SNP_PAGE_STATE_CHANGE_INFO) instead of using a hard-coded size. This allows for changes to the GHCB shared buffer size without having to make changes to the page state change code. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Erdem Aktas <erdemaktas@google.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Michael Roth <michael.roth@amd.com> Cc: Min Xu <min.m.xu@intel.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
This commit is contained in:
parent
6b14ef6b28
commit
5fe9db0f82
@ -133,23 +133,26 @@ BuildPageStateBuffer (
|
|||||||
IN EFI_PHYSICAL_ADDRESS EndAddress,
|
IN EFI_PHYSICAL_ADDRESS EndAddress,
|
||||||
IN SEV_SNP_PAGE_STATE State,
|
IN SEV_SNP_PAGE_STATE State,
|
||||||
IN BOOLEAN UseLargeEntry,
|
IN BOOLEAN UseLargeEntry,
|
||||||
IN SNP_PAGE_STATE_CHANGE_INFO *Info
|
IN SNP_PAGE_STATE_CHANGE_INFO *Info,
|
||||||
|
IN UINTN InfoSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PHYSICAL_ADDRESS NextAddress;
|
EFI_PHYSICAL_ADDRESS NextAddress;
|
||||||
UINTN RmpPageSize;
|
UINTN RmpPageSize;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
UINTN IndexMax;
|
||||||
|
|
||||||
// Clear the page state structure
|
// Clear the page state structure
|
||||||
SetMem (Info, sizeof (*Info), 0);
|
SetMem (Info, InfoSize, 0);
|
||||||
|
|
||||||
Index = 0;
|
Index = 0;
|
||||||
|
IndexMax = (InfoSize - sizeof (Info->Header)) / sizeof (Info->Entry[0]);
|
||||||
NextAddress = EndAddress;
|
NextAddress = EndAddress;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Populate the page state entry structure
|
// Populate the page state entry structure
|
||||||
//
|
//
|
||||||
while ((BaseAddress < EndAddress) && (Index < SNP_PAGE_STATE_MAX_ENTRY)) {
|
while ((BaseAddress < EndAddress) && (Index < IndexMax)) {
|
||||||
//
|
//
|
||||||
// Is this a 2MB aligned page? Check if we can use the Large RMP entry.
|
// Is this a 2MB aligned page? Check if we can use the Large RMP entry.
|
||||||
//
|
//
|
||||||
@ -265,7 +268,8 @@ InternalSetPageState (
|
|||||||
EndAddress,
|
EndAddress,
|
||||||
State,
|
State,
|
||||||
UseLargeEntry,
|
UseLargeEntry,
|
||||||
Info
|
Info,
|
||||||
|
sizeof (Ghcb->SharedBuffer)
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user