Skip to content

Commit f32e136

Browse files
committed
address review
Signed-off-by: Filip Lewiński <filip.lewinski@3mdeb.com>
1 parent 4f4fbd1 commit f32e136

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

DasharoPayloadPkg/Library/FmpDeviceSmmLib/FmpDeviceSmmLib.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ CountDifferingBlocks (
804804
IN CONST UINT8 *Image1,
805805
IN CONST UINT8 *Image2,
806806
IN UINTN Size,
807-
IN UINTN BlockSize
807+
IN UINTN BlockSize,
808+
IN BOOLEAN DescriptorLocked
808809
)
809810
{
810811
UINTN BlockCount;
@@ -821,10 +822,16 @@ CountDifferingBlocks (
821822
Offset = 0;
822823

823824
for (Block = 0; Block < BlockCount; Block++, Offset += BlockSize) {
824-
if (CompareMem (Image1 + Offset, Image2 + Offset, BlockSize) != 0) {
825-
DifferingCount++;
825+
if (CompareMem (Image1 + Offset, Image2 + Offset, BlockSize) == 0) {
826+
continue;
826827
}
827-
}
828+
829+
if (!IsRangeWriteable (Offset, BlockSize, DescriptorLocked)) {
830+
continue;
831+
}
832+
833+
DifferingCount++;
834+
}
828835

829836
return DifferingCount;
830837
}
@@ -1337,7 +1344,13 @@ FmpDeviceSetImageWithStatus (
13371344
//
13381345
// Count how many blocks actually differ to get accurate progress.
13391346
//
1340-
DifferingBlocks = CountDifferingBlocks (CurrentImage, UpdatedImage, ImageSize, BlockSize);
1347+
DifferingBlocks = CountDifferingBlocks (
1348+
CurrentImage,
1349+
UpdatedImage,
1350+
ImageSize,
1351+
BlockSize,
1352+
DescriptorLocked
1353+
);
13411354
DEBUG ((DEBUG_INFO, "%a(): %d blocks differ out of %d total\n",
13421355
__FUNCTION__, DifferingBlocks, BlockCount));
13431356

@@ -1346,7 +1359,6 @@ FmpDeviceSetImageWithStatus (
13461359
// CurrentUnits already has the read progress (BlockCount * READ_BLOCK_WEIGHT).
13471360
//
13481361
ProgressCtx.TotalUnits = BlockCount * READ_BLOCK_WEIGHT + DifferingBlocks * UPDATE_BLOCK_WEIGHT;
1349-
ReportProgress (&ProgressCtx);
13501362
}
13511363

13521364
Offset = 0;

0 commit comments

Comments
 (0)