forked from flashrom/flashrom
-
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
Open
m-iwanicki
wants to merge
5
commits into
sync
Choose a base branch
from
refuse-flashing-if-protected
base: sync
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6be9938
flashrom.c: Fail immediately when trying to write/erase wp regions
m-iwanicki 8484210
Check PR ranges when deciding if range is wp protected
m-iwanicki 11e7895
.gitignore: Add folders generated by 'meson test'
m-iwanicki c80f032
flashrom.c & ichspi.c: code style fixes
m-iwanicki 4de6d01
ichspi.c: set write_prot if rwperms is LOCKED
m-iwanicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ | |
/util/ich_descriptors_tool/.obj | ||
|
||
target/ | ||
|
||
subprojects/cmocka-*/ | ||
subprojects/packagecache/ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -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 commentThe 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 commentThe 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
|
||||
struct protected_range _ranges[MAX_PR_REGISTERS]; | ||||
struct protected_ranges ranges = { | ||||
.count = 0, | ||||
.ranges = _ranges, | ||||
}; | ||||
|
||||
static struct hwseq_data *get_hwseq_data_from_context(const struct flashctx *flash) | ||||
{ | ||||
return flash->mst->opaque.data; | ||||
|
@@ -1471,6 +1478,10 @@ static void ich_get_region(const struct flashctx *flash, unsigned int addr, stru | |||
region->name = strdup(name); | ||||
} | ||||
|
||||
static struct protected_ranges ich_get_protected_ranges() { | ||||
return ranges; | ||||
} | ||||
|
||||
/* Given RDID info, return pointer to entry in flashchips[] */ | ||||
static const struct flashchip *flash_id_to_entry(uint32_t mfg_id, uint32_t model_id) | ||||
{ | ||||
|
@@ -1950,13 +1961,18 @@ static enum ich_access_protection ich9_handle_region_access(struct fd_region *fd | |||
#define ICH_PR_PERMS(pr) (((~((pr) >> PR_RP_OFF) & 1) << 0) | \ | ||||
((~((pr) >> PR_WP_OFF) & 1) << 1)) | ||||
|
||||
static enum ich_access_protection ich9_handle_pr(const size_t reg_pr0, unsigned int i) | ||||
static enum ich_access_protection ich9_handle_pr(const size_t reg_pr0, unsigned int i, struct protected_range* prot) | ||||
{ | ||||
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) || (rwperms == LOCKED); | ||||
prot->read_prot = (rwperms == READ_PROT) || (rwperms == LOCKED); | ||||
|
||||
/* From 5 on we have GPR registers and start from 0 again. */ | ||||
const char *const prefix = i >= 5 ? "G" : ""; | ||||
if (i >= 5) | ||||
|
@@ -2019,6 +2035,7 @@ static const struct opaque_master opaque_master_ich_hwseq = { | |||
.read_register = ich_hwseq_read_status, | ||||
.write_register = ich_hwseq_write_status, | ||||
.get_region = ich_get_region, | ||||
.get_protected_ranges = ich_get_protected_ranges, | ||||
.shutdown = ich_hwseq_shutdown, | ||||
}; | ||||
|
||||
|
@@ -2239,11 +2256,12 @@ static int init_ich_default(const struct programmer_cfg *cfg, void *spibar, enum | |||
} | ||||
|
||||
/* Handle PR registers */ | ||||
ranges.count = num_pr; | ||||
for (i = 0; i < num_pr; i++) { | ||||
/* if not locked down try to disable PR locks first */ | ||||
if (!ichspi_lock) | ||||
ich9_set_pr(reg_pr0, i, 0, 0); | ||||
ich_spi_rw_restricted |= ich9_handle_pr(reg_pr0, i); | ||||
ich_spi_rw_restricted |= ich9_handle_pr(reg_pr0, i, &_ranges[i]); | ||||
} | ||||
|
||||
switch (ich_spi_rw_restricted) { | ||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.