diff options
author | Simon Glass | 2023-12-27 13:07:05 -0800 |
---|---|---|
committer | Simon Glass | 2023-12-31 07:21:02 -0700 |
commit | 997dac6edebe5b82f4d6f9b90753f0af6e9d04f0 (patch) | |
tree | 42c0bebc0af5e779a3982bd983646a78bfb53253 /common | |
parent | 47e1047b0cc25269124737696971ab0c3187666d (diff) |
bloblist: Checksum the entire bloblist
Use a sinple 8-bit checksum for bloblist, as specified by the spec
version 0.9.
Spec v0.9 specifies that the entire bloblist area is checksummed,
including unused portions. Update the code to follow this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Co-developed-by: Raymond Mao <raymond.mao@linaro.org>
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/bloblist.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/common/bloblist.c b/common/bloblist.c index 88e2a0f5c06..705d9c6ae99 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -13,6 +13,7 @@ #include <malloc.h> #include <mapmem.h> #include <spl.h> +#include <tables_csum.h> #include <asm/global_data.h> #include <u-boot/crc.h> @@ -318,16 +319,10 @@ int bloblist_resize(uint tag, int new_size) static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) { - struct bloblist_rec *rec; - u32 chksum; + u8 chksum; - chksum = crc32(0, (unsigned char *)hdr, - offsetof(struct bloblist_hdr, chksum)); - foreach_rec(rec, hdr) { - chksum = crc32(chksum, (void *)rec, rec_hdr_size(rec)); - chksum = crc32(chksum, (void *)rec + rec_hdr_size(rec), - rec->size); - } + chksum = table_compute_checksum(hdr, hdr->alloced); + chksum += hdr->chksum; return chksum; } |