Skip to content

Commit

Permalink
MdeModulePkg: Tried to fix OvmfIa32 DEBUG_CLANGPDB TestLinux crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Jul 1, 2024
1 parent 7c804fc commit 89ec579
Showing 1 changed file with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,16 @@ SplitRecord (
NewImageRecord = GetImageRecordByAddress (PhysicalStart, PhysicalEnd - PhysicalStart, ImageRecordList);
if (NewImageRecord == NULL) {
//
// No more images cover this range, check if we've reached the end of the old descriptor. If not,
// add the remaining range to the new descriptor list.
// No more image covered by this range, stop
//
if (PhysicalEnd > PhysicalStart) {
if ((PhysicalEnd > PhysicalStart) && (ImageRecord != NULL)) {
//
// Always create a new entry for non-PE image record
//
NewRecord->Type = TempRecord.Type;
NewRecord->PhysicalStart = PhysicalStart;
NewRecord->PhysicalStart = TempRecord.PhysicalStart;
NewRecord->VirtualStart = 0;
NewRecord->NumberOfPages = EfiSizeToPages (PhysicalEnd - PhysicalStart);
NewRecord->NumberOfPages = TempRecord.NumberOfPages;
NewRecord->Attribute = TempRecord.Attribute;
TotalNewRecordCount++;
}
Expand All @@ -323,24 +325,6 @@ SplitRecord (

ImageRecord = NewImageRecord;

//
// Update PhysicalStart to exclude the portion before the image buffer
//
if (TempRecord.PhysicalStart < ImageRecord->StartAddress) {
NewRecord->Type = TempRecord.Type;
NewRecord->PhysicalStart = TempRecord.PhysicalStart;
NewRecord->VirtualStart = 0;
NewRecord->NumberOfPages = EfiSizeToPages (ImageRecord->StartAddress - TempRecord.PhysicalStart);
NewRecord->Attribute = TempRecord.Attribute;
TotalNewRecordCount++;

PhysicalStart = ImageRecord->StartAddress;
TempRecord.PhysicalStart = PhysicalStart;
TempRecord.NumberOfPages = EfiSizeToPages (PhysicalEnd - PhysicalStart);

NewRecord = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)NewRecord + DescriptorSize);
}

//
// Set new record
//
Expand Down

0 comments on commit 89ec579

Please sign in to comment.