UefiCpuPkg/PiSmmCpuDxeSmm: Add support for PCD PcdPteMemoryEncryptionAddressOrMask
This PCD holds the address mask for page table entries when memory encryption is enabled on AMD processors supporting the Secure Encrypted Virtualization (SEV) feature. The mask is applied when page tables entriees are created or modified. CC: Jeff Fan <jeff.fan@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leo Duran <leo.duran@amd.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
Enable SMM profile.
|
||||
|
||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -513,7 +515,7 @@ InitPaging (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
Pde = (UINT64 *)(UINTN)(Pml4[Level1] & PHYSICAL_ADDRESS_MASK);
|
||||
Pde = (UINT64 *)(UINTN)(Pml4[Level1] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
} else {
|
||||
Pde = (UINT64*)(UINTN)mSmmProfileCr3;
|
||||
}
|
||||
@@ -530,7 +532,7 @@ InitPaging (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
Pte = (UINT64 *)(UINTN)(*Pde & PHYSICAL_ADDRESS_MASK);
|
||||
Pte = (UINT64 *)(UINTN)(*Pde & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
if (Pte == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -557,9 +559,9 @@ InitPaging (
|
||||
|
||||
// Split it
|
||||
for (Level4 = 0; Level4 < SIZE_4KB / sizeof(*Pt); Level4++) {
|
||||
Pt[Level4] = Address + ((Level4 << 12) | PAGE_ATTRIBUTE_BITS);
|
||||
Pt[Level4] = Address + ((Level4 << 12) | mAddressEncMask | PAGE_ATTRIBUTE_BITS);
|
||||
} // end for PT
|
||||
*Pte = (UINTN)Pt | PAGE_ATTRIBUTE_BITS;
|
||||
*Pte = (UINT64)(UINTN)Pt | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
|
||||
} // end if IsAddressSplit
|
||||
} // end for PTE
|
||||
} // end for PDE
|
||||
@@ -577,7 +579,7 @@ InitPaging (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
Pde = (UINT64 *)(UINTN)(Pml4[Level1] & PHYSICAL_ADDRESS_MASK);
|
||||
Pde = (UINT64 *)(UINTN)(Pml4[Level1] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
} else {
|
||||
Pde = (UINT64*)(UINTN)mSmmProfileCr3;
|
||||
}
|
||||
@@ -597,7 +599,7 @@ InitPaging (
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Pte = (UINT64 *)(UINTN)(*Pde & PHYSICAL_ADDRESS_MASK);
|
||||
Pte = (UINT64 *)(UINTN)(*Pde & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
if (Pte == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -624,7 +626,7 @@ InitPaging (
|
||||
}
|
||||
} else {
|
||||
// 4KB page
|
||||
Pt = (UINT64 *)(UINTN)(*Pte & PHYSICAL_ADDRESS_MASK);
|
||||
Pt = (UINT64 *)(UINTN)(*Pte & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
|
||||
if (Pt == 0) {
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user