diff options
author | Oliver O'Halloran <oohall@gmail.com> | 2019-05-10 14:44:59 +1000 |
---|---|---|
committer | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2019-06-08 14:29:02 +0530 |
commit | 8409bb744d809211fa5ce184cedab3f2d057f1ba (patch) | |
tree | 3a4f924df246d6fb046fb04d4f8f347fee389c25 | |
parent | 425e48e98dded75a851965fa2d08e2429f0abc24 (diff) | |
download | skiboot-8409bb744d809211fa5ce184cedab3f2d057f1ba.zip skiboot-8409bb744d809211fa5ce184cedab3f2d057f1ba.tar.gz skiboot-8409bb744d809211fa5ce184cedab3f2d057f1ba.tar.bz2 |
opal-gard: Account for ECC size when clearing partition
[ Upstream commit 27d1ef2ebabb07a1958b94049cac3d90a101c3d5 ]
When 'opal-gard clear all' is run, it works by erasing the GUARD then
using blockevel_smart_write() to write nothing to the partition. This
second write call is needed because we rely on libflash to set the ECC
bits appropriately when the partition contained ECCed data.
The API for this is a little odd with the caller specifying how much
actual data to write, and libflash writing size + size/8 bytes
since there is one additional ECC byte for every eight bytes of data.
We currently do not account for the extra space consumed by the ECC data
in reset_partition() which is used to handle the 'clear all' command.
Which results in the paritition following the GUARD partition being
partially overwritten when the command is used. This patch fixes the
problem by reducing the length we would normally write by the number
of ECC bytes required.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Tested-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
-rw-r--r-- | external/gard/gard.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c index 16da76a..ba15e87 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -598,6 +598,7 @@ static int do_clear_i(struct gard_ctx *ctx, int pos, struct gard_record *gard, v static int reset_partition(struct gard_ctx *ctx) { + int no_ecc_len = (ctx->gard_data_len / 9) * 8; struct gard_record *gard; int rc = 0; @@ -613,7 +614,7 @@ static int reset_partition(struct gard_ctx *ctx) goto out; } - rc = blocklevel_write(ctx->bl, ctx->gard_data_pos, gard, ctx->gard_data_len); + rc = blocklevel_write(ctx->bl, ctx->gard_data_pos, gard, no_ecc_len); if (rc) fprintf(stderr, "Couldn't reset the entire gard partition. Bailing out\n"); |