Add ARMv8 PSCI framework
cover Add ARMv8 PSCI framework
From: Hongbo Zhang <[email protected]>
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: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI support
arch/arm/config.mk | 3 +- arch/arm/cpu/armv8/Kconfig | 6 + arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/cpu-dt.c | 12 +- arch/arm/cpu/armv8/cpu.c | 22 ++ 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 | 65 ++++++ 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 | 18 ++ configs/ls1043ardb_defconfig | 1 + include/configs/ls1043ardb.h | 2 +- 24 files changed, 477 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
PATCH 1/6 ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
From: Hongbo Zhang <[email protected]>
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/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 | 2 +- 9 files changed, 11 insertions(+), 9 deletions(-)
arch/arm/cpu/armv8/cpu-dt.c +1 -1
@@ -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/cpu.c +2 -1
@@ -379,7 +379,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
@@ -41,7 +41,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
@@ -199,7 +199,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
@@ -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
@@ -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
@@ -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
@@ -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 +1 -1
@@ -12,7 +12,7 @@#if defined(CONFIG_FSL_LS_PPA )#define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #define SEC_FIRMWARE_ERET_ADDR_REVERT -#define CONFIG_ARMV8_PSCI +#define CONFIG_FSL_PPA_ARMV8_PSCI #define CONFIG_SYS_LS_PPA_FW_IN_XIP #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
Signature · 1 line
2.1.4
PATCH 2/6 ARMv8: Add secure sections for PSCI text and data
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
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/u-boot.lds | 65 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-)
arch/arm/config.mk +2 -1
@@ -118,7 +118,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/u-boot.lds +65 -0
82 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 3/6 ARMv8: Add basic PSCI framework
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
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 | 6 + arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/psci.S | 286 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm/include/asm/psci.h | 15 +++ 4 files changed, 308 insertions(+) create mode 100644 arch/arm/cpu/armv8/psci.S
arch/arm/cpu/armv8/Kconfig +6 -0
@@ -21,4 +21,10 @@ config ARMV8_SPIN_TABLE - Reserve the code for the spin-table and the release address via a /memreserve/ region in the Device Tree. +config ARMV8_PSCI + bool "Enable PSCI support" if EXPERT + default n + help + Say Y here to enable PSCI support. + endif
arch/arm/cpu/armv8/Makefile +1 -0
@@ -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
@@ -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
PATCH 4/6 ARMv8: Setup PSCI memory and dt
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
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 | 10 ++++++++++ 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(+), 4 deletions(-)
arch/arm/cpu/armv8/cpu-dt.c +10 -0
@@ -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
@@ -27,5 +28,14 @@ int psci_update_dt(void *fdt)fdt_psci (fdt);#endif #endif + +#ifdef CONFIG_ARMV8_PSCI +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 return 0 ; }
arch/arm/cpu/armv8/cpu.c +22 -0
@@ -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
@@ -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
@@ -126,6 +126,17 @@ void smc_call(struct pt_regs *args);void __noreturn psci_system_reset (bool smc); +#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
@@ -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_FSL_PPA_ARMV8_PSCI ) || \ + defined(CONFIG_ARMV8_PSCI ) ret =psci_update_dt (blob);if (ret)return ret;
arch/arm/lib/bootm.c +3 -0
@@ -291,6 +291,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
@@ -16,7 +16,8 @@int fdt_psci (void *fdt) { -#if defined(CONFIG_FSL_PPA_ARMV8_PSCI ) || defined(CONFIG_ARMV7_PSCI ) +#if defined(CONFIG_FSL_PPA_ARMV8_PSCI ) || defined(CONFIG_ARMV7_PSCI ) || \ + defined(CONFIG_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
PATCH 4/6 ARMv8: Setup PSCI memory and dt
Quoted 29 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
Newly add ARMv8 PSCI needs to be initialized, be copied or reserved in right place, this patch does all the setup steps.
Signed-off-by Hongbo Zhang <[email protected]>--- arch/arm/cpu/armv8/cpu-dt.c | 10 ++++++++++ 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(+), 4 deletions(-)arch/arm/cpu/armv8/cpu-dt.c +1
-0@@ -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
arch/arm/cpu/armv8/cpu-dt.c int psci_update_dt(void *fdt) · line 34
Quoted 7 lines
arch/arm/cpu/armv8/cpu-dt.c +4
-0@@ -27,5 +28,14 @@ int psci_update_dt(void *fdt)fdt_psci (fdt);#endif #endif + +#ifdef CONFIG_ARMV8_PSCI +fdt_psci (fdt); +#ifndef CONFIG_ARMV8_SECURE_BASE
Is this backward?
arch/arm/cpu/armv8/cpu-dt.c int psci_update_dt(void *fdt) · line 41
Quoted 7 lines
arch/arm/cpu/armv8/cpu-dt.c +5
-0+/* secure code lives in RAM, keep it alive */ +fdt_add_mem_rsv (fdt, (unsigned long )__secure_start, + __secure_end - __secure_start); +#endif +#endif return 0 ; }
York
PATCH 4/6 ARMv8: Setup PSCI memory and dt
Quoted 23 lines · york sun
Quoted 22 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
Newly add ARMv8 PSCI needs to be initialized, be copied or reserved in right place, this patch does all the setup steps.
Signed-off-by Hongbo Zhang <[email protected]>--- arch/arm/cpu/armv8/cpu-dt.c | 10 ++++++++++ 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(+), 4 deletions(-)arch/arm/cpu/armv8/cpu-dt.c +0
-0@@ -6,6 +6,7 @@
Quoted 16 lines
Quoted 7 lines
arch/arm/cpu/armv8/cpu-dt.c +1
-0#include <common.h> #include <asm/psci.h> +#include <asm/system.h> #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #include <asm/armv8/sec_firmware.h> #endif arch/arm/cpu/armv8/cpu-dt.c int psci_update_dt(void *fdt) · line 34
Quoted 7 lines
arch/arm/cpu/armv8/cpu-dt.c +4
-0@@ -27,5 +28,14 @@ int psci_update_dt(void *fdt)fdt_psci (fdt);#endif #endif + +#ifdef CONFIG_ARMV8_PSCI +fdt_psci (fdt); +#ifndef CONFIG_ARMV8_SECURE_BASE Is this backward?
Hi York,
I'm sorry not so clear about your concern. CONFIG_ARMV8_SECURE_BASE, this macro is only for generic ARMv8 PSCI, not for NXP private PSCI in PPA firmware.
Please feel free to raise concerns / doubts if any.
Thanks.
Quoted 12 lines
arch/arm/cpu/armv8/cpu-dt.c int psci_update_dt(void *fdt) · line 41
Quoted 8 lines
arch/arm/cpu/armv8/cpu-dt.c +5
-0+/* secure code lives in RAM, keep it alive */ +fdt_add_mem_rsv (fdt, (unsigned long )__secure_start, + __secure_end - __secure_start); +#endif +#endif return 0 ; }York
PATCH 5/6 ARMv8: Enable SMC instruction
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
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
@@ -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
PATCH 5/6 ARMv8: Enable SMC instruction
This patch should be move before adding or setting up PSCI, because if PSCI is ready without SMC enabled, kernel detects PSCI exist from DT, then it issues SMC call for psci_version(), this causes instruction not defined exception.
Will update this in next iteration, and welcome any review comments, thanks.
Quoted 27 lines · On Tue, Sep 27, 2016 at 5:29 PM, <[email protected]> wrote:
From: Hongbo Zhang <[email protected]>
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.
Signed-off-by Hongbo Zhang <[email protected]>--- arch/arm/include/asm/macro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/include/asm/macro.h +1
-2@@ -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 --2.1.4
PATCH 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
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 | 18 ++++++++++++++++++ configs/ls1043ardb_defconfig | 1 + 4 files changed, 40 insertions(+) create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
arch/arm/cpu/armv8/fsl-layerscape/Makefile +1 -0
@@ -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_LS1012A),)
arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S new file +20 -0
@@ -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 +18 -0
@@ -13,4 +13,22 @@ config SYS_SOC config SYS_CONFIG_NAME default "ls1043ardb" +if ARMV8_PSCI + +config ARMV8_PSCI_NR_CPUS + int "Number of total CPUs on board" + default 4 + +config CPU_PER_CLUSTER + int "Number of CPUs per cluster" + default 4 + +config ARMV8_SECURE_BASE + hex "Address of PSCI text, data and stack" + default 0x10010000 + help + The PSCI is placed in OCRAM2. + +endif + endif
configs/ls1043ardb_defconfig +1 -0
@@ -26,3 +26,4 @@ CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_ARMV8_PSCI=y
Signature · 1 line
2.1.4
cover Add ARMv8 PSCI framework
In reply to macro.wave.z at gmail.comQuoted 14 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
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.
Quoted 7 lines
Hongbo Zhang (6):
ARMv8: LS1043A: change macroCONFIG_ARMV8_PSCIdefinition
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI support
Conceptually this is good. I have some issues around order of the patches, and where the Kconfig entries end up. Looking over the series we introduce usage of some CONFIG symbols prior to declaring them in Kconfig. This is more of a hard no now as it will break bisecting when the test for no new CONFIG symbols is tripped. The other problem is that I think the symbols you're adding in board/freescale/ls1043ardb/Kconfig need to be in arch/arm/cpu/armv8/Kconfig and then use default ... if ... to give the right address for the layerscape boards.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160927/5cec1182/attachment.sig>
cover Add ARMv8 PSCI framework
Quoted 23 lines · Tom Rini
Quoted 14 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
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.
Quoted 7 lines
Hongbo Zhang (6):
ARMv8: LS1043A: change macroCONFIG_ARMV8_PSCIdefinition
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI support
Quoted 9 lines
Conceptually this is good. I have some issues around order of the patches, and where the
Kconfigentries end up. Looking over the series we introduce usage of some CONFIG symbols prior to declaring them inKconfig. This is more of a hard no now as it will break bisecting when the test for no new CONFIG symbols is tripped. The other problem is that I think the symbols you're adding in board/freescale/ls1043ardb/Kconfig need to be inarch/arm/cpu/armv8/Kconfigand then use default ... if ... to give the right address for the layerscape boards.
Thanks Tom for quick response.
For config options introduced:CONFIG_ARMV8_PSCICONFIG_ARMV8_PSCI_NR_CPUSCONFIG_CPU_PER_CLUSTERCONFIG_ARMV8_SECURE_BASE
I've tested adding patch one by one, there is no problem with the check-config script.
And my idea was like this: let the CONFIG_ARMV8_PSCI to be an overall switch, and if it is enabled even without the other three ones, the default PSCI still works, as I've tested, this really works because any of the other three macros, when used, there is a #ifdef to check if it exists, if no, a default value is used or it isn't used at all. The later three macros, because they are platform specific so I intended to let every platform to define them.
This is slightly different from ARMv7, plan was if this get accepted, I would like to send patch to update ARMv7's.
Quoted 3 lines
--
Tom
cover Add ARMv8 PSCI framework
I just explained why and how I tried to place newly introduced macros in arch/arm/cpu/armv8/Kconfig and board/freescale/ls1043ardb/Kconfig.
As to the order, is it compulsory to define such a CONFIG_* before using it, even there is #ifdef test when using it?
If yes, I have to define all the four new CONFIG_* into arch/arm/cpu/armv8/Kconfig along with the adding-secure-sections patch, but default values have to be set which is bit hard to handle, for the CONFIG_ARMV8_PSCI_NR_CPUS, we can set a 4 although it isn't correct in most cases, but for the CONFIG_ARMV8_SECURE_BASE, we don't know its default value, it is really platform specific.
In my implementation, I just wanted to treat CONFIG_ARMV8_PSCI_NR_CPUS and CONFIG_CPU_PER_CLUSTER as same as CONFIG_ARMV8_SECURE_BASE, since they are all platform specific.
And for the CONFIG_ARMV8_PSCI_NR_CPUS, it is slightly different form ARMv7's, if not defined, the lds file still works:
#ifdef CONFIG_ARMV8_PSCI_NR_CPUS
. = . + CONFIG_ARMV8_PSCI_NR_CPUS * ARM_PSCI_STACK_SIZE; #else
. = . + 4 * ARM_PSCI_STACK_SIZE;
#endif
Quoted 59 lines · Hongbo Zhang
Quoted 23 lines · Tom Rini
Quoted 14 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
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.
Quoted 7 lines
Hongbo Zhang (6):
ARMv8: LS1043A: change macroCONFIG_ARMV8_PSCIdefinition
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI supportQuoted 9 lines
Conceptually this is good. I have some issues around order of the patches, and where the
Kconfigentries end up. Looking over the series we introduce usage of some CONFIG symbols prior to declaring them inKconfig. This is more of a hard no now as it will break bisecting when the test for no new CONFIG symbols is tripped. The other problem is that I think the symbols you're adding in board/freescale/ls1043ardb/Kconfig need to be inarch/arm/cpu/armv8/Kconfigand then use default ... if ... to give the right address for the layerscape boards.Thanks Tom for quick response.
For config options introduced:
CONFIG_ARMV8_PSCICONFIG_ARMV8_PSCI_NR_CPUSCONFIG_CPU_PER_CLUSTERCONFIG_ARMV8_SECURE_BASEI've tested adding patch one by one, there is no problem with the check-config script.
And my idea was like this: let the
CONFIG_ARMV8_PSCIto be an overall switch, and if it is enabled even without the other three ones, the default PSCI still works, as I've tested, this really works because any of the other three macros, when used, there is a #ifdef to check if it exists, if no, a default value is used or it isn't used at all. The later three macros, because they are platform specific so I intended to let every platform to define them.This is slightly different from ARMv7, plan was if this get accepted, I would like to send patch to update ARMv7's.
Quoted 3 lines
--
Tom
cover Add ARMv8 PSCI framework
Ping all,
Some time ago I saw several people mentioned ARMv8 PSCI, are you interested in leaving your review comments?
I know it is not so easy for reviewing assembly language patches, but code structures and assembly instructions in this patch set are not complicated.
When this common framework gets merged, it will be possible for each platform to implement their platform PSCI functions in C too.
Hi Tom,
Any further concerns? comments?
Thanks all.
Quoted 87 lines · Hongbo Zhang
I just explained why and how I tried to place newly introduced macros in
arch/arm/cpu/armv8/Kconfigand board/freescale/ls1043ardb/Kconfig.As to the order, is it compulsory to define such a CONFIG_* before using it, even there is #ifdef test when using it?
If yes, I have to define all the four new CONFIG_* into
arch/arm/cpu/armv8/Kconfigalong with the adding-secure-sections patch, but default values have to be set which is bit hard to handle, for theCONFIG_ARMV8_PSCI_NR_CPUS, we can set a 4 although it isn't correct in most cases, but for theCONFIG_ARMV8_SECURE_BASE, we don't know its default value, it is really platform specific.In my implementation, I just wanted to treat
CONFIG_ARMV8_PSCI_NR_CPUSandCONFIG_CPU_PER_CLUSTERas same asCONFIG_ARMV8_SECURE_BASE, since they are all platform specific.And for the
CONFIG_ARMV8_PSCI_NR_CPUS, it is slightly different form ARMv7's, if not defined, the lds file still works:
#ifdefCONFIG_ARMV8_PSCI_NR_CPUS
. = . +CONFIG_ARMV8_PSCI_NR_CPUS*ARM_PSCI_STACK_SIZE; #else
. = . + 4 *ARM_PSCI_STACK_SIZE;
#endifQuoted 59 lines · Hongbo Zhang
Quoted 23 lines · Tom Rini
Quoted 14 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
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.
Quoted 7 lines
Hongbo Zhang (6):
ARMv8: LS1043A: change macroCONFIG_ARMV8_PSCIdefinition
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI supportQuoted 9 lines
Conceptually this is good. I have some issues around order of the patches, and where the
Kconfigentries end up. Looking over the series we introduce usage of some CONFIG symbols prior to declaring them inKconfig. This is more of a hard no now as it will break bisecting when the test for no new CONFIG symbols is tripped. The other problem is that I think the symbols you're adding in board/freescale/ls1043ardb/Kconfig need to be inarch/arm/cpu/armv8/Kconfigand then use default ... if ... to give the right address for the layerscape boards.Thanks Tom for quick response.
For config options introduced:
CONFIG_ARMV8_PSCICONFIG_ARMV8_PSCI_NR_CPUSCONFIG_CPU_PER_CLUSTERCONFIG_ARMV8_SECURE_BASEI've tested adding patch one by one, there is no problem with the check-config script.
And my idea was like this: let the
CONFIG_ARMV8_PSCIto be an overall switch, and if it is enabled even without the other three ones, the default PSCI still works, as I've tested, this really works because any of the other three macros, when used, there is a #ifdef to check if it exists, if no, a default value is used or it isn't used at all. The later three macros, because they are platform specific so I intended to let every platform to define them.This is slightly different from ARMv7, plan was if this get accepted, I would like to send patch to update ARMv7's.
Quoted 3 lines
--
Tom
cover Add ARMv8 PSCI framework
Quoted 9 lines · Hongbo Zhang
Ping all,
Some time ago I saw several people mentioned ARMv8 PSCI, are you interested in leaving your review comments?
I know it is not so easy for reviewing assembly language patches, but code structures and assembly instructions in this patch set are not complicated.
When this common framework gets merged, it will be possible for each platform to implement their platform PSCI functions in C too.
Quoted 4 lines
Hi Tom,
Any further concerns? comments?Thanks all.
Hongbo,
This set has been marked as "changes requested" in patchwork. Did you get feedback other than those captured by patchwork? Are you going to send an update?
York
cover Add ARMv8 PSCI framework
York,
Yes I am going to send an update, one patch needs to be reordered as I've mentioned.
I didn't get other feedback.
But one thing I'm wondering is how to introduce the CONFIG_ options well, Tom's concerns make sense, and I had my explain too, we need a final solution before I send out a v2.
Quoted 23 lines · york sun
Quoted 9 lines · Hongbo Zhang
Ping all,
Some time ago I saw several people mentioned ARMv8 PSCI, are you interested in leaving your review comments?
I know it is not so easy for reviewing assembly language patches, but code structures and assembly instructions in this patch set are not complicated.
When this common framework gets merged, it will be possible for each platform to implement their platform PSCI functions in C too.Quoted 4 lines
Hi Tom,
Any further concerns? comments?Thanks all.
Hongbo,
This set has been marked as "changes requested" in patchwork. Did you get feedback other than those captured by patchwork? Are you going to send an update?
York
cover Add ARMv8 PSCI framework
In reply to Hongbo ZhangQuoted 36 lines · Hongbo Zhang
Quoted 23 lines · Tom Rini
Quoted 14 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
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.
Quoted 7 lines
Hongbo Zhang (6):
ARMv8: LS1043A: change macroCONFIG_ARMV8_PSCIdefinition
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI supportQuoted 9 lines
Conceptually this is good. I have some issues around order of the patches, and where the
Kconfigentries end up. Looking over the series we introduce usage of some CONFIG symbols prior to declaring them inKconfig. This is more of a hard no now as it will break bisecting when the test for no new CONFIG symbols is tripped. The other problem is that I think the symbols you're adding in board/freescale/ls1043ardb/Kconfig need to be inarch/arm/cpu/armv8/Kconfigand then use default ... if ... to give the right address for the layerscape boards.Thanks Tom for quick response.
Quoted 8 lines
For config options introduced:
CONFIG_ARMV8_PSCICONFIG_ARMV8_PSCI_NR_CPUSCONFIG_CPU_PER_CLUSTERCONFIG_ARMV8_SECURE_BASEI've tested adding patch one by one, there is no problem with the check-config script.
OK.
Quoted 10 lines
And my idea was like this: let the
CONFIG_ARMV8_PSCIto be an overall switch, and if it is enabled even without the other three ones, the default PSCI still works, as I've tested, this really works because any of the other three macros, when used, there is a #ifdef to check if it exists, if no, a default value is used or it isn't used at all. The later three macros, because they are platform specific so I intended to let every platform to define them.This is slightly different from ARMv7, plan was if this get accepted, I would like to send patch to update ARMv7's.
I think that at the end of the day we need to have less options be defined and asked under board/ and make more and in some cases better use of the common Kconfig files. Looking at how things are done in the Linux Kernel, in general, can be instructive here. Maybe the right answer here is to have CONFIG_ARCH_WANT_GENERIC_PSCI_... with default y (if most cases would be the generic one) and in the negative use the other option which is board specific values.
But re-reading patch 6/6, I'm still not convinced that we shouldn't start out with these being all in arch/arm/cpu/armv8/Kconfig, under the PSCI option, for everyone, and default ... if layerscape. And that reminds that I wonder if we shouldn't have some higher level option to say "I am ARMv8 Layerscape" to cover the cases where today we test vs a number of TARGET_LS.... choices. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161028/cd35e660/attachment.sig>
cover Add ARMv8 PSCI framework
Thanks Tom.
I am sending out an updated v2 soon, with the related configs updated.
Quoted 76 lines · Tom Rini
Quoted 36 lines · Hongbo Zhang
Quoted 23 lines · Tom Rini
Quoted 14 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
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.
Quoted 7 lines
Hongbo Zhang (6):
ARMv8: LS1043A: change macroCONFIG_ARMV8_PSCIdefinition
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: Enable SMC instruction
ARMv8: LS1043A: Enable LS1043A default PSCI supportQuoted 9 lines
Conceptually this is good. I have some issues around order of the patches, and where the
Kconfigentries end up. Looking over the series we introduce usage of some CONFIG symbols prior to declaring them inKconfig. This is more of a hard no now as it will break bisecting when the test for no new CONFIG symbols is tripped. The other problem is that I think the symbols you're adding in board/freescale/ls1043ardb/Kconfig need to be inarch/arm/cpu/armv8/Kconfigand then use default ... if ... to give the right address for the layerscape boards.Thanks Tom for quick response.
Quoted 8 lines
For config options introduced:
CONFIG_ARMV8_PSCICONFIG_ARMV8_PSCI_NR_CPUSCONFIG_CPU_PER_CLUSTERCONFIG_ARMV8_SECURE_BASEI've tested adding patch one by one, there is no problem with the check-config script.
OK.
Quoted 10 lines
And my idea was like this: let the
CONFIG_ARMV8_PSCIto be an overall switch, and if it is enabled even without the other three ones, the default PSCI still works, as I've tested, this really works because any of the other three macros, when used, there is a #ifdef to check if it exists, if no, a default value is used or it isn't used at all. The later three macros, because they are platform specific so I intended to let every platform to define them.This is slightly different from ARMv7, plan was if this get accepted, I would like to send patch to update ARMv7's.
I think that at the end of the day we need to have less options be defined and asked under board/ and make more and in some cases better use of the common
Kconfigfiles. Looking at how things are done in the Linux Kernel, in general, can be instructive here. Maybe the right answer here is to haveCONFIG_ARCH_WANT_GENERIC_PSCI_... with default y (if most cases would be the generic one) and in the negative use the other option which is board specific values.But re-reading patch 6/6, I'm still not convinced that we shouldn't start out with these being all in
arch/arm/cpu/armv8/Kconfig, under the PSCI option, for everyone, and default ... if layerscape. And that reminds that I wonder if we shouldn't have some higher level option to say "I am ARMv8 Layerscape" to cover the cases where today we test vs a number ofTARGET_LS.... choices. Thanks!--
Tom