[PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
Add support for specifying the parameters needed for capsule generation through a config file, instead of passing them through command-line. Parameters for more than a single capsule file can be specified, resulting in generation of multiple capsules through a single invocation of the command. This path is to be used for generating capsules through a make target, with the parameters being parsed from the config file. Signed-off-by: Sughosh Ganu --- tools/Kconfig | 9 + tools/Makefile | 1 + tools/eficapsule.h | 110 tools/mkeficapsule.c | 106 +++- tools/mkeficapsule_parse.c | 345 + 5 files changed, 531 insertions(+), 40 deletions(-) create mode 100644 tools/mkeficapsule_parse.c diff --git a/tools/Kconfig b/tools/Kconfig index 539708f277..95f27b7c45 100644 --- a/tools/Kconfig +++ b/tools/Kconfig @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE optionally sign that file. If you want to enable UEFI capsule update feature on your target, you certainly need this. +config EFI_CAPSULE_CFG_FILE + string "Path to the EFI Capsule Config File" + default "" + help + Path to the EFI capsule config file which provides the + parameters needed to build capsule(s). Parameters can be + provided for multiple payloads resulting in corresponding + capsule images being generated. + menuconfig FSPI_CONF_HEADER bool "FlexSPI Header Configuration" help diff --git a/tools/Makefile b/tools/Makefile index d793cf3bec..ef366f3d61 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ HOSTLDLIBS_mkeficapsule += \ $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o # We build some files with extra pedantic flags to try to minimize things # that won't build on some weird host compiler -- though there are lots of diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 072a4b5598..42e66c6d6a 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -52,6 +52,38 @@ typedef struct { /* flags */ #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 +enum capsule_type { + CAPSULE_NORMAL_BLOB = 0, + CAPSULE_ACCEPT, + CAPSULE_REVERT, +}; + +/** + * struct efi_capsule_params - Capsule parameters + * @image_guid: Guid value of the payload input image + * @image_index: Image index value + * @hardware_instance: Hardware instance to be used for the image + * @monotonic_count: Monotonic count value to be used for signed capsule + * @privkey_file: Path to private key used in capsule signing + * @cert_file: Path to public key certificate used in capsule signing + * @input_file: Path to payload input image + * @capsule_file: Path to the output capsule file + * @oemflags: Oemflags to be populated in the capsule header + * @capsule: Capsule Type, normal or accept or revert + */ +struct efi_capsule_params { + efi_guid_t *image_guid; + unsigned long image_index; + unsigned long hardware_instance; + uint64_t monotonic_count; + char *privkey_file; + char *cert_file; + char *input_file; + char *capsule_file; + unsigned long oemflags; + enum capsule_type capsule; +}; + struct efi_capsule_header { efi_guid_t capsule_guid; uint32_t header_size; @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { struct win_certificate_uefi_guid auth_info; } __packed; +/** + * capsule_with_cfg_file() - Generate capsule from config file + * @cfg_file: Path to the config file + * + * Parse the capsule parameters from the config file and use the + * parameters for generating one or more capsules. + * + * Return: None + * + */ +void capsule_with_cfg_file(const char *cfg_file); + +/** + * convert_uuid_to_guid() - convert UUID to GUID + * @buf: UUID binary + * + * UUID and GUID have the same data structure, but their binary + * formats are different due to the endianness. See lib/uuid.c. + * Since uuid_parse() can handle only UUID, this function must + * be called to get correct data for GUID when parsing a string. + * + * The correct data will be returned in @buf. + */ +void convert_uuid_to_guid(unsigned char *buf); + +/** + * create_empty_capsule() - Generate an empty capsule + * @path: Path to the empty capsule file to be generated + * @guid: Guid value of the image for which empty capsule is generated + * @fw_accept: Flag to specify whether to generate accept or revert capsule + * + * Generate an empty capsule, either an accept or a revert capsule to be + * used to flag acceptance or rejection of an earlier executed firmware + * update operation. Being used in the FWU Multi Bank firmware update + * feature. + * + * Return: 0 if OK, -ve on error + * + */ +int create_empty_capsule(char
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
Hi Sughosh, I think this is a good extension to mkeficapsule, but On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > Add support for specifying the parameters needed for capsule > generation through a config file, instead of passing them through > command-line. Parameters for more than a single capsule file can be > specified, resulting in generation of multiple capsules through a > single invocation of the command. > > This path is to be used for generating capsules through a make target, > with the parameters being parsed from the config file. > > Signed-off-by: Sughosh Ganu > --- > tools/Kconfig | 9 + > tools/Makefile | 1 + > tools/eficapsule.h | 110 > tools/mkeficapsule.c | 106 +++- > tools/mkeficapsule_parse.c | 345 + > 5 files changed, 531 insertions(+), 40 deletions(-) > create mode 100644 tools/mkeficapsule_parse.c > > diff --git a/tools/Kconfig b/tools/Kconfig > index 539708f277..95f27b7c45 100644 > --- a/tools/Kconfig > +++ b/tools/Kconfig > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > optionally sign that file. If you want to enable UEFI capsule > update feature on your target, you certainly need this. > > +config EFI_CAPSULE_CFG_FILE > + string "Path to the EFI Capsule Config File" > + default "" > + help > + Path to the EFI capsule config file which provides the > + parameters needed to build capsule(s). Parameters can be > + provided for multiple payloads resulting in corresponding > + capsule images being generated. > + > menuconfig FSPI_CONF_HEADER > bool "FlexSPI Header Configuration" > help > diff --git a/tools/Makefile b/tools/Makefile > index d793cf3bec..ef366f3d61 100644 > --- a/tools/Makefile > +++ b/tools/Makefile > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > HOSTLDLIBS_mkeficapsule += \ > $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > # We build some files with extra pedantic flags to try to minimize things > # that won't build on some weird host compiler -- though there are lots of > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > index 072a4b5598..42e66c6d6a 100644 > --- a/tools/eficapsule.h > +++ b/tools/eficapsule.h > @@ -52,6 +52,38 @@ typedef struct { > /* flags */ > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > +enum capsule_type { > + CAPSULE_NORMAL_BLOB = 0, > + CAPSULE_ACCEPT, > + CAPSULE_REVERT, > +}; > + > +/** > + * struct efi_capsule_params - Capsule parameters > + * @image_guid: Guid value of the payload input image > + * @image_index: Image index value > + * @hardware_instance: Hardware instance to be used for the image > + * @monotonic_count: Monotonic count value to be used for signed capsule > + * @privkey_file: Path to private key used in capsule signing > + * @cert_file: Path to public key certificate used in capsule signing > + * @input_file: Path to payload input image > + * @capsule_file: Path to the output capsule file > + * @oemflags: Oemflags to be populated in the capsule header > + * @capsule: Capsule Type, normal or accept or revert > + */ > +struct efi_capsule_params { > + efi_guid_t *image_guid; > + unsigned long image_index; > + unsigned long hardware_instance; > + uint64_t monotonic_count; > + char *privkey_file; > + char *cert_file; > + char *input_file; > + char *capsule_file; > + unsigned long oemflags; > + enum capsule_type capsule; > +}; > + > struct efi_capsule_header { > efi_guid_t capsule_guid; > uint32_t header_size; > @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { > struct win_certificate_uefi_guid auth_info; > } __packed; > > +/** > + * capsule_with_cfg_file() - Generate capsule from config file > + * @cfg_file: Path to the config file > + * > + * Parse the capsule parameters from the config file and use the > + * parameters for generating one or more capsules. > + * > + * Return: None > + * > + */ > +void capsule_with_cfg_file(const char *cfg_file); > + > +/** > + * convert_uuid_to_guid() - convert UUID to GUID > + * @buf: UUID binary > + * > + * UUID and GUID have the same data structure, but their binary > + * formats are different due to the endianness. See lib/uuid.c. > + * Since uuid_parse() can handle only UUID, this function must > + * be called to get correct data for GUID when parsing a string. > + * > + * The correct data will be returned in @buf. > + */ > +void convert_uuid_to_guid(unsigned char *buf); > + > +/** > + * create_empty_capsule() - Generate an empty capsule > + * @path: Path to the empty capsule file to be generated > + * @guid: Guid value of the image for which empty capsule is generated > + * @fw_accept: Flag to specify whether to generate accept or
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
hi Takahiro, On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi wrote: > > Hi Sughosh, > > I think this is a good extension to mkeficapsule, but > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > Add support for specifying the parameters needed for capsule > > generation through a config file, instead of passing them through > > command-line. Parameters for more than a single capsule file can be > > specified, resulting in generation of multiple capsules through a > > single invocation of the command. > > > > This path is to be used for generating capsules through a make target, > > with the parameters being parsed from the config file. > > > > Signed-off-by: Sughosh Ganu > > --- > > tools/Kconfig | 9 + > > tools/Makefile | 1 + > > tools/eficapsule.h | 110 > > tools/mkeficapsule.c | 106 +++- > > tools/mkeficapsule_parse.c | 345 + > > 5 files changed, 531 insertions(+), 40 deletions(-) > > create mode 100644 tools/mkeficapsule_parse.c > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > index 539708f277..95f27b7c45 100644 > > --- a/tools/Kconfig > > +++ b/tools/Kconfig > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > optionally sign that file. If you want to enable UEFI capsule > > update feature on your target, you certainly need this. > > > > +config EFI_CAPSULE_CFG_FILE > > + string "Path to the EFI Capsule Config File" > > + default "" > > + help > > + Path to the EFI capsule config file which provides the > > + parameters needed to build capsule(s). Parameters can be > > + provided for multiple payloads resulting in corresponding > > + capsule images being generated. > > + > > menuconfig FSPI_CONF_HEADER > > bool "FlexSPI Header Configuration" > > help > > diff --git a/tools/Makefile b/tools/Makefile > > index d793cf3bec..ef366f3d61 100644 > > --- a/tools/Makefile > > +++ b/tools/Makefile > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > HOSTLDLIBS_mkeficapsule += \ > > $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > # We build some files with extra pedantic flags to try to minimize things > > # that won't build on some weird host compiler -- though there are lots of > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > index 072a4b5598..42e66c6d6a 100644 > > --- a/tools/eficapsule.h > > +++ b/tools/eficapsule.h > > @@ -52,6 +52,38 @@ typedef struct { > > /* flags */ > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > +enum capsule_type { > > + CAPSULE_NORMAL_BLOB = 0, > > + CAPSULE_ACCEPT, > > + CAPSULE_REVERT, > > +}; > > + > > +/** > > + * struct efi_capsule_params - Capsule parameters > > + * @image_guid: Guid value of the payload input image > > + * @image_index: Image index value > > + * @hardware_instance: Hardware instance to be used for the image > > + * @monotonic_count: Monotonic count value to be used for signed capsule > > + * @privkey_file: Path to private key used in capsule signing > > + * @cert_file: Path to public key certificate used in capsule signing > > + * @input_file: Path to payload input image > > + * @capsule_file: Path to the output capsule file > > + * @oemflags: Oemflags to be populated in the capsule header > > + * @capsule: Capsule Type, normal or accept or revert > > + */ > > +struct efi_capsule_params { > > + efi_guid_t *image_guid; > > + unsigned long image_index; > > + unsigned long hardware_instance; > > + uint64_t monotonic_count; > > + char *privkey_file; > > + char *cert_file; > > + char *input_file; > > + char *capsule_file; > > + unsigned long oemflags; > > + enum capsule_type capsule; > > +}; > > + > > struct efi_capsule_header { > > efi_guid_t capsule_guid; > > uint32_t header_size; > > @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { > > struct win_certificate_uefi_guid auth_info; > > } __packed; > > > > +/** > > + * capsule_with_cfg_file() - Generate capsule from config file > > + * @cfg_file: Path to the config file > > + * > > + * Parse the capsule parameters from the config file and use the > > + * parameters for generating one or more capsules. > > + * > > + * Return: None > > + * > > + */ > > +void capsule_with_cfg_file(const char *cfg_file); > > + > > +/** > > + * convert_uuid_to_guid() - convert UUID to GUID > > + * @buf: UUID binary > > + * > > + * UUID and GUID have the same data structure, but their binary > > + * formats are different due to the endianness. See lib/uuid.c. > > + * Since uuid_parse() can handle only UUID, this function must > > + * be called to get correct data for GUID when parsing a string. > > + * > > + * The correct data will be returned in @buf. > > + */ > > +v
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > hi Takahiro, > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > wrote: > > > > Hi Sughosh, > > > > I think this is a good extension to mkeficapsule, but > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > Add support for specifying the parameters needed for capsule > > > generation through a config file, instead of passing them through > > > command-line. Parameters for more than a single capsule file can be > > > specified, resulting in generation of multiple capsules through a > > > single invocation of the command. > > > > > > This path is to be used for generating capsules through a make target, > > > with the parameters being parsed from the config file. > > > > > > Signed-off-by: Sughosh Ganu > > > --- > > > tools/Kconfig | 9 + > > > tools/Makefile | 1 + > > > tools/eficapsule.h | 110 > > > tools/mkeficapsule.c | 106 +++- > > > tools/mkeficapsule_parse.c | 345 + > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > index 539708f277..95f27b7c45 100644 > > > --- a/tools/Kconfig > > > +++ b/tools/Kconfig > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > optionally sign that file. If you want to enable UEFI capsule > > > update feature on your target, you certainly need this. > > > > > > +config EFI_CAPSULE_CFG_FILE > > > + string "Path to the EFI Capsule Config File" > > > + default "" > > > + help > > > + Path to the EFI capsule config file which provides the > > > + parameters needed to build capsule(s). Parameters can be > > > + provided for multiple payloads resulting in corresponding > > > + capsule images being generated. > > > + > > > menuconfig FSPI_CONF_HEADER > > > bool "FlexSPI Header Configuration" > > > help > > > diff --git a/tools/Makefile b/tools/Makefile > > > index d793cf3bec..ef366f3d61 100644 > > > --- a/tools/Makefile > > > +++ b/tools/Makefile > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > HOSTLDLIBS_mkeficapsule += \ > > > $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > # We build some files with extra pedantic flags to try to minimize things > > > # that won't build on some weird host compiler -- though there are lots > > > of > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > index 072a4b5598..42e66c6d6a 100644 > > > --- a/tools/eficapsule.h > > > +++ b/tools/eficapsule.h > > > @@ -52,6 +52,38 @@ typedef struct { > > > /* flags */ > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > +enum capsule_type { > > > + CAPSULE_NORMAL_BLOB = 0, > > > + CAPSULE_ACCEPT, > > > + CAPSULE_REVERT, > > > +}; > > > + > > > +/** > > > + * struct efi_capsule_params - Capsule parameters > > > + * @image_guid: Guid value of the payload input image > > > + * @image_index: Image index value > > > + * @hardware_instance: Hardware instance to be used for the image > > > + * @monotonic_count: Monotonic count value to be used for signed capsule > > > + * @privkey_file: Path to private key used in capsule signing > > > + * @cert_file: Path to public key certificate used in capsule signing > > > + * @input_file: Path to payload input image > > > + * @capsule_file: Path to the output capsule file > > > + * @oemflags: Oemflags to be populated in the capsule header > > > + * @capsule: Capsule Type, normal or accept or revert > > > + */ > > > +struct efi_capsule_params { > > > + efi_guid_t *image_guid; > > > + unsigned long image_index; > > > + unsigned long hardware_instance; > > > + uint64_t monotonic_count; > > > + char *privkey_file; > > > + char *cert_file; > > > + char *input_file; > > > + char *capsule_file; > > > + unsigned long oemflags; > > > + enum capsule_type capsule; > > > +}; > > > + > > > struct efi_capsule_header { > > > efi_guid_t capsule_guid; > > > uint32_t header_size; > > > @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { > > > struct win_certificate_uefi_guid auth_info; > > > } __packed; > > > > > > +/** > > > + * capsule_with_cfg_file() - Generate capsule from config file > > > + * @cfg_file: Path to the config file > > > + * > > > + * Parse the capsule parameters from the config file and use the > > > + * parameters for generating one or more capsules. > > > + * > > > + * Return: None > > > + * > > > + */ > > > +void capsule_with_cfg_file(const char *cfg_file); > > > + > > > +/** > > > + * convert_uuid_to_guid() - convert UUID to GUID > > > + * @buf: UUID binary > > > + * > > > + * UUID and GUID have the
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi wrote: > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > hi Takahiro, > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > wrote: > > > > > > Hi Sughosh, > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > Add support for specifying the parameters needed for capsule > > > > generation through a config file, instead of passing them through > > > > command-line. Parameters for more than a single capsule file can be > > > > specified, resulting in generation of multiple capsules through a > > > > single invocation of the command. > > > > > > > > This path is to be used for generating capsules through a make target, > > > > with the parameters being parsed from the config file. > > > > > > > > Signed-off-by: Sughosh Ganu > > > > --- > > > > tools/Kconfig | 9 + > > > > tools/Makefile | 1 + > > > > tools/eficapsule.h | 110 > > > > tools/mkeficapsule.c | 106 +++- > > > > tools/mkeficapsule_parse.c | 345 + > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > index 539708f277..95f27b7c45 100644 > > > > --- a/tools/Kconfig > > > > +++ b/tools/Kconfig > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > optionally sign that file. If you want to enable UEFI capsule > > > > update feature on your target, you certainly need this. > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > + string "Path to the EFI Capsule Config File" > > > > + default "" > > > > + help > > > > + Path to the EFI capsule config file which provides the > > > > + parameters needed to build capsule(s). Parameters can be > > > > + provided for multiple payloads resulting in corresponding > > > > + capsule images being generated. > > > > + > > > > menuconfig FSPI_CONF_HEADER > > > > bool "FlexSPI Header Configuration" > > > > help > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > index d793cf3bec..ef366f3d61 100644 > > > > --- a/tools/Makefile > > > > +++ b/tools/Makefile > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > HOSTLDLIBS_mkeficapsule += \ > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > # We build some files with extra pedantic flags to try to minimize > > > > things > > > > # that won't build on some weird host compiler -- though there are > > > > lots of > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > index 072a4b5598..42e66c6d6a 100644 > > > > --- a/tools/eficapsule.h > > > > +++ b/tools/eficapsule.h > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > /* flags */ > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > +enum capsule_type { > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > + CAPSULE_ACCEPT, > > > > + CAPSULE_REVERT, > > > > +}; > > > > + > > > > +/** > > > > + * struct efi_capsule_params - Capsule parameters > > > > + * @image_guid: Guid value of the payload input image > > > > + * @image_index: Image index value > > > > + * @hardware_instance: Hardware instance to be used for the image > > > > + * @monotonic_count: Monotonic count value to be used for signed > > > > capsule > > > > + * @privkey_file: Path to private key used in capsule signing > > > > + * @cert_file: Path to public key certificate used in capsule signing > > > > + * @input_file: Path to payload input image > > > > + * @capsule_file: Path to the output capsule file > > > > + * @oemflags: Oemflags to be populated in the capsule header > > > > + * @capsule: Capsule Type, normal or accept or revert > > > > + */ > > > > +struct efi_capsule_params { > > > > + efi_guid_t *image_guid; > > > > + unsigned long image_index; > > > > + unsigned long hardware_instance; > > > > + uint64_t monotonic_count; > > > > + char *privkey_file; > > > > + char *cert_file; > > > > + char *input_file; > > > > + char *capsule_file; > > > > + unsigned long oemflags; > > > > + enum capsule_type capsule; > > > > +}; > > > > + > > > > struct efi_capsule_header { > > > > efi_guid_t capsule_guid; > > > > uint32_t header_size; > > > > @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { > > > > struct win_certificate_uefi_guid auth_info; > > > > } __packed; > > > > > > > > +/** > > > > + * capsule_with_cfg_file() - Generate capsule from config file > > > > + * @cfg_file: Path to the config file > > > > + * > > > > + * Parse the capsule parameters from the config file and use the > > > > + * para
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > wrote: > > > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > > hi Takahiro, > > > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > > wrote: > > > > > > > > Hi Sughosh, > > > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > > Add support for specifying the parameters needed for capsule > > > > > generation through a config file, instead of passing them through > > > > > command-line. Parameters for more than a single capsule file can be > > > > > specified, resulting in generation of multiple capsules through a > > > > > single invocation of the command. > > > > > > > > > > This path is to be used for generating capsules through a make target, > > > > > with the parameters being parsed from the config file. > > > > > > > > > > Signed-off-by: Sughosh Ganu > > > > > --- > > > > > tools/Kconfig | 9 + > > > > > tools/Makefile | 1 + > > > > > tools/eficapsule.h | 110 > > > > > tools/mkeficapsule.c | 106 +++- > > > > > tools/mkeficapsule_parse.c | 345 > > > > > + > > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > > index 539708f277..95f27b7c45 100644 > > > > > --- a/tools/Kconfig > > > > > +++ b/tools/Kconfig > > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > > optionally sign that file. If you want to enable UEFI capsule > > > > > update feature on your target, you certainly need this. > > > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > > + string "Path to the EFI Capsule Config File" > > > > > + default "" > > > > > + help > > > > > + Path to the EFI capsule config file which provides the > > > > > + parameters needed to build capsule(s). Parameters can be > > > > > + provided for multiple payloads resulting in corresponding > > > > > + capsule images being generated. > > > > > + > > > > > menuconfig FSPI_CONF_HEADER > > > > > bool "FlexSPI Header Configuration" > > > > > help > > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > > index d793cf3bec..ef366f3d61 100644 > > > > > --- a/tools/Makefile > > > > > +++ b/tools/Makefile > > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > > HOSTLDLIBS_mkeficapsule += \ > > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") > > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > > > # We build some files with extra pedantic flags to try to minimize > > > > > things > > > > > # that won't build on some weird host compiler -- though there are > > > > > lots of > > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > > index 072a4b5598..42e66c6d6a 100644 > > > > > --- a/tools/eficapsule.h > > > > > +++ b/tools/eficapsule.h > > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > > /* flags */ > > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > > > +enum capsule_type { > > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > > + CAPSULE_ACCEPT, > > > > > + CAPSULE_REVERT, > > > > > +}; > > > > > + > > > > > +/** > > > > > + * struct efi_capsule_params - Capsule parameters > > > > > + * @image_guid: Guid value of the payload input image > > > > > + * @image_index: Image index value > > > > > + * @hardware_instance: Hardware instance to be used for the image > > > > > + * @monotonic_count: Monotonic count value to be used for signed > > > > > capsule > > > > > + * @privkey_file: Path to private key used in capsule signing > > > > > + * @cert_file: Path to public key certificate used in capsule signing > > > > > + * @input_file: Path to payload input image > > > > > + * @capsule_file: Path to the output capsule file > > > > > + * @oemflags: Oemflags to be populated in the capsule header > > > > > + * @capsule: Capsule Type, normal or accept or revert > > > > > + */ > > > > > +struct efi_capsule_params { > > > > > + efi_guid_t *image_guid; > > > > > + unsigned long image_index; > > > > > + unsigned long hardware_instance; > > > > > + uint64_t monotonic_count; > > > > > + char *privkey_file; > > > > > + char *cert_file; > > > > > + char *input_file; > > > > > + char *capsule_file; > > > > > + unsigned long oemflags; > > > > > + enum capsule_type capsule; > > > > > +}; > > > > > + > > > > > struct efi_capsule_header { > > > > > efi_guid_t capsule_guid; > > > > > uint32_t header_size; > > > > > @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { > > > > > struct w
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi wrote: > > On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > > wrote: > > > > > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > > > hi Takahiro, > > > > > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > > > wrote: > > > > > > > > > > Hi Sughosh, > > > > > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > > > Add support for specifying the parameters needed for capsule > > > > > > generation through a config file, instead of passing them through > > > > > > command-line. Parameters for more than a single capsule file can be > > > > > > specified, resulting in generation of multiple capsules through a > > > > > > single invocation of the command. > > > > > > > > > > > > This path is to be used for generating capsules through a make > > > > > > target, > > > > > > with the parameters being parsed from the config file. > > > > > > > > > > > > Signed-off-by: Sughosh Ganu > > > > > > --- > > > > > > tools/Kconfig | 9 + > > > > > > tools/Makefile | 1 + > > > > > > tools/eficapsule.h | 110 > > > > > > tools/mkeficapsule.c | 106 +++- > > > > > > tools/mkeficapsule_parse.c | 345 > > > > > > + > > > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > > > index 539708f277..95f27b7c45 100644 > > > > > > --- a/tools/Kconfig > > > > > > +++ b/tools/Kconfig > > > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > > > optionally sign that file. If you want to enable UEFI > > > > > > capsule > > > > > > update feature on your target, you certainly need this. > > > > > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > > > + string "Path to the EFI Capsule Config File" > > > > > > + default "" > > > > > > + help > > > > > > + Path to the EFI capsule config file which provides the > > > > > > + parameters needed to build capsule(s). Parameters can be > > > > > > + provided for multiple payloads resulting in corresponding > > > > > > + capsule images being generated. > > > > > > + > > > > > > menuconfig FSPI_CONF_HEADER > > > > > > bool "FlexSPI Header Configuration" > > > > > > help > > > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > > > index d793cf3bec..ef366f3d61 100644 > > > > > > --- a/tools/Makefile > > > > > > +++ b/tools/Makefile > > > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > > > HOSTLDLIBS_mkeficapsule += \ > > > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") > > > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > > > > > # We build some files with extra pedantic flags to try to minimize > > > > > > things > > > > > > # that won't build on some weird host compiler -- though there are > > > > > > lots of > > > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > > > index 072a4b5598..42e66c6d6a 100644 > > > > > > --- a/tools/eficapsule.h > > > > > > +++ b/tools/eficapsule.h > > > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > > > /* flags */ > > > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > > > > > +enum capsule_type { > > > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > > > + CAPSULE_ACCEPT, > > > > > > + CAPSULE_REVERT, > > > > > > +}; > > > > > > + > > > > > > +/** > > > > > > + * struct efi_capsule_params - Capsule parameters > > > > > > + * @image_guid: Guid value of the payload input image > > > > > > + * @image_index: Image index value > > > > > > + * @hardware_instance: Hardware instance to be used for the image > > > > > > + * @monotonic_count: Monotonic count value to be used for signed > > > > > > capsule > > > > > > + * @privkey_file: Path to private key used in capsule signing > > > > > > + * @cert_file: Path to public key certificate used in capsule > > > > > > signing > > > > > > + * @input_file: Path to payload input image > > > > > > + * @capsule_file: Path to the output capsule file > > > > > > + * @oemflags: Oemflags to be populated in the capsule header > > > > > > + * @capsule: Capsule Type, normal or accept or revert > > > > > > + */ > > > > > > +struct efi_capsule_params { > > > > > > + efi_guid_t *image_guid; > > > > > > + unsigned long image_index; > > > > > > + unsigned long hardware_instance; > > > > > > + uint64_t monotonic_count; > > > > > > + char *privkey_file; > > > > > > + char *cert_file; > > > > > > + char *input_file; > > > > > > + char *capsule_file; > > > > > > +
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
Hi Sughosh, On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: > On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi > wrote: > > > > On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > > > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > > > wrote: > > > > > > > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > > > > hi Takahiro, > > > > > > > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > > > > wrote: > > > > > > > > > > > > Hi Sughosh, > > > > > > > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > > > > Add support for specifying the parameters needed for capsule > > > > > > > generation through a config file, instead of passing them through > > > > > > > command-line. Parameters for more than a single capsule file can > > > > > > > be > > > > > > > specified, resulting in generation of multiple capsules through a > > > > > > > single invocation of the command. > > > > > > > > > > > > > > This path is to be used for generating capsules through a make > > > > > > > target, > > > > > > > with the parameters being parsed from the config file. > > > > > > > > > > > > > > Signed-off-by: Sughosh Ganu > > > > > > > --- > > > > > > > tools/Kconfig | 9 + > > > > > > > tools/Makefile | 1 + > > > > > > > tools/eficapsule.h | 110 > > > > > > > tools/mkeficapsule.c | 106 +++- > > > > > > > tools/mkeficapsule_parse.c | 345 > > > > > > > + > > > > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > > > > index 539708f277..95f27b7c45 100644 > > > > > > > --- a/tools/Kconfig > > > > > > > +++ b/tools/Kconfig > > > > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > > > > optionally sign that file. If you want to enable UEFI > > > > > > > capsule > > > > > > > update feature on your target, you certainly need this. > > > > > > > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > > > > + string "Path to the EFI Capsule Config File" > > > > > > > + default "" > > > > > > > + help > > > > > > > + Path to the EFI capsule config file which provides the > > > > > > > + parameters needed to build capsule(s). Parameters can be > > > > > > > + provided for multiple payloads resulting in corresponding > > > > > > > + capsule images being generated. > > > > > > > + > > > > > > > menuconfig FSPI_CONF_HEADER > > > > > > > bool "FlexSPI Header Configuration" > > > > > > > help > > > > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > > > > index d793cf3bec..ef366f3d61 100644 > > > > > > > --- a/tools/Makefile > > > > > > > +++ b/tools/Makefile > > > > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > > > > HOSTLDLIBS_mkeficapsule += \ > > > > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo > > > > > > > "-luuid") > > > > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > > > > > > > # We build some files with extra pedantic flags to try to > > > > > > > minimize things > > > > > > > # that won't build on some weird host compiler -- though there > > > > > > > are lots of > > > > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > > > > index 072a4b5598..42e66c6d6a 100644 > > > > > > > --- a/tools/eficapsule.h > > > > > > > +++ b/tools/eficapsule.h > > > > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > > > > /* flags */ > > > > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > > > > > > > +enum capsule_type { > > > > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > > > > + CAPSULE_ACCEPT, > > > > > > > + CAPSULE_REVERT, > > > > > > > +}; > > > > > > > + > > > > > > > +/** > > > > > > > + * struct efi_capsule_params - Capsule parameters > > > > > > > + * @image_guid: Guid value of the payload input image > > > > > > > + * @image_index: Image index value > > > > > > > + * @hardware_instance: Hardware instance to be used for the image > > > > > > > + * @monotonic_count: Monotonic count value to be used for signed > > > > > > > capsule > > > > > > > + * @privkey_file: Path to private key used in capsule signing > > > > > > > + * @cert_file: Path to public key certificate used in capsule > > > > > > > signing > > > > > > > + * @input_file: Path to payload input image > > > > > > > + * @capsule_file: Path to the output capsule file > > > > > > > + * @oemflags: Oemflags to be populated in the capsule header > > > > > > > + * @capsule: Capsule Type, normal or accept or revert > > > > > > > + */ > > > > > > > +struct efi_capsule_params { > > > > > > > + efi_guid_t *im
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
hi Takahiro, On Fri, 16 Jun 2023 at 10:16, Takahiro Akashi wrote: > > Hi Sughosh, > > On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: > > On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi > > wrote: > > > > > > On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > > > > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > > > > wrote: > > > > > > > > > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > > > > > hi Takahiro, > > > > > > > > > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > > > > > wrote: > > > > > > > > > > > > > > Hi Sughosh, > > > > > > > > > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > > > > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > > > > > Add support for specifying the parameters needed for capsule > > > > > > > > generation through a config file, instead of passing them > > > > > > > > through > > > > > > > > command-line. Parameters for more than a single capsule file > > > > > > > > can be > > > > > > > > specified, resulting in generation of multiple capsules through > > > > > > > > a > > > > > > > > single invocation of the command. > > > > > > > > > > > > > > > > This path is to be used for generating capsules through a make > > > > > > > > target, > > > > > > > > with the parameters being parsed from the config file. > > > > > > > > > > > > > > > > Signed-off-by: Sughosh Ganu > > > > > > > > --- > > > > > > > > tools/Kconfig | 9 + > > > > > > > > tools/Makefile | 1 + > > > > > > > > tools/eficapsule.h | 110 > > > > > > > > tools/mkeficapsule.c | 106 +++- > > > > > > > > tools/mkeficapsule_parse.c | 345 > > > > > > > > + > > > > > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > > > > > index 539708f277..95f27b7c45 100644 > > > > > > > > --- a/tools/Kconfig > > > > > > > > +++ b/tools/Kconfig > > > > > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > > > > > optionally sign that file. If you want to enable UEFI > > > > > > > > capsule > > > > > > > > update feature on your target, you certainly need this. > > > > > > > > > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > > > > > + string "Path to the EFI Capsule Config File" > > > > > > > > + default "" > > > > > > > > + help > > > > > > > > + Path to the EFI capsule config file which provides the > > > > > > > > + parameters needed to build capsule(s). Parameters can be > > > > > > > > + provided for multiple payloads resulting in > > > > > > > > corresponding > > > > > > > > + capsule images being generated. > > > > > > > > + > > > > > > > > menuconfig FSPI_CONF_HEADER > > > > > > > > bool "FlexSPI Header Configuration" > > > > > > > > help > > > > > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > > > > > index d793cf3bec..ef366f3d61 100644 > > > > > > > > --- a/tools/Makefile > > > > > > > > +++ b/tools/Makefile > > > > > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > > > > > HOSTLDLIBS_mkeficapsule += \ > > > > > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo > > > > > > > > "-luuid") > > > > > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > > > > > > > > > # We build some files with extra pedantic flags to try to > > > > > > > > minimize things > > > > > > > > # that won't build on some weird host compiler -- though there > > > > > > > > are lots of > > > > > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > > > > > index 072a4b5598..42e66c6d6a 100644 > > > > > > > > --- a/tools/eficapsule.h > > > > > > > > +++ b/tools/eficapsule.h > > > > > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > > > > > /* flags */ > > > > > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > > > > > > > > > +enum capsule_type { > > > > > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > > > > > + CAPSULE_ACCEPT, > > > > > > > > + CAPSULE_REVERT, > > > > > > > > +}; > > > > > > > > + > > > > > > > > +/** > > > > > > > > + * struct efi_capsule_params - Capsule parameters > > > > > > > > + * @image_guid: Guid value of the payload input image > > > > > > > > + * @image_index: Image index value > > > > > > > > + * @hardware_instance: Hardware instance to be used for the > > > > > > > > image > > > > > > > > + * @monotonic_count: Monotonic count value to be used for > > > > > > > > signed capsule > > > > > > > > + * @privkey_file: Path to private key used in capsule signing > > > > > > > > + * @cert_file: Path to public key certificate used in capsule > > > > > > > > signing > > > > > > > > + * @i
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
On Fri, Jun 16, 2023 at 10:37:01AM +0530, Sughosh Ganu wrote: > hi Takahiro, > > On Fri, 16 Jun 2023 at 10:16, Takahiro Akashi > wrote: > > > > Hi Sughosh, > > > > On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: > > > On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi > > > wrote: > > > > > > > > On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > > > > > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > > > > > wrote: > > > > > > > > > > > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > > > > > > hi Takahiro, > > > > > > > > > > > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > > > > > > wrote: > > > > > > > > > > > > > > > > Hi Sughosh, > > > > > > > > > > > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > > > > > > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > > > > > > Add support for specifying the parameters needed for capsule > > > > > > > > > generation through a config file, instead of passing them > > > > > > > > > through > > > > > > > > > command-line. Parameters for more than a single capsule file > > > > > > > > > can be > > > > > > > > > specified, resulting in generation of multiple capsules > > > > > > > > > through a > > > > > > > > > single invocation of the command. > > > > > > > > > > > > > > > > > > This path is to be used for generating capsules through a > > > > > > > > > make target, > > > > > > > > > with the parameters being parsed from the config file. > > > > > > > > > > > > > > > > > > Signed-off-by: Sughosh Ganu > > > > > > > > > --- > > > > > > > > > tools/Kconfig | 9 + > > > > > > > > > tools/Makefile | 1 + > > > > > > > > > tools/eficapsule.h | 110 > > > > > > > > > tools/mkeficapsule.c | 106 +++- > > > > > > > > > tools/mkeficapsule_parse.c | 345 > > > > > > > > > + > > > > > > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > > > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > > > > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > > > > > > index 539708f277..95f27b7c45 100644 > > > > > > > > > --- a/tools/Kconfig > > > > > > > > > +++ b/tools/Kconfig > > > > > > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > > > > > > optionally sign that file. If you want to enable UEFI > > > > > > > > > capsule > > > > > > > > > update feature on your target, you certainly need > > > > > > > > > this. > > > > > > > > > > > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > > > > > > + string "Path to the EFI Capsule Config File" > > > > > > > > > + default "" > > > > > > > > > + help > > > > > > > > > + Path to the EFI capsule config file which provides the > > > > > > > > > + parameters needed to build capsule(s). Parameters can > > > > > > > > > be > > > > > > > > > + provided for multiple payloads resulting in > > > > > > > > > corresponding > > > > > > > > > + capsule images being generated. > > > > > > > > > + > > > > > > > > > menuconfig FSPI_CONF_HEADER > > > > > > > > > bool "FlexSPI Header Configuration" > > > > > > > > > help > > > > > > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > > > > > > index d793cf3bec..ef366f3d61 100644 > > > > > > > > > --- a/tools/Makefile > > > > > > > > > +++ b/tools/Makefile > > > > > > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > > > > > > HOSTLDLIBS_mkeficapsule += \ > > > > > > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo > > > > > > > > > "-luuid") > > > > > > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > > > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > > > > > > > > > > > # We build some files with extra pedantic flags to try to > > > > > > > > > minimize things > > > > > > > > > # that won't build on some weird host compiler -- though > > > > > > > > > there are lots of > > > > > > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > > > > > > index 072a4b5598..42e66c6d6a 100644 > > > > > > > > > --- a/tools/eficapsule.h > > > > > > > > > +++ b/tools/eficapsule.h > > > > > > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > > > > > > /* flags */ > > > > > > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > > > > > > > > > > > +enum capsule_type { > > > > > > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > > > > > > + CAPSULE_ACCEPT, > > > > > > > > > + CAPSULE_REVERT, > > > > > > > > > +}; > > > > > > > > > + > > > > > > > > > +/** > > > > > > > > > + * struct efi_capsule_params - Capsule parameters > > > > > > > > > + * @image_guid: Guid value of the payload input image > > > > > > > > > + * @image_index: Image index value > > > > > > > > > + * @hardware_instance: Hardware instance to be used for the > > > > > > > > > imag
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
On Fri, 16 Jun 2023 at 10:48, Takahiro Akashi wrote: > > On Fri, Jun 16, 2023 at 10:37:01AM +0530, Sughosh Ganu wrote: > > hi Takahiro, > > > > On Fri, 16 Jun 2023 at 10:16, Takahiro Akashi > > wrote: > > > > > > Hi Sughosh, > > > > > > On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: > > > > On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi > > > > wrote: > > > > > > > > > > On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > > > > > > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > > > > > > wrote: > > > > > > > > > > > > > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > > > > > > > hi Takahiro, > > > > > > > > > > > > > > > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > Hi Sughosh, > > > > > > > > > > > > > > > > > > I think this is a good extension to mkeficapsule, but > > > > > > > > > > > > > > > > > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > > > > > > > > > Add support for specifying the parameters needed for capsule > > > > > > > > > > generation through a config file, instead of passing them > > > > > > > > > > through > > > > > > > > > > command-line. Parameters for more than a single capsule > > > > > > > > > > file can be > > > > > > > > > > specified, resulting in generation of multiple capsules > > > > > > > > > > through a > > > > > > > > > > single invocation of the command. > > > > > > > > > > > > > > > > > > > > This path is to be used for generating capsules through a > > > > > > > > > > make target, > > > > > > > > > > with the parameters being parsed from the config file. > > > > > > > > > > > > > > > > > > > > Signed-off-by: Sughosh Ganu > > > > > > > > > > --- > > > > > > > > > > tools/Kconfig | 9 + > > > > > > > > > > tools/Makefile | 1 + > > > > > > > > > > tools/eficapsule.h | 110 > > > > > > > > > > tools/mkeficapsule.c | 106 +++- > > > > > > > > > > tools/mkeficapsule_parse.c | 345 > > > > > > > > > > + > > > > > > > > > > 5 files changed, 531 insertions(+), 40 deletions(-) > > > > > > > > > > create mode 100644 tools/mkeficapsule_parse.c > > > > > > > > > > > > > > > > > > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > > > > > > > > index 539708f277..95f27b7c45 100644 > > > > > > > > > > --- a/tools/Kconfig > > > > > > > > > > +++ b/tools/Kconfig > > > > > > > > > > @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE > > > > > > > > > > optionally sign that file. If you want to enable > > > > > > > > > > UEFI capsule > > > > > > > > > > update feature on your target, you certainly need > > > > > > > > > > this. > > > > > > > > > > > > > > > > > > > > +config EFI_CAPSULE_CFG_FILE > > > > > > > > > > + string "Path to the EFI Capsule Config File" > > > > > > > > > > + default "" > > > > > > > > > > + help > > > > > > > > > > + Path to the EFI capsule config file which provides > > > > > > > > > > the > > > > > > > > > > + parameters needed to build capsule(s). Parameters > > > > > > > > > > can be > > > > > > > > > > + provided for multiple payloads resulting in > > > > > > > > > > corresponding > > > > > > > > > > + capsule images being generated. > > > > > > > > > > + > > > > > > > > > > menuconfig FSPI_CONF_HEADER > > > > > > > > > > bool "FlexSPI Header Configuration" > > > > > > > > > > help > > > > > > > > > > diff --git a/tools/Makefile b/tools/Makefile > > > > > > > > > > index d793cf3bec..ef366f3d61 100644 > > > > > > > > > > --- a/tools/Makefile > > > > > > > > > > +++ b/tools/Makefile > > > > > > > > > > @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ > > > > > > > > > > HOSTLDLIBS_mkeficapsule += \ > > > > > > > > > > $(shell pkg-config --libs uuid 2> /dev/null || echo > > > > > > > > > > "-luuid") > > > > > > > > > > hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule > > > > > > > > > > +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o > > > > > > > > > > > > > > > > > > > > # We build some files with extra pedantic flags to try to > > > > > > > > > > minimize things > > > > > > > > > > # that won't build on some weird host compiler -- though > > > > > > > > > > there are lots of > > > > > > > > > > diff --git a/tools/eficapsule.h b/tools/eficapsule.h > > > > > > > > > > index 072a4b5598..42e66c6d6a 100644 > > > > > > > > > > --- a/tools/eficapsule.h > > > > > > > > > > +++ b/tools/eficapsule.h > > > > > > > > > > @@ -52,6 +52,38 @@ typedef struct { > > > > > > > > > > /* flags */ > > > > > > > > > > #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 > > > > > > > > > > > > > > > > > > > > +enum capsule_type { > > > > > > > > > > + CAPSULE_NORMAL_BLOB = 0, > > > > > > > > > > + CAPSULE_ACCEPT, > > > > > > > > > > + CAPSULE_REVERT, > > > > > > > > > > +}; > > > > > > > > > > + > > > > > > > > > > +/** > > > > > >
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
Hi sughosh, Am 16.06.2023 um 08:35 schrieb Sughosh Ganu: On Fri, 16 Jun 2023 at 10:48, Takahiro Akashi wrote: On Fri, Jun 16, 2023 at 10:37:01AM +0530, Sughosh Ganu wrote: hi Takahiro, On Fri, 16 Jun 2023 at 10:16, Takahiro Akashi wrote: Hi Sughosh, On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi wrote: On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi wrote: On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: hi Takahiro, On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi wrote: Hi Sughosh, I think this is a good extension to mkeficapsule, but On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: Add support for specifying the parameters needed for capsule generation through a config file, instead of passing them through command-line. Parameters for more than a single capsule file can be specified, resulting in generation of multiple capsules through a single invocation of the command. This path is to be used for generating capsules through a make target, with the parameters being parsed from the config file. Signed-off-by: Sughosh Ganu --- tools/Kconfig | 9 + tools/Makefile | 1 + tools/eficapsule.h | 110 tools/mkeficapsule.c | 106 +++- tools/mkeficapsule_parse.c | 345 + 5 files changed, 531 insertions(+), 40 deletions(-) create mode 100644 tools/mkeficapsule_parse.c diff --git a/tools/Kconfig b/tools/Kconfig index 539708f277..95f27b7c45 100644 --- a/tools/Kconfig +++ b/tools/Kconfig @@ -98,6 +98,15 @@ config TOOLS_MKEFICAPSULE optionally sign that file. If you want to enable UEFI capsule update feature on your target, you certainly need this. +config EFI_CAPSULE_CFG_FILE + string "Path to the EFI Capsule Config File" + default "" + help + Path to the EFI capsule config file which provides the + parameters needed to build capsule(s). Parameters can be + provided for multiple payloads resulting in corresponding + capsule images being generated. + menuconfig FSPI_CONF_HEADER bool "FlexSPI Header Configuration" help diff --git a/tools/Makefile b/tools/Makefile index d793cf3bec..ef366f3d61 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -250,6 +250,7 @@ HOSTLDLIBS_mkeficapsule += \ HOSTLDLIBS_mkeficapsule += \ $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule +mkeficapsule-objs := mkeficapsule.o mkeficapsule_parse.o # We build some files with extra pedantic flags to try to minimize things # that won't build on some weird host compiler -- though there are lots of diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 072a4b5598..42e66c6d6a 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -52,6 +52,38 @@ typedef struct { /* flags */ #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001 +enum capsule_type { + CAPSULE_NORMAL_BLOB = 0, + CAPSULE_ACCEPT, + CAPSULE_REVERT, +}; + +/** + * struct efi_capsule_params - Capsule parameters + * @image_guid: Guid value of the payload input image + * @image_index: Image index value + * @hardware_instance: Hardware instance to be used for the image + * @monotonic_count: Monotonic count value to be used for signed capsule + * @privkey_file: Path to private key used in capsule signing + * @cert_file: Path to public key certificate used in capsule signing + * @input_file: Path to payload input image + * @capsule_file: Path to the output capsule file + * @oemflags: Oemflags to be populated in the capsule header + * @capsule: Capsule Type, normal or accept or revert + */ +struct efi_capsule_params { + efi_guid_t *image_guid; + unsigned long image_index; + unsigned long hardware_instance; + uint64_t monotonic_count; + char *privkey_file; + char *cert_file; + char *input_file; + char *capsule_file; + unsigned long oemflags; + enum capsule_type capsule; +}; + struct efi_capsule_header { efi_guid_t capsule_guid; uint32_t header_size; @@ -113,4 +145,82 @@ struct efi_firmware_image_authentication { struct win_certificate_uefi_guid auth_info; } __packed; +/** + * capsule_with_cfg_file() - Generate capsule from config file + * @cfg_file: Path to the config file + * + * Parse the capsule parameters from the config file and use the + * parameters for generating one or more capsules. + * + * Return: None + * + */ +void capsule_with_cfg_file(const char *cfg_file); + +/** + * convert_uuid_to_guid() - convert UUID to GUID + * @buf: UUID binary + * + * UUID and GUID have the same data structure, but their binary + * formats are different due to the endianness. See lib/uuid.c. + * Since uuid_parse() can handle only UUID, this function must + * be called to get corre
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
hi Malte, On Fri, 16 Jun 2023 at 18:42, Schmidt, Malte wrote: > > Hi sughosh, > > Am 16.06.2023 um 08:35 schrieb Sughosh Ganu: > > On Fri, 16 Jun 2023 at 10:48, Takahiro Akashi > wrote: > > On Fri, Jun 16, 2023 at 10:37:01AM +0530, Sughosh Ganu wrote: > > hi Takahiro, > > On Fri, 16 Jun 2023 at 10:16, Takahiro Akashi > wrote: > > Hi Sughosh, > > On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: > > On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi > wrote: > > On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: > > On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi > wrote: > > On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: > > hi Takahiro, > > On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi > wrote: > > Hi Sughosh, > > I think this is a good extension to mkeficapsule, but > > On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: > > Add support for specifying the parameters needed for capsule > generation through a config file, instead of passing them through > command-line. Parameters for more than a single capsule file can be > specified, resulting in generation of multiple capsules through a > single invocation of the command. > > This path is to be used for generating capsules through a make target, > with the parameters being parsed from the config file. > > Signed-off-by: Sughosh Ganu > --- > tools/Kconfig | 9 + > tools/Makefile | 1 + > tools/eficapsule.h | 110 > tools/mkeficapsule.c | 106 +++- > tools/mkeficapsule_parse.c | 345 + > 5 files changed, 531 insertions(+), 40 deletions(-) > create mode 100644 tools/mkeficapsule_parse.c > > diff --git a/tools/mkeficapsule_parse.c b/tools/mkeficapsule_parse.c > new file mode 100644 > index 00..ef4f3f6705 > --- /dev/null > +++ b/tools/mkeficapsule_parse.c > @@ -0,0 +1,345 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright 2023 Linaro Limited > + */ > + > +/* > + * The code in this file adds parsing ability to the mkeficapsule > + * tool. This allows specifying parameters needed to build the capsule > + * through the config file instead of specifying them on the command-line. > + * Parameters can be specified for more than one payload, generating the > + * corresponding capsule files. > + * > + * The parameters are specified in a "key:value" pair. All the parameters > + * that are currently supported by the mkeficapsule tool can be specified > + * in the config file. > + * > + * The example below shows four payloads. The first payload is an example > + * of generating a signed capsule. The second payload is an example of > + * generating an unsigned capsule. The third payload is an accept empty > + * capsule, while the fourth payload is the revert empty capsule, used > + * for the multi-bank firmware update feature. > + * > + * This functionality can be easily extended to generate a single capsule > + * comprising multiple payloads. > + > + { > + image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660 > + hardware-instance: 0 > + monotonic-count: 1 > + payload: u-boot.bin > + image-index: 1 > + private-key: /path/to/priv/key > + pub-key-cert: /path/to/pub/key > + capsule: u-boot.capsule > + } > + { > + image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e > + hardware-instance: 0 > + payload: u-boot.itb > + image-index: 2 > + oemflags: 0x8000 > + capsule: fit.capsule > + } > + { > + capsule-type: accept > + image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e > + capsule: accept.capsule > + } > + { > + capsule-type: revert > + capsule: revert.capsule > + } > +*/ > + > > If i understand it correctly the EDK2 GenerateCapsule tool allows for multiple > payloads inside one capsule by specifying a list of payloads in the JSON-file. > I think something similar should be done here to support multiple payloads > inside one capsule. What about something like this: > > { > > content: [{ > image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660 > hardware-instance: 0 > monotonic-count: 1 > payload: u-boot.bin > image-index: 1 > },{ > > image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660 > hardware-instance: 1 > monotonic-count: 1 > payload: boot.bin > image-index: 2 > }], > > private-key: /path/to/priv/key > pub-key-cert: /path/to/pub/key > capsule: u-boot.capsule > > } > > ? I am aware of these additional brackets and the "Payloads" keyword that is used in the EDK2 json file. Adding this should not be a big effort. However, the reason I did not add this is that I did not see any value in adding this. I believe the EDK2 json file also is used for providing information about additional files, like optional driver images. But we don't support that with the u-boot tool. So will we be adding any
Re: [PATCH 4/7] tools: mkeficapsule: Add support for parsing capsule params from config file
Hi sughosh, Am 19.06.2023 um 09:27 schrieb Sughosh Ganu: hi Malte, On Fri, 16 Jun 2023 at 18:42, Schmidt, Malte wrote: Hi sughosh, Am 16.06.2023 um 08:35 schrieb Sughosh Ganu: On Fri, 16 Jun 2023 at 10:48, Takahiro Akashi wrote: On Fri, Jun 16, 2023 at 10:37:01AM +0530, Sughosh Ganu wrote: hi Takahiro, On Fri, 16 Jun 2023 at 10:16, Takahiro Akashi wrote: Hi Sughosh, On Fri, Jun 16, 2023 at 09:56:33AM +0530, Sughosh Ganu wrote: On Thu, 15 Jun 2023 at 11:19, Takahiro Akashi wrote: On Thu, Jun 15, 2023 at 10:09:06AM +0530, Sughosh Ganu wrote: On Wed, 14 Jun 2023 at 11:23, Takahiro Akashi wrote: On Wed, Jun 14, 2023 at 10:56:23AM +0530, Sughosh Ganu wrote: hi Takahiro, On Wed, 14 Jun 2023 at 09:09, Takahiro Akashi wrote: Hi Sughosh, I think this is a good extension to mkeficapsule, but On Tue, Jun 13, 2023 at 04:08:03PM +0530, Sughosh Ganu wrote: Add support for specifying the parameters needed for capsule generation through a config file, instead of passing them through command-line. Parameters for more than a single capsule file can be specified, resulting in generation of multiple capsules through a single invocation of the command. This path is to be used for generating capsules through a make target, with the parameters being parsed from the config file. Signed-off-by: Sughosh Ganu --- tools/Kconfig | 9 + tools/Makefile | 1 + tools/eficapsule.h | 110 tools/mkeficapsule.c | 106 +++- tools/mkeficapsule_parse.c | 345 + 5 files changed, 531 insertions(+), 40 deletions(-) create mode 100644 tools/mkeficapsule_parse.c diff --git a/tools/mkeficapsule_parse.c b/tools/mkeficapsule_parse.c new file mode 100644 index 00..ef4f3f6705 --- /dev/null +++ b/tools/mkeficapsule_parse.c @@ -0,0 +1,345 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2023 Linaro Limited + */ + +/* + * The code in this file adds parsing ability to the mkeficapsule + * tool. This allows specifying parameters needed to build the capsule + * through the config file instead of specifying them on the command-line. + * Parameters can be specified for more than one payload, generating the + * corresponding capsule files. + * + * The parameters are specified in a "key:value" pair. All the parameters + * that are currently supported by the mkeficapsule tool can be specified + * in the config file. + * + * The example below shows four payloads. The first payload is an example + * of generating a signed capsule. The second payload is an example of + * generating an unsigned capsule. The third payload is an accept empty + * capsule, while the fourth payload is the revert empty capsule, used + * for the multi-bank firmware update feature. + * + * This functionality can be easily extended to generate a single capsule + * comprising multiple payloads. + + { + image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660 + hardware-instance: 0 + monotonic-count: 1 + payload: u-boot.bin + image-index: 1 + private-key: /path/to/priv/key + pub-key-cert: /path/to/pub/key + capsule: u-boot.capsule + } + { + image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e + hardware-instance: 0 + payload: u-boot.itb + image-index: 2 + oemflags: 0x8000 + capsule: fit.capsule + } + { + capsule-type: accept + image-guid: 4ce292da-1dd8-428d-a1c2-77743ef8b96e + capsule: accept.capsule + } + { + capsule-type: revert + capsule: revert.capsule + } +*/ + If i understand it correctly the EDK2 GenerateCapsule tool allows for multiple payloads inside one capsule by specifying a list of payloads in the JSON-file. I think something similar should be done here to support multiple payloads inside one capsule. What about something like this: { content: [{ image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660 hardware-instance: 0 monotonic-count: 1 payload: u-boot.bin image-index: 1 },{ image-guid: 02f4d760-cfd5-43bd-8e2d-a42acb33c660 hardware-instance: 1 monotonic-count: 1 payload: boot.bin image-index: 2 }], private-key: /path/to/priv/key pub-key-cert: /path/to/pub/key capsule: u-boot.capsule } ? I am aware of these additional brackets and the "Payloads" keyword that is used in the EDK2 json file. Adding this should not be a big effort. However, the reason I did not add this is that I did not see any value in adding this. I believe the EDK2 json file also is used for providing information about additional files, like optional driver images. But we don't support that with the u-boot tool. So will we be adding any value by putting these additional brackets. The other question is, in case of a single capsule file consisting of multiple payloads, how do we pass the name of the output capsule file.