Attention is currently required from: Edward O'Callaghan, Nikolai Artemiev.
Edward O'Callaghan has uploaded a new patch set (#7) to the change originally created by Nikolai Artemiev. ( https://review.coreboot.org/c/flashrom/+/70517 )
Change subject: flashrom: Check for flash access restricitons in erase path
......................................................................
flashrom: Check for flash access restricitons in erase path
Skip unwritable regions if FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS is
true. If the flag is false, erase operations that include an unwritable
region will not erase anything and return an error.
BUG=b:260440773
BRANCH=none
TEST=flashrom -E on dedede (JSL)
Change-Id: If027a96a024782c7707c6d38680709a1a117f3ef
CoAuthored-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Nikolai Artemiev <nartemiev(a)google.com>
---
M flashrom.c
1 file changed, 51 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/17/70517/7
--
To view, visit https://review.coreboot.org/c/flashrom/+/70517
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If027a96a024782c7707c6d38680709a1a117f3ef
Gerrit-Change-Number: 70517
Gerrit-PatchSet: 7
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-MessageType: newpatchset
Attention is currently required from: Nikolai Artemiev.
Edward O'Callaghan has uploaded a new patch set (#7) to the change originally created by Nikolai Artemiev. ( https://review.coreboot.org/c/flashrom/+/70516 )
Change subject: flashrom: Check for flash access restricitons in write_flash()
......................................................................
flashrom: Check for flash access restricitons in write_flash()
Make write_flash() skip unwritable regions if
FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS is true. If the flag is false
write operations that include an unwritable region will not write
anything and return an error.
BUG=b:260440773
BRANCH=none
TEST=flashrom -w on dedede (JSL)
Change-Id: Idacf0d5218da9d9929f4877fc7665fe608b87fe0
CoAuthored-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Nikolai Artemiev <nartemiev(a)google.com>
---
M flashrom.c
1 file changed, 88 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/16/70516/7
--
To view, visit https://review.coreboot.org/c/flashrom/+/70516
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Idacf0d5218da9d9929f4877fc7665fe608b87fe0
Gerrit-Change-Number: 70516
Gerrit-PatchSet: 7
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-MessageType: newpatchset
Attention is currently required from: Nikolai Artemiev.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/70516 )
Change subject: flashrom: Check for flash access restricitons in write_flash()
......................................................................
Patch Set 6:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/70516/comment/f051c325_7c9457b4
PS6, Line 10: UNREADABLE
`UNWRITABLE`
--
To view, visit https://review.coreboot.org/c/flashrom/+/70516
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Idacf0d5218da9d9929f4877fc7665fe608b87fe0
Gerrit-Change-Number: 70516
Gerrit-PatchSet: 6
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Comment-Date: Sun, 18 Dec 2022 01:24:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nikolai Artemiev.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/70516 )
Change subject: flashrom: Check for flash access restricitons in write_flash()
......................................................................
Patch Set 5:
(2 comments)
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/70516/comment/21ca61e3_989955a3
PS5, Line 367: }
> ``` […]
Done
https://review.coreboot.org/c/flashrom/+/70516/comment/bf41819f_d3bd894c
PS5, Line 371:
> spurious
Done
--
To view, visit https://review.coreboot.org/c/flashrom/+/70516
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Idacf0d5218da9d9929f4877fc7665fe608b87fe0
Gerrit-Change-Number: 70516
Gerrit-PatchSet: 5
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Comment-Date: Sun, 18 Dec 2022 00:45:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Nikolai Artemiev.
Edward O'Callaghan has uploaded a new patch set (#6) to the change originally created by Nikolai Artemiev. ( https://review.coreboot.org/c/flashrom/+/70516 )
Change subject: flashrom: Check for flash access restricitons in write_flash()
......................................................................
flashrom: Check for flash access restricitons in write_flash()
Make write_flash() skip unwritable regions if
FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS is true. If the flag is false
write operations that include an unwritable region will not write
anything and return an error.
BUG=b:260440773
BRANCH=none
TEST=flashrom -w on dedede (JSL)
Change-Id: Idacf0d5218da9d9929f4877fc7665fe608b87fe0
CoAuthored-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Nikolai Artemiev <nartemiev(a)google.com>
---
M flashrom.c
1 file changed, 88 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/16/70516/6
--
To view, visit https://review.coreboot.org/c/flashrom/+/70516
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Idacf0d5218da9d9929f4877fc7665fe608b87fe0
Gerrit-Change-Number: 70516
Gerrit-PatchSet: 6
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-MessageType: newpatchset
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/70515 )
(
3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: flashrom: Check for flash access restricitons in verify_range()
......................................................................
flashrom: Check for flash access restricitons in verify_range()
Make verify_flash() skip read/write-protected regions based on the
FLASHROM_FLAG_SKIP_UNREADABLE and FLASHROM_FLAG_SKIP_UNWRITABLE flags.
If FLASHROM_FLAG_SKIP_UNREADABLE is false, read-protected regions will cause
verification to fail.
If FLASHROM_FLAG_SKIP_UNWRITABLE is false, read-only regions will still
be verified and any mismatch will cause verification to fail. It can be
useful to set the flag to true so that expected mismatches in read-only
regions are ignored by verify_range() after flashing.
BUG=b:260440773
BRANCH=none
TEST=flashrom -v on dedede (JSL)
Change-Id: I61dfadd3c75365f2e55abeea75f673ab791ca5cc
CoAuthored-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Nikolai Artemiev <nartemiev(a)google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/70515
Reviewed-by: Edward O'Callaghan <quasisec(a)chromium.org>
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Angel Pons <th3fanbus(a)gmail.com>
---
M flashrom.c
1 file changed, 72 insertions(+), 7 deletions(-)
Approvals:
build bot (Jenkins): Verified
Angel Pons: Looks good to me, but someone else must approve
Edward O'Callaghan: Looks good to me, approved
diff --git a/flashrom.c b/flashrom.c
index d036b5c..573f10b 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -604,15 +604,49 @@
return -1;
}
- int ret = read_flash(flash, readbuf, start, len);
- if (ret) {
- msg_gerr("Verification impossible because read failed "
- "at 0x%x (len 0x%x)\n", start, len);
- ret = -1;
- goto out_free;
+ int ret = 0;
+
+ msg_gdbg("%#06x..%#06x ", start, start + len - 1);
+
+ unsigned int read_len;
+ for (size_t addr = start; addr < start + len; addr += read_len) {
+ struct flash_region region;
+ get_flash_region(flash, addr, ®ion);
+ read_len = min(start + len, region.end) - addr;
+
+ if ((region.write_prot && flash->flags.skip_unwritable_regions) ||
+ (region.read_prot && flash->flags.skip_unreadable_regions)) {
+ msg_gdbg("%s: Skipping verification of %s region (%#08x..%#08x)\n",
+ __func__, region.name, region.start, region.end - 1);
+ free(region.name);
+ continue;
+ }
+
+ if (region.read_prot) {
+ msg_gerr("%s: Verification imposible because %s region (%#08x..%#08x) is unreadable.\n",
+ __func__, region.name, region.start, region.end - 1);
+ free(region.name);
+ goto out_free;
+ }
+
+ msg_gdbg("%s: Verifying %s region (%#08x..%#08x)\n",
+ __func__, region.name, region.start, region.end - 1);
+ free(region.name);
+
+ ret = read_flash(flash, readbuf, addr, read_len);
+ if (ret) {
+ msg_gerr("Verification impossible because read failed "
+ "at 0x%x (len 0x%x)\n", start, len);
+ ret = -1;
+ goto out_free;
+ }
+
+ ret = compare_range(cmpbuf + (addr - start), readbuf, addr, read_len);
+ if (ret)
+ goto out_free;
+
}
- ret = compare_range(cmpbuf, readbuf, start, len);
out_free:
free(readbuf);
return ret;
--
To view, visit https://review.coreboot.org/c/flashrom/+/70515
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I61dfadd3c75365f2e55abeea75f673ab791ca5cc
Gerrit-Change-Number: 70515
Gerrit-PatchSet: 5
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: merged
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/70128 )
Change subject: libflashrom: Add flags to skip unreadable and unwritable regions
......................................................................
libflashrom: Add flags to skip unreadable and unwritable regions
Add flags to allow libflashrom users to configure how operations that
include unreadable or unwritable regions should be behave.
If the flags are set to true, a read/write operation will just skip the
inaccessible region and will still be executed in other regions.
If the flags are set to false, the inaccessible region will cause the
entire operation to fail.
BUG=b:260440773
BRANCH=none
TEST=builds
Change-Id: I9b96fb04b863625d2c9f9a00b97c35b3ddb0871b
CoAuthored-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
Signed-off-by: Nikolai Artemiev <nartemiev(a)google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/70128
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec(a)chromium.org>
Reviewed-by: Angel Pons <th3fanbus(a)gmail.com>
---
M include/flash.h
M include/libflashrom.h
M libflashrom.c
3 files changed, 46 insertions(+), 9 deletions(-)
Approvals:
build bot (Jenkins): Verified
Angel Pons: Looks good to me, but someone else must approve
Edward O'Callaghan: Looks good to me, approved
diff --git a/include/flash.h b/include/flash.h
index aabc785..2ea9c86 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -530,6 +530,8 @@
bool force_boardmismatch;
bool verify_after_write;
bool verify_whole_chip;
+ bool skip_unreadable_regions;
+ bool skip_unwritable_regions;
} flags;
/* We cache the state of the extended address register (highest byte
* of a 4BA for 3BA instructions) and the state of the 4BA mode here.
diff --git a/include/libflashrom.h b/include/libflashrom.h
index bac76c2..490ef03 100644
--- a/include/libflashrom.h
+++ b/include/libflashrom.h
@@ -251,6 +251,8 @@
FLASHROM_FLAG_FORCE_BOARDMISMATCH,
FLASHROM_FLAG_VERIFY_AFTER_WRITE,
FLASHROM_FLAG_VERIFY_WHOLE_CHIP,
+ FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS,
+ FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS,
};
/**
diff --git a/libflashrom.c b/libflashrom.c
index 44f297f..2e89fe5 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -265,21 +265,25 @@
const enum flashrom_flag flag, const bool value)
{
switch (flag) {
- case FLASHROM_FLAG_FORCE: flashctx->flags.force = value; break;
- case FLASHROM_FLAG_FORCE_BOARDMISMATCH: flashctx->flags.force_boardmismatch = value; break;
- case FLASHROM_FLAG_VERIFY_AFTER_WRITE: flashctx->flags.verify_after_write = value; break;
- case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: flashctx->flags.verify_whole_chip = value; break;
+ case FLASHROM_FLAG_FORCE: flashctx->flags.force = value; break;
+ case FLASHROM_FLAG_FORCE_BOARDMISMATCH: flashctx->flags.force_boardmismatch = value; break;
+ case FLASHROM_FLAG_VERIFY_AFTER_WRITE: flashctx->flags.verify_after_write = value; break;
+ case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: flashctx->flags.verify_whole_chip = value; break;
+ case FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS: flashctx->flags.skip_unreadable_regions = value; break;
+ case FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS: flashctx->flags.skip_unwritable_regions = value; break;
}
}
bool flashrom_flag_get(const struct flashrom_flashctx *const flashctx, const enum flashrom_flag flag)
{
switch (flag) {
- case FLASHROM_FLAG_FORCE: return flashctx->flags.force;
- case FLASHROM_FLAG_FORCE_BOARDMISMATCH: return flashctx->flags.force_boardmismatch;
- case FLASHROM_FLAG_VERIFY_AFTER_WRITE: return flashctx->flags.verify_after_write;
- case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: return flashctx->flags.verify_whole_chip;
- default: return false;
+ case FLASHROM_FLAG_FORCE: return flashctx->flags.force;
+ case FLASHROM_FLAG_FORCE_BOARDMISMATCH: return flashctx->flags.force_boardmismatch;
+ case FLASHROM_FLAG_VERIFY_AFTER_WRITE: return flashctx->flags.verify_after_write;
+ case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: return flashctx->flags.verify_whole_chip;
+ case FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS: return flashctx->flags.skip_unreadable_regions;
+ case FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS: return flashctx->flags.skip_unwritable_regions;
+ default: return false;
}
}
--
To view, visit https://review.coreboot.org/c/flashrom/+/70128
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9b96fb04b863625d2c9f9a00b97c35b3ddb0871b
Gerrit-Change-Number: 70128
Gerrit-PatchSet: 24
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: merged
Attention is currently required from: Edward O'Callaghan, Nikolai Artemiev.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/70517 )
Change subject: flashrom: Check for flash access restricitons in erase path
......................................................................
Patch Set 5: Code-Review+1
--
To view, visit https://review.coreboot.org/c/flashrom/+/70517
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If027a96a024782c7707c6d38680709a1a117f3ef
Gerrit-Change-Number: 70517
Gerrit-PatchSet: 5
Gerrit-Owner: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Comment-Date: Sat, 17 Dec 2022 23:45:52 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment