summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2017-03-28 14:01:24 +0800
committerJeff Fan <jeff.fan@intel.com>2017-04-01 11:45:00 +0800
commitee58438970c13329fe35d04e2432e0b7d2703190 (patch)
treedb21475a1e04643f5a63a719f5c0c093384583c5 /UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
parent97f1061e8b3fa638a445ee6ea68d4cf0a342f91d (diff)
downloadedk2-ee58438970c13329fe35d04e2432e0b7d2703190.tar.gz
edk2-ee58438970c13329fe35d04e2432e0b7d2703190.tar.bz2
edk2-ee58438970c13329fe35d04e2432e0b7d2703190.zip
UefiCpuPkg/PiSmmCpuDxeSmm: Update saved SMM ranges check in SmmProfile
SmmProfile feature required to protect all SMM ranges by structure mProtectionMemRangeTemplate. This update is to add additonal save SMM ranges into mProtectionMemRangeTemplate besides the range specified by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
index 7125aec8a9..2713b19dd2 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
@@ -83,6 +83,12 @@ MEMORY_PROTECTION_RANGE mProtectionMemRangeTemplate[] = {
{{0x00000000, 0x00000000},TRUE,TRUE},
//
+ // SMRAM ranges not covered by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz (to be fixed in runtime).
+ // It is always present and instruction fetches are allowed.
+ // {{0x00000000, 0x00000000},TRUE,FALSE},
+ //
+
+ //
// Future extended range could be added here.
//
@@ -360,7 +366,7 @@ InitProtectedMemRange (
{
UINTN Index;
UINTN NumberOfDescriptors;
- UINTN NumberOfMmioDescriptors;
+ UINTN NumberOfAddedDescriptors;
UINTN NumberOfProtectRange;
UINTN NumberOfSpliteRange;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
@@ -373,7 +379,7 @@ InitProtectedMemRange (
UINT64 Low4KBPageSize;
NumberOfDescriptors = 0;
- NumberOfMmioDescriptors = 0;
+ NumberOfAddedDescriptors = mSmmCpuSmramRangeCount;
NumberOfSpliteRange = 0;
MemorySpaceMap = NULL;
@@ -386,12 +392,12 @@ InitProtectedMemRange (
);
for (Index = 0; Index < NumberOfDescriptors; Index++) {
if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) {
- NumberOfMmioDescriptors++;
+ NumberOfAddedDescriptors++;
}
}
- if (NumberOfMmioDescriptors != 0) {
- TotalSize = NumberOfMmioDescriptors * sizeof (MEMORY_PROTECTION_RANGE) + sizeof (mProtectionMemRangeTemplate);
+ if (NumberOfAddedDescriptors != 0) {
+ TotalSize = NumberOfAddedDescriptors * sizeof (MEMORY_PROTECTION_RANGE) + sizeof (mProtectionMemRangeTemplate);
mProtectionMemRange = (MEMORY_PROTECTION_RANGE *) AllocateZeroPool (TotalSize);
ASSERT (mProtectionMemRange != NULL);
mProtectionMemRangeCount = TotalSize / sizeof (MEMORY_PROTECTION_RANGE);
@@ -409,9 +415,27 @@ InitProtectedMemRange (
ASSERT (mSplitMemRange != NULL);
//
+ // Create SMM ranges which are set to present and execution-enable.
+ //
+ NumberOfProtectRange = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE);
+ for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
+ if (mSmmCpuSmramRanges[Index].CpuStart >= mProtectionMemRange[0].Range.Base &&
+ mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize < mProtectionMemRange[0].Range.Top) {
+ //
+ // If the address have been already covered by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz
+ //
+ break;
+ }
+ mProtectionMemRange[NumberOfProtectRange].Range.Base = mSmmCpuSmramRanges[Index].CpuStart;
+ mProtectionMemRange[NumberOfProtectRange].Range.Top = mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize;
+ mProtectionMemRange[NumberOfProtectRange].Present = TRUE;
+ mProtectionMemRange[NumberOfProtectRange].Nx = FALSE;
+ NumberOfProtectRange++;
+ }
+
+ //
// Create MMIO ranges which are set to present and execution-disable.
//
- NumberOfProtectRange = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE);
for (Index = 0; Index < NumberOfDescriptors; Index++) {
if (MemorySpaceMap[Index].GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {
continue;
@@ -422,6 +446,12 @@ InitProtectedMemRange (
mProtectionMemRange[NumberOfProtectRange].Nx = TRUE;
NumberOfProtectRange++;
}
+
+ //
+ // Check and updated actual protected memory ranges count
+ //
+ ASSERT (NumberOfProtectRange <= mProtectionMemRangeCount);
+ mProtectionMemRangeCount = NumberOfProtectRange;
}
//