mirror of https://github.com/acidanthera/audk.git
MdeModulePkg: Fix MAT Descriptor Count Calculation
|4K PAGE|DATA|CODE|DATA|CODE|DATA|4K PAGE| Say the above memory region is currently one memory map descriptor. The above image memory layout example contains two code sections oriented in a way that maximizes the number of descriptors which would be required to describe each section. NOTE: It's unlikely that a data section would ever be between two code sections, but it's still handled by the below formula for correctness. There are two code sections (let's say CodeSegmentMax == 2), three data sections, and two unrelated memory regions flanking the image. The number of required descriptors to describe this layout will be 2 * 2 + 3 == 7. This patch updates the calculations to account for the worst-case scenario. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Dandan Bi <dandan.bi@intel.com> Signed-off-by: Taylor Beebe <taylor.d.beebe@gmail.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
parent
0a9e215312
commit
acb29d4cbe
|
@ -517,7 +517,7 @@ CoreGetMemoryMapWithSeparatedImageSection (
|
|||
|
||||
CoreAcquiremMemoryAttributesTableLock ();
|
||||
|
||||
AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 1) * mImagePropertiesPrivateData.ImageRecordCount;
|
||||
AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 3) * mImagePropertiesPrivateData.ImageRecordCount;
|
||||
|
||||
OldMemoryMapSize = *MemoryMapSize;
|
||||
Status = CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
|
||||
|
|
|
@ -277,7 +277,7 @@ GetMaxSplitRecordCount (
|
|||
break;
|
||||
}
|
||||
|
||||
SplitRecordCount += (2 * ImageRecord->CodeSegmentCount + 1);
|
||||
SplitRecordCount += (2 * ImageRecord->CodeSegmentCount + 3);
|
||||
PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
|
||||
} while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
|
||||
|
||||
|
|
Loading…
Reference in New Issue