Skip to contentSkip to conversation

ARM: HYP/non-sec: Make a variable as a local one

PATCH New Tang Yuantian 2 participants 3 messages Sep 18, 2014 – Sep 19, 2014 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: HYP/non-sec: Make a variable as a local one

Defining variable gic_dist_addr as a globe one prevents some functions, which use this variable, from being used before relocation which happened in the deep sleep resume process on Freescale SoC platforms.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/virt-v7.c +7 -2
index 651ca40..b69fd37 100644
@@ -15,8 +15,6 @@
 #include <asm/io.h>
 #include <asm/secure.h>
 
-unsigned long gic_dist_addr;
-
 static unsigned int read_id_pfr1(void)
 {
 	unsigned int reg;
@@ -68,6 +66,12 @@ static void kick_secondary_cpus_gic(unsigned long gicdaddr)
 
 void __weak smp_kick_all_cpus(void)
 {
+	unsigned long gic_dist_addr;
+
+	gic_dist_addr = get_gicd_base_address();
+	if (gic_dist_addr == -1)
+		return;
+
 	kick_secondary_cpus_gic(gic_dist_addr);
 }
 
@@ -75,6 +79,7 @@ int armv7_init_nonsec(void)
 {
 	unsigned int reg;
 	unsigned itlinesnr, i;
+	unsigned long gic_dist_addr;
 
 	/* check whether the CPU supports the security extensions */
 	reg = read_id_pfr1();
Signature · 1 line
2.1.0.27.g96db324
#1 lore raw

PATCH 1/1 ARM: HYP/non-sec: Make a variable as a local one

Hi Tang,

Please fix subject / commit summary to indicate which variable is to be made local.

Quoted 37 lines · Tang Yuantian

Defining variable gic_dist_addr as a globe one prevents some functions, which use this variable, from being used before relocation which happened in the deep sleep resume process on Freescale SoC platforms.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/virt-v7.c +6 -2
index 651ca40..b69fd37 100644
@@ -15,8 +15,6 @@
 #include <asm/io.h>
 #include <asm/secure.h>
 
-unsigned long gic_dist_addr;
-
 static unsigned int read_id_pfr1(void)
 {
 	unsigned int reg;
@@ -68,6 +66,12 @@ static void kick_secondary_cpus_gic(unsigned long gicdaddr)
 
 void __weak smp_kick_all_cpus(void)
 {
+	unsigned long gic_dist_addr;
+
+	gic_dist_addr = get_gicd_base_address();
+	if (gic_dist_addr == -1)
+		return;
+
 	kick_secondary_cpus_gic(gic_dist_addr);
 }
 

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

Quoted 7 lines
arch/arm/cpu/armv7/virt-v7.c +1 -0
@@ -75,6 +79,7 @@ int armv7_init_nonsec(void)
 {
 	unsigned int reg;
 	unsigned itlinesnr, i;
+	unsigned long gic_dist_addr;
 
 	/* check whether the CPU supports the security extensions */
 	reg = read_id_pfr1();

Did you check that the global was not used as a common variable between the functions?

Amicalement,

Signature · 1 line
Albert.
#2 lore raw

PATCH 1/1 ARM: HYP/non-sec: Make a variable as a local one

Quoted 57 lines

-----Original Message-----
From: Albert ARIBAUD [mailto:albert.u.boot at aribaud.net]
Sent: Thursday, September 18, 2014 5:44 PM
To: Tang Yuantian-B29983
Cc: andre.przywara at linaro.org; ijc at hellion.org.uk; marc.zyngier at arm.com; u-boot at lists.denx.de; Jin Zhengxiong-R64188
Subject: Re: [PATCH] ARM: HYP/non-sec: Make a variable as a local one

Hi Tang,

Please fix subject / commit summary to indicate which variable is to be made local.

Quoted 41 lines · Tang Yuantian

Defining variable gic_dist_addr as a globe one prevents some functions, which use this variable, from being used before relocation which happened in the deep sleep resume process on Freescale SoC platforms.

---
 arch/arm/cpu/armv7/virt-v7.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/virt-v7.c index 651ca40..b69fd37 100644

arch/arm/cpu/armv7/virt-v7.c +7 -2
@@ -15,8 +15,6 @@
 #include <asm/io.h>
 #include <asm/secure.h>
 
-unsigned long gic_dist_addr;
-
 static unsigned int read_id_pfr1(void)  {
 	unsigned int reg;
@@ -68,6 +66,12 @@ static void kick_secondary_cpus_gic(unsigned long
 gicdaddr)
 
 void __weak smp_kick_all_cpus(void)
 {
+	unsigned long gic_dist_addr;
+
+	gic_dist_addr = get_gicd_base_address();
+	if (gic_dist_addr == -1)
+		return;
+
 	kick_secondary_cpus_gic(gic_dist_addr);
 }
@@ -75,6 +79,7 @@ int armv7_init_nonsec(void)  {
 	unsigned int reg;
 	unsigned itlinesnr, i;
+	unsigned long gic_dist_addr;
 
Quoted 6 lines

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

Quoted 2 lines
arch/arm/cpu/armv7/virt-v7.c +0 -0
 	/* check whether the CPU supports the security extensions */
 	reg = read_id_pfr1();

Did you check that the global was not used as a common variable between the functions?

Yes, I grep it globally. It was referred by only 2 places which are both in virt-v7.c file.

I will fix the subject.

Thanks,
Yuantian

Quoted 3 lines

Amicalement,
--
Albert.