Skip to contentSkip to conversation

Enable private ATF handoff structure

PATCH New Michal Simek 3 participants 8 messages Dec 19, 2019 – Jan 17, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Enable private ATF handoff structure

Hi,

Xilinx ZynqMP platform is using from the beggining specific structure which is passed from FSBL/SPL to ATF.
Maybe in future both options can be supported by ATF and we can remove this private structure completely. But as of now bl31_params are completely ignored by ATF by RESET_TO_BL31=1 build flag.

Thanks,
Michal

Michal Simek (2):
spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()
arm: zynqmp: Wire SPL/ATF handoff structure properly

 arch/arm/mach-zynqmp/handoff.c                | 17 +++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 common/spl/spl_atf.c                          | 15 +-------------
 include/spl.h                                 | 20 +++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)
Signature · 1 line
2.24.0
#1 lore raw

PATCH 1/2 spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()

Xilinx ZynqMP platform is passing information to ATF in private format and ATF bl31 parameters are not used. That's why enable option to rewrite this function by platform specific implementation.

The patch also move and update kernel-doc format with missing parameters.

---

 common/spl/spl_atf.c | 15 +--------------
 include/spl.h        | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 14 deletions(-)
common/spl/spl_atf.c +1 -14
index 24fd35ed85f4..702367b2a23c 100644
@@ -18,20 +18,7 @@
 static struct bl2_to_bl31_params_mem bl31_params_mem;
 static struct bl31_params *bl2_to_bl31_params;
 
-/**
- * bl2_plat_get_bl31_params() - prepare params for bl31.
- *
- * This function assigns a pointer to the memory that the platform has kept
- * aside to pass platform specific and trusted firmware related information
- * to BL31. This memory is allocated by allocating memory to
- * bl2_to_bl31_params_mem structure which is a superset of all the
- * structure whose information is passed to BL31
- * NOTE: This function should be called only once and should be done
- * before generating params to BL31
- *
- * @return bl31 params structure pointer
- */
-static struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
+__weak struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
 						    uintptr_t bl33_entry,
 						    uintptr_t fdt_addr)
 {
include/spl.h +20 -0
index 08ffddac29f2..90162f2e36a1 100644
@@ -442,6 +442,26 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
  */
 void spl_invoke_atf(struct spl_image_info *spl_image);
 
+/**
+ * bl2_plat_get_bl31_params() - prepare params for bl31.
+ * @bl32_entry	address of BL32 executable (secure)
+ * @bl33_entry	address of BL33 executable (non secure)
+ * @fdt_addr	address of Flat Device Tree
+ *
+ * This function assigns a pointer to the memory that the platform has kept
+ * aside to pass platform specific and trusted firmware related information
+ * to BL31. This memory is allocated by allocating memory to
+ * bl2_to_bl31_params_mem structure which is a superset of all the
+ * structure whose information is passed to BL31
+ * NOTE: This function should be called only once and should be done
+ * before generating params to BL31
+ *
+ * @return bl31 params structure pointer
+ */
+struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
+					     uintptr_t bl33_entry,
+					     uintptr_t fdt_addr);
+
 /**
  * spl_optee_entry - entry function for optee
  *
Signature · 1 line
2.24.0
#2 lore raw

PATCH 2/2 arm: zynqmp: Wire SPL/ATF handoff structure properly

In reply to Michal Simek

handoff_setup() was used to generate fixed handoff structure for ATF on ZynqMP platform.
Switching to bl2_plat_get_bl31_params() platform brings more flexibility because information can be taken from fit image where /fit-images node is created at run time.

---

 arch/arm/mach-zynqmp/handoff.c                | 17 ++++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 3 files changed, 12 insertions(+), 9 deletions(-)
arch/arm/mach-zynqmp/handoff.c +12 -5
index f71ff7b3d257..64e5320acc68 100644
@@ -66,7 +66,9 @@ struct xfsbl_atf_handoff_params {
 };
 
 #ifdef CONFIG_SPL_OS_BOOT
-void handoff_setup(void)
+struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
+					     uintptr_t bl33_entry,
+					     uintptr_t fdt_addr)
 {
 	struct xfsbl_atf_handoff_params *atfhandoffparams;
 
@@ -76,11 +78,16 @@ void handoff_setup(void)
 	atfhandoffparams->magic[2] = 'N';
 	atfhandoffparams->magic[3] = 'X';
 
-	atfhandoffparams->num_entries = 1;
-	atfhandoffparams->partition[0].entry_point = CONFIG_SYS_TEXT_BASE;
-	atfhandoffparams->partition[0].flags = FSBL_FLAGS_EL2 <<
-					       FSBL_FLAGS_EL_SHIFT;
+	atfhandoffparams->num_entries = 0;
+	if (bl33_entry) {
+		atfhandoffparams->partition[0].entry_point = bl33_entry;
+		atfhandoffparams->partition[0].flags = FSBL_FLAGS_EL2 <<
+						       FSBL_FLAGS_EL_SHIFT;
+		atfhandoffparams->num_entries++;
+	}
 
 	writel(CONFIG_SPL_TEXT_BASE, &pmu_base->gen_storage6);
+
+	return NULL;
 }
 #endif
arch/arm/mach-zynqmp/include/mach/sys_proto.h +0 -2
index 10b70761de4a..2974ffbc2f56 100644
@@ -46,8 +46,6 @@ struct zynqmp_ipi_msg {
 int zynq_board_read_rom_ethaddr(unsigned char *ethaddr);
 unsigned int zynqmp_get_silicon_version(void);
 
-void handoff_setup(void);
-
 int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value);
 int zynqmp_mmio_read(const u32 address, u32 *value);
 
arch/arm/mach-zynqmp/spl.c +0 -2
index 8cb82635fa3a..a83e095687f6 100644
@@ -120,8 +120,6 @@ u32 spl_boot_device(void)
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
-	handoff_setup();
-
 	return 0;
 }
 #endif
Signature · 1 line
2.24.0
Applied
#3 lore raw

cover Enable private ATF handoff structure

In reply to Michal Simek

čt 19. 12. 2019 v 18:32 odesílatel Michal Simek
<[email protected]> napsal:

Quoted 24 lines

Hi,

Xilinx ZynqMP platform is using from the beggining specific structure which is passed from FSBL/SPL to ATF.
Maybe in future both options can be supported by ATF and we can remove this private structure completely. But as of now bl31_params are completely ignored by ATF by RESET_TO_BL31=1 build flag.

Thanks,
Michal

Michal Simek (2):
spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()
arm: zynqmp: Wire SPL/ATF handoff structure properly

 arch/arm/mach-zynqmp/handoff.c                | 17 +++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 common/spl/spl_atf.c                          | 15 +-------------
 include/spl.h                                 | 20 +++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)
Quoted 3 lines

--
2.24.0

Applied.
M

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
#4 lore raw

cover Enable private ATF handoff structure

Quoted 26 lines · Michal Simek

čt 19. 12. 2019 v 18:32 odesílatel Michal Simek
<[email protected]> napsal:

Quoted 24 lines

Hi,

Xilinx ZynqMP platform is using from the beggining specific structure which is passed from FSBL/SPL to ATF.
Maybe in future both options can be supported by ATF and we can remove this private structure completely. But as of now bl31_params are completely ignored by ATF by RESET_TO_BL31=1 build flag.

Thanks,
Michal

Michal Simek (2):
spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()
arm: zynqmp: Wire SPL/ATF handoff structure properly

 arch/arm/mach-zynqmp/handoff.c                | 17 +++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 common/spl/spl_atf.c                          | 15 +-------------
 include/spl.h                                 | 20 +++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)
Quoted 5 lines
Quoted 3 lines

--
2.24.0

Applied.

Can't you rather pass DT around ?

#5 lore raw

cover Enable private ATF handoff structure

Quoted 27 lines · Marek Vasut
Quoted 26 lines · Michal Simek

čt 19. 12. 2019 v 18:32 odesílatel Michal Simek
<[email protected]> napsal:

Quoted 24 lines

Hi,

Xilinx ZynqMP platform is using from the beggining specific structure which is passed from FSBL/SPL to ATF.
Maybe in future both options can be supported by ATF and we can remove this private structure completely. But as of now bl31_params are completely ignored by ATF by RESET_TO_BL31=1 build flag.

Thanks,
Michal

Michal Simek (2):
spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()
arm: zynqmp: Wire SPL/ATF handoff structure properly

 arch/arm/mach-zynqmp/handoff.c                | 17 +++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 common/spl/spl_atf.c                          | 15 +-------------
 include/spl.h                                 | 20 +++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

--
2.24.0

Applied.

Can't you rather pass DT around ?

Unfortunately not. The best will be just update ATF to support standard method how to get information but that means that we break all backward compatibility and nothing will work.
Xilinx handoff structure is around fro quite a long time and that's something I need to unfortunately live with.

Thanks,
Michal

#6 lore raw

cover Enable private ATF handoff structure

Quoted 32 lines · Michal Simek
Quoted 31 lines · Marek Vasut
Quoted 30 lines · Michal Simek

čt 19. 12. 2019 v 18:32 odesílatel Michal Simek
<[email protected]> napsal:

Quoted 27 lines

Hi,

Xilinx ZynqMP platform is using from the beggining specific structure which is passed from FSBL/SPL to ATF.
Maybe in future both options can be supported by ATF and we can remove this private structure completely. But as of now bl31_params are completely ignored by ATF by RESET_TO_BL31=1 build flag.

Thanks,
Michal

Michal Simek (2):
spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()
arm: zynqmp: Wire SPL/ATF handoff structure properly

 arch/arm/mach-zynqmp/handoff.c                | 17 +++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 common/spl/spl_atf.c                          | 15 +-------------
 include/spl.h                                 | 20 +++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)

--
2.24.0

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Applied.

Can't you rather pass DT around ?

Unfortunately not. The best will be just update ATF to support standard method how to get information but that means that we break all backward compatibility and nothing will work.

Isn't that what Xilinx does with their ABI between all BSP versions ? The only stable thing is the ABI version, which never changes :-)

Quoted 2 lines

Xilinx handoff structure is around fro quite a long time and that's something I need to unfortunately live with.

Maybe you can develop a better method (DT) in parallel and slowly switch over then ?

#7 lore raw

cover Enable private ATF handoff structure

Quoted 38 lines · Marek Vasut
Quoted 37 lines · Michal Simek
Quoted 35 lines · Marek Vasut
Quoted 26 lines · Michal Simek

čt 19. 12. 2019 v 18:32 odesílatel Michal Simek
<[email protected]> napsal:

Quoted 24 lines

Hi,

Xilinx ZynqMP platform is using from the beggining specific structure which is passed from FSBL/SPL to ATF.
Maybe in future both options can be supported by ATF and we can remove this private structure completely. But as of now bl31_params are completely ignored by ATF by RESET_TO_BL31=1 build flag.

Thanks,
Michal

Michal Simek (2):
spl: atf: Enable option to rewrite bl2_plat_get_bl31_params()
arm: zynqmp: Wire SPL/ATF handoff structure properly

 arch/arm/mach-zynqmp/handoff.c                | 17 +++++++++++-----
 arch/arm/mach-zynqmp/include/mach/sys_proto.h |  2 --
 arch/arm/mach-zynqmp/spl.c                    |  2 --
 common/spl/spl_atf.c                          | 15 +-------------
 include/spl.h                                 | 20 +++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)
Quoted 5 lines
Quoted 3 lines

--
2.24.0

Applied.

Can't you rather pass DT around ?

Quoted 6 lines
Quoted 3 lines

Unfortunately not. The best will be just update ATF to support standard method how to get information but that means that we break all backward compatibility and nothing will work.

Isn't that what Xilinx does with their ABI between all BSP versions ? The only stable thing is the ABI version, which never changes :-)

This handoff structure is stable from beginning.

Quoted 5 lines
Quoted 2 lines

Xilinx handoff structure is around fro quite a long time and that's something I need to unfortunately live with.

Maybe you can develop a better method (DT) in parallel and slowly switch over then ?

bl2_plat_get_bl31_params() is something what it is used by ATF for a long time. Not sure if they are moving to DT way how to describe stuff. But from my point of view having alternatives and a way for conversion is right way to go.

Thanks,
Michal