From 9a596836c9c07c446f341b1279febbd37e4f645b Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Wed, 25 May 2022 14:23:05 +0200 Subject: [PATCH] kirkstone migration: update libubootenv package Refresh patches so they apply on top of new version 0.3.2 Signed-off-by: Javier Viguera --- ...t-for-environment-encryption-by-CAAM.patch | 30 ++++++++----------- ...-U-Boot-environment-access-functions.patch | 12 +++----- ...pport-to-set-dynamic-location-of-env.patch | 16 ++++------ 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0001-Implement-support-for-environment-encryption-by-CAAM.patch b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0001-Implement-support-for-environment-encryption-by-CAAM.patch index eb8bca7f3..a2e25acf2 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0001-Implement-support-for-environment-encryption-by-CAAM.patch +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0001-Implement-support-for-environment-encryption-by-CAAM.patch @@ -1,7 +1,6 @@ -From 58977c4d6709f6ce4dc444e844b3665b031c556f Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 7 Apr 2021 09:15:07 +0200 -Subject: [PATCH 1/3] Implement support for environment encryption by CAAM +Subject: [PATCH] Implement support for environment encryption by CAAM Use the md5sum of HWID words (on the device tree) as key modifier. This is based on the u-boot-fw-utils implementation of the CAAM encryption support. @@ -29,7 +28,7 @@ Signed-off-by: Gabriel Valcazar create mode 100644 src/md5.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index a04dd11..659594a 100644 +index 4b71bc588827..d7e38a12feed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,8 @@ @@ -43,7 +42,7 @@ index a04dd11..659594a 100644 ) diff --git a/src/caam_keyblob.h b/src/caam_keyblob.h new file mode 100644 -index 0000000..e313e87 +index 000000000000..e313e87a3854 --- /dev/null +++ b/src/caam_keyblob.h @@ -0,0 +1,42 @@ @@ -91,7 +90,7 @@ index 0000000..e313e87 +#endif /* CAAM_KEYBLOB_H */ diff --git a/src/md5.c b/src/md5.c new file mode 100644 -index 0000000..47ae8bf +index 000000000000..47ae8bf34a4d --- /dev/null +++ b/src/md5.c @@ -0,0 +1,275 @@ @@ -372,7 +371,7 @@ index 0000000..47ae8bf +} diff --git a/src/md5.h b/src/md5.h new file mode 100644 -index 0000000..02a9a9d +index 000000000000..02a9a9d23e34 --- /dev/null +++ b/src/md5.h @@ -0,0 +1,24 @@ @@ -401,7 +400,7 @@ index 0000000..02a9a9d + +#endif /* _MD5_H */ diff --git a/src/uboot_env.c b/src/uboot_env.c -index c9a900f..53b3576 100644 +index 30c39ebf6fa9..2fd08f5a07db 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -33,11 +33,21 @@ @@ -426,7 +425,7 @@ index c9a900f..53b3576 100644 #define UBI_MAX_VOLUME 128 #define DEVICE_MTD_NAME "/dev/mtd" -@@ -840,6 +850,105 @@ static int set_obsolete_flag(struct uboot_flash_env *dev) +@@ -844,6 +854,105 @@ static int set_obsolete_flag(struct uboot_flash_env *dev) return ret; } @@ -532,7 +531,7 @@ index c9a900f..53b3576 100644 int libuboot_env_store(struct uboot_ctx *ctx) { struct var_entry *entry; -@@ -914,6 +1023,15 @@ int libuboot_env_store(struct uboot_ctx *ctx) +@@ -919,6 +1028,15 @@ int libuboot_env_store(struct uboot_ctx *ctx) ((struct uboot_env_redund *)image)->flags = flags; } @@ -548,10 +547,10 @@ index c9a900f..53b3576 100644 *(uint32_t *)image = crc32(0, (uint8_t *)data, ctx->size - offsetdata); copy = ctx->redundant ? (ctx->current ? 0 : 1) : 0; -@@ -978,6 +1096,13 @@ static int libuboot_load(struct uboot_ctx *ctx) +@@ -984,6 +1102,13 @@ static int libuboot_load(struct uboot_ctx *ctx) } crc = *(uint32_t *)(buf[i] + offsetcrc); - dev->crc = crc32(0, (uint8_t *)data, ctx->size - offsetdata); + dev->crc = crc32(0, (uint8_t *)data, usable_envsize); + if (ctx->encrypted) { + ret = env_caam_crypt((char *)data, ctx->usable_size, 0); + if (ret) { @@ -562,7 +561,7 @@ index c9a900f..53b3576 100644 crcenv[i] = dev->crc == crc; if (ctx->redundant) dev->flags = *(uint8_t *)(buf[i] + offsetflags); -@@ -1258,6 +1383,11 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) +@@ -1264,6 +1389,11 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) break; } } @@ -574,7 +573,7 @@ index c9a900f..53b3576 100644 if (ndev == 0) retval = -EINVAL; -@@ -1446,6 +1576,7 @@ int libuboot_initialize(struct uboot_ctx **out, +@@ -1461,6 +1591,7 @@ int libuboot_initialize(struct uboot_ctx **out, return -ENOMEM; ctx->valid = false; @@ -583,7 +582,7 @@ index c9a900f..53b3576 100644 if (ret < 0) { diff --git a/src/uboot_private.h b/src/uboot_private.h -index 4b7a9f9..22c8c14 100644 +index 4b7a9f9602a6..22c8c14ce8cc 100644 --- a/src/uboot_private.h +++ b/src/uboot_private.h @@ -111,10 +111,14 @@ LIST_HEAD(vars, var_entry); @@ -601,6 +600,3 @@ index 4b7a9f9..22c8c14 100644 /** devices where environment is stored */ struct uboot_flash_env envdevs[2]; /** Set which device contains the current(last valid) environment */ --- -2.17.1 - diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0002-Implement-U-Boot-environment-access-functions.patch b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0002-Implement-U-Boot-environment-access-functions.patch index b00080cf9..065db6515 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0002-Implement-U-Boot-environment-access-functions.patch +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0002-Implement-U-Boot-environment-access-functions.patch @@ -1,7 +1,6 @@ -From 00d0ef9a96cf5480146c800c64557f7c88ac9db4 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 7 Apr 2021 11:35:15 +0200 -Subject: [PATCH 2/3] Implement U-Boot environment access functions +Subject: [PATCH] Implement U-Boot environment access functions Keep the same function signatures as u-boot-fw-utils, so that all code making use of this functionality remains compatible. Use the libubootenv @@ -19,7 +18,7 @@ Signed-off-by: Gabriel Valcazar 2 files changed, 119 insertions(+) diff --git a/src/libuboot.h b/src/libuboot.h -index bfcaeb1..b15969f 100644 +index bfcaeb1d609f..b15969f89174 100644 --- a/src/libuboot.h +++ b/src/libuboot.h @@ -159,6 +159,29 @@ const char *libuboot_getname(void *entry); @@ -53,10 +52,10 @@ index bfcaeb1..b15969f 100644 } #endif diff --git a/src/uboot_env.c b/src/uboot_env.c -index 53b3576..bcc4af9 100644 +index 2fd08f5a07db..87f831b0cdc7 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c -@@ -1617,3 +1617,99 @@ void libuboot_close(struct uboot_ctx *ctx) { +@@ -1632,3 +1632,99 @@ void libuboot_close(struct uboot_ctx *ctx) { void libuboot_exit(struct uboot_ctx *ctx) { free(ctx); } @@ -156,6 +155,3 @@ index 53b3576..bcc4af9 100644 + + return ret ? -1 : 0; +} --- -2.17.1 - diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0003-tools-env-add-support-to-set-dynamic-location-of-env.patch b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0003-tools-env-add-support-to-set-dynamic-location-of-env.patch index 14937f598..f4e744757 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0003-tools-env-add-support-to-set-dynamic-location-of-env.patch +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0003-tools-env-add-support-to-set-dynamic-location-of-env.patch @@ -1,7 +1,6 @@ -From cd5e40f6dbef29a04cdfabec47fd3674d764f74e Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 7 Apr 2021 13:47:37 +0200 -Subject: [PATCH 3/3] tools: env: add support to set dynamic location of +Subject: [PATCH] tools: env: add support to set dynamic location of environment copies A mechanism was added in U-Boot to set the location of environment copies @@ -28,7 +27,7 @@ Signed-off-by: Gabriel Valcazar 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/uboot_env.c b/src/uboot_env.c -index bcc4af9..71fef10 100644 +index 87f831b0cdc7..539e22f9a8ac 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -431,6 +431,73 @@ static int check_env_device(struct uboot_ctx *ctx, struct uboot_flash_env *dev) @@ -118,7 +117,7 @@ index bcc4af9..71fef10 100644 return true; } -@@ -485,7 +558,7 @@ static int fileread(struct uboot_flash_env *dev, void *data) +@@ -488,7 +561,7 @@ static int fileread(struct uboot_flash_env *dev, void *data) return ret; } @@ -127,7 +126,7 @@ index bcc4af9..71fef10 100644 { size_t count; size_t blocksize; -@@ -504,6 +577,17 @@ static int mtdread(struct uboot_flash_env *dev, void *data) +@@ -507,6 +580,17 @@ static int mtdread(struct uboot_flash_env *dev, void *data) ret = read(dev->fd, data, dev->envsize); break; case MTD_NANDFLASH: @@ -145,7 +144,7 @@ index bcc4af9..71fef10 100644 if (dev->offset) if (lseek(dev->fd, dev->offset, SEEK_SET) < 0) { ret = -EIO; -@@ -579,7 +663,7 @@ static int devread(struct uboot_ctx *ctx, unsigned int copy, void *data) +@@ -582,7 +666,7 @@ static int devread(struct uboot_ctx *ctx, unsigned int copy, void *data) ret = fileread(dev, data); break; case DEVICE_MTD: @@ -155,7 +154,7 @@ index bcc4af9..71fef10 100644 case DEVICE_UBI: ret = ubiread(dev, data); diff --git a/src/uboot_private.h b/src/uboot_private.h -index 22c8c14..591df20 100644 +index 22c8c14ce8cc..591df20d6936 100644 --- a/src/uboot_private.h +++ b/src/uboot_private.h @@ -113,10 +113,14 @@ struct uboot_ctx { @@ -173,6 +172,3 @@ index 22c8c14..591df20 100644 /** usable environment size */ unsigned int usable_size; /** devices where environment is stored */ --- -2.17.1 -