diff mbox series

[3/4] ARM: stm32: Pass ROM API table pointer to U-Boot proper

Message ID 20221206023357.113361-3-marex@denx.de
State Superseded
Delegated to: Patrice Chotard
Headers show
Series [1/4] ARM: stm32: Fix ECDSA authentication with Dcache enabled | expand

Commit Message

Marek Vasut Dec. 6, 2022, 2:33 a.m. UTC
The ROM API table pointer is no longer accessible from U-Boot, fix
this by passing the ROM API pointer through. This makes it possible
for U-Boot to call ROM API functions to authenticate payload like
signed fitImages.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
---
 arch/arm/mach-stm32mp/cpu.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Patrice CHOTARD Dec. 6, 2022, 8:09 a.m. UTC | #1
On 12/6/22 03:33, Marek Vasut wrote:
> The ROM API table pointer is no longer accessible from U-Boot, fix
> this by passing the ROM API pointer through. This makes it possible
> for U-Boot to call ROM API functions to authenticate payload like
> signed fitImages.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>  arch/arm/mach-stm32mp/cpu.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
> index fa02a11d867..9553ecd243c 100644
> --- a/arch/arm/mach-stm32mp/cpu.c
> +++ b/arch/arm/mach-stm32mp/cpu.c
> @@ -22,6 +22,7 @@
>  #include <dm/device.h>
>  #include <dm/uclass.h>
>  #include <linux/bitops.h>
> +#include <spl.h>
>  
>  /*
>   * early TLB into the .data section so that it not get cleared
> @@ -413,3 +414,17 @@ uintptr_t get_stm32mp_bl2_dtb(void)
>  {
>  	return nt_fw_dtb;
>  }
> +
> +#ifdef CONFIG_SPL_BUILD
> +void jump_to_image_no_args(struct spl_image_info *spl_image)
> +{
> +	typedef void __noreturn (*image_entry_noargs_t)(u32 romapi);
> +	uintptr_t romapi = get_stm32mp_rom_api_table();
> +
> +	image_entry_noargs_t image_entry =
> +		(image_entry_noargs_t)spl_image->entry_point;
> +
> +	printf("image entry point: 0x%lx\n", spl_image->entry_point);
> +	image_entry(romapi);
> +}
> +#endif

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Patrick Delaunay Dec. 6, 2022, 8:53 a.m. UTC | #2
Hi,

minor comment

On 12/6/22 03:33, Marek Vasut wrote:
> The ROM API table pointer is no longer accessible from U-Boot, fix
> this by passing the ROM API pointer through. This makes it possible
> for U-Boot to call ROM API functions to authenticate payload like
> signed fitImages.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>   arch/arm/mach-stm32mp/cpu.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
>
> diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
> index fa02a11d867..9553ecd243c 100644
> --- a/arch/arm/mach-stm32mp/cpu.c
> +++ b/arch/arm/mach-stm32mp/cpu.c
> @@ -22,6 +22,7 @@
>   #include <dm/device.h>
>   #include <dm/uclass.h>
>   #include <linux/bitops.h>
> +#include <spl.h>
>   
>   /*
>    * early TLB into the .data section so that it not get cleared
> @@ -413,3 +414,17 @@ uintptr_t get_stm32mp_bl2_dtb(void)
>   {
>   	return nt_fw_dtb;
>   }
> +
> +#ifdef CONFIG_SPL_BUILD
> +void jump_to_image_no_args(struct spl_image_info *spl_image)

missing "__noreturn" ?


void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)

> +{
> +	typedef void __noreturn (*image_entry_noargs_t)(u32 romapi);

really 'noargs' ?

  I propose to replace to 'arg' => image_entry_arg_t

arch/powerpc/lib/spl.c:20

base on arch/arm/lib/spl.c:71

arch/microblaze/cpu/spl.c:37

typedef void __noreturn (*image_entry_noargs_t)(u32 romapi);


or with stm32:

typedef void __noreturn (*image_entry_stm32_t)(u32 romapi);

based on arch/riscv/lib/spl.c:40


> +	uintptr_t romapi = get_stm32mp_rom_api_table();
> +
> +	image_entry_noargs_t image_entry =
> +		(image_entry_noargs_t)spl_image->entry_point;
> +
> +	printf("image entry point: 0x%lx\n", spl_image->entry_point);
> +	image_entry(romapi);
> +}
> +#endif


regards

Patrick
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index fa02a11d867..9553ecd243c 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -22,6 +22,7 @@ 
 #include <dm/device.h>
 #include <dm/uclass.h>
 #include <linux/bitops.h>
+#include <spl.h>
 
 /*
  * early TLB into the .data section so that it not get cleared
@@ -413,3 +414,17 @@  uintptr_t get_stm32mp_bl2_dtb(void)
 {
 	return nt_fw_dtb;
 }
+
+#ifdef CONFIG_SPL_BUILD
+void jump_to_image_no_args(struct spl_image_info *spl_image)
+{
+	typedef void __noreturn (*image_entry_noargs_t)(u32 romapi);
+	uintptr_t romapi = get_stm32mp_rom_api_table();
+
+	image_entry_noargs_t image_entry =
+		(image_entry_noargs_t)spl_image->entry_point;
+
+	printf("image entry point: 0x%lx\n", spl_image->entry_point);
+	image_entry(romapi);
+}
+#endif