diff options
author | Michael Roth <michael.roth@amd.com> | 2023-11-15 11:51:53 -0600 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-12-08 13:25:11 +0000 |
commit | e8c23d1e27f70dcb2e59010ded6df32374eaa84a (patch) | |
tree | f92ec73f0c6c4b9473d732ee1b3ce4ee482962f6 | |
parent | 7eb504060787c9c37d5b3c33f5d65021d553ea3f (diff) | |
download | edk2-e8c23d1e27f70dcb2e59010ded6df32374eaa84a.tar.gz edk2-e8c23d1e27f70dcb2e59010ded6df32374eaa84a.tar.bz2 edk2-e8c23d1e27f70dcb2e59010ded6df32374eaa84a.zip |
OvmfPkg/MemEncryptSevLib: Fix address overflow during PVALIDATE
The struct used for GHCB-based page-state change requests uses a 40-bit
bit-field for the GFN, which is shifted by PAGE_SHIFT to generate a
64-bit address. However, anything beyond 40-bits simply gets shifted off
when doing this, which will cause issues when dealing with 1TB+
addresses. Fix this by casting the 40-bit GFN values to 64-bit ones
prior to shifting it by PAGE_SHIFT.
Fixes: ade62c18f474 ("OvmfPkg/MemEncryptSevLib: add support to validate system RAM")
Signed-off-by: Michael Roth <michael.roth@amd.com>
Message-Id: <20231115175153.813213-1-michael.roth@amd.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c index 85eb41585b..46c6682760 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c @@ -78,13 +78,14 @@ PvalidateRange ( IN BOOLEAN Validate
)
{
- UINTN Address, RmpPageSize, Ret, i;
+ UINTN RmpPageSize, Ret, i;
+ EFI_PHYSICAL_ADDRESS Address;
for ( ; StartIndex <= EndIndex; StartIndex++) {
//
// Get the address and the page size from the Info.
//
- Address = Info->Entry[StartIndex].GuestFrameNumber << EFI_PAGE_SHIFT;
+ Address = ((EFI_PHYSICAL_ADDRESS)Info->Entry[StartIndex].GuestFrameNumber) << EFI_PAGE_SHIFT;
RmpPageSize = Info->Entry[StartIndex].PageSize;
Ret = AsmPvalidate (RmpPageSize, Validate, Address);
|