Attention is currently required from: Yu-Ping Wu.
Hello Yu-Ping Wu,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/85460?usp=email
to review the following change.
Change subject: commonlib/device_tree: Make END token part of struct_size ......................................................................
commonlib/device_tree: Make END token part of struct_size
According to the FDT specification the FDT_END token is supposed to be the last token in the structure block, not a free-floating token immediately outside of it. That means we're supposed to count it in struct_size. It seems that the kernel never cared about this, but some FDT parsing utilities like `fdtgrep` do.
Change-Id: Ic756245fbd673d961cb66936e47691e1dbc86836 Signed-off-by: Julius Werner jwerner@chromium.org --- M src/commonlib/device_tree.c 1 file changed, 2 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/85460/1
diff --git a/src/commonlib/device_tree.c b/src/commonlib/device_tree.c index cb7a596..b2daac9 100644 --- a/src/commonlib/device_tree.c +++ b/src/commonlib/device_tree.c @@ -935,12 +935,11 @@
uint8_t *struct_start = dest; header->structure_offset = htobe32(dest - (uint8_t *)start_dest); + be32enc(&dest[struct_size], FDT_TOKEN_END); + struct_size += sizeof(uint32_t); header->structure_size = htobe32(struct_size); dest += struct_size;
- *((uint32_t *)dest) = htobe32(FDT_TOKEN_END); - dest += sizeof(uint32_t); - uint8_t *strings_start = dest; header->strings_offset = htobe32(dest - (uint8_t *)start_dest); header->strings_size = htobe32(strings_size);