[PATCH v2] arm: imx: fix signature_block_hdr struct fields order

2024-04-04 Thread Javier Viguera
According to the documentation (for example NXP's AN13994 on encrypted
boot on AHAB-enabled devices), the format of the signature block is:

  +--+--+--+-+
  | Tag  | Length - msb | Length - lsb | Version |
  +--+--+--+-+
  | SRK Table offset| Certificate offset |
  +-++
  | Blob offset | Signature offset   |
  +-++

There is no runtime error in the current u-boot code. The only user of
struct signature_block_hdr is the "get_container_size" function in the
"arch/arm/mach-imx/image-container.c" file, and it's only using the very
first fields of the struct (which are in the correct position) and thus
there is no runtime failure.

On the other hand, extending the code to get the data encryption key
blob offset on the signature header gives a wrong value as the field is
in the wrong order.

Signed-off-by: Javier Viguera 
---

Notes:
v2:
  - Improve commit log

 include/imx_container.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/imx_container.h b/include/imx_container.h
index 54cd684e35d5..691c764b3e5b 100644
--- a/include/imx_container.h
+++ b/include/imx_container.h
@@ -50,10 +50,10 @@ struct signature_block_hdr {
u8 length_lsb;
u8 length_msb;
u8 tag;
-   u16 srk_table_offset;
u16 cert_offset;
-   u16 blob_offset;
+   u16 srk_table_offset;
u16 signature_offset;
+   u16 blob_offset;
u32 reserved;
 } __packed;
 


[PATCH] arm: imx: fix signature_block_hdr struct fields order

2024-03-26 Thread Javier Viguera
According to the documentation (for example AN13994), for AHAB-enabled
devices the format of the signature block is:

  +--+--+--+-+
  | Tag  | Length - msb | Length - lsb | Version |
  +--+--+--+-+
  | SRK Table offset| Certificate offset |
  +-++
  | Blob offset | Signature offset   |
  +-++

Signed-off-by: Javier Viguera 
---
 include/imx_container.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/imx_container.h b/include/imx_container.h
index 54cd684e35d5..691c764b3e5b 100644
--- a/include/imx_container.h
+++ b/include/imx_container.h
@@ -50,10 +50,10 @@ struct signature_block_hdr {
u8 length_lsb;
u8 length_msb;
u8 tag;
-   u16 srk_table_offset;
u16 cert_offset;
-   u16 blob_offset;
+   u16 srk_table_offset;
u16 signature_offset;
+   u16 blob_offset;
u32 reserved;
 } __packed;
 


Re: [PATCH] env: mmc: fix environment on hw boot partition 2

2023-12-01 Thread Javier Viguera

Hi all,

Please disregard this patch. I'm not sure if CONFIG_VAL is the correct
macro when there are no SPL_,TPL_ versions for SYS_MMC_ENV_PART option.

So back on square one.

How do we solve this to support SYS_MMC_ENV_PART = 2?

We have a configuration where we want the environment on "mmcblk0boot1"
(which is the **second** boot partition) and the IS_ENABLED evaluates to
**0** which prevents the "hwpart = mmc_get_env_part(mmc);" to even run.

Thanks for your help.

--
Javier Viguera


On 1/12/23 12:09, Javier Viguera wrote:

SYS_MMC_ENV_PART is an integer option. If it is set to 2 to use the
second hardware boot partition, the IS_ENABLED check fails as it expects
a boolean, and then it does not get the correct hwpart.

Signed-off-by: Javier Viguera 
---
  env/mmc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/mmc.c b/env/mmc.c
index cb14bbb58f13..df82969d4231 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -111,7 +111,7 @@ static inline s64 mmc_offset(struct mmc *mmc, int copy)
int hwpart = 0;
int err;

-   if (IS_ENABLED(CONFIG_SYS_MMC_ENV_PART))
+   if (CONFIG_VAL(SYS_MMC_ENV_PART))
hwpart = mmc_get_env_part(mmc);

  #if defined(CONFIG_ENV_MMC_PARTITION)





[PATCH] env: mmc: fix environment on hw boot partition 2

2023-12-01 Thread Javier Viguera
SYS_MMC_ENV_PART is an integer option. If it is set to 2 to use the
second hardware boot partition, the IS_ENABLED check fails as it expects
a boolean, and then it does not get the correct hwpart.

Signed-off-by: Javier Viguera 
---
 env/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/mmc.c b/env/mmc.c
index cb14bbb58f13..df82969d4231 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -111,7 +111,7 @@ static inline s64 mmc_offset(struct mmc *mmc, int copy)
int hwpart = 0;
int err;
 
-   if (IS_ENABLED(CONFIG_SYS_MMC_ENV_PART))
+   if (CONFIG_VAL(SYS_MMC_ENV_PART))
hwpart = mmc_get_env_part(mmc);
 
 #if defined(CONFIG_ENV_MMC_PARTITION)