Skip to contentSkip to conversation

Add ARMv8 PSCI framework

PATCH Superseded Hongbo Zhang 2 participants 20 messages Nov 25, 2016 – Dec 7, 2016 1 message not in the archive Arm (32-bit)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add ARMv8 PSCI framework

v3-v4 changes:
- Re-added the 1/6 from v2, and move the newly re-named macro into Kconfig
- Add "Reviewed-by: Tom Rini <[email protected]>" for patch 4/6 ~ 6/6.

v2-v3 changes:
- Drop the previous 1/6, since the previous CONFIG_ARMV8_PSCI in common parts
of codes also work for generic PSCI framework, so there are 5 patches in this iteration.
- Add "Reviewed-by: Tom Rini <[email protected]>" for patches 1/5 and 2/5,
which were 2/6 and 3/6.
- Move config values for ls1043 from armv8/Kconfig to s1043ardb_defconfig.

v1-v2 changes:
- The new config options are introduced in Kconfig when used for first time
- Introduce new config options in armv8/Kconfig instead of LS1043 platform
- Move previous patch 5/6 to current 2/6 place

v1 notes:

This patch set introduces ARMv8 PSCI framework, all the PSCI functions are implemented a default dummy one, it is up to each platform to implement their own specific ones.

The first 1/6 patch is a prepare clean up for adding ARMv8 PSCI. Patches 2/6 to 5/6 introduce new ARMv8 framework and set it up. The last 6/6 adds a most simple implementation on NXP LS1043 platform, to verify this framework.

This patch set mainly introduces ARMv8 PSCI framework, for easier review and merge, further PSCI implementation on LS1043 is coming later.

Hongbo Zhang (6):
ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
ARMv8: Enable SMC instruction
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and device tree
ARMv8: LS1043A: Enable LS1043A default PSCI support

 arch/arm/config.mk                               |   3 +-
 arch/arm/cpu/armv8/Kconfig                       |  41 ++++
 arch/arm/cpu/armv8/Makefile                      |   1 +
 arch/arm/cpu/armv8/cpu-dt.c                      |  11 +-
 arch/arm/cpu/armv8/cpu.c                         |  22 ++
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig        |  20 ++
 arch/arm/cpu/armv8/fsl-layerscape/Makefile       |   1 +
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c          |   3 +-
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c          |   3 +-
 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S |  20 ++
 arch/arm/cpu/armv8/psci.S                        | 286 +++++++++++++++++++++++
 arch/arm/cpu/armv8/sec_firmware.c                |   2 +-
 arch/arm/cpu/armv8/sec_firmware_asm.S            |   2 +-
 arch/arm/cpu/armv8/u-boot.lds                    |  57 +++++
 arch/arm/include/asm/armv8/sec_firmware.h        |   2 +-
 arch/arm/include/asm/macro.h                     |   2 +-
 arch/arm/include/asm/psci.h                      |  15 ++
 arch/arm/include/asm/secure.h                    |   2 +-
 arch/arm/include/asm/system.h                    |  11 +
 arch/arm/lib/bootm-fdt.c                         |   3 +-
 arch/arm/lib/bootm.c                             |   3 +
 arch/arm/lib/psci-dt.c                           |   5 +-
 board/freescale/ls1043ardb/Kconfig               |   9 +
 configs/ls1043ardb_defconfig                     |   3 +
 include/configs/ls1043ardb.h                     |   1 -
 25 files changed, 515 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
 create mode 100644 arch/arm/cpu/armv8/psci.S
Signature · 1 line
2.1.4
#1 lore raw

PATCH v4 1/6 ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition

NXP/Freescale uses macro CONFIG_ARMV8_PSCI to enable their private PSCI implementation in PPA firmware, but this macro naming too generic, so this patch replaces it with a specic one CONFIG_FSL_PPA_ARMV8_PSCI. And this macro CONFIG_ARMV8_PSCI will be used for a generic PSCI for ARMv8 which will be added in following patchs.

---
 arch/arm/cpu/armv8/cpu-dt.c               |  2 +-
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 20 ++++++++++++++++++++
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |  3 ++-
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c   |  3 ++-
 arch/arm/cpu/armv8/sec_firmware.c         |  2 +-
 arch/arm/cpu/armv8/sec_firmware_asm.S     |  2 +-
 arch/arm/include/asm/armv8/sec_firmware.h |  2 +-
 arch/arm/lib/bootm-fdt.c                  |  2 +-
 arch/arm/lib/psci-dt.c                    |  2 +-
 include/configs/ls1043ardb.h              |  1 -
 10 files changed, 30 insertions(+), 9 deletions(-)
arch/arm/cpu/armv8/cpu-dt.c +1 -1
index 9ffb49c..659ec27 100644
@@ -13,7 +13,7 @@
 int psci_update_dt(void *fdt)
 {
 #ifdef CONFIG_MP
-#if defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_FSL_PPA_ARMV8_PSCI)
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 	/*
 	 * If the PSCI in SEC Firmware didn't work, avoid to update the
arch/arm/cpu/armv8/fsl-layerscape/Kconfig +20 -0
index 94ec8d5..3179c2a 100644
@@ -44,6 +44,26 @@ config FSL_LSCH3
 menu "Layerscape architecture"
 	depends on FSL_LSCH2 || FSL_LSCH3
 
+menu "Layerscape PPA"
+config FSL_LS_PPA
+	bool "FSL Layerscape PPA firmware support"
+	depends on ARCH_LS1043A || ARCH_LS1046A
+	select FSL_PPA_ARMV8_PSCI
+	help
+	  The FSL Primary Protected Application (PPA) is a software component
+	  which is loaded during boot stage, and then remains resident in RAM
+	  and runs in the TrustZone after boot.
+	  Say y to enable it.
+
+config FSL_PPA_ARMV8_PSCI
+	bool "PSCI implementation in PPA firmware"
+	depends on FSL_LS_PPA
+	help
+	  This config enables the ARMv8 PSCI implementation in PPA firmware.
+	  This is a private PSCI implementation and different from those
+	  implemented under the common ARMv8 PSCI framework.
+endmenu
+
 config SYS_FSL_MMDC
 	bool
 
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +2 -1
index 0b516e3..e47219a 100644
@@ -403,7 +403,8 @@ int arch_early_init_r(void)
 #endif
 
 #ifdef CONFIG_MP
-#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \
+	defined(CONFIG_FSL_PPA_ARMV8_PSCI)
 	/* Check the psci version to determine if the psci is supported */
 	psci_ver = sec_firmware_support_psci_version();
 #endif
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +2 -1
index 0dae5fa..c10ccf9 100644
@@ -42,7 +42,8 @@ void ft_fixup_cpu(void *blob)
 	int addr_cells;
 	u64 val, core_id;
 	size_t *boot_code_size = &(__secondary_boot_code_size);
-#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \
+	defined(CONFIG_FSL_PPA_ARMV8_PSCI)
 	int node;
 	u32 psci_ver;
 
arch/arm/cpu/armv8/sec_firmware.c +1 -1
index 2ddd67e..0b973f0 100644
@@ -209,7 +209,7 @@ __weak bool sec_firmware_is_valid(const void *sec_firmware_img)
 	return true;
 }
 
-#ifdef CONFIG_ARMV8_PSCI
+#ifdef CONFIG_FSL_PPA_ARMV8_PSCI
 /*
  * The PSCI_VERSION function is added from PSCI v0.2. When the PSCI
  * v0.1 received this function, the NOT_SUPPORTED (0xffff_ffff) error
arch/arm/cpu/armv8/sec_firmware_asm.S +1 -1
index 0c6a462..d4a26b4 100644
@@ -41,7 +41,7 @@ WEAK(_sec_firmware_entry)
         ret
 ENDPROC(_sec_firmware_entry)
 
-#ifdef CONFIG_ARMV8_PSCI
+#ifdef CONFIG_FSL_PPA_ARMV8_PSCI
 ENTRY(_sec_firmware_support_psci_version)
 	mov	x0, 0x84000000
 	mov	x1, 0x0
arch/arm/include/asm/armv8/sec_firmware.h +1 -1
index eb68185..a4e144b 100644
@@ -14,7 +14,7 @@
 int sec_firmware_init(const void *, u32 *, u32 *);
 int _sec_firmware_entry(const void *, u32 *, u32 *);
 bool sec_firmware_is_valid(const void *);
-#ifdef CONFIG_ARMV8_PSCI
+#ifdef CONFIG_FSL_PPA_ARMV8_PSCI
 unsigned int sec_firmware_support_psci_version(void);
 unsigned int _sec_firmware_support_psci_version(void);
 #endif
arch/arm/lib/bootm-fdt.c +1 -1
index a517550..10a56e8 100644
@@ -53,7 +53,7 @@ int arch_fixup_fdt(void *blob)
 		return ret;
 #endif
 
-#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_FSL_PPA_ARMV8_PSCI)
 	ret = psci_update_dt(blob);
 	if (ret)
 		return ret;
arch/arm/lib/psci-dt.c +1 -1
index baf6d70..41e139e 100644
@@ -16,7 +16,7 @@
 
 int fdt_psci(void *fdt)
 {
-#if defined(CONFIG_ARMV8_PSCI) || defined(CONFIG_ARMV7_PSCI)
+#if defined(CONFIG_FSL_PPA_ARMV8_PSCI) || defined(CONFIG_ARMV7_PSCI)
 	int nodeoff;
 	unsigned int psci_ver = 0;
 	int tmp;
include/configs/ls1043ardb.h +0 -1
index 849a6cb..71c26bd 100644
@@ -12,7 +12,6 @@
 #if defined(CONFIG_FSL_LS_PPA)
 #define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 #define SEC_FIRMWARE_ERET_ADDR_REVERT
-#define CONFIG_ARMV8_PSCI
 
 #define CONFIG_SYS_LS_PPA_FW_IN_XIP
 #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
Signature · 1 line
2.1.4
#2 lore raw

PATCH v4 2/6 ARMv8: Enable SMC instruction

In reply to Hongbo Zhang

PSCI implementation needs the SMC instruction to be enabled. Following the legacy codes pattern, no bit macro definition and bit operation are used, only the immediate data used in line is changed.

---
 arch/arm/include/asm/macro.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/macro.h +1 -1
index 9bb0efa..35ea002 100644
@@ -137,7 +137,7 @@ lr	.req	x30
 
 .macro armv8_switch_to_el2_m, xreg1
 	/* 64bit EL2 | HCE | SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1 */
-	mov	\xreg1, #0x5b1
+	mov	\xreg1, #0x531
 	msr	scr_el3, \xreg1
 	msr	cptr_el3, xzr		/* Disable coprocessor traps to EL3 */
 	mov	\xreg1, #0x33ff
Signature · 1 line
2.1.4
#3 lore raw

PATCH v4 2/6 ARMv8: Enable SMC instruction

Quoted 16 lines · Hongbo Zhang

PSCI implementation needs the SMC instruction to be enabled. Following the legacy codes pattern, no bit macro definition and bit operation are used, only the immediate data used in line is changed.

---
 arch/arm/include/asm/macro.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/macro.h +0 -0
index 9bb0efa..35ea002 100644

arch/arm/include/asm/macro.h lr .req x30 · line 143

Quoted 8 lines
arch/arm/include/asm/macro.h +1 -1
@@ -137,7 +137,7 @@ lr	.req	x30
 
 .macro armv8_switch_to_el2_m, xreg1
 	/* 64bit EL2 | HCE | SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1 */
-	mov	\xreg1, #0x5b1
+	mov	\xreg1, #0x531
 	msr	scr_el3, \xreg1
 	msr	cptr_el3, xzr		/* Disable coprocessor traps to EL3 */
 	mov	\xreg1, #0x33ff

Hongbo,

This has a conflict. Please work with Alison Wang to figure out the SMD bit as she has changed the code to deal with both 64- and 32-bit. I can guess a fix to this conflict, but rather to have her onboard.

York

#4 lore raw

PATCH v4 2/6 ARMv8: Enable SMC instruction

OK.

And currently this series are against the community tree, and if this should go to your tree, I should rebase to yours, right?

Quoted 33 lines · york sun
Quoted 16 lines · Hongbo Zhang

PSCI implementation needs the SMC instruction to be enabled. Following the legacy codes pattern, no bit macro definition and bit operation are used, only the immediate data used in line is changed.

---
 arch/arm/include/asm/macro.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/macro.h +0 -0
index 9bb0efa..35ea002 100644

arch/arm/include/asm/macro.h lr .req x30 · line 143

Quoted 8 lines
arch/arm/include/asm/macro.h +1 -1
@@ -137,7 +137,7 @@ lr        .req    x30
 
 .macro armv8_switch_to_el2_m, xreg1
      /* 64bit EL2 | HCE | SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1 */
-     mov     \xreg1, #0x5b1
+     mov     \xreg1, #0x531
      msr     scr_el3, \xreg1
      msr     cptr_el3, xzr           /* Disable coprocessor traps to EL3 */
      mov     \xreg1, #0x33ff

Hongbo,

This has a conflict. Please work with Alison Wang to figure out the SMD bit as she has changed the code to deal with both 64- and 32-bit. I can guess a fix to this conflict, but rather to have her onboard.

York

#5 lore raw

PATCH v4 2/6 ARMv8: Enable SMC instruction

Quoted 5 lines · Hongbo Zhang

OK.

And currently this series are against the community tree, and if this should go to your tree, I should rebase to yours, right?

No. Please use upstream master branch. I trye to keep my repo in sync but mostly it is behind by several merges.

York

#6 lore raw

PATCH v4 3/6 ARMv8: Add secure sections for PSCI text and data

In reply to Hongbo Zhang

This patch adds secure_text, secure_data and secure_stack sections for ARMv8 to hold PSCI text and data, and it is based on the legacy implementation of ARMv7.

---
 arch/arm/config.mk            |  3 ++-
 arch/arm/cpu/armv8/Kconfig    | 31 +++++++++++++++++++++++
 arch/arm/cpu/armv8/u-boot.lds | 57 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
arch/arm/config.mk +2 -1
index 008da39..3a81f13 100644
@@ -121,7 +121,8 @@ endif
 
 # limit ourselves to the sections we want in the .bin.
 ifdef CONFIG_ARM64
-OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn
+OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
+		-j .u_boot_list -j .rela.dyn
 else
 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
 		-j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
arch/arm/cpu/armv8/Kconfig +31 -0
index 965a8d1..edae43d 100644
@@ -40,4 +40,35 @@ config PSCI_RESET
 
 	  Select Y here to make use of PSCI calls for system reset
 
+config ARMV8_PSCI
+	bool "Enable PSCI support" if EXPERT
+	default n
+	help
+	  PSCI is Power State Coordination Interface defined by ARM.
+	  The PSCI in U-boot provides a general framework and each platform
+	  can implement their own specific PSCI functions.
+	  Say Y here to enable PSCI support on ARMv8 platform.
+
+config ARMV8_PSCI_NR_CPUS
+	int "Maximum supported CPUs for PSCI"
+	depends on ARMV8_PSCI
+	default 4
+	help
+	  The maximum number of CPUs supported in the PSCI firmware.
+	  It is no problem to set a larger value than the number of CPUs in
+	  the actual hardware implementation.
+
+if SYS_HAS_ARMV8_SECURE_BASE
+
+config ARMV8_SECURE_BASE
+	hex "Secure address for PSCI image"
+	depends on ARMV8_PSCI
+	help
+	  Address for placing the PSCI text, data and stack sections.
+	  If not defined, the PSCI sections are placed together with the u-boot
+	  but platform can choose to place PSCI code image separately in other
+	  places such as some secure RAM built-in SOC etc.
+
+endif
+
 endif
arch/arm/cpu/armv8/u-boot.lds +57 -0

74 lines not on this page · raw message

Signature · 1 line
2.1.4
#7 lore raw

PATCH v4 3/6 ARMv8: Add secure sections for PSCI text and data

Quoted 54 lines · Hongbo Zhang

This patch adds secure_text, secure_data and secure_stack sections for ARMv8 to hold PSCI text and data, and it is based on the legacy implementation of ARMv7.

---
 arch/arm/config.mk            |  3 ++-
 arch/arm/cpu/armv8/Kconfig    | 31 +++++++++++++++++++++++
 arch/arm/cpu/armv8/u-boot.lds | 57 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
arch/arm/config.mk +2 -1
index 008da39..3a81f13 100644
@@ -121,7 +121,8 @@ endif
 
 # limit ourselves to the sections we want in the .bin.
 ifdef CONFIG_ARM64
-OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn
+OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
+		-j .u_boot_list -j .rela.dyn
 else
 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
 		-j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
arch/arm/cpu/armv8/Kconfig +21 -0
index 965a8d1..edae43d 100644
@@ -40,4 +40,35 @@ config PSCI_RESET
 
 	  Select Y here to make use of PSCI calls for system reset
 
+config ARMV8_PSCI
+	bool "Enable PSCI support" if EXPERT
+	default n
+	help
+	  PSCI is Power State Coordination Interface defined by ARM.
+	  The PSCI in U-boot provides a general framework and each platform
+	  can implement their own specific PSCI functions.
+	  Say Y here to enable PSCI support on ARMv8 platform.
+
+config ARMV8_PSCI_NR_CPUS
+	int "Maximum supported CPUs for PSCI"
+	depends on ARMV8_PSCI
+	default 4
+	help
+	  The maximum number of CPUs supported in the PSCI firmware.
+	  It is no problem to set a larger value than the number of CPUs in
+	  the actual hardware implementation.
+
+if SYS_HAS_ARMV8_SECURE_BASE
+
+config ARMV8_SECURE_BASE

arch/arm/cpu/armv8/Kconfig config PSCI_RESET · line 73

Quoted 10 lines
arch/arm/cpu/armv8/Kconfig +10 -0
+	hex "Secure address for PSCI image"
+	depends on ARMV8_PSCI
+	help
+	  Address for placing the PSCI text, data and stack sections.
+	  If not defined, the PSCI sections are placed together with the u-boot
+	  but platform can choose to place PSCI code image separately in other
+	  places such as some secure RAM built-in SOC etc.
+
+endif
+

These changes to Kconfig is not related to the secure sections you described in the commit message.

York

#8 lore raw

PATCH v4 3/6 ARMv8: Add secure sections for PSCI text and data

Quoted 60 lines · york sun
Quoted 59 lines · Hongbo Zhang

This patch adds secure_text, secure_data and secure_stack sections for ARMv8 to hold PSCI text and data, and it is based on the legacy implementation of ARMv7.

---
 arch/arm/config.mk            |  3 ++-
 arch/arm/cpu/armv8/Kconfig    | 31 +++++++++++++++++++++++
 arch/arm/cpu/armv8/u-boot.lds | 57 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
arch/arm/config.mk +2 -1
index 008da39..3a81f13 100644
@@ -121,7 +121,8 @@ endif
 
 # limit ourselves to the sections we want in the .bin.
 ifdef CONFIG_ARM64
-OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn
+OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
+             -j .u_boot_list -j .rela.dyn
 else
 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
              -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
arch/arm/cpu/armv8/Kconfig +26 -0
index 965a8d1..edae43d 100644
@@ -40,4 +40,35 @@ config PSCI_RESET
 
        Select Y here to make use of PSCI calls for system reset
 
+config ARMV8_PSCI
+     bool "Enable PSCI support" if EXPERT
+     default n
+     help
+       PSCI is Power State Coordination Interface defined by ARM.
+       The PSCI in U-boot provides a general framework and each platform
+       can implement their own specific PSCI functions.
+       Say Y here to enable PSCI support on ARMv8 platform.
+
+config ARMV8_PSCI_NR_CPUS
+     int "Maximum supported CPUs for PSCI"
+     depends on ARMV8_PSCI
+     default 4
+     help
+       The maximum number of CPUs supported in the PSCI firmware.
+       It is no problem to set a larger value than the number of CPUs in
+       the actual hardware implementation.
+
+if SYS_HAS_ARMV8_SECURE_BASE
+
+config ARMV8_SECURE_BASE
+     hex "Secure address for PSCI image"
+     depends on ARMV8_PSCI
+     help
+       Address for placing the PSCI text, data and stack sections.
+       If not defined, the PSCI sections are placed together with the u-boot
Quoted 9 lines

arch/arm/cpu/armv8/Kconfig config PSCI_RESET · line 73

Quoted 5 lines
arch/arm/cpu/armv8/Kconfig +5 -0
+       but platform can choose to place PSCI code image separately in other
+       places such as some secure RAM built-in SOC etc.
+
+endif
+

These changes to Kconfig is not related to the secure sections you described in the commit message.

These configs were originally in the patch of introducing generic PSCI framework, following Tom's suggest that configs should be introduced in Kconfig when they are used first time. I'll mention this in commit message to let it match.

Quoted 2 lines

York

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

PATCH v4 3/6 ARMv8: Add secure sections for PSCI text and data

Quoted 40 lines · york.sun at nxp.com
Quoted 39 lines · Hongbo Zhang

This patch adds secure_text, secure_data and secure_stack sections for ARMv8 to
hold PSCI text and data, and it is based on the legacy implementation of ARMv7.

---
 arch/arm/config.mk            |  3 ++-
 arch/arm/cpu/armv8/Kconfig    | 31 +++++++++++++++++++++++
 arch/arm/cpu/armv8/u-boot.lds | 57
+++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
arch/arm/config.mk +0 -1
index 008da39..3a81f13 100644
@@ -121,7 +121,8 @@ endif
 
 # limit ourselves to the sections we want in the .bin.
 ifdef CONFIG_ARM64
-OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j

.rela.dyn

arch/arm/config.mk +2 -2
+OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata
-j .data \
+        -j .u_boot_list -j .rela.dyn
 else
 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata
-j .hash \
         -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
arch/arm/cpu/armv8/Kconfig +0 -0
index 965a8d1..edae43d 100644
@@ -40,4 +40,35 @@ config PSCI_RESET
 
       Select Y here to make use of PSCI calls for system reset
 
Quoted 8 lines

arch/arm/cpu/armv8/Kconfig config PSCI_RESET · line 50

Quoted 8 lines
arch/arm/cpu/armv8/Kconfig +8 -0
+config ARMV8_PSCI
+    bool "Enable PSCI support" if EXPERT
+    default n
+    help
+      PSCI is Power State Coordination Interface defined by ARM.
+      The PSCI in U-boot provides a general framework and each platform
+      can implement their own specific PSCI functions.
+      Say Y here to enable PSCI support on ARMv8 platform.

I don't see how you make this option mutually exclusive from PPA PSCI implementation.

York

#11 lore raw

PATCH v4 3/6 ARMv8: Add secure sections for PSCI text and data

Hmm, my way was still programmer "manually" exclusive. Will add that.

Thanks.

Quoted 55 lines · york sun
Quoted 40 lines · york.sun at nxp.com
Quoted 39 lines · Hongbo Zhang

This patch adds secure_text, secure_data and secure_stack sections for ARMv8 to
hold PSCI text and data, and it is based on the legacy implementation of ARMv7.

---
 arch/arm/config.mk            |  3 ++-
 arch/arm/cpu/armv8/Kconfig    | 31 +++++++++++++++++++++++
 arch/arm/cpu/armv8/u-boot.lds | 57
+++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
arch/arm/config.mk +0 -1
index 008da39..3a81f13 100644
@@ -121,7 +121,8 @@ endif
 
 # limit ourselves to the sections we want in the .bin.
 ifdef CONFIG_ARM64
-OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j

.rela.dyn

arch/arm/config.mk +2 -2
+OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata
-j .data \
+        -j .u_boot_list -j .rela.dyn
 else
 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata
-j .hash \
         -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
arch/arm/cpu/armv8/Kconfig +0 -0
index 965a8d1..edae43d 100644
@@ -40,4 +40,35 @@ config PSCI_RESET
 
       Select Y here to make use of PSCI calls for system reset
 
Quoted 8 lines

arch/arm/cpu/armv8/Kconfig config PSCI_RESET · line 50

Quoted 8 lines
arch/arm/cpu/armv8/Kconfig +8 -0
+config ARMV8_PSCI
+    bool "Enable PSCI support" if EXPERT
+    default n
+    help
+      PSCI is Power State Coordination Interface defined by ARM.
+      The PSCI in U-boot provides a general framework and each platform
+      can implement their own specific PSCI functions.
+      Say Y here to enable PSCI support on ARMv8 platform.

I don't see how you make this option mutually exclusive from PPA PSCI implementation.

York

#12 lore raw

PATCH v4 4/6 ARMv8: Add basic PSCI framework

In reply to Hongbo Zhang

This patch introduces a generic ARMv8 PSCI framework, with all functions returning a dummy ARM_PSCI_RET_NI (Not Implemented), then it is up to each platform to implement their own functions based on this framework.

---
 arch/arm/cpu/armv8/Kconfig  |  10 ++
 arch/arm/cpu/armv8/Makefile |   1 +
 arch/arm/cpu/armv8/psci.S   | 286 ++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/psci.h |  15 +++
 4 files changed, 312 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/psci.S
arch/arm/cpu/armv8/Kconfig +10 -0
index edae43d..22dce88 100644
@@ -58,6 +58,16 @@ config ARMV8_PSCI_NR_CPUS
 	  It is no problem to set a larger value than the number of CPUs in
 	  the actual hardware implementation.
 
+config ARMV8_PSCI_CPUS_PER_CLUSTER
+	int "Number of CPUs per cluster"
+	depends on ARMV8_PSCI
+	default 0
+	help
+	  The number of CPUs per cluster, suppose each cluster has same number
+	  of CPU cores, platforms with asymmetric clusters don't apply here.
+	  A value 0 or no definition of it works for single cluster system.
+	  System with multi-cluster should difine their own exact value.
+
 if SYS_HAS_ARMV8_SECURE_BASE
 
 config ARMV8_SECURE_BASE
arch/arm/cpu/armv8/Makefile +1 -0
index dea1465..28ba786 100644
@@ -25,3 +25,4 @@ obj-$(CONFIG_FSL_LAYERSCAPE) += fsl-layerscape/
 obj-$(CONFIG_S32V234) += s32v234/
 obj-$(CONFIG_ARCH_ZYNQMP) += zynqmp/
 obj-$(CONFIG_TARGET_HIKEY) += hisilicon/
+obj-$(CONFIG_ARMV8_PSCI) += psci.o
arch/arm/cpu/armv8/psci.S new file +286 -0

286 lines not on this page · raw message

arch/arm/include/asm/psci.h +15 -0
index 9f1f779..ac8b00d 100644
@@ -45,6 +45,9 @@
 #define ARM_PSCI_0_2_FN_BASE			0x84000000
 #define ARM_PSCI_0_2_FN(n)			(ARM_PSCI_0_2_FN_BASE + (n))
 
+#define ARM_PSCI_0_2_FN64_BASE			0xC4000000
+#define ARM_PSCI_0_2_FN64(n)			(ARM_PSCI_0_2_FN64_BASE + (n))
+
 #define ARM_PSCI_0_2_FN_PSCI_VERSION		ARM_PSCI_0_2_FN(0)
 #define ARM_PSCI_0_2_FN_CPU_SUSPEND		ARM_PSCI_0_2_FN(1)
 #define ARM_PSCI_0_2_FN_CPU_OFF			ARM_PSCI_0_2_FN(2)
@@ -56,6 +59,12 @@
 #define ARM_PSCI_0_2_FN_SYSTEM_OFF		ARM_PSCI_0_2_FN(8)
 #define ARM_PSCI_0_2_FN_SYSTEM_RESET		ARM_PSCI_0_2_FN(9)
 
+#define ARM_PSCI_0_2_FN64_CPU_SUSPEND		ARM_PSCI_0_2_FN64(1)
+#define ARM_PSCI_0_2_FN64_CPU_ON		ARM_PSCI_0_2_FN64(3)
+#define ARM_PSCI_0_2_FN64_AFFINITY_INFO		ARM_PSCI_0_2_FN64(4)
+#define ARM_PSCI_0_2_FN64_MIGRATE		ARM_PSCI_0_2_FN64(5)
+#define ARM_PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU	ARM_PSCI_0_2_FN64(7)
+
 /* PSCI 1.0 interface */
 #define ARM_PSCI_1_0_FN_PSCI_FEATURES		ARM_PSCI_0_2_FN(10)
 #define ARM_PSCI_1_0_FN_CPU_FREEZE		ARM_PSCI_0_2_FN(11)
@@ -66,6 +75,12 @@
 #define ARM_PSCI_1_0_FN_STAT_RESIDENCY		ARM_PSCI_0_2_FN(16)
 #define ARM_PSCI_1_0_FN_STAT_COUNT		ARM_PSCI_0_2_FN(17)
 
+#define ARM_PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND	ARM_PSCI_0_2_FN64(12)
+#define ARM_PSCI_1_0_FN64_NODE_HW_STATE		ARM_PSCI_0_2_FN64(13)
+#define ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND	ARM_PSCI_0_2_FN64(14)
+#define ARM_PSCI_1_0_FN64_STAT_RESIDENCY	ARM_PSCI_0_2_FN64(16)
+#define ARM_PSCI_1_0_FN64_STAT_COUNT		ARM_PSCI_0_2_FN64(17)
+
 /* 1KB stack per core */
 #define ARM_PSCI_STACK_SHIFT	10
 #define ARM_PSCI_STACK_SIZE	(1 << ARM_PSCI_STACK_SHIFT)
Signature · 1 line
2.1.4
#13 lore raw

PATCH v4 5/6 ARMv8: Setup PSCI memory and device tree

In reply to Hongbo Zhang

Newly add ARMv8 PSCI needs to be initialized, be copied or reserved in right place, this patch does all the setup steps.

---
 arch/arm/cpu/armv8/cpu-dt.c   | 11 ++++++++++-
 arch/arm/cpu/armv8/cpu.c      | 22 ++++++++++++++++++++++
 arch/arm/include/asm/secure.h |  2 +-
 arch/arm/include/asm/system.h | 11 +++++++++++
 arch/arm/lib/bootm-fdt.c      |  3 ++-
 arch/arm/lib/bootm.c          |  3 +++
 arch/arm/lib/psci-dt.c        |  5 +++--
 7 files changed, 52 insertions(+), 5 deletions(-)
arch/arm/cpu/armv8/cpu-dt.c +10 -1
index 659ec27..d275cfa 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <asm/psci.h>
+#include <asm/system.h>
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 #include <asm/armv8/sec_firmware.h>
 #endif
@@ -13,7 +14,8 @@
 int psci_update_dt(void *fdt)
 {
 #ifdef CONFIG_MP
-#if defined(CONFIG_FSL_PPA_ARMV8_PSCI)
+#if defined(CONFIG_ARMV8_PSCI) || defined(CONFIG_FSL_PPA_ARMV8_PSCI)
+
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 	/*
 	 * If the PSCI in SEC Firmware didn't work, avoid to update the
@@ -25,6 +27,13 @@ int psci_update_dt(void *fdt)
 		return 0;
 #endif
 	fdt_psci(fdt);
+
+#ifndef CONFIG_ARMV8_SECURE_BASE
+	/* secure code lives in RAM, keep it alive */
+	fdt_add_mem_rsv(fdt, (unsigned long)__secure_start,
+			__secure_end - __secure_start);
+#endif
+
 #endif
 #endif
 	return 0;
arch/arm/cpu/armv8/cpu.c +22 -0
index e06c3cc..5dcb5e2 100644
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/system.h>
+#include <asm/secure.h>
 #include <linux/compiler.h>
 
 int cleanup_before_linux(void)
@@ -41,3 +42,24 @@ int cleanup_before_linux(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_ARMV8_PSCI
+static void relocate_secure_section(void)
+{
+#ifdef CONFIG_ARMV8_SECURE_BASE
+	size_t sz = __secure_end - __secure_start;
+
+	memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
+	flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
+			   CONFIG_ARMV8_SECURE_BASE + sz + 1);
+	invalidate_icache_all();
+#endif
+}
+
+void armv8_setup_psci(void)
+{
+	relocate_secure_section();
+	secure_ram_addr(psci_setup_vectors)();
+	secure_ram_addr(psci_arch_init)();
+}
+#endif
arch/arm/include/asm/secure.h +1 -1
index 5a403bc..d23044a 100644
@@ -6,7 +6,7 @@
 #define __secure __attribute__ ((section ("._secure.text")))
 #define __secure_data __attribute__ ((section ("._secure.data")))
 
-#ifdef CONFIG_ARMV7_SECURE_BASE
+#if defined(CONFIG_ARMV7_SECURE_BASE) || defined(CONFIG_ARMV8_SECURE_BASE)
 /*
  * Warning, horror ahead.
  *
arch/arm/include/asm/system.h +11 -0
index 574a0e7..3f8e133 100644
@@ -120,6 +120,17 @@ void smc_call(struct pt_regs *args);
 void __noreturn psci_system_reset(void);
 void __noreturn psci_system_off(void);
 
+#ifdef CONFIG_ARMV8_PSCI
+extern char __secure_start[];
+extern char __secure_end[];
+extern char __secure_stack_start[];
+extern char __secure_stack_end[];
+
+void armv8_setup_psci(void);
+void psci_setup_vectors(void);
+void psci_arch_init(void);
+#endif
+
 #endif	/* __ASSEMBLY__ */
 
 #else /* CONFIG_ARM64 */
arch/arm/lib/bootm-fdt.c +2 -1
index 10a56e8..2c111bc 100644
@@ -53,7 +53,8 @@ int arch_fixup_fdt(void *blob)
 		return ret;
 #endif
 
-#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_FSL_PPA_ARMV8_PSCI)
+#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \
+	defined(CONFIG_FSL_PPA_ARMV8_PSCI)
 	ret = psci_update_dt(blob);
 	if (ret)
 		return ret;
arch/arm/lib/bootm.c +3 -0
index dedcd1e..88919db 100644
@@ -298,6 +298,9 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 	announce_and_cleanup(fake);
 
 	if (!fake) {
+#ifdef CONFIG_ARMV8_PSCI
+		armv8_setup_psci();
+#endif
 		do_nonsec_virt_switch();
 		kernel_entry(images->ft_addr, NULL, NULL, NULL);
 	}
arch/arm/lib/psci-dt.c +3 -2
index 41e139e..45af037 100644
@@ -16,7 +16,8 @@
 
 int fdt_psci(void *fdt)
 {
-#if defined(CONFIG_FSL_PPA_ARMV8_PSCI) || defined(CONFIG_ARMV7_PSCI)
+#if defined(CONFIG_ARMV7_PSCI) || defined(CONFIG_ARMV8_PSCI) || \
+	defined(CONFIG_FSL_PPA_ARMV8_PSCI)
 	int nodeoff;
 	unsigned int psci_ver = 0;
 	int tmp;
@@ -65,7 +66,7 @@ int fdt_psci(void *fdt)
 init_psci_node:
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 	psci_ver = sec_firmware_support_psci_version();
-#elif defined(CONFIG_ARMV7_PSCI_1_0)
+#elif defined(CONFIG_ARMV7_PSCI_1_0) || defined(CONFIG_ARMV8_PSCI)
 	psci_ver = ARM_PSCI_VER_1_0;
 #endif
 	switch (psci_ver) {
Signature · 1 line
2.1.4
#14 lore raw

PATCH v4 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support

In reply to Hongbo Zhang

A most basic PSCI implementation with only one psci_version is added for LS1043A, this can verify the generic PSCI framework, and more platform specific implementation will be added later.

---
 arch/arm/cpu/armv8/fsl-layerscape/Makefile       |  1 +
 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++++++++++++++++++++
 board/freescale/ls1043ardb/Kconfig               |  9 +++++++++
 configs/ls1043ardb_defconfig                     |  3 +++
 4 files changed, 33 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
arch/arm/cpu/armv8/fsl-layerscape/Makefile +1 -0
index 51c1cee..423b4b3 100644
@@ -28,6 +28,7 @@ endif
 
 ifneq ($(CONFIG_LS1043A),)
 obj-$(CONFIG_SYS_HAS_SERDES) += ls1043a_serdes.o
+obj-$(CONFIG_ARMV8_PSCI) += ls1043a_psci.o
 endif
 
 ifneq ($(CONFIG_ARCH_LS1012A),)
arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S new file +20 -0
new file mode 100644
index 0000000..86045ac
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Hongbo Zhang <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ * This file implements LS102X platform PSCI SYSTEM-SUSPEND function
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/psci.h>
+
+	.pushsection ._secure.text, "ax"
+
+.globl	psci_version
+psci_version:
+	ldr	w0, =0x00010000		/* PSCI v1.0 */
+	ret
+
+	.popsection
board/freescale/ls1043ardb/Kconfig +9 -0
index 51818ec..0c596f9 100644
@@ -13,4 +13,13 @@ config SYS_SOC
 config SYS_CONFIG_NAME
 	default "ls1043ardb"
 
+config SYS_HAS_ARMV8_SECURE_BASE
+	bool "Enable secure RAM for PSCI image"
+	depends on ARMV8_PSCI
+	default y
+	help
+	  PSCI image can be re-located to secure RAM.
+	  If enabled, please also define the value for ARMV8_SECURE_BASE,
+	  for LS1043ARDB, it is address in OCRAM.
+
 endif
configs/ls1043ardb_defconfig +3 -0
index 79a4eb2..cb189f3 100644
@@ -28,3 +28,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_ARMV8_PSCI=y
+CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER=4
+CONFIG_ARMV8_SECURE_BASE=0x10010000
Signature · 1 line
2.1.4
#15 lore raw

PATCH v4 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support

Quoted 76 lines · Hongbo Zhang

A most basic PSCI implementation with only one psci_version is added for LS1043A, this can verify the generic PSCI framework, and more platform specific implementation will be added later.

---
 arch/arm/cpu/armv8/fsl-layerscape/Makefile       |  1 +
 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++++++++++++++++++++
 board/freescale/ls1043ardb/Kconfig               |  9 +++++++++
 configs/ls1043ardb_defconfig                     |  3 +++
 4 files changed, 33 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
arch/arm/cpu/armv8/fsl-layerscape/Makefile +1 -0
index 51c1cee..423b4b3 100644
@@ -28,6 +28,7 @@ endif
 
 ifneq ($(CONFIG_LS1043A),)
 obj-$(CONFIG_SYS_HAS_SERDES) += ls1043a_serdes.o
+obj-$(CONFIG_ARMV8_PSCI) += ls1043a_psci.o
 endif
 
 ifneq ($(CONFIG_ARCH_LS1012A),)
arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S new file +20 -0
new file mode 100644
index 0000000..86045ac
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Hongbo Zhang <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ * This file implements LS102X platform PSCI SYSTEM-SUSPEND function
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/psci.h>
+
+	.pushsection ._secure.text, "ax"
+
+.globl	psci_version
+psci_version:
+	ldr	w0, =0x00010000		/* PSCI v1.0 */
+	ret
+
+	.popsection
board/freescale/ls1043ardb/Kconfig +9 -0
index 51818ec..0c596f9 100644
@@ -13,4 +13,13 @@ config SYS_SOC
 config SYS_CONFIG_NAME
 	default "ls1043ardb"
 
+config SYS_HAS_ARMV8_SECURE_BASE
+	bool "Enable secure RAM for PSCI image"
+	depends on ARMV8_PSCI
+	default y
+	help
+	  PSCI image can be re-located to secure RAM.
+	  If enabled, please also define the value for ARMV8_SECURE_BASE,
+	  for LS1043ARDB, it is address in OCRAM.
+
 endif
configs/ls1043ardb_defconfig +0 -0
index 79a4eb2..cb189f3 100644

configs/ls1043ardb_defconfig CONFIG_DM_USB=y · line 33

Quoted 6 lines
configs/ls1043ardb_defconfig +3 -0
@@ -28,3 +28,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_ARMV8_PSCI=y
+CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER=4
+CONFIG_ARMV8_SECURE_BASE=0x10010000

You enabled this generic PSCI support for LS1043A. How do you use PPA then?

York

#16 lore raw

PATCH v4 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support

Oops.
I did remove this generic PSCI for LS platform since we have our specific PPA, but that change wasn't included at last, I'll update this.

Quoted 87 lines · york sun
Quoted 76 lines · Hongbo Zhang

A most basic PSCI implementation with only one psci_version is added for LS1043A, this can verify the generic PSCI framework, and more platform specific implementation will be added later.

---
 arch/arm/cpu/armv8/fsl-layerscape/Makefile       |  1 +
 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++++++++++++++++++++
 board/freescale/ls1043ardb/Kconfig               |  9 +++++++++
 configs/ls1043ardb_defconfig                     |  3 +++
 4 files changed, 33 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
arch/arm/cpu/armv8/fsl-layerscape/Makefile +1 -0
index 51c1cee..423b4b3 100644
@@ -28,6 +28,7 @@ endif
 
 ifneq ($(CONFIG_LS1043A),)
 obj-$(CONFIG_SYS_HAS_SERDES) += ls1043a_serdes.o
+obj-$(CONFIG_ARMV8_PSCI) += ls1043a_psci.o
 endif
 
 ifneq ($(CONFIG_ARCH_LS1012A),)
arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S new file +20 -0
new file mode 100644
index 0000000..86045ac
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Hongbo Zhang <[email protected]>
+ *
+ * SPDX-License-Identifier:  GPL-2.0+
+ * This file implements LS102X platform PSCI SYSTEM-SUSPEND function
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/psci.h>
+
+     .pushsection ._secure.text, "ax"
+
+.globl       psci_version
+psci_version:
+     ldr     w0, =0x00010000         /* PSCI v1.0 */
+     ret
+
+     .popsection
board/freescale/ls1043ardb/Kconfig +9 -0
index 51818ec..0c596f9 100644
@@ -13,4 +13,13 @@ config SYS_SOC
 config SYS_CONFIG_NAME
      default "ls1043ardb"
 
+config SYS_HAS_ARMV8_SECURE_BASE
+     bool "Enable secure RAM for PSCI image"
+     depends on ARMV8_PSCI
+     default y
+     help
+       PSCI image can be re-located to secure RAM.
+       If enabled, please also define the value for ARMV8_SECURE_BASE,
+       for LS1043ARDB, it is address in OCRAM.
+
 endif
configs/ls1043ardb_defconfig +0 -0
index 79a4eb2..cb189f3 100644

configs/ls1043ardb_defconfig CONFIG_DM_USB=y · line 33

Quoted 6 lines
configs/ls1043ardb_defconfig +3 -0
@@ -28,3 +28,6 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_ARMV8_PSCI=y
+CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER=4
+CONFIG_ARMV8_SECURE_BASE=0x10010000

You enabled this generic PSCI support for LS1043A. How do you use PPA then?

York

#17 lore raw

v4 cover Add ARMv8 PSCI framework

In reply to Hongbo Zhang
Quoted 23 lines · Hongbo Zhang

v3-v4 changes:
- Re-added the 1/6 from v2, and move the newly re-named macro into Kconfig
- Add "Reviewed-by: Tom Rini <[email protected]>" for patch 4/6 ~ 6/6.

v2-v3 changes:
- Drop the previous 1/6, since the previous CONFIG_ARMV8_PSCI in common parts
of codes also work for generic PSCI framework, so there are 5 patches in this iteration.
- Add "Reviewed-by: Tom Rini <[email protected]>" for patches 1/5 and 2/5,
which were 2/6 and 3/6.
- Move config values for ls1043 from armv8/Kconfig to s1043ardb_defconfig.

v1-v2 changes:
- The new config options are introduced in Kconfig when used for first time
- Introduce new config options in armv8/Kconfig instead of LS1043 platform
- Move previous patch 5/6 to current 2/6 place

v1 notes:

This patch set introduces ARMv8 PSCI framework, all the PSCI functions are implemented a default dummy one, it is up to each platform to implement their own specific ones.

Quoted 8 lines

The first 1/6 patch is a prepare clean up for adding ARMv8 PSCI. Patches 2/6 to 5/6 introduce new ARMv8 framework and set it up. The last 6/6 adds a most simple implementation on NXP LS1043 platform, to verify this framework.

This patch set mainly introduces ARMv8 PSCI framework, for easier review and merge, further PSCI implementation on LS1043 is coming later.

Hongbo,

Can you educate me how this generic PSCI framework co-exist with PPA or other secure firmware?

York

#18 lore raw

v4 cover Add ARMv8 PSCI framework

Hi York,
This generic PSCI is controlled by CONFIG_ARMV8_PSCI, if enabled, any platform can implement their own PSCI functions under this framework, this is all similar with ARMv7's.

While PPA is controlled by CONFIG_FSL_LS_PPA, and the private PSCI inside the PPA is controlled by FSL_PPA_ARMV8_PSCI, this macro depends on and selected by CONFIG_FSL_LS_PPA.

That is to say, they are using separate configs, and only one of them can be enabled at one time.

Quoted 39 lines · york sun
Quoted 23 lines · Hongbo Zhang

v3-v4 changes:
- Re-added the 1/6 from v2, and move the newly re-named macro into Kconfig
- Add "Reviewed-by: Tom Rini <[email protected]>" for patch 4/6 ~ 6/6.

v2-v3 changes:
- Drop the previous 1/6, since the previous CONFIG_ARMV8_PSCI in common parts
of codes also work for generic PSCI framework, so there are 5 patches in this iteration.
- Add "Reviewed-by: Tom Rini <[email protected]>" for patches 1/5 and 2/5,
which were 2/6 and 3/6.
- Move config values for ls1043 from armv8/Kconfig to s1043ardb_defconfig.

v1-v2 changes:
- The new config options are introduced in Kconfig when used for first time
- Introduce new config options in armv8/Kconfig instead of LS1043 platform
- Move previous patch 5/6 to current 2/6 place

v1 notes:

This patch set introduces ARMv8 PSCI framework, all the PSCI functions are implemented a default dummy one, it is up to each platform to implement their own specific ones.

Quoted 8 lines

The first 1/6 patch is a prepare clean up for adding ARMv8 PSCI. Patches 2/6 to 5/6 introduce new ARMv8 framework and set it up. The last 6/6 adds a most simple implementation on NXP LS1043 platform, to verify this framework.

This patch set mainly introduces ARMv8 PSCI framework, for easier review and merge, further PSCI implementation on LS1043 is coming later.

Hongbo,

Can you educate me how this generic PSCI framework co-exist with PPA or other secure firmware?

York

#19 lore raw

v4 cover Add ARMv8 PSCI framework

Quoted 5 lines · Hongbo Zhang

Hi York,
This generic PSCI is controlled by CONFIG_ARMV8_PSCI, if enabled, any platform can implement their own PSCI functions under this framework, this is all similar with ARMv7's.

Quoted 7 lines

While PPA is controlled by CONFIG_FSL_LS_PPA, and the private PSCI inside the PPA is controlled by FSL_PPA_ARMV8_PSCI, this macro depends on and selected by CONFIG_FSL_LS_PPA.

That is to say, they are using separate configs, and only one of them can be enabled at one time.

That's what I am looking for. So these two options are mutually exclusive. But you don't have that in Kconfig. I can run menuconfig and get this result in .config file

#
# Layerscape PPA
#
CONFIG_FSL_LS_PPA=y
CONFIG_FSL_PPA_ARMV8_PSCI=y
CONFIG_SYS_FSL_ERRATUM_A010539=y
CONFIG_ARMV8_MULTIENTRY=y
# CONFIG_ARMV8_SPIN_TABLE is not set
CONFIG_ARMV8_PSCI=y
CONFIG_ARMV8_PSCI_NR_CPUS=4
CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER=0
CONFIG_IDENT_STRING=""
# CONFIG_PRE_CONSOLE_BUFFER is not set
# CONFIG_VIDEO is not set

You can see both options can be enabled from menuconfig. Please see comments in other patches as well.

York

#20 lore raw

v4 cover Add ARMv8 PSCI framework

Will add "depends on !ARMV8_PSCI" for FSL_LS_PPA
and "depends on !FSL_LS_PPA" for ARMV8_PSCI

Thanks.

Quoted 37 lines · york sun
Quoted 5 lines · Hongbo Zhang

Hi York,
This generic PSCI is controlled by CONFIG_ARMV8_PSCI, if enabled, any platform can implement their own PSCI functions under this framework, this is all similar with ARMv7's.

Quoted 7 lines

While PPA is controlled by CONFIG_FSL_LS_PPA, and the private PSCI inside the PPA is controlled by FSL_PPA_ARMV8_PSCI, this macro depends on and selected by CONFIG_FSL_LS_PPA.

That is to say, they are using separate configs, and only one of them can be enabled at one time.

That's what I am looking for. So these two options are mutually exclusive. But you don't have that in Kconfig. I can run menuconfig and get this result in .config file

#
# Layerscape PPA
#
CONFIG_FSL_LS_PPA=y
CONFIG_FSL_PPA_ARMV8_PSCI=y
CONFIG_SYS_FSL_ERRATUM_A010539=y
CONFIG_ARMV8_MULTIENTRY=y
# CONFIG_ARMV8_SPIN_TABLE is not set
CONFIG_ARMV8_PSCI=y
CONFIG_ARMV8_PSCI_NR_CPUS=4
CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER=0
CONFIG_IDENT_STRING=""
# CONFIG_PRE_CONSOLE_BUFFER is not set
# CONFIG_VIDEO is not set

You can see both options can be enabled from menuconfig. Please see comments in other patches as well.

York