efi: Minimal revert to rodata change
v2 cover efi: Minimal revert to rodata change
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
- it provides no memory production in any case, particularly when U-Boot is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for this
Revert this until a new direction can be established.
Changes in v2:
- Also revert two other patches, based on comment from Takahiro
Simon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"
board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-) create mode 100644 board/emulation/common/qemu_capsule.c create mode 100644 doc/board/emulation/qemu_capsule_update.rst delete mode 100644 lib/efi_loader/efi_capsule_key.S
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
PATCH v2 1/3 Revert "doc: Update CapsuleUpdate READMEs"
This reverts commit 316ab801c0d91c02b21b8be1e3db7e69555364e9.
---
(no changes since v1)
doc/board/emulation/qemu_capsule_update.rst | 203 ++++++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ------------ 2 files changed, 203 insertions(+), 125 deletions(-) create mode 100644 doc/board/emulation/qemu_capsule_update.rst
doc/board/emulation/qemu_capsule_update.rst new file +203 -0
@@ -0,0 +1,203 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (C) 2020, Linaro Limited + +Enabling UEFI Capsule Update feature +------------------------------------ + +Support has been added for the UEFI capsule update feature which +enables updating the U-Boot image using the UEFI firmware management +protocol (fmp). The capsules are not passed to the firmware through +the UpdateCapsule runtime service. Instead, capsule-on-disk +functionality is used for fetching the capsule from the EFI System +Partition (ESP) by placing the capsule file under the +\EFI\UpdateCapsule directory. + +Currently, support has been added on the QEMU ARM64 virt platform for +updating the U-Boot binary as a raw image when the platform is booted +in non-secure mode, i.e. with CONFIG_TFABOOT disabled. For this +configuration, the QEMU platform needs to be booted with +'secure=off'. The U-Boot binary placed on the first bank of the NOR +flash at offset 0x0. The U-Boot environment is placed on the second +NOR flash bank at offset 0x4000000. + +The capsule update feature is enabled with the following configuration +settings:: + + CONFIG_MTD=y + CONFIG_FLASH_CFI_MTD=y + CONFIG_CMD_MTDPARTS=y + CONFIG_CMD_DFU=y + CONFIG_DFU_MTD=y + CONFIG_PCI_INIT_R=y + CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT=y + CONFIG_EFI_CAPSULE_FIRMWARE=y + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y + CONFIG_EFI_CAPSULE_FMP_HEADER=y + +In addition, the following config needs to be disabled(QEMU ARM specific):: + + CONFIG_TFABOOT + +The capsule file can be generated by using the tools/mkeficapsule:: + + $ mkeficapsule --raw <u-boot.bin> --index 1 <capsule_file_name> + +As per the UEFI specification, the capsule file needs to be placed on +the EFI System Partition, under the \EFI\UpdateCapsule directory. The +EFI System Partition can be a virtio-blk-device. + +Before initiating the firmware update, the efi variables BootNext, +BootXXXX and OsIndications need to be set. The BootXXXX variable needs +to be pointing to the EFI System Partition which contains the capsule +file. The BootNext, BootXXXX and OsIndications variables can be set +using the following commands:: + + => efidebug boot add -b 0 Boot0000 virtio 0:1 <capsule_file_name> + => efidebug boot next 0 + => setenv -e -nv -bs -rt -v OsIndications =0x04 + => saveenv + +Finally, the capsule update can be initiated with the following +command:: + + => efidebug capsule disk-update + +The updated U-Boot image will be booted on subsequent boot. + +Enabling Capsule Authentication +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The UEFI specification defines a way of authenticating the capsule to +be updated by verifying the capsule signature. The capsule signature +is computed and prepended to the capsule payload at the time of +capsule generation. This signature is then verified by using the +public key stored as part of the X509 certificate. This certificate is +in the form of an efi signature list (esl) file, which is embedded as +part of the platform's device tree blob using the mkeficapsule +utility. + +On the QEMU virt platforms, the device-tree is generated on the fly +based on the devices configured. This device tree is then passed on to +the various software components booting on the platform, including +U-Boot. Therefore, on the QEMU virt platform, the signatute is +embedded on an overlay. This overlay is then applied at runtime to the +base platform device-tree. Steps needed for embedding the esl file in +the overlay are highlighted below. + +The capsule authentication feature can be enabled through the +following config, in addition to the configs listed above for capsule +update:: + + CONFIG_EFI_CAPSULE_AUTHENTICATE=y + +The public and private keys used for the signing process are generated +and used by the steps highlighted below:: + + 1. Install utility commands on your host + * OPENSSL + * efitools + + 2. Create signing keys and certificate files on your host + + $ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=CRT/ \ + -keyout CRT.key -out CRT.crt -nodes -days 365 + $ cert-to-efi-sig-list CRT.crt CRT.esl + + $ openssl x509 -in CRT.crt -out CRT.cer -outform DER + $ openssl x509 -inform DER -in CRT.cer -outform PEM -out CRT.pub.pem + + $ openssl pkcs12 -export -out CRT.pfx -inkey CRT.key -in CRT.crt + $ openssl pkcs12 -in CRT.pfx -nodes -out CRT.pem + +The capsule file can be generated by using the GenerateCapsule.py +script in EDKII:: + + $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \ + <capsule_file_name> --monotonic-count <val> --fw-version \ + <val> --lsv <val> --guid \ + e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose \ + --update-image-index <val> --signer-private-cert \ + /path/to/CRT.pem --trusted-public-cert \ + /path/to/CRT.pub.pem --other-public-cert /path/to/CRT.pub.pem \ + <u-boot.bin> + +Place the capsule generated in the above step on the EFI System +Partition under the EFI/UpdateCapsule directory + +For embedding the public key certificate, the following steps need to +be followed:: + + 1. Generate a skeleton overlay dts file, with a single fragment + node and an empty __overlay__ node + + A typical skeleton overlay file will look like this + + /dts-v1/; + /plugin/; + + / { + fragment@0 { + target-path = "/"; + __overlay__ { + }; + }; + }; + + + 2. Convert the dts to a corresponding dtb with the following + command + ./scripts/dtc/dtc -@ -I dts -O dtb -o <ov_dtb_file_name> \ + <dts_file> + + 3. Run the dtb file generated above through the mkeficapsule tool + in U-Boot + ./tools/mkeficapsule -O <pub_key.esl> -D <ov_dtb> + +Running the above command results in the creation of a 'signature' +node in the dtb, under which the public key is stored as a +'capsule-key' property. The '-O' option is to be used since the +public key certificate(esl) file is being embedded in an overlay. + +The dtb file embedded with the certificate is now to be placed on an +EFI System Partition. This would then be loaded and "merged" with the +base platform flattened device-tree(dtb) at runtime. + +Build U-Boot with the following steps(QEMU ARM64):: + + $ make qemu_arm64_defconfig + $ make menuconfig + Disable CONFIG_TFABOOT + Enable CONFIG_EFI_CAPSULE_AUTHENTICATE + Enable all configs needed for capsule update(listed above) + $ make all + +Boot the platform and perform the following steps on the U-Boot +command line:: + + 1. Enable capsule authentication by setting the following env + variable + + => setenv capsule_authentication_enabled 1 + => saveenv + + 2. Load the overlay dtb to memory and merge it with the base fdt + + => fatload virtio 0:1 <$fdtovaddr> EFI/<ov_dtb_file> + => fdt addr $fdtcontroladdr + => fdt resize <size_of_ov_dtb_file> + => fdt apply <$fdtovaddr> + + 3. Set the following environment and UEFI boot variables + + => setenv -e -nv -bs -rt -v OsIndications =0x04 + => efidebug boot add -b 0 Boot0000 virtio 0:1 <capsule_file_name> + => efidebug boot next 0 + => saveenv + + 4. Finally, the capsule update can be initiated with the following + command + + => efidebug capsule disk-update + +On subsequent reboot, the platform should boot the updated U-Boot binary.
doc/develop/uefi/uefi.rst +0 -125
131 lines not on this page · raw message
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
PATCH v2 2/3 Revert "mkeficapsule: Remove dtb related options"
In reply to Simon GlassThis reverts commit f86caab058ff062ce72b24cd1ab9ec1253cc1352.
---
(no changes since v1)
tools/mkeficapsule.c | 229 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 7 deletions(-)
tools/mkeficapsule.c +222 -7
@@ -4,17 +4,22 @@* Author: AKASHI Takahiro */ +#include <errno.h> #include <getopt.h> #include <malloc.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <linux/types.h> +#include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> +#include "fdt_host.h" +typedef __u8 u8 ;typedef __u16 u16 ;typedef __u32 u32 ;
@@ -24,6 +29,9 @@ typedef __s32 s32;#define aligned_u64 __aligned_u64 +#define SIGNATURE_NODENAME "signature" +#define OVERLAY_NODENAME "__overlay__" +#ifndef __packed#define __packed __attribute__((packed))#endif
@@ -44,6 +52,9 @@ static struct option options[] = { {"raw", required_argument, NULL, 'r'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'}, + {"dtb", required_argument, NULL, 'D'}, + {"public key", required_argument, NULL, 'K'}, + {"overlay", no_argument, NULL, 'O'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, };
@@ -57,10 +68,187 @@ static void print_usage(void)"\t-r, --raw <raw image> new raw image file\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n" +"\t-K, --public-key <key file> public key esl file\n" +"\t-D, --dtb <dtb file> dtb file\n" +"\t-O, --overlay the dtb file is an overlay\n" "\t-h, --help print a help message\n" , tool_name); } +static int fdt_add_pub_key_data (void *sptr,void *dptr,size_t key_size, +bool overlay) +{ +int parent; +int ov_node; +int frag_node; +int ret =0 ; + +if (overlay) { +/* +* The signature would be stored in the +* first fragment node of the overlay +*/ + frag_node =fdt_first_subnode (dptr,0 ); +if (frag_node == -FDT_ERR_NOTFOUND ) { +fprintf (stderr, +"Couldn't find the fragment node: %s\n" , +fdt_strerror (frag_node)); + goto done; + } + + ov_node =fdt_subnode_offset (dptr, frag_node,OVERLAY_NODENAME ); +if (ov_node == -FDT_ERR_NOTFOUND ) { +fprintf (stderr, +"Couldn't find the __overlay__ node: %s\n" , +fdt_strerror (ov_node)); + goto done; + } + }else { + ov_node =0 ; + } + + parent =fdt_subnode_offset (dptr, ov_node,SIGNATURE_NODENAME ); +if (parent == -FDT_ERR_NOTFOUND ) { + parent =fdt_add_subnode (dptr, ov_node,SIGNATURE_NODENAME ); +if (parent <0 ) { + ret = parent; +if (ret != -FDT_ERR_NOSPACE ) { +fprintf (stderr, +"Couldn't create signature node: %s\n" , +fdt_strerror (parent)); + } + } + } +if (ret) + goto done; + +/* Write the key to the FDT node */ + ret =fdt_setprop (dptr, parent,"capsule-key" , + sptr, key_size); + +done: +if (ret) + ret = ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO ; + +return ret; +} + +static int add_public_key (const char *pkey_file,const char *dtb_file, +bool overlay) +{ +int ret; +int srcfd =-1 ; +int destfd =-1 ; +void *sptr =NULL ; +void *dptr =NULL ; +off_t src_size; +struct stat pub_key; +struct stat dtb; + +/* Find out the size of the public key */ + srcfd =open (pkey_file,O_RDONLY ); +if (srcfd ==-1 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + + ret =fstat (srcfd, &pub_key); +if (ret ==-1 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + + src_size = pub_key.st_size; + +/* mmap the public key esl file */ + sptr =mmap (0 , src_size,PROT_READ ,MAP_SHARED , srcfd,0 ); +if (sptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Failed to mmap %s:%s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + +/* Open the dest FDT */ + destfd =open (dtb_file,O_RDWR ); +if (destfd ==-1 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + + ret =fstat (destfd, &dtb); +if (ret ==-1 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + __func__, dtb_file,strerror (errno)); + goto err; + } + + dtb.st_size += src_size +0x30 ; +if (ftruncate (destfd, dtb.st_size)) { +fprintf (stderr,"%s: Can't expand %s: %s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + + errno =0 ; +/* mmap the dtb file */ + dptr =mmap (0 , dtb.st_size,PROT_READ |PROT_WRITE ,MAP_SHARED , + destfd,0 ); +if (dptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Failed to mmap %s:%s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + +if (fdt_check_header (dptr)) { +fprintf (stderr,"%s: Invalid FDT header\n" , __func__); + ret =-1 ; + goto err; + } + + ret =fdt_open_into (dptr, dptr, dtb.st_size); +if (ret) { +fprintf (stderr,"%s: Cannot expand FDT: %s\n" , + __func__,fdt_strerror (ret)); + ret =-1 ; + goto err; + } + +/* Copy the esl file to the expanded FDT */ + ret =fdt_add_pub_key_data (sptr, dptr, src_size, overlay); +if (ret <0 ) { +fprintf (stderr,"%s: Unable to add public key to the FDT\n" , + __func__); + ret =-1 ; + goto err; + } + + ret =0 ; + +err: +if (sptr) +munmap (sptr, src_size); + +if (dptr) +munmap (dptr, dtb.st_size); + +if (srcfd !=-1 ) +close (srcfd); + +if (destfd !=-1 ) +close (destfd); + +return ret; +} +static int create_fwbin (char *path,char *bin,efi_guid_t *guid,unsigned long index,unsigned long instance) {
@@ -178,16 +366,22 @@ err_1:int main (int argc,char **argv) {char *file; +char *pkey_file; +char *dtb_file;efi_guid_t *guid;unsigned long index, instance;int c, idx; +int ret; +bool overlay = false; file =NULL ; + pkey_file =NULL ; + dtb_file =NULL ; guid =NULL ; index =0 ; instance =0 ;for (;;) { - c =getopt_long (argc, argv,"f:r:i:I:v:h" , options, &idx); + c =getopt_long (argc, argv,"f:r:i:I:v:D:K:Oh" , options, &idx);if (c ==-1 )break ;
@@ -214,22 +408,43 @@ int main(int argc, char **argv)case 'I' : instance =strtoul (optarg,NULL ,0 );break ; +case 'K' : +if (pkey_file) { +printf ("Public Key already specified\n" ); +return -1 ; + } + pkey_file = optarg; +break ; +case 'D' : +if (dtb_file) { +printf ("DTB file already specified\n" ); +return -1 ; + } + dtb_file = optarg; +break ; +case 'O' : + overlay = true; +break ;case 'h' :print_usage ();return 0 ; } } -/* need an output file */ -if (argc != optind +1 ) { +/* need a fit image file or raw image file */ +if (!file && !pkey_file && !dtb_file) {print_usage ();exit (EXIT_FAILURE ); } -/* need a fit image file or raw image file */ -if (!file) { -print_usage (); -exit (EXIT_SUCCESS ); +if (pkey_file && dtb_file) { + ret =add_public_key (pkey_file, dtb_file, overlay); +if (ret ==-1 ) { +printf ("Adding public key to the dtb failed\n" ); +exit (EXIT_FAILURE ); + }else { +exit (EXIT_SUCCESS ); + } } if (create_fwbin(argv[optind], file, guid, index, instance)
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
Re: [PATCH v2 2/3] Revert "mkeficapsule: Remove dtb related options"
Simon,
Quoted 1 line · Simon Glass
This reverts commit
f86caab058ff062ce72b24cd1ab9ec1253cc1352.
Whether we choose a devicetree approach or not, we don't have to revert this patch because we can do the same thing with standard commands (i.e. fdtoverlay).
See my patches and discussions[1].
(We all agreed to removing this feature from mkeficapsule.)
[1] https://lists.denx.de/pipermail/u-boot/2021-May/449573.html
https://lists.denx.de/pipermail/u-boot/2021-May/449574.html
-Takahiro Akashi
Quoted 320 lines
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
tools/mkeficapsule.c | 229 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 7 deletions(-)tools/mkeficapsule.c +222
-7@@ -4,17 +4,22 @@* Author: AKASHI Takahiro */ +#include <errno.h> #include <getopt.h> #include <malloc.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <linux/types.h> +#include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> +#include "fdt_host.h" +typedef __u8 u8 ;typedef __u16 u16 ;typedef __u32 u32 ;@@ -24,6 +29,9 @@ typedef __s32 s32;#define aligned_u64 __aligned_u64 +#define SIGNATURE_NODENAME "signature" +#define OVERLAY_NODENAME "__overlay__" +#ifndef __packed#define __packed __attribute__((packed))#endif @@ -44,6 +52,9 @@ static struct option options[] = { {"raw", required_argument, NULL, 'r'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'}, + {"dtb", required_argument, NULL, 'D'}, + {"public key", required_argument, NULL, 'K'}, + {"overlay", no_argument, NULL, 'O'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, };@@ -57,10 +68,187 @@ static void print_usage(void)"\t-r, --raw <raw image> new raw image file\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n" +"\t-K, --public-key <key file> public key esl file\n" +"\t-D, --dtb <dtb file> dtb file\n" +"\t-O, --overlay the dtb file is an overlay\n" "\t-h, --help print a help message\n" , tool_name); } +static int fdt_add_pub_key_data (void *sptr,void *dptr,size_t key_size, +bool overlay) +{ +int parent; +int ov_node; +int frag_node; +int ret =0 ; + +if (overlay) { +/* +* The signature would be stored in the +* first fragment node of the overlay +*/ + frag_node =fdt_first_subnode (dptr,0 ); +if (frag_node == -FDT_ERR_NOTFOUND ) { +fprintf (stderr, +"Couldn't find the fragment node: %s\n" , +fdt_strerror (frag_node)); + goto done; + } + + ov_node =fdt_subnode_offset (dptr, frag_node,OVERLAY_NODENAME ); +if (ov_node == -FDT_ERR_NOTFOUND ) { +fprintf (stderr, +"Couldn't find the __overlay__ node: %s\n" , +fdt_strerror (ov_node)); + goto done; + } + }else { + ov_node =0 ; + } + + parent =fdt_subnode_offset (dptr, ov_node,SIGNATURE_NODENAME ); +if (parent == -FDT_ERR_NOTFOUND ) { + parent =fdt_add_subnode (dptr, ov_node,SIGNATURE_NODENAME ); +if (parent <0 ) { + ret = parent; +if (ret != -FDT_ERR_NOSPACE ) { +fprintf (stderr, +"Couldn't create signature node: %s\n" , +fdt_strerror (parent)); + } + } + } +if (ret) + goto done; + +/* Write the key to the FDT node */ + ret =fdt_setprop (dptr, parent,"capsule-key" , + sptr, key_size); + +done: +if (ret) + ret = ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO ; + +return ret; +} + +static int add_public_key (const char *pkey_file,const char *dtb_file, +bool overlay) +{ +int ret; +int srcfd =-1 ; +int destfd =-1 ; +void *sptr =NULL ; +void *dptr =NULL ; +off_t src_size; +struct stat pub_key; +struct stat dtb; + +/* Find out the size of the public key */ + srcfd =open (pkey_file,O_RDONLY ); +if (srcfd ==-1 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + + ret =fstat (srcfd, &pub_key); +if (ret ==-1 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + + src_size = pub_key.st_size; + +/* mmap the public key esl file */ + sptr =mmap (0 , src_size,PROT_READ ,MAP_SHARED , srcfd,0 ); +if (sptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Failed to mmap %s:%s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + +/* Open the dest FDT */ + destfd =open (dtb_file,O_RDWR ); +if (destfd ==-1 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + + ret =fstat (destfd, &dtb); +if (ret ==-1 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + __func__, dtb_file,strerror (errno)); + goto err; + } + + dtb.st_size += src_size +0x30 ; +if (ftruncate (destfd, dtb.st_size)) { +fprintf (stderr,"%s: Can't expand %s: %s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + + errno =0 ; +/* mmap the dtb file */ + dptr =mmap (0 , dtb.st_size,PROT_READ |PROT_WRITE ,MAP_SHARED , + destfd,0 ); +if (dptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Failed to mmap %s:%s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + +if (fdt_check_header (dptr)) { +fprintf (stderr,"%s: Invalid FDT header\n" , __func__); + ret =-1 ; + goto err; + } + + ret =fdt_open_into (dptr, dptr, dtb.st_size); +if (ret) { +fprintf (stderr,"%s: Cannot expand FDT: %s\n" , + __func__,fdt_strerror (ret)); + ret =-1 ; + goto err; + } + +/* Copy the esl file to the expanded FDT */ + ret =fdt_add_pub_key_data (sptr, dptr, src_size, overlay); +if (ret <0 ) { +fprintf (stderr,"%s: Unable to add public key to the FDT\n" , + __func__); + ret =-1 ; + goto err; + } + + ret =0 ; + +err: +if (sptr) +munmap (sptr, src_size); + +if (dptr) +munmap (dptr, dtb.st_size); + +if (srcfd !=-1 ) +close (srcfd); + +if (destfd !=-1 ) +close (destfd); + +return ret; +} +static int create_fwbin (char *path,char *bin,efi_guid_t *guid,unsigned long index,unsigned long instance) {@@ -178,16 +366,22 @@ err_1:int main (int argc,char **argv) {char *file; +char *pkey_file; +char *dtb_file;efi_guid_t *guid;unsigned long index, instance;int c, idx; +int ret; +bool overlay = false; file =NULL ; + pkey_file =NULL ; + dtb_file =NULL ; guid =NULL ; index =0 ; instance =0 ;for (;;) { - c =getopt_long (argc, argv,"f:r:i:I:v:h" , options, &idx); + c =getopt_long (argc, argv,"f:r:i:I:v:D:K:Oh" , options, &idx);if (c ==-1 )break ;@@ -214,22 +408,43 @@ int main(int argc, char **argv)case 'I' : instance =strtoul (optarg,NULL ,0 );break ; +case 'K' : +if (pkey_file) { +printf ("Public Key already specified\n" ); +return -1 ; + } + pkey_file = optarg; +break ; +case 'D' : +if (dtb_file) { +printf ("DTB file already specified\n" ); +return -1 ; + } + dtb_file = optarg; +break ; +case 'O' : + overlay = true; +break ;case 'h' :print_usage ();return 0 ; } } -/* need an output file */ -if (argc != optind +1 ) { +/* need a fit image file or raw image file */ +if (!file && !pkey_file && !dtb_file) {print_usage ();exit (EXIT_FAILURE ); } -/* need a fit image file or raw image file */ -if (!file) { -print_usage (); -exit (EXIT_SUCCESS ); +if (pkey_file && dtb_file) { + ret =add_public_key (pkey_file, dtb_file, overlay); +if (ret ==-1 ) { +printf ("Adding public key to the dtb failed\n" ); +exit (EXIT_FAILURE ); + }else { +exit (EXIT_SUCCESS ); + } } if (create_fwbin(argv[optind], file, guid, index, instance)Signature · 1 line
2.32.0.554.ge1b32706d8-goog
Re: [PATCH v2 2/3] Revert "mkeficapsule: Remove dtb related options"
Hi Takahiro,
Quoted 4 lines · KASHI Takahiro
Simon,
On Mon, Aug 02, 2021 at 08:44:30AM -0600, Simon Glass wrote:
Quoted 8 lines
Quoted 1 line
This reverts commit
f86caab058ff062ce72b24cd1ab9ec1253cc1352.Whether we choose a devicetree approach or not, we don't have to revert this patch because we can do the same thing with standard commands (i.e. fdtoverlay).
See my patches and discussions[1].
(We all agreed to removing this feature from mkeficapsule.)
Well this just shows that I am not the right person to be sorting out this mess. Can someone in the team working on come up with the right fix?
Regards,
Simon
Quoted 327 lines
[1] https://lists.denx.de/pipermail/u-boot/2021-May/449573.html
https://lists.denx.de/pipermail/u-boot/2021-May/449574.html-Takahiro Akashi
Quoted 320 lines
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
tools/mkeficapsule.c | 229 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 7 deletions(-)tools/mkeficapsule.c +222
-8@@ -4,17 +4,22 @@* Author: AKASHI Takahiro */ +#include <errno.h> #include <getopt.h> #include <malloc.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <linux/types.h> +#include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> +#include "fdt_host.h" +typedef __u8 u8 ;typedef __u16 u16 ;typedef __u32 u32 ;@@ -24,6 +29,9 @@ typedef __s32 s32;#define aligned_u64 __aligned_u64 +#define SIGNATURE_NODENAME "signature" +#define OVERLAY_NODENAME "__overlay__" +#ifndef __packed#define __packed __attribute__((packed))#endif @@ -44,6 +52,9 @@ static struct option options[] = { {"raw", required_argument, NULL, 'r'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'}, + {"dtb", required_argument, NULL, 'D'}, + {"public key", required_argument, NULL, 'K'}, + {"overlay", no_argument, NULL, 'O'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, };@@ -57,10 +68,187 @@ static void print_usage(void)"\t-r, --raw <raw image> new raw image file\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n" +"\t-K, --public-key <key file> public key esl file\n" +"\t-D, --dtb <dtb file> dtb file\n" +"\t-O, --overlay the dtb file is an overlay\n" "\t-h, --help print a help message\n" , tool_name); } +static int fdt_add_pub_key_data (void *sptr,void *dptr,size_t key_size, +bool overlay) +{ +int parent; +int ov_node; +int frag_node; +int ret =0 ; + +if (overlay) { +/* +* The signature would be stored in the +* first fragment node of the overlay +*/ + frag_node =fdt_first_subnode (dptr,0 ); +if (frag_node == -FDT_ERR_NOTFOUND ) { +fprintf (stderr, +"Couldn't find the fragment node: %s\n" , +fdt_strerror (frag_node)); + goto done; + } + + ov_node =fdt_subnode_offset (dptr, frag_node,OVERLAY_NODENAME ); +if (ov_node == -FDT_ERR_NOTFOUND ) { +fprintf (stderr, +"Couldn't find the __overlay__ node: %s\n" , +fdt_strerror (ov_node)); + goto done; + } + }else { + ov_node =0 ; + } + + parent =fdt_subnode_offset (dptr, ov_node,SIGNATURE_NODENAME ); +if (parent == -FDT_ERR_NOTFOUND ) { + parent =fdt_add_subnode (dptr, ov_node,SIGNATURE_NODENAME ); +if (parent <0 ) { + ret = parent; +if (ret != -FDT_ERR_NOSPACE ) { +fprintf (stderr, +"Couldn't create signature node: %s\n" , +fdt_strerror (parent)); + } + } + } +if (ret) + goto done; + +/* Write the key to the FDT node */ + ret =fdt_setprop (dptr, parent,"capsule-key" , + sptr, key_size); + +done: +if (ret) + ret = ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO ; + +return ret; +} + +static int add_public_key (const char *pkey_file,const char *dtb_file, +bool overlay) +{ +int ret; +int srcfd =-1 ; +int destfd =-1 ; +void *sptr =NULL ; +void *dptr =NULL ; +off_t src_size; +struct stat pub_key; +struct stat dtb; + +/* Find out the size of the public key */ + srcfd =open (pkey_file,O_RDONLY ); +if (srcfd ==-1 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + + ret =fstat (srcfd, &pub_key); +if (ret ==-1 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + + src_size = pub_key.st_size; + +/* mmap the public key esl file */ + sptr =mmap (0 , src_size,PROT_READ ,MAP_SHARED , srcfd,0 ); +if (sptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Failed to mmap %s:%s\n" , + __func__, pkey_file,strerror (errno)); + ret =-1 ; + goto err; + } + +/* Open the dest FDT */ + destfd =open (dtb_file,O_RDWR ); +if (destfd ==-1 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + + ret =fstat (destfd, &dtb); +if (ret ==-1 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + __func__, dtb_file,strerror (errno)); + goto err; + } + + dtb.st_size += src_size +0x30 ; +if (ftruncate (destfd, dtb.st_size)) { +fprintf (stderr,"%s: Can't expand %s: %s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + + errno =0 ; +/* mmap the dtb file */ + dptr =mmap (0 , dtb.st_size,PROT_READ |PROT_WRITE ,MAP_SHARED , + destfd,0 ); +if (dptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Failed to mmap %s:%s\n" , + __func__, dtb_file,strerror (errno)); + ret =-1 ; + goto err; + } + +if (fdt_check_header (dptr)) { +fprintf (stderr,"%s: Invalid FDT header\n" , __func__); + ret =-1 ; + goto err; + } + + ret =fdt_open_into (dptr, dptr, dtb.st_size); +if (ret) { +fprintf (stderr,"%s: Cannot expand FDT: %s\n" , + __func__,fdt_strerror (ret)); + ret =-1 ; + goto err; + } + +/* Copy the esl file to the expanded FDT */ + ret =fdt_add_pub_key_data (sptr, dptr, src_size, overlay); +if (ret <0 ) { +fprintf (stderr,"%s: Unable to add public key to the FDT\n" , + __func__); + ret =-1 ; + goto err; + } + + ret =0 ; + +err: +if (sptr) +munmap (sptr, src_size); + +if (dptr) +munmap (dptr, dtb.st_size); + +if (srcfd !=-1 ) +close (srcfd); + +if (destfd !=-1 ) +close (destfd); + +return ret; +} +static int create_fwbin (char *path,char *bin,efi_guid_t *guid,unsigned long index,unsigned long instance) {@@ -178,16 +366,22 @@ err_1:int main (int argc,char **argv) {char *file; +char *pkey_file; +char *dtb_file;efi_guid_t *guid;unsigned long index, instance;int c, idx; +int ret; +bool overlay = false; file =NULL ; + pkey_file =NULL ; + dtb_file =NULL ; guid =NULL ; index =0 ; instance =0 ;for (;;) { - c =getopt_long (argc, argv,"f:r:i:I:v:h" , options, &idx); + c =getopt_long (argc, argv,"f:r:i:I:v:D:K:Oh" , options, &idx);if (c ==-1 )break ;@@ -214,22 +408,43 @@ int main(int argc, char **argv)case 'I' : instance =strtoul (optarg,NULL ,0 );break ; +case 'K' : +if (pkey_file) { +printf ("Public Key already specified\n" ); +return -1 ; + } + pkey_file = optarg; +break ; +case 'D' : +if (dtb_file) { +printf ("DTB file already specified\n" ); +return -1 ; + } + dtb_file = optarg; +break ; +case 'O' : + overlay = true; +break ;case 'h' :print_usage ();return 0 ; } } -/* need an output file */ -if (argc != optind +1 ) { +/* need a fit image file or raw image file */ +if (!file && !pkey_file && !dtb_file) {print_usage ();exit (EXIT_FAILURE ); } -/* need a fit image file or raw image file */ -if (!file) { -print_usage (); -exit (EXIT_SUCCESS ); +if (pkey_file && dtb_file) { + ret =add_public_key (pkey_file, dtb_file, overlay); +if (ret ==-1 ) { +printf ("Adding public key to the dtb failed\n" ); +exit (EXIT_FAILURE ); + }else { +exit (EXIT_SUCCESS ); + } } if (create_fwbin(argv[optind], file, guid, index, instance) --2.32.0.554.ge1b32706d8-goog
PATCH v2 3/3 Revert "efi_capsule: Move signature from DTB to .rodata"
In reply to Simon GlassThis was unfortunately applied despite much discussion about it beiong the wrong way to implement this feature.
Revert it before too many other things are built on top of it.
This reverts commit ddf67daac39de76d2697d587148f4c2cb768f492.
---
Changes in v2:
- Also revert two other patches, based on comment from Takahiro
board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 +++++++++++++++++++++++++++ include/asm-generic/sections.h | 2 -- lib/efi_loader/Kconfig | 7 ----- lib/efi_loader/Makefile | 8 ----- lib/efi_loader/efi_capsule.c | 18 ++--------- lib/efi_loader/efi_capsule_key.S | 17 ----------- 7 files changed, 47 insertions(+), 49 deletions(-) create mode 100644 board/emulation/common/qemu_capsule.c delete mode 100644 lib/efi_loader/efi_capsule_key.S
board/emulation/common/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += qemu_mtdparts.o obj-$(CONFIG_SET_DFU_ALT_INFO) += qemu_dfu.o +obj-$(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) += qemu_capsule.o
board/emulation/common/qemu_capsule.c new file +43 -0
43 lines not on this page · raw message
include/asm-generic/sections.h +0 -2
@@ -27,8 +27,6 @@ extern char __efi_helloworld_begin[];extern char __efi_helloworld_end[];extern char __efi_var_file_begin[];extern char __efi_var_file_end[]; -extern char __efi_capsule_sig_begin[]; -extern char __efi_capsule_sig_end[];/* Private data used by of-platdata devices/uclasses */ extern char __priv_data_start[], __priv_data_end[];
lib/efi_loader/Kconfig +0 -7
@@ -214,13 +214,6 @@ config EFI_CAPSULE_AUTHENTICATE Select this option if you want to enable capsule authentication -config EFI_CAPSULE_KEY_PATH - string "Path to .esl cert for capsule authentication" - depends on EFI_CAPSULE_AUTHENTICATE - help - Provide the EFI signature list (esl) certificate used for capsule - authentication - config EFI_DEVICE_PATH_TO_TEXT bool "Device path to text protocol" default y
lib/efi_loader/Makefile +0 -8
@@ -20,19 +20,11 @@ always += helloworld.efi targets += helloworld.o endif -ifeq ($(CONFIG_EFI_CAPSULE_AUTHENTICATE),y) -EFI_CAPSULE_KEY_PATH := $(subst $\",,$(CONFIG_EFI_CAPSULE_KEY_PATH)) -ifeq ("$(wildcard $(EFI_CAPSULE_KEY_PATH))","") -$(error .esl cerificate not found. Configure your CONFIG_EFI_CAPSULE_KEY_PATH) -endif -endif - obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o obj-y += efi_boottime.o obj-y += efi_helper.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o -obj-$(CONFIG_EFI_CAPSULE_AUTHENTICATE) += efi_capsule_key.o obj-$(CONFIG_EFI_CAPSULE_FIRMWARE) += efi_firmware.o obj-y += efi_console.o obj-y += efi_device_path.o
lib/efi_loader/efi_capsule.c +3 -15
@@ -16,7 +16,6 @@#include <mapmem.h> #include <sort.h> -#include <asm/sections.h> #include <crypto/pkcs7.h> #include <crypto/pkcs7_parser.h> #include <linux/err.h>
@@ -253,23 +252,12 @@ out:#if defined(CONFIG_EFI_CAPSULE_AUTHENTICATE ) -static int efi_get_public_key_data (void **pkey,efi_uintn_t *pkey_len) -{ -const void *blob = __efi_capsule_sig_begin; -const int len = __efi_capsule_sig_end - __efi_capsule_sig_begin; - - *pkey = (void *)blob; - *pkey_len = len; - -return 0 ; -} -efi_status_t efi_capsule_authenticate (const void *capsule,efi_uintn_t capsule_size,void **image,efi_uintn_t *image_size) {u8 *buf;int ret; -void *stored_pkey, *pkey; +void *fdt_pkey, *pkey;efi_uintn_t pkey_len;uint64_t monotonic_count;struct efi_signature_store *truststore;
@@ -322,7 +310,7 @@ efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_s goto out; } - ret =efi_get_public_key_data (&stored_pkey, &pkey_len); + ret =efi_get_public_key_data (&fdt_pkey, &pkey_len);if (ret <0 ) goto out;
@@ -330,7 +318,7 @@ efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_sif (!pkey) goto out; -memcpy (pkey, stored_pkey, pkey_len); +memcpy (pkey, fdt_pkey, pkey_len); truststore =efi_build_signature_store (pkey, pkey_len);if (!truststore) goto out;
lib/efi_loader/efi_capsule_key.S deleted +0 -17
@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * .esl cert for capsule authentication - * - * Copyright (c) 2021, Ilias Apalodimas <[email protected]> - */ - -#include <config.h> - -.section .rodata.capsule_key.init,"a" -.balign 16 -.global __efi_capsule_sig_begin -__efi_capsule_sig_begin: -.incbin CONFIG_EFI_CAPSULE_KEY_PATH -__efi_capsule_sig_end: -.global __efi_capsule_sig_end -.balign 16
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
Hi Simon,
Quoted 3 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
As I said on the previous thread, I think this should remain as is for a number of reasons (and mainly because it only works with 1/3 valid CONFIG_OF_XXX U-Boot provides), but I'll let Heinrich decide.
Quoted 8 lines
- devicetree is where config should be stored
- it provides no memory production in any case, particularly when U-Boot is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisRevert this until a new direction can be established.
Regards
/Ilias
Quoted 26 lines
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-) create mode 100644 board/emulation/common/qemu_capsule.c create mode 100644 doc/board/emulation/qemu_capsule_update.rst delete mode 100644 lib/efi_loader/efi_capsule_key.SSignature · 1 line
2.32.0.554.ge1b32706d8-goog
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 3 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
As I said on the previous thread, I think this should remain as is for a number of reasons (and mainly because it only works with 1/3 valid
CONFIG_OF_XXXU-Boot provides), but I'll let Heinrich decide.
Do you mean OF_EMBED and OF_HOSTFILE?
We happily use OF_HOSTFILE in the sandbox vboot tests. I don't see any issue there.
OF_EMBED should not be used in production code. It is for debugging only.
Quoted 38 lines
Quoted 9 lines
- devicetree is where config should be stored
- it provides no memory production in any case, particularly when U-Boot is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisRevert this until a new direction can be established.
Regards
/IliasQuoted 26 lines
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-) create mode 100644 board/emulation/common/qemu_capsule.c create mode 100644 doc/board/emulation/qemu_capsule_update.rst delete mode 100644 lib/efi_loader/efi_capsule_key.S--
2.32.0.554.ge1b32706d8-goog
Quoted 16 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 3 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
As I said on the previous thread, I think this should remain as is for a number of reasons (and mainly because it only works with 1/3 valid
CONFIG_OF_XXXU-Boot provides), but I'll let Heinrich decide.
Quoted 6 lines
Do you mean
OF_EMBEDandOF_HOSTFILE?We happily use
OF_HOSTFILEin the sandbox vboot tests. I don't see any issue there.
OF_EMBEDshould not be used in production code. It is for debugging only.
No I mean CONFIG_OF_SEPARATE and CONFIG_OF_PRIOR_STAGE (apart from CONFIG_OF_BOARD)
Thanks
/Ilias
Quoted 40 lines
Quoted 40 lines
Quoted 11 lines
- devicetree is where config should be stored
- it provides no memory production in any case, particularly when U-Boot is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisRevert this until a new direction can be established.
Regards
/IliasQuoted 26 lines
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-) create mode 100644 board/emulation/common/qemu_capsule.c create mode 100644 doc/board/emulation/qemu_capsule_update.rst delete mode 100644 lib/efi_loader/efi_capsule_key.S--
2.32.0.554.ge1b32706d8-goog
HI Ilias,
Quoted 20 lines · Ilias Apalodimas
Quoted 18 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 3 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
As I said on the previous thread, I think this should remain as is for a number of reasons (and mainly because it only works with 1/3 valid
CONFIG_OF_XXXU-Boot provides), but I'll let Heinrich decide.Do you mean
OF_EMBEDandOF_HOSTFILE?
Quoted 7 lines
Quoted 4 lines
We happily use
OF_HOSTFILEin the sandbox vboot tests. I don't see any issue there.
OF_EMBEDshould not be used in production code. It is for debugging only.No I mean
CONFIG_OF_SEPARATEandCONFIG_OF_PRIOR_STAGE(apart fromCONFIG_OF_BOARD)
Well OF_SEPARATE works fine.
OF_PRIOR_STAGE is no different, as I understand it. I just means that the prior stage (whatever that is) needs to have the public key.
Regards,
Simon
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here but about bundling a file.
Quoted 1 line
- it provides no memory production in any case, particularly when U-Boot
What do you mean by "production"?
Should you mean memory protection: I cannot see that the memory pages containing the devicetree are set to readonly. Furthermore setenv can completely replace the devicetree.
Quoted 5 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisRevert this until a new direction can be established.
We can change the current solution *after* anything better has been designed.
Best regards
Heinrich
Quoted 24 lines
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-)create mode 100644
board/emulation/common/qemu_capsule.ccreate mode 100644doc/board/emulation/qemu_capsule_update.rstdelete mode 100644lib/efi_loader/efi_capsule_key.S
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
Quoted 8 lines
We are not talking about configuration here but about bundling a file.
Quoted 1 line
- it provides no memory production in any case, particularly when U-Boot
What do you mean by "production"?
Should you mean memory protection: I cannot see that the memory pages containing the devicetree are set to readonly. Furthermore setenv can
Did you read the discussion? Neither can rodata, so this is a pointless change.
Quoted 1 line
completely replace the devicetree.
Yes and 'mw' can overwrite memory...so...?
Quoted 9 lines
Quoted 6 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisRevert this until a new direction can be established.
We can change the current solution *after* anything better has been designed.
The original solution was fine IMO and the new one is much worse. Now I see a patch to create a new sandbox build. All of this is yet another parallel implementation within U-Boot for EFI. I have yet to see any effort to address the parallel driver model.
We should just use devicetree for run-time configuration.
Regards,
SImon
Re: [PATCH v2 0/3] efi: Minimal revert to rodata change\
Quoted 14 lines · Simon Glass
Hi Heinrich,
Quoted 11 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here but about bundling a file.
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
- it provides no memory production in any case, particularly when U-Boot
What do you mean by "production"?
Should you mean memory protection: I cannot see that the memory pages containing the devicetree are set to readonly. Furthermore setenv can
Did you read the discussion? Neither can rodata, so this is a pointless change.
It's far from pointless imho. In that same discussion I pointed out that the DTB might need to remain r/w for it's entire lifetime, while .rodata is just a matter of missing code to switch pages to RO-.
Thanks
/Ilias
Quoted 23 lines
Quoted 1 line
completely replace the devicetree.
Yes and 'mw' can overwrite memory...so...?
Quoted 9 lines
Quoted 6 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisRevert this until a new direction can be established.
We can change the current solution *after* anything better has been designed.
The original solution was fine IMO and the new one is much worse. Now I see a patch to create a new sandbox build. All of this is yet another parallel implementation within U-Boot for EFI. I have yet to see any effort to address the parallel driver model.
We should just use devicetree for run-time configuration.
Regards,
SImon
Re: [PATCH v2 0/3] efi: Minimal revert to rodata change\
Hi Ilias,
Quoted 23 lines · Ilias Apalodimas
Quoted 21 lines · Simon Glass
Hi Heinrich,
Quoted 17 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here but about bundling a file.
Quoted 1 line
- it provides no memory production in any case, particularly when U-Boot
What do you mean by "production"?
Should you mean memory protection: I cannot see that the memory pages containing the devicetree are set to readonly. Furthermore setenv can
Quoted 6 lines
Quoted 2 lines
Did you read the discussion? Neither can rodata, so this is a pointless change.
It's far from pointless imho. In that same discussion I pointed out that the DTB might need to remain r/w for it's entire lifetime, while .rodata is just a matter of missing code to switch pages to RO-.
We don't support a r/w control DTB in U-Boot. At present any attempt to update the DTB will cause devices to fail to probe since the offsets they point to will be incorrect. If r/w is desired, I think OF_LIVE is the only reasonable option.
So I think that point is moot also.
[..]
Regards,
SImon
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here at all.
Quoted 1 line
- it provides no memory production in any case, particularly when U-Boot
No clue what you mean by "memory production".
Quoted 3 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for this
Having an extra config is not required when putting the certificate into .rodata.
Best regards
Heinrich
Quoted 26 lines
Revert this until a new direction can be established.
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-)create mode 100644
board/emulation/common/qemu_capsule.ccreate mode 100644doc/board/emulation/qemu_capsule_update.rstdelete mode 100644lib/efi_loader/efi_capsule_key.S
Hi Heinrich,
Quoted 10 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here at all.
I thought we were talking about the public key. That is run-time config in my book, just like the devicetree itself, which controls all the devices.
Quoted 4 lines
Quoted 2 lines
- it provides no memory production in any case, particularly when U-Boot
No clue what you mean by "memory production".
memory protection. But it turns out this is pointless anyway. We discussed it at length in the contributor call. We came down to one issue with the way the firmware is packaged by users (with U-Boot coming from one place and TF-A another). I think Ilias is going to write something up to help get to the bottom of it.
Quoted 7 lines
Quoted 4 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisHaving an extra config is not required when putting the certificate into .rodata.
The certificate should not go in rodata, period. Please just fix it. It use to be fine a few weeks ago so it should not be hard.
Regards,
Simon
Quoted 31 lines
Best regards
Heinrich
Quoted 26 lines
Revert this until a new direction can be established.
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-)create mode 100644
board/emulation/common/qemu_capsule.ccreate mode 100644doc/board/emulation/qemu_capsule_update.rstdelete mode 100644lib/efi_loader/efi_capsule_key.S
Quoted 19 lines · Simon Glass
Hi Heinrich,
Quoted 10 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here at all.
I thought we were talking about the public key. That is run-time config in my book, just like the devicetree itself, which controls all the devices.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
- it provides no memory production in any case, particularly when U-Boot
No clue what you mean by "memory production".
memory protection. But it turns out this is pointless anyway. We discussed it at length in the contributor call. We came down to one
What was clarified and decided in that meeting?
I know you have a meeting note, but it was not very clear for me which direction the discussion is heading now.
# Yes, I should have been there, but ...
# Simon, if possible, please announce the agenda a bit earlier
# so that I can notice that. I'm usually in the bed at that time :)
I don't think that memory protection is really a matter if there is no assumption that the storage where the firmware resides are securely protected.
-Takahiro Akashi
Quoted 49 lines
issue with the way the firmware is packaged by users (with U-Boot coming from one place and TF-A another). I think Ilias is going to write something up to help get to the bottom of it.
Quoted 7 lines
Quoted 4 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisHaving an extra config is not required when putting the certificate into .rodata.
The certificate should not go in rodata, period. Please just fix it. It use to be fine a few weeks ago so it should not be hard.
Regards,
SimonQuoted 31 lines
Best regards
Heinrich
Quoted 26 lines
Revert this until a new direction can be established.
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-)create mode 100644
board/emulation/common/qemu_capsule.ccreate mode 100644doc/board/emulation/qemu_capsule_update.rstdelete mode 100644lib/efi_loader/efi_capsule_key.S
Hi Takahiro,
Quoted 23 lines · KASHI Takahiro
Quoted 21 lines · Simon Glass
Hi Heinrich,
Quoted 10 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here at all.
I thought we were talking about the public key. That is run-time config in my book, just like the devicetree itself, which controls all the devices.
Quoted 3 lines
Quoted 2 lines
- it provides no memory production in any case, particularly when U-Boot
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
No clue what you mean by "memory production".
memory protection. But it turns out this is pointless anyway. We discussed it at length in the contributor call. We came down to one
What was clarified and decided in that meeting?
I know you have a meeting note, but it was not very clear for me which direction the discussion is heading now.
I don't think anything was decided, despite the time taken, but we did talk through a lot of the issues.
Quoted 4 lines
# Yes, I should have been there, but ...
# Simon, if possible, please announce the agenda a bit earlier# so that I can notice that. I'm usually in the bed at that time :)
The agenda in this case was added some days in advance but as one participant was a bit late we moved to the 'last-minute' topic of this thread.
Also note that I don't set the agenda, although I might add a topic if there is nothing there.
If you are in Asia, we used to have an Asia call but it was not well attended so we dropped it.
Quoted 4 lines
I don't think that memory protection is really a matter if there is no assumption that the storage where the firmware resides are securely protected.
OK. If it does matter, we can solve it.
Regards,
SImon
Quoted 52 lines
-Takahiro Akashi
Quoted 49 lines
issue with the way the firmware is packaged by users (with U-Boot coming from one place and TF-A another). I think Ilias is going to write something up to help get to the bottom of it.
Quoted 7 lines
Quoted 4 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for thisHaving an extra config is not required when putting the certificate into .rodata.
The certificate should not go in rodata, period. Please just fix it. It use to be fine a few weeks ago so it should not be hard.
Regards,
SimonQuoted 31 lines
Best regards
Heinrich
Quoted 26 lines
Revert this until a new direction can be established.
Changes in v2:
- Also revert two other patches, based on comment from TakahiroSimon Glass (3):
Revert "doc: Update CapsuleUpdate READMEs" Revert "mkeficapsule: Remove dtb related options" Revert "efi_capsule: Move signature from DTB to .rodata"board/emulation/common/Makefile | 1 + board/emulation/common/qemu_capsule.c | 43 ++++ doc/board/emulation/qemu_capsule_update.rst | 203 +++++++++++++++++ doc/develop/uefi/uefi.rst | 125 ----------- include/asm-generic/sections.h | 2 - lib/efi_loader/Kconfig | 7 - lib/efi_loader/Makefile | 8 - lib/efi_loader/efi_capsule.c | 18 +- lib/efi_loader/efi_capsule_key.S | 17 -- tools/mkeficapsule.c | 229 +++++++++++++++++++- 10 files changed, 472 insertions(+), 181 deletions(-)create mode 100644
board/emulation/common/qemu_capsule.ccreate mode 100644doc/board/emulation/qemu_capsule_update.rstdelete mode 100644lib/efi_loader/efi_capsule_key.S
Quoted 34 lines · Simon Glass
Hi Heinrich,
Quoted 10 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here at all.
I thought we were talking about the public key. That is run-time config in my book, just like the devicetree itself, which controls all the devices.
Quoted 4 lines
Quoted 2 lines
- it provides no memory production in any case, particularly when U-Boot
No clue what you mean by "memory production".
memory protection. But it turns out this is pointless anyway. We discussed it at length in the contributor call. We came down to one issue with the way the firmware is packaged by users (with U-Boot coming from one place and TF-A another). I think Ilias is going to write something up to help get to the bottom of it.
Quoted 5 lines
Quoted 4 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for this
Quoted 5 lines
Quoted 2 lines
Having an extra config is not required when putting the certificate into .rodata.
The certificate should not go in rodata, period. Please just fix it. It use to be fine a few weeks ago so it should not be hard.
Where are we at here, Heinrich? Thanks.
Signature · 1 line
Tom
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Heinrich,
Quoted 10 lines · Heinrich Schuchardt
Quoted 4 lines · Simon Glass
The changes to move from devicetree to rodata take things in the wrong direction for various reasons:
- devicetree is where config should be stored
We are not talking about configuration here at all.
I thought we were talking about the public key. That is run-time config in my book, just like the devicetree itself, which controls all the devices.
Quoted 4 lines
Quoted 2 lines
- it provides no memory production in any case, particularly when U-Boot
No clue what you mean by "memory production".
memory protection. But it turns out this is pointless anyway. We discussed it at length in the contributor call. We came down to one issue with the way the firmware is packaged by users (with U-Boot coming from one place and TF-A another). I think Ilias is going to write something up to help get to the bottom of it.
Quoted 5 lines
Quoted 4 lines
is relocated
- testing becomes harder, with the suggestion of adding an entire new sandbox build just for this
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Having an extra config is not required when putting the certificate into .rodata.
The certificate should not go in rodata, period. Please just fix it. It use to be fine a few weeks ago so it should not be hard.
Where are we at here, Heinrich? Thanks.
Heinrich?
Signature · 1 line
Tom