Anastasia Klimchuk submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: build bot (Jenkins): Verified Peter Marheine: Looks good to me, approved
erasure_layout: Fix unaligned region end offset by 1

In the case when layout region is not aligned with eraseblock,
end region boundary is extended to match the eraseblock. There is
a special handling of this extended area (between original end of
region and extended one). Fix the offset of this extended area by +1
so that it covers the extended area and not the original region.

Before the patch, the last byte of the original region was failed to
write since it was treated as if an extended area, while it was the
last byte of the normal layout region.

Ticket: https://ticket.coreboot.org/issues/494
Change-Id: I7f78a0090065cd2a952cba1a5d28179483ba4c55
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78984
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
---
M erasure_layout.c
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/erasure_layout.c b/erasure_layout.c
index c60305f..1dd6b60 100644
--- a/erasure_layout.c
+++ b/erasure_layout.c
@@ -279,9 +279,10 @@
memcpy(newcontents + region_start, curcontents + region_start, old_start - region_start);
}
if (region_end - old_end) {
- read_flash(flashctx, curcontents + old_end, old_end, region_end - old_end);
- memcpy(old_end_buf, newcontents + old_end, region_end - old_end);
- memcpy(newcontents + old_end, curcontents + old_end, region_end - old_end);
+ chipoff_t end_offset = old_end + 1;
+ read_flash(flashctx, curcontents + end_offset, end_offset, region_end - old_end);
+ memcpy(old_end_buf, newcontents + end_offset, region_end - old_end);
+ memcpy(newcontents + end_offset, curcontents + end_offset, region_end - old_end);
}

// select erase functions

To view, visit change 78984. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I7f78a0090065cd2a952cba1a5d28179483ba4c55
Gerrit-Change-Number: 78984
Gerrit-PatchSet: 4
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Aarya <aarya.chaumal@gmail.com>
Gerrit-Reviewer: Alexander Goncharov <chat@joursoir.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Carly Zlabek <carlyzlabek@gmail.com>
Gerrit-Reviewer: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Vincent Fazio <vfazio@gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged