-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flashrom.c: Fail immediately when trying to write/erase wp regions #17
base: sync
Are you sure you want to change the base?
Conversation
6892f59
to
4dc3fa9
Compare
Can you change this so that only attempting to flash the actually protected ranges will throw an error? For example if someone has WP_RO protected but only wants to flash RW_SECTION_* |
337da02
to
e7b4efa
Compare
Tests@mkopec
|
e7b4efa
to
ababbe1
Compare
Seems to work as described 👍 tested on NV40MB (Tiger Lake) |
@@ -20,3 +20,6 @@ | |||
/util/ich_descriptors_tool/.obj | |||
|
|||
target/ | |||
|
|||
subprojects/cmocka-*/ | |||
subprojects/packagecache/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either remove or split into a separate commit, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11e7895: those are folders generated by meson test
.
flashrom.c
Outdated
@@ -1752,6 +1796,13 @@ int prepare_flash_access(struct flashctx *const flash, | |||
return 1; | |||
} | |||
|
|||
if ((write_it || erase_it) && !flash->flags.force) { | |||
if(write_protect_check(flash)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(write_protect_check(flash)) { | |
if (write_protect_check(flash)) { |
Please make code style consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1289,6 +1289,13 @@ struct hwseq_data { | |||
struct fd_region fd_regions[MAX_FD_REGIONS]; | |||
}; | |||
|
|||
#define MAX_PR_REGISTERS 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this come from a specification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I used largest value that could be returned in
Line 2108 in ababbe1
static void init_chipset_properties(struct swseq_data *swseq, struct hwseq_data *hwseq, |
{ | ||
uint8_t off = reg_pr0 + (i * 4); | ||
uint32_t pr = mmio_readl(ich_spibar + off); | ||
unsigned int rwperms_idx = ICH_PR_PERMS(pr); | ||
enum ich_access_protection rwperms = access_perms_to_protection[rwperms_idx]; | ||
|
||
prot->base = ICH_FREG_BASE(pr); | ||
prot->limit = ICH_FREG_LIMIT(pr); | ||
prot->write_prot = rwperms == WRITE_PROT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prot->write_prot = rwperms == WRITE_PROT; | |
prot->write_prot = (rwperms == WRITE_PROT) || (rwperms == LOCKED); |
I think, at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed based on
Line 2267 in ababbe1
switch (ich_spi_rw_restricted) { |
If I'm reading this correctly in case
ich_spi_rw_restricted == LOCKED
then warning will only mention that's it's read-protected
ichspi.c
Outdated
prot->base = ICH_FREG_BASE(pr); | ||
prot->limit = ICH_FREG_LIMIT(pr); | ||
prot->write_prot = rwperms == WRITE_PROT; | ||
prot->read_prot = rwperms == READ_PROT || rwperms == LOCKED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prot->read_prot = rwperms == READ_PROT || rwperms == LOCKED; | |
prot->read_prot = (rwperms ==READ_PROT) || (rwperms == LOCKED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change-Id: Ic39b4acf1da73d093ce3a7df71c1c549d92240d5 Signed-off-by: Michał Iwanicki <[email protected]>
Change-Id: I989006eae97f5e015df20026b6f5361ad41223c1 Signed-off-by: Michał Iwanicki <[email protected]>
Change-Id: Iee172044959df8efd7148adb3a918a7dad963f6f Signed-off-by: Michał Iwanicki <[email protected]>
Change-Id: I1cdcfacaf61285bf4d7789610461a3f02ea4c64b Signed-off-by: Michał Iwanicki <[email protected]>
ababbe1
to
c80f032
Compare
write_protect_check
can be deleted and PR0 check will still happen but only one region at a time, so if we write/erase multiple regions (e.g.-i fd -i bios
) then first region might get written if it is read-write.In case of e.g.
FREG1: BIOS region (0x00580000-0x00ffffff) is read-write.
&PR0: Warning: 0x00b00000-0x00ffffff is read-only.
write/erase would still fail even if we tried to flash only unprotected parts of region e.g.0x00580000-0x00590000
To force write/erase add
--force
argument.meson test:
Tested on Protectli VP6670:
Try to flash whole chip:
Try to flash protected part:
Try to flash unprotected part:
WP protection checked with dummy programmer:
unprotected part:
Protected part: