diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2018-03-07 17:04:59 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.ibm.com> | 2018-04-09 19:02:11 -0500 |
commit | 5616c42d900afb04a4df77fe0a882f5258239211 (patch) | |
tree | f7abe843c0699e00223bddf7276a876c0b51787f /core | |
parent | 3df9b3cc82cd9c386a68250b46e3c3648daafd4b (diff) | |
download | talos-skiboot-5616c42d900afb04a4df77fe0a882f5258239211.tar.gz talos-skiboot-5616c42d900afb04a4df77fe0a882f5258239211.zip |
libflash/blocklevel: Make read/write be ECC agnostic for callers
The blocklevel abstraction allows for regions of the backing store to be
marked as ECC protected so that blocklevel can decode/encode the ECC
bytes into the buffer automatically without the caller having to be ECC
aware.
Unfortunately this abstraction is far from perfect, this is only useful
if reads and writes are performed at the start of the ECC region or in
some circumstances at an ECC aligned position - which requires the
caller be aware of the ECC regions.
The problem that has arisen is that the blocklevel abstraction is
initialised somewhere but when it is later called the caller is unaware
if ECC exists in the region it wants to arbitrarily read and write to.
This should not have been a problem since blocklevel knows. Currently
misaligned reads will fail ECC checks and misaligned writes will
overwrite ECC bytes and the backing store will become corrupted.
This patch add the smarts to blocklevel_read() and blocklevel_write() to
cope with the problem. Note that ECC can always be bypassed by calling
blocklevel_raw_() functions.
All this work means that the gard tool can can safely call
blocklevel_read() and blocklevel_write() and as long as the blocklevel
knows of the presence of ECC then it will deal with all cases.
This also commit removes code in the gard tool which compensated for
inadequacies no longer present in blocklevel.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Tested-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
[stewart: core/flash: Adapt to new libflash ECC API
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/flash.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/core/flash.c b/core/flash.c index d526ef33..7140e943 100644 --- a/core/flash.c +++ b/core/flash.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 IBM Corp. +/* Copyright 2013-2018 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -683,8 +683,7 @@ static int flash_load_resource(enum resource_id id, uint32_t subid, prlog(PR_DEBUG,"FLASH: %s partition %s ECC\n", name, ecc ? "has" : "doesn't have"); - if ((ecc ? ecc_buffer_size_minus_ecc(ffs_part_size) : ffs_part_size) < - SECURE_BOOT_HEADERS_SIZE) { + if (ffs_part_size < SECURE_BOOT_HEADERS_SIZE) { prerror("FLASH: secboot headers bigger than " "partition size 0x%x\n", ffs_part_size); goto out_free_ffs; @@ -722,8 +721,6 @@ static int flash_load_resource(enum resource_id id, uint32_t subid, } ffs_part_start += SECURE_BOOT_HEADERS_SIZE; - if (ecc) - ffs_part_start += ecc_size(SECURE_BOOT_HEADERS_SIZE); rc = blocklevel_read(flash->bl, ffs_part_start, bufp, content_size); |