Skip to contentSkip to conversation

armv8: Support loading 32-bit OS in AArch32 execution state

PATCH Superseded Alison Wang 5 participants 22 messages Oct 8, 2016 – Nov 10, 2016

Subsystems (3)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover armv8: Support loading 32-bit OS in AArch32 execution state

This series is to support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel. The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Spin-table method is used for secondary cores to load 32-bit OS. The architecture information will be got through checking FIT image and saved in the os_arch element of spin-table, then the secondary cores will check os_arch and jump to 32-bit OS or 64-bit OS automatically.

---------------------------------------
Changes in v7:
- Move the call for armv8_switch_to_el2_m into the first patch.

Changes in v6:
- Modified armv8_switch_to_el1(). It will always jump to ep when switching to AArch64 or AArch32 modes.
- Make other platforms compatible with the new armv8_switch_to_el2() and armv8_switch_to_el1().
- Make secondary_switch_to_el1() always jump to ep when switching to AArch64 or AArch32 modes.

Changes in v5:
- Modified armv8_switch_to_el2(). It will always jump to ep when switching to AArch64 or AArch32 modes.
- Make secondary_switch_to_el2() always jump to ep when switching to AArch64 or AArch32 modes.

Changes in v4:
- Correct config ARM64_SUPPORT_AARCH32.
- Omit arch and ftaddr arguments.
- Rename "xreg5" to "tmp".
- Use xxx_RES1 to combine all RES1 fields in xxx register.
- Use an immediate cmp directly.
- Use #ifdef for CONFIG_ARM64_SUPPORT_AARCH32.

Changes in v3:
- Comments the functions and the arguments.
- Rename the real parameters.
- Use the macros instead of the magic values.
- Remove the redundant codes.
- Clean up all of the mess in boot_jump_linux().
- Add CONFIG_ARM64_SUPPORT_AARCH32 to detect for some ARM64 system doesn't support AArch32 state.
- Adjust the arguments for armv8_switch_to_el2_m and armv8_switch_to_el1_m.

Changes in v2:
- armv8_switch_to_el2_aarch32() is removed. armv8_switch_to_el2_m is used to switch to AArch64 EL2 or AArch32 Hyp.
- armv8_switch_to_el1_aarch32() is removed. armv8_switch_to_el1_m is used to switch to AArch64 EL1 or AArch32 SVC.
- Support to call armv8_switch_to_el2_m and armv8_switch_to_el1_m.

----------------------------------------------------------------
Alison Wang (2):
armv8: Support loading 32-bit OS in AArch32 execution state
armv8: fsl-layerscape: SMP support for loading 32-bit OS

 arch/arm/Kconfig                              |   6 +++
 arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S  |  61 +++++++++++++++++++++-----
 arch/arm/cpu/armv8/fsl-layerscape/mp.c        |  10 +++++
 arch/arm/cpu/armv8/start.S                    |   8 ++++
 arch/arm/cpu/armv8/transition.S               |   8 ++--
 arch/arm/include/asm/arch-fsl-layerscape/mp.h |   6 +++
 arch/arm/include/asm/macro.h                  | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
 arch/arm/include/asm/system.h                 | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 arch/arm/lib/bootm.c                          |  45 ++++++++++++++++---
 arch/arm/mach-rmobile/lowlevel_init_gen3.S    |   9 +++-
 common/image-fit.c                            |  19 +++++++-
 11 files changed, 401 insertions(+), 66 deletions(-)
#1 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

To support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Changes in v6:
- Modified armv8_switch_to_el1(). It will always jump to ep when switching to AArch64 or AArch32 modes.
- Make other platforms compatible with the new armv8_switch_to_el2() and armv8_switch_to_el1().

Changes in v5:
- Modified armv8_switch_to_el2(). It will always jump to ep when switching to AArch64 or AArch32 modes.

Changes in v4:
- Correct config ARM64_SUPPORT_AARCH32.
- Omit arch and ftaddr arguments.
- Rename "xreg5" to "tmp".
- Use xxx_RES1 to combine all RES1 fields in xxx register.
- Use an immediate cmp directly.
- Use #ifdef for CONFIG_ARM64_SUPPORT_AARCH32.

Changes in v3:
- Comments the functions and the arguments.
- Rename the real parameters.
- Use the macros instead of the magic values.
- Remove the redundant codes.
- Clean up all of the mess in boot_jump_linux().
- Add CONFIG_ARM64_SUPPORT_AARCH32 to detect for some ARM64 system doesn't support AArch32 state.

Changes in v2:
- armv8_switch_to_el2_aarch32() is removed. armv8_switch_to_el2_m is used to switch to AArch64 EL2 or AArch32 Hyp.
- armv8_switch_to_el1_aarch32() is removed. armv8_switch_to_el1_m is used to switch to AArch64 EL1 or AArch32 SVC.

 arch/arm/Kconfig                              |   6 +
 arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S  |  61 +++++++--
 arch/arm/cpu/armv8/start.S                    |   8 ++
 arch/arm/cpu/armv8/transition.S               |   8 +-
 arch/arm/include/asm/arch-fsl-layerscape/mp.h |   4 +
 arch/arm/include/asm/macro.h                  | 176 +++++++++++++++++++-------
 arch/arm/include/asm/system.h                 | 119 ++++++++++++++++-
 arch/arm/lib/bootm.c                          |  39 +++++-
 arch/arm/mach-rmobile/lowlevel_init_gen3.S    |   9 +-
 common/image-fit.c                            |  19 ++-
 10 files changed, 383 insertions(+), 66 deletions(-)
arch/arm/Kconfig +6 -0
index e63309a..f122458 100644
@@ -126,6 +126,12 @@ config ENABLE_ARM_SOC_BOOT0_HOOK
 	  ARM_SOC_BOOT0_HOOK which contains the required assembler
 	  preprocessor code.
 
+config ARM64_SUPPORT_AARCH32
+	bool "ARM64 system support AArch32 execution state"
+	default y if ARM64 && !TARGET_THUNDERX_88XX
+	help
+	  This ARM64 system supports AArch32 execution state.
+
 choice
 	prompt "Target select"
 	default TARGET_HIKEY
arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S +51 -10

87 lines not on this page · raw message

arch/arm/cpu/armv8/start.S +8 -0
index 19c771d..4f5f6d8 100644
@@ -251,9 +251,17 @@ WEAK(lowlevel_init)
 	/*
 	 * All slaves will enter EL2 and optionally EL1.
 	 */
+	adr	x3, lowlevel_in_el2
+	ldr	x4, =ES_TO_AARCH64
 	bl	armv8_switch_to_el2
+
+lowlevel_in_el2:
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+	adr	x3, lowlevel_in_el1
+	ldr	x4, =ES_TO_AARCH64
 	bl	armv8_switch_to_el1
+
+lowlevel_in_el1:
 #endif
 
 #endif /* CONFIG_ARMV8_MULTIENTRY */
arch/arm/cpu/armv8/transition.S +4 -4
index 253a39b..115b6e9 100644
@@ -11,13 +11,13 @@
 #include <asm/macro.h>
 
 ENTRY(armv8_switch_to_el2)
-	switch_el x0, 1f, 0f, 0f
+	switch_el x5, 1f, 0f, 0f
 0:	ret
-1:	armv8_switch_to_el2_m x0
+1:	armv8_switch_to_el2_m x3, x4, x5
 ENDPROC(armv8_switch_to_el2)
 
 ENTRY(armv8_switch_to_el1)
-	switch_el x0, 0f, 1f, 0f
+	switch_el x5, 0f, 1f, 0f
 0:	ret
-1:	armv8_switch_to_el1_m x0, x1
+1:	armv8_switch_to_el1_m x3, x4, x5
 ENDPROC(armv8_switch_to_el1)
arch/arm/include/asm/arch-fsl-layerscape/mp.h +4 -0
index e46e076..14d9fcf 100644
@@ -35,4 +35,8 @@ phys_addr_t determine_mp_bootpg(void);
 void secondary_boot_func(void);
 int is_core_online(u64 cpu_id);
 #endif
+
+#define IH_ARCH_ARM		2	/* ARM */
+#define IH_ARCH_ARM64		22	/* ARM64 */
+
 #endif /* _FSL_LAYERSCAPE_MP_H */
arch/arm/include/asm/macro.h +133 -43

215 lines not on this page · raw message

arch/arm/include/asm/system.h +117 -2

131 lines not on this page · raw message

arch/arm/lib/bootm.c +34 -5
index 53c3141..7015573 100644
@@ -193,10 +193,6 @@ static void do_nonsec_virt_switch(void)
 {
 	smp_kick_all_cpus();
 	dcache_disable();	/* flush cache before swtiching to EL2 */
-	armv8_switch_to_el2();
-#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
-	armv8_switch_to_el1();
-#endif
 }
 #endif
 
@@ -273,6 +269,24 @@ bool armv7_boot_nonsec(void)
 }
 #endif
 
+#ifdef CONFIG_ARM64
+#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+static void switch_to_el1(void)
+{
+	if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
+	    (images.os.arch == IH_ARCH_ARM))
+		armv8_switch_to_el1(0, (u64)gd->bd->bi_arch_number,
+				    (u64)images.ft_addr,
+				    (u64)images.ep,
+				    ES_TO_AARCH32);
+	else
+		armv8_switch_to_el1((u64)images.ft_addr, 0, 0,
+				    images.ep,
+				    ES_TO_AARCH64);
+}
+#endif
+#endif
+
 /* Subcommand: GO */
 static void boot_jump_linux(bootm_headers_t *images, int flag)
 {
@@ -292,7 +306,22 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 
 	if (!fake) {
 		do_nonsec_virt_switch();
-		kernel_entry(images->ft_addr, NULL, NULL, NULL);
+
+#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+		armv8_switch_to_el2((u64)images->ft_addr, 0, 0,
+				    (u64)switch_to_el1, ES_TO_AARCH64);
+#else
+		if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
+		    (images->os.arch == IH_ARCH_ARM))
+			armv8_switch_to_el2(0, (u64)gd->bd->bi_arch_number,
+					    (u64)images->ft_addr,
+					    (u64)images->ep,
+					    ES_TO_AARCH32);
+		else
+			armv8_switch_to_el2((u64)images->ft_addr, 0, 0,
+					    images->ep,
+					    ES_TO_AARCH64);
+#endif
 	}
 #else
 	unsigned long machid = gd->bd->bi_arch_number;
arch/arm/mach-rmobile/lowlevel_init_gen3.S +8 -1
index 88ff56e..11acce0 100644
@@ -61,11 +61,18 @@ ENTRY(lowlevel_init)
 	/*
 	 * All slaves will enter EL2 and optionally EL1.
 	 */
+	adr	x3, lowlevel_in_el2
+	ldr	x4, =ES_TO_AARCH64
 	bl	armv8_switch_to_el2
+
+lowlevel_in_el2:
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+	adr	x3, lowlevel_in_el1
+	ldr	x4, =ES_TO_AARCH64
 	bl	armv8_switch_to_el1
-#endif
 
+lowlevel_in_el1:
+#endif
 #endif /* CONFIG_ARMV8_MULTIENTRY */
 
 	bl      s_init
common/image-fit.c +18 -1
index 9ce68f1..6ec5f8e 100644
@@ -27,6 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #include <u-boot/md5.h>
 #include <u-boot/sha1.h>
 #include <u-boot/sha256.h>
+#include <generated/autoconf.h>
 
 /*****************************************************************************/
 /* New uImage format routines */
@@ -1161,11 +1162,18 @@ int fit_image_check_os(const void *fit, int noffset, uint8_t os)
 int fit_image_check_arch(const void *fit, int noffset, uint8_t arch)
 {
 	uint8_t image_arch;
+	int aarch32_support = 0;
+
+#ifdef CONFIG_ARM64_SUPPORT_AARCH32
+	aarch32_support = 1;
+#endif
 
 	if (fit_image_get_arch(fit, noffset, &image_arch))
 		return 0;
 	return (arch == image_arch) ||
-		(arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64);
+		(arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64) ||
+		(arch == IH_ARCH_ARM64 && image_arch == IH_ARCH_ARM &&
+		 aarch32_support);
 }
 
 /**
@@ -1617,6 +1625,9 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	int type_ok, os_ok;
 	ulong load, data, len;
 	uint8_t os;
+#ifndef USE_HOSTCC
+	uint8_t os_arch;
+#endif
 	const char *prop_name;
 	int ret;
 
@@ -1700,6 +1711,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 		return -ENOEXEC;
 	}
 #endif
+
+#ifndef USE_HOSTCC
+	fit_image_get_arch(fit, noffset, &os_arch);
+	images->os.arch = os_arch;
+#endif
+
 	if (image_type == IH_TYPE_FLATDT &&
 	    !fit_image_check_comp(fit, noffset, IH_COMP_NONE)) {
 		puts("FDT image is compressed");
Signature · 1 line
2.1.0.27.g96db324
#21 lore raw

PATCH v7 2/2 armv8: fsl-layerscape: SMP support for loading 32-bit OS

In reply to Alison Wang

Spin-table method is used for secondary cores to load 32-bit OS. The architecture information will be got through checking FIT image and saved in the os_arch element of spin-table, then the secondary cores will check os_arch and jump to 32-bit OS or 64-bit OS automatically.

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into the first patch.

Changes in v6:
- Make secondary_switch_to_el1() always jump to ep when switching to AArch64 or AArch32 modes.

Changes in v5:
- Make secondary_switch_to_el2() always jump to ep when switching to AArch64 or AArch32 modes.

Changes in v4:
- Omit arch and ftaddr arguments.

Changes in v3:
- Adjust the arguments for armv8_switch_to_el2_m and armv8_switch_to_el1_m.

Changes in v2:
- Support to call armv8_switch_to_el2_m and armv8_switch_to_el1_m.

 arch/arm/cpu/armv8/fsl-layerscape/mp.c        | 10 ++++++++++
 arch/arm/include/asm/arch-fsl-layerscape/mp.h |  2 ++
 arch/arm/lib/bootm.c                          |  6 ++++++
 3 files changed, 18 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/mp.c +10 -0
index df7ffb8..dd91550 100644
@@ -22,6 +22,16 @@ phys_addr_t determine_mp_bootpg(void)
 	return (phys_addr_t)&secondary_boot_code;
 }
 
+void update_os_arch_secondary_cores(uint8_t os_arch)
+{
+	u64 *table = get_spin_tbl_addr();
+	int i;
+
+	for (i = 1; i < CONFIG_MAX_CPUS; i++)
+		table[i * WORDS_PER_SPIN_TABLE_ENTRY +
+			SPIN_TABLE_ELEM_OS_ARCH_IDX] = os_arch;
+}
+
 int fsl_layerscape_wake_seconday_cores(void)
 {
 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
arch/arm/include/asm/arch-fsl-layerscape/mp.h +2 -0
index 14d9fcf..55f0e0c 100644
@@ -13,6 +13,7 @@
 *      uint64_t entry_addr;
 *      uint64_t status;
 *      uint64_t lpid;
+*      uint64_t os_arch;
 * };
 * we pad this struct to 64 bytes so each entry is in its own cacheline
 * the actual spin table is an array of these structures
@@ -20,6 +21,7 @@
 #define SPIN_TABLE_ELEM_ENTRY_ADDR_IDX	0
 #define SPIN_TABLE_ELEM_STATUS_IDX	1
 #define SPIN_TABLE_ELEM_LPID_IDX	2
+#define SPIN_TABLE_ELEM_OS_ARCH_IDX	3
 #define WORDS_PER_SPIN_TABLE_ENTRY	8	/* pad to 64 bytes */
 #define SPIN_TABLE_ELEM_SIZE		64
 
arch/arm/lib/bootm.c +6 -0
index 7015573..17758d3 100644
@@ -270,6 +270,10 @@ bool armv7_boot_nonsec(void)
 #endif
 
 #ifdef CONFIG_ARM64
+__weak void update_os_arch_secondary_cores(uint8_t os_arch)
+{
+}
+
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
 static void switch_to_el1(void)
 {
@@ -307,6 +311,8 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 	if (!fake) {
 		do_nonsec_virt_switch();
 
+		update_os_arch_secondary_cores(images->os.arch);
+
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
 		armv8_switch_to_el2((u64)images->ft_addr, 0, 0,
 				    (u64)switch_to_el1, ES_TO_AARCH64);
Signature · 1 line
2.1.0.27.g96db324
#2 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

In reply to Alison Wang
Quoted 6 lines · Alison Wang

To support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

York

#3 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Hi York/Alison,

Sorry for not having had time to look at this earlier.

Quoted 15 lines · york sun
Quoted 6 lines · Alison Wang

To support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Quoted 5 lines

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

I've just tested these two patches on ARM's FVP Foundation and AEMv8 models and ARM's Juno board.

In all cases, with this patchset, the kernel fails to start. I see a continuous reboot, where the kernel starts then immediately resets:

--------------------------------------------------
Starting kernel ...

resetting ...
--------------------------------------------------

So I wouldn't want to see these patches merged.

Regards,
Ryan.

#4 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Alison,

Does Ryan have your 32-bit kernel image? I think kernel 32-bit doesn't support spin table. Please work with Ryan if your PSCI patch is required for the test.

York

-------- Original Message --------
From: Ryan Harkin <[email protected]>
Sent: Thursday, November 3, 2016 12:17 PM
To: york sun <[email protected]>
Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state
CC: Alison Wang <[email protected]>,agraf at suse.de,Scott Wood <[email protected]>,Stuart Yoder <[email protected]>,Leo Li <[email protected]>,fenghua at phytium.com.cn,monstr at monstr.eu,thomas.ab at samsung.com,mk7.kang at samsung.com,u-boot at lists.denx.de,Jason Jin <[email protected]>,Alison Wang <[email protected]>

Hi York/Alison,

Sorry for not having had time to look at this earlier.

Quoted 15 lines · york sun
Quoted 6 lines · Alison Wang

To support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Quoted 5 lines

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

I've just tested these two patches on ARM's FVP Foundation and AEMv8 models and ARM's Juno board.

In all cases, with this patchset, the kernel fails to start. I see a continuous reboot, where the kernel starts then immediately resets:

--------------------------------------------------
Starting kernel ...

resetting ...
--------------------------------------------------

So I wouldn't want to see these patches merged.

Regards,
Ryan.

#5 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

York,

No, he don?t have my 32-bit kernel image. I am not sure he is using 32-bit kernel or 64-bit kernel.

Ryan,

I am not familiar with the boards you tested, so I have some questions, please help to work with me to find the root cause.

1. Are you loading 32-bit kernel or 64-bit kernel?

2. Is CONFIG_ARMV8_SWITCH_TO_EL1 defined on these boards?

3. Are you using some secure firmware on these boards? In detail, I want to know which EL is running on these boards when calling armv8_switch_to_el2 in arch/arm/lib/bootm.c. If it is already running in EL2 when calling armv8_swith_to_el2, the attached patch with PSCI enabled is needed.

Best Regards,
Alison Wang

From: york sun
Sent: Friday, November 04, 2016 10:04 AM
To: ryan.harkin at linaro.org
Cc: Wang Huan <[email protected]>; agraf at suse.de; Scott Wood <[email protected]>; Stuart Yoder <[email protected]>; Leo Li <[email protected]>; fenghua at phytium.com.cn; monstr at monstr.eu; thomas.ab at samsung.com; mk7.kang at samsung.com; u-boot at lists.denx.de; Jason Jin <[email protected]>; Alison Wang <[email protected]>
Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state

Alison,

Does Ryan have your 32-bit kernel image? I think kernel 32-bit doesn't support spin table. Please work with Ryan if your PSCI patch is required for the test.

York

-------- Original Message --------
From: Ryan Harkin <ryan.harkin at linaro.org<mailto:[email protected]>>
Sent: Thursday, November 3, 2016 12:17 PM
To: york sun <york.sun at nxp.com<mailto:[email protected]>>
Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state
CC: Alison Wang <b18965 at freescale.com<mailto:[email protected]>>,agraf at suse.de,Scott Wood <scott.wood at nxp.com<mailto:[email protected]>>,Stuart Yoder <stuart.yoder at nxp.com<mailto:[email protected]>>,Leo Li <leoyang.li at nxp.com<mailto:[email protected]>>,fenghua at phytium.com.cn,monstr at monstr.eu,thomas.ab at samsung.com,mk7.kang at samsung.com,u-boot at lists.denx.de,Jason Jin <jason.jin at nxp.com<mailto:[email protected]>>,Alison Wang <alison.wang at nxp.com<mailto:[email protected]>>

Hi York/Alison,

Sorry for not having had time to look at this earlier.

Quoted 15 lines · On 26 October 2016 at 17:54, york sun <york.sun at…
Quoted 6 lines · Alison Wang

To support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines
Signed-off-by Ebony Zhu <ebony.zhu at nxp.com<mailto:[email protected]>>
Signed-off-by Alison Wang <alison.wang at nxp.com<mailto:[email protected]>>
Signed-off-by Chenhui Zhao <chenhui.zhao at nxp.com<mailto:[email protected]>>

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Quoted 5 lines

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

I've just tested these two patches on ARM's FVP Foundation and AEMv8 models and ARM's Juno board.

In all cases, with this patchset, the kernel fails to start. I see a continuous reboot, where the kernel starts then immediately resets:

--------------------------------------------------
Starting kernel ...

resetting ...
--------------------------------------------------

So I wouldn't want to see these patches merged.

Regards,
Ryan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-armv8-fsl-layerscape-Support-loading-32-bit-OS-with-.patch
Type: application/octet-stream
Size: 3098 bytes
Desc: 0001-armv8-fsl-layerscape-Support-loading-32-bit-OS-with-.patch
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161104/263dfc24/attachment.obj>

#6 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 9 lines · Alison Wang

York,

No, he don?t have my 32-bit kernel image. I am not sure he
is using 32-bit kernel or 64-bit kernel.

Quoted 5 lines

Ryan,

I am not familiar with the boards you tested,

The FVP Foundation model is free to use from ARM. The entire software stack I'm using is available via ARM's portal:

https://community.arm.com/groups/arm-development-platforms

Quoted 7 lines

so I have some
questions, please help to work with me to find the root cause.

1. Are you loading 32-bit kernel or 64-bit kernel?

I'm loading the "standard" 64-bit kernel. I was using a kernel based off 4.8:

https://git.linaro.org/landing-teams/working/arm/kernel-release.git/log/?h=latest-armlt-20161001

Quoted 2 lines

2. Is CONFIG_ARMV8_SWITCH_TO_EL1 defined on these boards?

I guess it is for the FVP models, if I grep for it, it's in my configs' .h file:

include/configs/vexpress_aemv8a.h:15:#define CONFIG_ARMV8_SWITCH_TO_EL1

-------------------------------------------------------
#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
#ifndef CONFIG_SEMIHOSTING
#error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING #endif
#define CONFIG_ARMV8_SWITCH_TO_EL1
#endif
-------------------------------------------------------

But it isn't in my Juno config.

Quoted 6 lines

3. Are you using some secure firmware on these boards? In detail, I
want to know which EL is running on these boards when calling armv8_switch_to_el2 in arch/arm/lib/bootm.c. If it is already running in EL2 when calling armv8_swith_to_el2, the attached patch with PSCI enabled is needed.

I'm using what ARM consider the "standard" boot flow. I'm using ARM Trusted Firmware to boot u-boot which in turn boots an arm64 kernel.

I'd expect my setup to still work after you've added patches to allow an aarch32 kernel to be booted, but I guess you're changing the boot path for non-aarch32 kernels also.

Regards,
Ryan.

Quoted 89 lines

Best Regards,

Alison Wang

From: york sun
Sent: Friday, November 04, 2016 10:04 AM
To: ryan.harkin at linaro.org
Cc: Wang Huan <[email protected]>; agraf at suse.de; Scott Wood <[email protected]>; Stuart Yoder <[email protected]>; Leo Li <[email protected]>; fenghua at phytium.com.cn; monstr at monstr.eu; thomas.ab at samsung.com; mk7.kang at samsung.com; u-boot at lists.denx.de; Jason Jin <[email protected]>; Alison Wang <[email protected]>

Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state

Alison,

Does Ryan have your 32-bit kernel image? I think kernel 32-bit doesn't support spin table. Please work with Ryan if your PSCI patch is required for the test.

York

-------- Original Message --------
From: Ryan Harkin <[email protected]>
Sent: Thursday, November 3, 2016 12:17 PM
To: york sun <[email protected]>
Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32
execution state
CC: Alison Wang <[email protected]>,agraf at suse.de,Scott Wood
<[email protected]>,Stuart Yoder <[email protected]>,Leo Li
<[email protected]>,fenghua at phytium.com.cn,monstr at monstr.eu,thomas.ab at samsung.com,mk7.kang at samsung.com,u-boot at lists.denx.de,Jason Jin <[email protected]>,Alison Wang <[email protected]>

Hi York/Alison,

Sorry for not having had time to look at this earlier.

Quoted 15 lines · york sun
Quoted 6 lines · Alison Wang

To support loading a 32-bit OS, the execution state will change from AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Quoted 5 lines

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

I've just tested these two patches on ARM's FVP Foundation and AEMv8 models and ARM's Juno board.

In all cases, with this patchset, the kernel fails to start. I see a continuous reboot, where the kernel starts then immediately resets:

--------------------------------------------------
Starting kernel ...

resetting ...
--------------------------------------------------

So I wouldn't want to see these patches merged.

Regards,
Ryan.

#7 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 61 lines · Alison Wang
Quoted 9 lines

York,

No, he don?t have my 32-bit kernel image. I am not
sure he is using 32-bit kernel or 64-bit kernel.

Quoted 5 lines

Ryan,

I am not familiar with the boards you tested,

The FVP Foundation model is free to use from ARM. The entire software stack I'm using is available via ARM's portal:

https://community.arm.com/groups/arm-development-platforms

Quoted 7 lines

so I have some
questions, please help to work with me to find the root cause.

1. Are you loading 32-bit kernel or 64-bit kernel?

I'm loading the "standard" 64-bit kernel. I was using a kernel based off 4.8:

https://git.linaro.org/landing-teams/working/arm/kernel-
release.git/log/?h=latest-armlt-20161001

Quoted 2 lines

2. Is CONFIG_ARMV8_SWITCH_TO_EL1 defined on these boards?

I guess it is for the FVP models, if I grep for it, it's in my configs' .h file:

include/configs/vexpress_aemv8a.h:15:#define CONFIG_ARMV8_SWITCH_TO_EL1

-------------------------------------------------------
#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP #ifndef CONFIG_SEMIHOSTING #error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING #endif #define CONFIG_ARMV8_SWITCH_TO_EL1 #endif
-------------------------------------------------------

But it isn't in my Juno config.

Quoted 1 line

3. Are you using some secure firmware on these boards? In

detail, I

Quoted 5 lines

want to know which EL is running on these boards when calling armv8_switch_to_el2 in arch/arm/lib/bootm.c. If it is already running in EL2 when calling armv8_swith_to_el2, the attached patch with PSCI enabled is needed.

Quoted 6 lines

I'm using what ARM consider the "standard" boot flow. I'm using ARM Trusted Firmware to boot u-boot which in turn boots an arm64 kernel.

I'd expect my setup to still work after you've added patches to allow an aarch32 kernel to be booted, but I guess you're changing the boot path for non-aarch32 kernels also.

[Alison Wang] Of course, although I add these patches to support aarch32 kernel, I should make sure aarch64 kernel work too.

If you are using ARM Trusted Firmware to boot u-boot, I want to know what EL is running for your U-Boot. If it is running in EL2 or EL1, please add the attached patch to test again.

Thanks.

Quoted 55 lines

Regards,
Ryan.

Quoted 20 lines

Best Regards,

Alison Wang

From: york sun
Sent: Friday, November 04, 2016 10:04 AM
To: ryan.harkin at linaro.org
Cc: Wang Huan <[email protected]>; agraf at suse.de; Scott Wood <[email protected]>; Stuart Yoder <[email protected]>; Leo Li <[email protected]>; fenghua at phytium.com.cn; monstr at monstr.eu; thomas.ab at samsung.com; mk7.kang at samsung.com; u-boot at lists.denx.de; Jason Jin <[email protected]>; Alison Wang <[email protected]>

Quoted 8 lines

Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state

Alison,

Does Ryan have your 32-bit kernel image? I think kernel 32-bit

doesn't

Quoted 7 lines

support spin table. Please work with Ryan if your PSCI patch is required for the test.

York

Quoted 9 lines

-------- Original Message --------
From: Ryan Harkin <[email protected]>
Sent: Thursday, November 3, 2016 12:17 PM
To: york sun <[email protected]>
Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state
CC: Alison Wang <[email protected]>,agraf at suse.de,Scott Wood <[email protected]>,Stuart Yoder <[email protected]>,Leo Li

<[email protected]>,fenghua at phytium.com.cn,monstr at monstr.eu,thomas.ab

Quoted 5 lines

@samsung.com,mk7.kang at samsung.com,u-boot at lists.denx.de,Jason Jin <[email protected]>,Alison Wang <[email protected]>

Hi York/Alison,

Quoted 42 lines
Quoted 6 lines

Sorry for not having had time to look at this earlier.

Quoted 2 lines · york sun
Quoted 1 line · Alison Wang

To support loading a 32-bit OS, the execution state will change

from

Quoted 35 lines
Quoted 13 lines
Quoted 5 lines

AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Quoted 5 lines

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

I've just tested these two patches on ARM's FVP Foundation and AEMv8 models and ARM's Juno board.

In all cases, with this patchset, the kernel fails to start. I see a continuous reboot, where the kernel starts then immediately resets:

--------------------------------------------------
Starting kernel ...

resetting ...
--------------------------------------------------

So I wouldn't want to see these patches merged.

Regards,
Ryan.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-armv8-fsl-layerscape-Support-loading-32-bit-OS-with-.patch
Type: application/octet-stream
Size: 3098 bytes
Desc: 0001-armv8-fsl-layerscape-Support-loading-32-bit-OS-with-.patch
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161104/ef6fe168/attachment.obj>

#8 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 64 lines · Alison Wang
Quoted 64 lines · Alison Wang
Quoted 9 lines

York,

No, he don?t have my 32-bit kernel image. I am not
sure he is using 32-bit kernel or 64-bit kernel.

Quoted 5 lines

Ryan,

I am not familiar with the boards you tested,

The FVP Foundation model is free to use from ARM. The entire software stack I'm using is available via ARM's portal:

https://community.arm.com/groups/arm-development-platforms

Quoted 7 lines

so I have some
questions, please help to work with me to find the root cause.

1. Are you loading 32-bit kernel or 64-bit kernel?

I'm loading the "standard" 64-bit kernel. I was using a kernel based off 4.8:

https://git.linaro.org/landing-teams/working/arm/kernel-
release.git/log/?h=latest-armlt-20161001

Quoted 2 lines

2. Is CONFIG_ARMV8_SWITCH_TO_EL1 defined on these boards?

I guess it is for the FVP models, if I grep for it, it's in my configs' .h file:

include/configs/vexpress_aemv8a.h:15:#define CONFIG_ARMV8_SWITCH_TO_EL1

-------------------------------------------------------
#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP #ifndef CONFIG_SEMIHOSTING #error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING #endif #define CONFIG_ARMV8_SWITCH_TO_EL1 #endif
-------------------------------------------------------

But it isn't in my Juno config.

Quoted 1 line

3. Are you using some secure firmware on these boards? In

detail, I

Quoted 5 lines

want to know which EL is running on these boards when calling armv8_switch_to_el2 in arch/arm/lib/bootm.c. If it is already running in EL2 when calling armv8_swith_to_el2, the attached patch with PSCI enabled is needed.

I'm using what ARM consider the "standard" boot flow. I'm using ARM Trusted Firmware to boot u-boot which in turn boots an arm64 kernel.

Quoted 8 lines
Quoted 3 lines

I'd expect my setup to still work after you've added patches to allow an aarch32 kernel to be booted, but I guess you're changing the boot path for non-aarch32 kernels also.

[Alison Wang] Of course, although I add these patches to support aarch32 kernel, I should make sure aarch64 kernel work too.

If you are using ARM Trusted Firmware to boot u-boot, I want to know what EL is running for your U-Boot.

I guess I'm running U-Boot at EL2. U-Boot is BL33 and the ARM-TF docs say:

---------------------------------------------------------
BL33 (Non-trusted Firmware) execution

EL3 Runtime Software initializes the EL2 or EL1 processor context for normal- world cold boot, ensuring that no secure state information finds its way into the non-secure execution state. EL3 Runtime Software uses the entrypoint information provided by BL2 to jump to the Non-trusted firmware image (BL33) at the highest available Exception Level (EL2 if available, otherwise EL1).
---------------------------------------------------------

Quoted 2 lines

If it is running in EL2 or EL1, please add
the attached patch to test again.

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 98 lines

Thanks.

Quoted 97 lines

Regards,
Ryan.

Quoted 20 lines

Best Regards,

Alison Wang

From: york sun
Sent: Friday, November 04, 2016 10:04 AM
To: ryan.harkin at linaro.org
Cc: Wang Huan <[email protected]>; agraf at suse.de; Scott Wood <[email protected]>; Stuart Yoder <[email protected]>; Leo Li <[email protected]>; fenghua at phytium.com.cn; monstr at monstr.eu; thomas.ab at samsung.com; mk7.kang at samsung.com; u-boot at lists.denx.de; Jason Jin <[email protected]>; Alison Wang <[email protected]>

Quoted 8 lines

Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state

Alison,

Does Ryan have your 32-bit kernel image? I think kernel 32-bit

doesn't

Quoted 7 lines

support spin table. Please work with Ryan if your PSCI patch is required for the test.

York

Quoted 9 lines

-------- Original Message --------
From: Ryan Harkin <[email protected]>
Sent: Thursday, November 3, 2016 12:17 PM
To: york sun <[email protected]>
Subject: Re: [PATCH v7 1/2] armv8: Support loading 32-bit OS in AArch32 execution state
CC: Alison Wang <[email protected]>,agraf at suse.de,Scott Wood <[email protected]>,Stuart Yoder <[email protected]>,Leo Li

<[email protected]>,fenghua at phytium.com.cn,monstr at monstr.eu,thomas.ab

Quoted 11 lines

@samsung.com,mk7.kang at samsung.com,u-boot at lists.denx.de,Jason Jin <[email protected]>,Alison Wang <[email protected]>

Hi York/Alison,

Sorry for not having had time to look at this earlier.

Quoted 2 lines · york sun
Quoted 1 line · Alison Wang

To support loading a 32-bit OS, the execution state will change

from

Quoted 35 lines
Quoted 13 lines
Quoted 5 lines

AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image, then U-Boot will load 32-bit OS or 64-bit OS automatically.

Quoted 7 lines

---
Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch.

Quoted 5 lines

Reviewers,

May I have your comment please? I intend to merge this set when the merge window opens.

I've just tested these two patches on ARM's FVP Foundation and AEMv8 models and ARM's Juno board.

In all cases, with this patchset, the kernel fails to start. I see a continuous reboot, where the kernel starts then immediately resets:

--------------------------------------------------
Starting kernel ...

resetting ...
--------------------------------------------------

So I wouldn't want to see these patches merged.

Regards,
Ryan.

#9 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 95 lines · Ryan Harkin
Quoted 64 lines · Alison Wang
Quoted 64 lines · Alison Wang
Quoted 9 lines

York,

No, he don?t have my 32-bit kernel image. I am not
sure he is using 32-bit kernel or 64-bit kernel.

Quoted 5 lines

Ryan,

I am not familiar with the boards you tested,

The FVP Foundation model is free to use from ARM. The entire software stack I'm using is available via ARM's portal:

https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.arm.com%2Fgroups%2Farm-development-platforms&data=01%7C01%7Cyork.sun%40nxp.com%7C2327a62e481a449f1e7608d404a6794c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=sr1vyQ38lglMJPIGE1i2HaNTxJqsiPgqJtlZJpOvfHc%3D&reserved=0

Quoted 7 lines

so I have some
questions, please help to work with me to find the root cause.

1. Are you loading 32-bit kernel or 64-bit kernel?

I'm loading the "standard" 64-bit kernel. I was using a kernel based off 4.8:

https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.linaro.org%2Flanding-teams%2Fworking%2Farm%2Fkernel-&data=01%7C01%7Cyork.sun%40nxp.com%7C2327a62e481a449f1e7608d404a6794c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=N9sN8rBtRtib8gBCICvuH2EmwOswW203ERcRtA3FiFU%3D&reserved=0
release.git/log/?h=latest-armlt-20161001

Quoted 2 lines

2. Is CONFIG_ARMV8_SWITCH_TO_EL1 defined on these boards?

I guess it is for the FVP models, if I grep for it, it's in my configs' .h file:

include/configs/vexpress_aemv8a.h:15:#define CONFIG_ARMV8_SWITCH_TO_EL1

-------------------------------------------------------
#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP #ifndef CONFIG_SEMIHOSTING #error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING #endif #define CONFIG_ARMV8_SWITCH_TO_EL1 #endif
-------------------------------------------------------

But it isn't in my Juno config.

Quoted 1 line

3. Are you using some secure firmware on these boards? In

detail, I

Quoted 5 lines

want to know which EL is running on these boards when calling armv8_switch_to_el2 in arch/arm/lib/bootm.c. If it is already running in EL2 when calling armv8_swith_to_el2, the attached patch with PSCI enabled is needed.

I'm using what ARM consider the "standard" boot flow. I'm using ARM Trusted Firmware to boot u-boot which in turn boots an arm64 kernel.

Quoted 8 lines
Quoted 3 lines

I'd expect my setup to still work after you've added patches to allow an aarch32 kernel to be booted, but I guess you're changing the boot path for non-aarch32 kernels also.

[Alison Wang] Of course, although I add these patches to support aarch32 kernel, I should make sure aarch64 kernel work too.

If you are using ARM Trusted Firmware to boot u-boot, I want to know what EL is running for your U-Boot.

I guess I'm running U-Boot at EL2. U-Boot is BL33 and the ARM-TF docs say:

---------------------------------------------------------
BL33 (Non-trusted Firmware) execution

EL3 Runtime Software initializes the EL2 or EL1 processor context for normal- world cold boot, ensuring that no secure state information finds its way into the non-secure execution state. EL3 Runtime Software uses the entrypoint information provided by BL2 to jump to the Non-trusted firmware image (BL33) at the highest available Exception Level (EL2 if available, otherwise EL1).
---------------------------------------------------------

Quoted 2 lines

If it is running in EL2 or EL1, please add
the attached patch to test again.

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch. It gets EL2 working after the 2nd set. If there is room to clarify in the commit message, please kindly suggest.

York

#10 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 104 lines · york sun
Quoted 95 lines · Ryan Harkin
Quoted 64 lines · Alison Wang
Quoted 64 lines · Alison Wang
Quoted 9 lines

York,

No, he don?t have my 32-bit kernel image. I am not
sure he is using 32-bit kernel or 64-bit kernel.

Quoted 5 lines

Ryan,

I am not familiar with the boards you tested,

The FVP Foundation model is free to use from ARM. The entire software stack I'm using is available via ARM's portal:

https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.arm.com%2Fgroups%2Farm-development-platforms&data=01%7C01%7Cyork.sun%40nxp.com%7C2327a62e481a449f1e7608d404a6794c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=sr1vyQ38lglMJPIGE1i2HaNTxJqsiPgqJtlZJpOvfHc%3D&reserved=0

Quoted 7 lines

so I have some
questions, please help to work with me to find the root cause.

1. Are you loading 32-bit kernel or 64-bit kernel?

I'm loading the "standard" 64-bit kernel. I was using a kernel based off 4.8:

https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.linaro.org%2Flanding-teams%2Fworking%2Farm%2Fkernel-&data=01%7C01%7Cyork.sun%40nxp.com%7C2327a62e481a449f1e7608d404a6794c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=N9sN8rBtRtib8gBCICvuH2EmwOswW203ERcRtA3FiFU%3D&reserved=0
release.git/log/?h=latest-armlt-20161001

Quoted 2 lines

2. Is CONFIG_ARMV8_SWITCH_TO_EL1 defined on these boards?

I guess it is for the FVP models, if I grep for it, it's in my configs' .h file:

include/configs/vexpress_aemv8a.h:15:#define CONFIG_ARMV8_SWITCH_TO_EL1

-------------------------------------------------------
#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP #ifndef CONFIG_SEMIHOSTING #error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING #endif #define CONFIG_ARMV8_SWITCH_TO_EL1 #endif
-------------------------------------------------------

But it isn't in my Juno config.

Quoted 1 line

3. Are you using some secure firmware on these boards? In

detail, I

Quoted 5 lines

want to know which EL is running on these boards when calling armv8_switch_to_el2 in arch/arm/lib/bootm.c. If it is already running in EL2 when calling armv8_swith_to_el2, the attached patch with PSCI enabled is needed.

I'm using what ARM consider the "standard" boot flow. I'm using ARM Trusted Firmware to boot u-boot which in turn boots an arm64 kernel.

Quoted 8 lines
Quoted 3 lines

I'd expect my setup to still work after you've added patches to allow an aarch32 kernel to be booted, but I guess you're changing the boot path for non-aarch32 kernels also.

[Alison Wang] Of course, although I add these patches to support aarch32 kernel, I should make sure aarch64 kernel work too.

If you are using ARM Trusted Firmware to boot u-boot, I want to know what EL is running for your U-Boot.

I guess I'm running U-Boot at EL2. U-Boot is BL33 and the ARM-TF docs say:

---------------------------------------------------------
BL33 (Non-trusted Firmware) execution

EL3 Runtime Software initializes the EL2 or EL1 processor context for normal- world cold boot, ensuring that no secure state information finds its way into the non-secure execution state. EL3 Runtime Software uses the entrypoint information provided by BL2 to jump to the Non-trusted firmware image (BL33) at the highest available Exception Level (EL2 if available, otherwise EL1).
---------------------------------------------------------

Quoted 2 lines

If it is running in EL2 or EL1, please add
the attached patch to test again.

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Regards,
Ryan.

#11 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 28 lines · Ryan Harkin
Quoted 13 lines
Quoted 5 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Quoted 6 lines

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set, does something break? My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

York

#12 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 36 lines · york sun
Quoted 28 lines · Ryan Harkin
Quoted 13 lines
Quoted 5 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Quoted 6 lines

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Quoted 5 lines

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set, does something break?

Yes, with the patches booting 64bit Linux with U-Boot running in EL2 breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

Alex

#13 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 50 lines · Alexander Graf
Quoted 40 lines · york sun
Quoted 31 lines · Ryan Harkin
Quoted 15 lines
Quoted 6 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Quoted 6 lines

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Quoted 5 lines

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set, does something break?

Quoted 9 lines

Yes, with the patches booting 64bit Linux with U-Boot running in EL2 breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Correct. Thanks Alex for clarifying what I'm trying to say :)

Quoted 4 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

#14 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

In reply to Alexander Graf
Quoted 45 lines · Alexander Graf
Quoted 36 lines · york sun
Quoted 28 lines · Ryan Harkin
Quoted 13 lines
Quoted 5 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Quoted 6 lines

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Quoted 5 lines

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set, does something break?

Quoted 7 lines

Yes, with the patches booting 64bit Linux with U-Boot running in EL2 breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Thanks for the confirmation.

Quoted 4 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

If you are referring the trusted firmware, we are following that direction. Just not fully up yet on some platform.

It is definitely not our intention to be cumbersome. Please point out where it went sideway beside the trusted firmware.

York

#15 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 61 lines · york sun
Quoted 45 lines · Alexander Graf
Quoted 36 lines · york sun
Quoted 28 lines · Ryan Harkin
Quoted 13 lines
Quoted 5 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Quoted 6 lines

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Quoted 5 lines

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set, does something break?

Quoted 7 lines

Yes, with the patches booting 64bit Linux with U-Boot running in EL2 breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Thanks for the confirmation.

Quoted 4 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

Quoted 5 lines

If you are referring the trusted firmware, we are following that direction. Just not fully up yet on some platform.

It is definitely not our intention to be cumbersome. Please point out where it went sideway beside the trusted firmware.

Basically it boils down to the fact that you are the only platform that runs U-Boot in EL3 :).

If you want to keep the memory initialization inside of U-Boot, I think that's great. But you could either split that into SPL/EL2 or degrade yourself into EL2 as soon as possible by calling into an EL3 firmware. Whether you build that firmware as part of U-Boot (the stock one could be very trivial) or externally is not really too much of a problem.

Things like Alison's patches could then do a simple PSCI call into said EL3 firmware to call into 32bit code in EL2 for example.

Alex

#16 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 73 lines · Alexander Graf
Quoted 61 lines · york sun
Quoted 45 lines · Alexander Graf
Quoted 36 lines · york sun
Quoted 28 lines · Ryan Harkin
Quoted 13 lines
Quoted 5 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would not be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code is doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Quoted 5 lines

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 3 lines

It gets EL2 working after the 2nd set. If
there is room to clarify in the commit message, please kindly suggest.

Quoted 6 lines

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch sequence. That's generally unacceptable on most projects I work on. Keeping the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Quoted 5 lines

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set, does something break?

Quoted 7 lines

Yes, with the patches booting 64bit Linux with U-Boot running in EL2 breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Thanks for the confirmation.

Quoted 4 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

Quoted 5 lines

If you are referring the trusted firmware, we are following that direction. Just not fully up yet on some platform.

It is definitely not our intention to be cumbersome. Please point out where it went sideway beside the trusted firmware.

Basically it boils down to the fact that you are the only platform that runs U-Boot in EL3 :).

Quoted 9 lines

If you want to keep the memory initialization inside of U-Boot, I think that's great. But you could either split that into SPL/EL2 or degrade yourself into EL2 as soon as possible by calling into an EL3 firmware. Whether you build that firmware as part of U-Boot (the stock one could be very trivial) or externally is not really too much of a problem.

Things like Alison's patches could then do a simple PSCI call into said EL3 firmware to call into 32bit code in EL2 for example.

Basically I agree with you. U-Boot will run at EL2 as soon as we have the trusted firmware in place.

York

#17 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Quoted 89 lines · Alexander Graf
Quoted 7 lines · york sun
Quoted 4 lines · Alexander Graf
Quoted 3 lines · york sun
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Ryan Harkin
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would

not

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code

is

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines
Quoted 2 lines

doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

It gets EL2 working after the 2nd set. If there is room to clarify in the commit message, please kindly suggest.

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch

sequence.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

That's generally unacceptable on most projects I work on.

Keeping

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set,

does something break?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Yes, with the patches booting 64bit Linux with U-Boot running in

EL2

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Thanks for the confirmation.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

If you are referring the trusted firmware, we are following that direction. Just not fully up yet on some platform.

It is definitely not our intention to be cumbersome. Please point

out

Quoted 8 lines
Quoted 1 line

where it went sideway beside the trusted firmware.

Basically it boils down to the fact that you are the only platform that runs U-Boot in EL3 :).

If you want to keep the memory initialization inside of U-Boot, I think that's great. But you could either split that into SPL/EL2 or degrade yourself into EL2 as soon as possible by calling into an EL3

firmware.

Quoted 1 line

Whether you build that firmware as part of U-Boot (the stock one

could

Quoted 2 lines

be very trivial) or externally is not really too much of a problem.

Quoted 8 lines
Quoted 4 lines

Things like Alison's patches could then do a simple PSCI call into said
EL3 firmware to call into 32bit code in EL2 for example.

Basically I agree with you. U-Boot will run at EL2 as soon as we have the trusted firmware in place.

[Alison Wang] Thanks for all your comments.

For the issue about the tree would not be bisect-able, I have
a solution. Actually it is the root cause that 64-bit kernel could not boot up when U-Boot is running in EL2. I will move these codes from the third patch to the first patch.

ENTRY(armv8_switch_to_el2)

        switch_el x5, 1f, 0f, 0f
-0:     ret
+       /*
+        * x3 is kernel entry point or switch_to_el1
+         * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
+         * When running in EL2 now, jump to the
+         * address saved in x3.

+ */
+0: br x3
1: armv8_switch_to_el2_m x3, x4, x5
ENDPROC(armv8_switch_to_el2)

ENTRY(armv8_switch_to_el1)
switch_el x5, 0f, 1f, 0f
-0: ret
+
+ /*
+ * x3 is kernel entry point. When running in EL1
+ * now, jump to the address saved in x3.
+ */
+0: br x3
1: armv8_switch_to_el1_m x3, x4, x5
ENDPROC(armv8_switch_to_el1)

With this re-order, the bitsect issue will be fixed and there is not a point that kernel could not boot up.

If you all agree with this re-order, I will send out the v8 patch includes the first, second and third patches.

Best Regards,
Alison Wang

#18 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

Hi Alison,

Quoted 129 lines · Alison Wang
Quoted 89 lines · Alexander Graf
Quoted 7 lines · york sun
Quoted 4 lines · Alexander Graf
Quoted 3 lines · york sun
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Ryan Harkin
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would

not

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this code

is

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines
Quoted 2 lines

doing, I'm just testing it with my standard boot flow to make sure nothing is broken for me.

Ryan,

I support Alison's patch order for her 32-bit patch sets. This feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

It gets EL2 working after the 2nd set. If there is room to clarify in the commit message, please kindly suggest.

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch

sequence.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

That's generally unacceptable on most projects I work on.

Keeping

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set,

does something break?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Yes, with the patches booting 64bit Linux with U-Boot running in

EL2

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Thanks for the confirmation.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

If you are referring the trusted firmware, we are following that direction. Just not fully up yet on some platform.

It is definitely not our intention to be cumbersome. Please point

out

Quoted 8 lines
Quoted 1 line

where it went sideway beside the trusted firmware.

Basically it boils down to the fact that you are the only platform that runs U-Boot in EL3 :).

If you want to keep the memory initialization inside of U-Boot, I think that's great. But you could either split that into SPL/EL2 or degrade yourself into EL2 as soon as possible by calling into an EL3

firmware.

Quoted 1 line

Whether you build that firmware as part of U-Boot (the stock one

could

Quoted 2 lines

be very trivial) or externally is not really too much of a problem.

Quoted 8 lines
Quoted 4 lines

Things like Alison's patches could then do a simple PSCI call into said
EL3 firmware to call into 32bit code in EL2 for example.

Basically I agree with you. U-Boot will run at EL2 as soon as we have the trusted firmware in place.

[Alison Wang] Thanks for all your comments.

For the issue about the tree would not be bisect-able, I have
a solution. Actually it is the root cause that 64-bit kernel could not boot up when U-Boot is running in EL2. I will move these codes from the third patch to the first patch.

ENTRY(armv8_switch_to_el2)

        switch_el x5, 1f, 0f, 0f

-0: ret

(quoted diff) +13 -1
+       /*
+        * x3 is kernel entry point or switch_to_el1
+         * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
+         * When running in EL2 now, jump to the
+         * address saved in x3.
+        */
+0:     br x3
 1:     armv8_switch_to_el2_m x3, x4, x5
 ENDPROC(armv8_switch_to_el2)
 
 ENTRY(armv8_switch_to_el1)
          switch_el x5, 0f, 1f, 0f
-0:     ret
+
+       /*
+         * x3 is kernel entry point. When running in EL1
+         * now, jump to the address saved in x3.
+        */
+0:     br x3
 1:     armv8_switch_to_el1_m x3, x4, x5
 ENDPROC(armv8_switch_to_el1)
Quoted 3 lines

With this re-order, the bitsect issue will be fixed and there is not a point that kernel could not boot up.

That sounds perfect.

Quoted 3 lines

If you all agree with this re-order, I will send out the v8 patch includes the first, second and third patches.

I haven't tried to understand this code, so I can't say if that order will work or not, but I'm very happy to test it if you produce a series like this.

Regards,
Ryan.

Quoted 3 lines

Best Regards,
Alison Wang

#20 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

In reply to Alison Wang
Quoted 11 lines · Alison Wang
Quoted 1 line

[Alison Wang] Thanks for all your comments.

For the issue about the tree would not be bisect-able, I have
a solution. Actually it is the root cause that 64-bit kernel could not boot up when U-Boot is running in EL2. I will move these codes from the third patch to the first patch.

ENTRY(armv8_switch_to_el2)

        switch_el x5, 1f, 0f, 0f

-0: ret

Review

Quoted 3 lines
(quoted diff) +3 -0
+       /*
+        * x3 is kernel entry point or switch_to_el1
+         * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.

I guess you meant EL2 here.

Quoted 19 lines
(quoted diff) +10 -1
+         * When running in EL2 now, jump to the
+         * address saved in x3.
+        */
+0:     br x3
 1:     armv8_switch_to_el2_m x3, x4, x5
 ENDPROC(armv8_switch_to_el2)
 
 ENTRY(armv8_switch_to_el1)
 	  switch_el x5, 0f, 1f, 0f
-0:     ret
+
+       /*
+         * x3 is kernel entry point. When running in EL1
+         * now, jump to the address saved in x3.
+        */
+0:     br x3
 1:     armv8_switch_to_el1_m x3, x4, x5
 ENDPROC(armv8_switch_to_el1)
Quoted 6 lines

With this re-order, the bitsect issue will be fixed and there is not a point that kernel could not boot up.

If you all agree with this re-order, I will send out the v8 patch includes the first, second and third patches.

Would it be a good idea to setup the simulator and verify booting process?

York

#19 lore raw

PATCH v7 1/2 armv8: Support loading 32-bit OS in AArch32 execution state

In reply to Ryan Harkin
Quoted 146 lines · Alison Wang
Quoted 14 lines
Quoted 14 lines · Alexander Graf
Quoted 13 lines · york sun
Quoted 10 lines · Alexander Graf
Quoted 9 lines · york sun
Quoted 6 lines · Ryan Harkin
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Yes, with the attached patch on top of your original 2 patches, everything works again. I tested on FVP Foundation and AEMv8 models and Juno R0, R1 and R2.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think it would be good to stack these three patches the way they are presented in the upstream tree because it would

not

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

be bisect-able. Some re-work or re-ordering would be needed.

Note: I haven't attempted to understand what any of this

code

Quoted 2 lines
Quoted 2 lines

is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

doing, I'm just testing it with my standard boot flow to

make

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

sure nothing is broken for me.

Ryan,

I support Alison's patch order for her 32-bit patch sets.

This

Quoted 49 lines
Quoted 49 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

feature doesn't exist before her first set. It is functional if you run U-Boot at EL3 after the first patch.

Which I don't do. I follow the boot flow recommended by ARM and it doesn't work for that setup, which I don't think is the right thing to do.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

It gets EL2 working after the 2nd set. If there is room to clarify in the commit message, please kindly suggest.

Well, I'm not the maintainer of the tree, but I wouldn't want to have a tree that wasn't bootable at any point in the patch

sequence.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

That's generally unacceptable on most projects I work on.

Keeping

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

the tree bisect-able to prove which commit caused a problem is considered to be a valuable tool.

Ryan,

Thanks for sharing your concern. I support git-bisect. It is valuable, no doubt. Let me try to understand the issue here. Without Alison's patches, everything boots OK. With her first set,

does something break?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Yes, with the patches booting 64bit Linux with U-Boot running in

EL2

Quoted 18 lines
Quoted 18 lines
Quoted 6 lines

breaks according to Ryan.

Quoted 2 lines

My understanding is 32-bit OS can boot. If existing 64-bit OS fails, then she needs to fix it.

That's his point :). And I concur.

Thanks for the confirmation.

Quoted 4 lines

(btw, you guys really should start thinking about following the ARM recommended boot model. It's pretty cumbersome to do everything different just for NXP)

If you are referring the trusted firmware, we are following that direction. Just not fully up yet on some platform.

It is definitely not our intention to be cumbersome. Please point

Quoted 8 lines
Quoted 8 lines

out

Quoted 7 lines
Quoted 1 line

where it went sideway beside the trusted firmware.

Basically it boils down to the fact that you are the only platform that runs U-Boot in EL3 :).

If you want to keep the memory initialization inside of U-Boot, I think that's great. But you could either split that into SPL/EL2

or

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

degrade yourself into EL2 as soon as possible by calling into an EL3

firmware.

Quoted 1 line

Whether you build that firmware as part of U-Boot (the stock one

could

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

be very trivial) or externally is not really too much of a problem.

Things like Alison's patches could then do a simple PSCI call into said
EL3 firmware to call into 32bit code in EL2 for example.

Basically I agree with you. U-Boot will run at EL2 as soon as we

have

Quoted 34 lines
Quoted 2 lines

the trusted firmware in place.

[Alison Wang] Thanks for all your comments.

For the issue about the tree would not be bisect-able, I have a solution. Actually it is the root cause that 64-bit kernel could not boot up when U-Boot is running in EL2. I will move these codes from the third patch to the first patch.

ENTRY(armv8_switch_to_el2)

        switch_el x5, 1f, 0f, 0f

-0: ret

(quoted diff) +13 -1
+       /*
+        * x3 is kernel entry point or switch_to_el1
+         * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
+         * When running in EL2 now, jump to the
+         * address saved in x3.
+        */
+0:     br x3
 1:     armv8_switch_to_el2_m x3, x4, x5
 ENDPROC(armv8_switch_to_el2)
 
 ENTRY(armv8_switch_to_el1)
          switch_el x5, 0f, 1f, 0f
-0:     ret
+
+       /*
+         * x3 is kernel entry point. When running in EL1
+         * now, jump to the address saved in x3.
+        */
+0:     br x3
 1:     armv8_switch_to_el1_m x3, x4, x5
 ENDPROC(armv8_switch_to_el1)
Quoted 1 line

With this re-order, the bitsect issue will be fixed and there is not

a

Quoted 2 lines

point that kernel could not boot up.

That sounds perfect.

Quoted 7 lines
Quoted 3 lines

If you all agree with this re-order, I will send out the v8 patch includes the first, second and third patches.

I haven't tried to understand this code, so I can't say if that order will work or not, but I'm very happy to test it if you produce a series like this.

[Alison Wang] Thanks for your support. V8 series is sent out.

Best Regards,
Alison Wang