Add payload info all and payload info nonstatic commands for Dauntless signed image descriptors#213
Add payload info all and payload info nonstatic commands for Dauntless signed image descriptors#213vsk-ant wants to merge 1 commit intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
jhand2
left a comment
There was a problem hiding this comment.
Thank you! Left a few minor comments.
examples/htool_payload.c
Outdated
| int fd = open(image_file, O_RDONLY, 0); | ||
| if (fd == -1) { | ||
| fprintf(stderr, "Error opening file %s: %s\n", image_file, strerror(errno)); | ||
| return -1; | ||
| } | ||
| struct stat statbuf; | ||
| if (fstat(fd, &statbuf)) { | ||
| fprintf(stderr, "fstat error: %s\n", strerror(errno)); | ||
| goto cleanup2; | ||
| } | ||
| if (statbuf.st_size > SIZE_MAX) { | ||
| fprintf(stderr, "file too large\n"); | ||
| goto cleanup2; | ||
| } | ||
|
|
||
| uint8_t* image = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | ||
| if (image == MAP_FAILED) { | ||
| fprintf(stderr, "mmap error: %s\n", strerror(errno)); | ||
| goto cleanup2; | ||
| } |
There was a problem hiding this comment.
nit: Duplicated from the payload_info function. What do you think about refactoring the code to read a payload file into a shared function?
There was a problem hiding this comment.
Updated, thanks for the feedback.
examples/htool_payload.c
Outdated
|
|
||
| printf("Non-static regions:\n"); | ||
| bool found_non_static = false; | ||
| for (uint8_t i = 0; i < info_all.region_count; i++) { |
There was a problem hiding this comment.
Seems like the region printing code could be shared with the all function by passing an attribute mask. e.g. print_regions(&info_all, /*skip_mask=*/IMAGE_REGION_STATIC)
examples/htool.c
Outdated
| .func = htool_payload_info_all, | ||
| }, | ||
| { | ||
| .verbs = (const char*[]){"payload", "info", "gaps", NULL}, |
There was a problem hiding this comment.
Payload descriptors are required to have no gaps (all flash regions must be described in the regions list). Otherwise they are considered invalid and the RoT will reject them.
So I think instead this command can just be payload info nonstatic.
935ff3d to
efebef1
Compare
…s signed image descriptors
efebef1 to
89df90d
Compare
Add payload info all and payload info nonstatic commands for Dauntless signed image descriptors.