aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-07-28 16:46:28 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-08-01 13:57:35 +1000
commit6b9791e7a309b3622974f948cdfb89dd831148b2 (patch)
tree69f6ea4651d88516e955a8d32334f26496a64927 /external
parentff632ec422d26d1689d732f374d4bfe55b3f39c7 (diff)
downloadskiboot-6b9791e7a309b3622974f948cdfb89dd831148b2.zip
skiboot-6b9791e7a309b3622974f948cdfb89dd831148b2.tar.gz
skiboot-6b9791e7a309b3622974f948cdfb89dd831148b2.tar.bz2
external/pflash: Correct erase alignment checks
pflash should check the alignment of addresses and sizes when asked to erase. There are two possibilities: 1. The user has specified sizes manually in which case pflash should be as flexible as possible, blocklevel_smart_erase() permits this. To prevent possible mistakes pflash will require --force to perform a manual erase of unaligned sizes. 2. The user used -P to specify a partition, partitions aren't necessarily erase granule aligned anymore, blocklevel_smart_erase() can handle. In this it doesn't make sense to warn/error about misalignment since the misalignment is inherent to the FFS partition and not really user input. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/pflash/pflash.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 657e814..f5e6a06 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -610,7 +610,6 @@ int main(int argc, char *argv[])
{
const char *pname = argv[0];
uint32_t address = 0, read_size = 0, write_size = 0, detail_id = UINT_MAX;
- uint32_t erase_start = 0, erase_size = 0;
bool erase = false, do_clear = false;
bool program = false, erase_all = false, info = false, do_read = false;
bool enable_4B = false, disable_4B = false;
@@ -981,33 +980,20 @@ int main(int argc, char *argv[])
goto out;
}
-
- /* If erasing, check partition alignment */
- if (erase && ((pstart | pmaxsz) & 0xfff)) {
- fprintf(stderr,"Partition not aligned properly\n");
- goto out;
- }
-
/* Set address */
address = pstart;
- }
-
- /* Align erase boundaries */
- if (erase && !erase_all) {
- uint32_t mask = 0xfff;
- uint32_t erase_end;
-
- /* Dummy size for erase, will be adjusted later */
- if (!write_size)
- write_size = 1;
- erase_start = address & ~mask;
- erase_end = ((address + write_size) + mask) & ~mask;
- erase_size = erase_end - erase_start;
-
- if (erase_start != address || erase_size != write_size)
- fprintf(stderr, "WARNING: Erase region adjusted"
- " to 0x%08x..0x%08x\n",
- erase_start, erase_end);
+ } else if (erase) {
+ if ((address | write_size) & (fl_erase_granule - 1)) {
+ if (must_confirm) {
+ printf("ERROR: Erase at 0x%08x for 0x%08x isn't erase block aligned\n",
+ address, write_size);
+ printf("Use --force to force\n");
+ goto out;
+ } else {
+ printf("WARNING: Erase at 0x%08x for 0x%08x isn't erase block aligned\n",
+ address, write_size);
+ }
+ }
}
/* Process commands */
@@ -1041,7 +1027,7 @@ int main(int argc, char *argv[])
if (erase_all)
erase_chip();
else if (erase)
- erase_range(erase_start, erase_size, program);
+ erase_range(address, write_size, program);
if (program)
program_file(write_file, address, write_size);
if (do_clear)