Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81964?usp=email )
Change subject: util/cbfstool: Add --64 option for 64-bit payload stitching ......................................................................
util/cbfstool: Add --64 option for 64-bit payload stitching
When the --64 option is passed, cbfstool now:
* Stitches payloads with x86_64 support enabled. * Injects the CBFS_FILE_ATTR_TAG_PAYLOAD/"PLOD" tag into the payload header.
This allows direct long mode jumps into the payload if supported, otherwise falling back to protected mode. Existing 32-bit payload behavior remains unchanged.
BUG=b:242829490 TEST=Able to verify "PLOD" signature at the payload header while passing `--64` with cbfstool as an argument for stitching payload.
Change-Id: I41562041d6c09869c7966ea31503f002ca1caefa Signed-off-by: Subrata Banik subratabanik@google.com --- M src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h M util/cbfstool/cbfstool.c 2 files changed, 45 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/64/81964/1
diff --git a/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h b/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h index b6a7baa..7451181 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h +++ b/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h @@ -135,8 +135,16 @@ CBFS_FILE_ATTR_TAG_IBB = 0x32494242, /* BE: '2IBB' */ CBFS_FILE_ATTR_TAG_PADDING = 0x47444150, /* BE: 'GNDP' */ CBFS_FILE_ATTR_TAG_STAGEHEADER = 0x53746748, /* BE: 'StgH' */ + CBFS_FILE_ATTR_TAG_PAYLOAD = 0x504C4F44, /* BE: 'PLOD' */ };
+struct cbfs_file_attr_payload { + uint32_t tag; + uint32_t len; + /* 1 for 64-bit payload. 0 for 32-bit payload. */ + uint32_t payload_64_bit; +} __packed; + struct cbfs_file_attr_compression { uint32_t tag; uint32_t len; diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 88bf22b..a973051 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -89,6 +89,7 @@ bool machine_parseable; bool unprocessed; bool ibb; + bool payload_64_bit; enum cbfs_compression compression; int precompression; enum vb2_hash_algorithm hash; @@ -116,6 +117,7 @@ .headeroffset = HEADER_OFFSET_UNKNOWN, .region_name = SECTION_NAME_PRIMARY_CBFS, .u64val = -1, + .payload_64_bit = false, };
/* @@ -1275,6 +1277,34 @@ return 0; }
+static int cbfstool_convert_payload_type(struct cbfs_file *header) +{ + struct cbfs_file_attr_payload *attrs = + (struct cbfs_file_attr_payload *) + cbfs_add_file_attr(header, + CBFS_FILE_ATTR_TAG_PAYLOAD, + sizeof(struct cbfs_file_attr_payload)); + + if (attrs == NULL) + return -1; + + /* Mark as 64-bit payload */ + attrs->payload_64_bit = 1; + return 0; +} + +static int cbfstool_convert_payload_misc(struct buffer *buffer, + unused uint32_t *offset, struct cbfs_file *header) +{ + if (cbfstool_convert_mkpayload(buffer, offset, header) < 0) + return -1; + + if (param.payload_64_bit && cbfstool_convert_payload_type(header) < 0) + return -1; + + return 0; +} + static int cbfstool_convert_mkflatpayload(struct buffer *buffer, unused uint32_t *offset, struct cbfs_file *header) { @@ -1332,7 +1362,7 @@ return cbfs_add_component(param.filename, param.name, param.headeroffset, - cbfstool_convert_mkpayload); + cbfstool_convert_payload_misc); }
static int cbfs_add_flat_binary(void) @@ -1812,6 +1842,7 @@ LONGOPT_START = 256, LONGOPT_IBB = LONGOPT_START, LONGOPT_MMAP, + LONGOPT_PAYLOAD_64, LONGOPT_END, };
@@ -1854,6 +1885,7 @@ {"unprocessed", no_argument, 0, 'U' }, {"ibb", no_argument, 0, LONGOPT_IBB }, {"mmap", required_argument, 0, LONGOPT_MMAP }, + {"64", no_argument, 0, LONGOPT_PAYLOAD_64 }, {NULL, 0, 0, 0 } };
@@ -1971,6 +2003,7 @@ " -j valid size: 0x10000 0x20000 0x40000 0x80000 0x100000 \n" " add-payload [-r image,regions] -f FILE -n NAME [-A hash] \\n" " [-c compression] [-b base-address] \\n" + " [--64 if Payload is 64-bit] \\n" " (linux specific: [-C cmdline] [-I initrd]) " "Add a payload to the ROM\n" " add-stage [-r image,regions] -f FILE -n NAME [-A hash] \\n" @@ -2303,6 +2336,9 @@ case '?': usage(argv[0]); return 1; + case LONGOPT_PAYLOAD_64: + param.payload_64_bit = true; + break; default: break; }