Skip to contentSkip to conversation

ARM: HYP/non-sec: relocation before enable secondary cores

PATCH New Peng Fan 5 participants 5 messages Feb 4, 2015 – Mar 27, 2015 Arm (32-bit)

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 ARM: HYP/non-sec: relocation before enable secondary cores

If CONFIG_ARMV7_PSCI is not defined and CONFIG_ARMV7_SECURE_BASE is defined, smp_kicl_all_cpus may enable secondary cores and runs into secure_ram_addr( _smp_pen), before code is relocated to secure ram.
So need relocation to secure ram before enable secondary cores.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/virt-v7.c +8 -1
index b69fd37..4cb8806 100644
@@ -112,13 +112,20 @@ int armv7_init_nonsec(void)
 	for (i = 1; i <= itlinesnr; i++)
 		writel((unsigned)-1, gic_dist_addr + GICD_IGROUPRn + 4 * i);
 
+	/*
+	 * Relocate secure section before any cpu runs in secure ram.
+	 * smp_kick_all_cpus may enable other cores and runs into secure
+	 * ram, so need to relocate secure section before enabling other
+	 * cores.
+	 */
+	relocate_secure_section();
+
 #ifndef CONFIG_ARMV7_PSCI
 	smp_set_core_boot_addr((unsigned long)secure_ram_addr(_smp_pen), -1);
 	smp_kick_all_cpus();
 #endif
 
 	/* call the non-sec switching code on this CPU also */
-	relocate_secure_section();
 	secure_ram_addr(_nonsec_init)();
 	return 0;
 }
Signature · 1 line
1.8.4
#1 lore raw

PATCH 1/1 ARM: HYP/non-sec: relocation before enable secondary cores

Quoted 27 lines · Peng Fan

If CONFIG_ARMV7_PSCI is not defined and CONFIG_ARMV7_SECURE_BASE is defined, smp_kicl_all_cpus may enable secondary cores and runs into secure_ram_addr( _smp_pen), before code is relocated to secure ram.
So need relocation to secure ram before enable secondary cores.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/virt-v7.c +8 -0
index b69fd37..4cb8806 100644
@@ -112,13 +112,20 @@ int armv7_init_nonsec(void)
 	for (i = 1; i <= itlinesnr; i++)
 		writel((unsigned)-1, gic_dist_addr + GICD_IGROUPRn + 4 * i);
 
+	/*
+	 * Relocate secure section before any cpu runs in secure ram.
+	 * smp_kick_all_cpus may enable other cores and runs into secure
+	 * ram, so need to relocate secure section before enabling other
+	 * cores.
+	 */
+	relocate_secure_section();
+

arch/arm/cpu/armv7/virt-v7.c int armv7_init_nonsec(void) · line 131

Quoted 10 lines
arch/arm/cpu/armv7/virt-v7.c +0 -1
 #ifndef CONFIG_ARMV7_PSCI
 	smp_set_core_boot_addr((unsigned long)secure_ram_addr(_smp_pen), -1);
 	smp_kick_all_cpus();
 #endif
 
 	/* call the non-sec switching code on this CPU also */
-	relocate_secure_section();
 	secure_ram_addr(_nonsec_init)();
 	return 0;
 }

Seems like a sensible thing to do. FWIW:

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#2 lore raw

PATCH 1/1 ARM: HYP/non-sec: relocation before enable secondary cores

Hi, Albert and Tom

Quoted 40 lines · Marc Zyngier
Quoted 27 lines · Peng Fan

If CONFIG_ARMV7_PSCI is not defined and CONFIG_ARMV7_SECURE_BASE is defined, smp_kicl_all_cpus may enable secondary cores and runs into secure_ram_addr( _smp_pen), before code is relocated to secure ram.
So need relocation to secure ram before enable secondary cores.

---
  arch/arm/cpu/armv7/virt-v7.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/virt-v7.c +8 -0
index b69fd37..4cb8806 100644
@@ -112,13 +112,20 @@ int armv7_init_nonsec(void)
  	for (i = 1; i <= itlinesnr; i++)
  		writel((unsigned)-1, gic_dist_addr + GICD_IGROUPRn + 4 * i);
 
+	/*
+	 * Relocate secure section before any cpu runs in secure ram.
+	 * smp_kick_all_cpus may enable other cores and runs into secure
+	 * ram, so need to relocate secure section before enabling other
+	 * cores.
+	 */
+	relocate_secure_section();
+

arch/arm/cpu/armv7/virt-v7.c int armv7_init_nonsec(void) · line 131

Quoted 10 lines
arch/arm/cpu/armv7/virt-v7.c +0 -1
  #ifndef CONFIG_ARMV7_PSCI
  	smp_set_core_boot_addr((unsigned long)secure_ram_addr(_smp_pen), -1);
  	smp_kick_all_cpus();
  #endif
 
  	/* call the non-sec switching code on this CPU also */
-	relocate_secure_section();
  	secure_ram_addr(_nonsec_init)();
  	return 0;
  }

Seems like a sensible thing to do. FWIW:

Quoted 1 line

Just kindly remind. Will this patch be merged into u-boot-arm git repo or directly into u-boot master git repo?

Quoted 2 lines
	M.

Thanks,
Peng.

#3 lore raw

PATCH 1/1 ARM: HYP/non-sec: relocation before enable secondary cores

Quoted 41 lines · Peng Fan

Hi, Albert and Tom

Quoted 38 lines · Marc Zyngier
Quoted 25 lines · Peng Fan

If CONFIG_ARMV7_PSCI is not defined and CONFIG_ARMV7_SECURE_BASE is defined, smp_kicl_all_cpus may enable secondary cores and runs into secure_ram_addr( _smp_pen), before code is relocated to secure ram.
So need relocation to secure ram before enable secondary cores.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/virt-v7.c +8 -0
index b69fd37..4cb8806 100644
@@ -112,13 +112,20 @@ int armv7_init_nonsec(void)
 	for (i = 1; i <= itlinesnr; i++)
 		writel((unsigned)-1, gic_dist_addr + GICD_IGROUPRn + 4 * i);
+	/*
+	 * Relocate secure section before any cpu runs in secure ram.
+	 * smp_kick_all_cpus may enable other cores and runs into secure
+	 * ram, so need to relocate secure section before enabling other
+	 * cores.
+	 */
+	relocate_secure_section();
+

arch/arm/cpu/armv7/virt-v7.c int armv7_init_nonsec(void) · line 130

Quoted 10 lines
arch/arm/cpu/armv7/virt-v7.c +0 -1
 #ifndef CONFIG_ARMV7_PSCI
 	smp_set_core_boot_addr((unsigned long)secure_ram_addr(_smp_pen), -1);
 	smp_kick_all_cpus();
 #endif
 	/* call the non-sec switching code on this CPU also */
-	relocate_secure_section();
 	secure_ram_addr(_nonsec_init)();
 	return 0;
 }
 

Seems like a sensible thing to do. FWIW:

Quoted 3 lines
Quoted 1 line

Just kindly remind. Will this patch be merged into u-boot-arm git repo or directly into u-boot master git repo?

This is a core ARM thing so I'm expecting Albert to pick it up. Albert? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150213/cf4494bc/attachment.sig>
#4 lore raw

PATCH 1/1 ARM: HYP/non-sec: relocation before enable secondary cores

Hello Tom,

Quoted 42 lines · Tom Rini
Quoted 41 lines · Peng Fan

Hi, Albert and Tom

Quoted 38 lines · Marc Zyngier
Quoted 25 lines · Peng Fan

If CONFIG_ARMV7_PSCI is not defined and CONFIG_ARMV7_SECURE_BASE is defined, smp_kicl_all_cpus may enable secondary cores and runs into secure_ram_addr( _smp_pen), before code is relocated to secure ram.
So need relocation to secure ram before enable secondary cores.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/virt-v7.c +8 -0
index b69fd37..4cb8806 100644
@@ -112,13 +112,20 @@ int armv7_init_nonsec(void)
 	for (i = 1; i <= itlinesnr; i++)
 		writel((unsigned)-1, gic_dist_addr + GICD_IGROUPRn + 4 * i);
+	/*
+	 * Relocate secure section before any cpu runs in secure ram.
+	 * smp_kick_all_cpus may enable other cores and runs into secure
+	 * ram, so need to relocate secure section before enabling other
+	 * cores.
+	 */
+	relocate_secure_section();
+

arch/arm/cpu/armv7/virt-v7.c int armv7_init_nonsec(void) · line 130

Quoted 10 lines
arch/arm/cpu/armv7/virt-v7.c +0 -1
 #ifndef CONFIG_ARMV7_PSCI
 	smp_set_core_boot_addr((unsigned long)secure_ram_addr(_smp_pen), -1);
 	smp_kick_all_cpus();
 #endif
 	/* call the non-sec switching code on this CPU also */
-	relocate_secure_section();
 	secure_ram_addr(_nonsec_init)();
 	return 0;
 }
 

Seems like a sensible thing to do. FWIW:

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Just kindly remind. Will this patch be merged into u-boot-arm git repo or directly into u-boot master git repo?

This is a core ARM thing so I'm expecting Albert to pick it up. Albert? Thanks!

Signature · 1 line
Tom

Applied (for a while now, actually) to u-boot-arm/master, thanks!

Amicalement,

Signature · 1 line
Albert.