libflash/libffs: Correctly update the actual size of the partition

Message ID 20170621063436.25140-1-cyril.bur@au1.ibm.com
State New
Headers show

Commit Message

Cyril Bur June 21, 2017, 6:34 a.m.
libffs has been updating FFS partition information in the wrong place
which leads to incomplete erases and corruption.

Fixes: 602dee45 libflash/libffs: Rework libffs
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 libflash/libffs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stewart Smith June 21, 2017, 8:42 a.m. | #1
Cyril Bur <cyril.bur@au1.ibm.com> writes:
> libffs has been updating FFS partition information in the wrong place
> which leads to incomplete erases and corruption.
>
> Fixes: 602dee45 libflash/libffs: Rework libffs
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>

Ouch. Yeah, this bit me a bit. Luckily, the hostboot log message that
could hint at the problem is only a few hundred lines prior to the point
where you end in a world of pain.

Merged to master (even though it hasn't shown up in patchwork yet) as of
73e1e8a727a9e7179719eb7844bd4248d9890114.

Joel/Andrew/Patrick: It's been a way too long day for me to remember who
looks after the pflash build in OpenBMC, but you're *really* going to
want to bump up to something that includes this ASAP.
Joel Stanley June 21, 2017, 9:24 a.m. | #2
On Wed, Jun 21, 2017 at 6:12 PM, Stewart Smith
<stewart@linux.vnet.ibm.com> wrote:
> Cyril Bur <cyril.bur@au1.ibm.com> writes:
>> libffs has been updating FFS partition information in the wrong place
>> which leads to incomplete erases and corruption.
>>
>> Fixes: 602dee45 libflash/libffs: Rework libffs
>> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
>
> Ouch. Yeah, this bit me a bit. Luckily, the hostboot log message that
> could hint at the problem is only a few hundred lines prior to the point
> where you end in a world of pain.
>
> Merged to master (even though it hasn't shown up in patchwork yet) as of
> 73e1e8a727a9e7179719eb7844bd4248d9890114.
>
> Joel/Andrew/Patrick: It's been a way too long day for me to remember who
> looks after the pflash build in OpenBMC, but you're *really* going to
> want to bump up to something that includes this ASAP.

I've put the patch into the OpenBMC tree here:

 https://gerrit.openbmc-project.xyz/#/c/4906/

Cheers,

Joel

Patch

diff --git a/libflash/libffs.c b/libflash/libffs.c
index dca40188..6d896334 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -781,7 +781,7 @@  int ffs_update_act_size(struct ffs_handle *ffs, uint32_t part_idx,
 		FL_DBG("FFS: Entry not found\n");
 		return FFS_ERR_PART_NOT_FOUND;
 	}
-	offset = ent->base;
+	offset = ffs->toc_offset + ffs_hdr_raw_size(part_idx);
 	FL_DBG("FFS: part index %d at offset 0x%08x\n",
 	       part_idx, offset);