aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2021-07-27 14:14:14 +0100
committerMark Rutland <mark.rutland@arm.com>2021-08-02 15:36:52 +0100
commit587b1c6e4c7104630d8353520bbc66bb0e235bbc (patch)
tree6d2219ce98eea55a373a730b05addeb1c551bac3
parent4a50f69c550473b989f0d38f096d4d9a3a6804c7 (diff)
downloadboot-wrapper-aarch64-587b1c6e4c7104630d8353520bbc66bb0e235bbc.tar.gz
Consistently use logical CPU IDs
In some places we assume that the cpu with MPIDR_EL1.Aff* == 0 is the same as logical CPU 0. While this is almost certainly true, it would be best to consistently use the logical ID. Add a new `this_cpu_logical_id()` helper, and use this in preference to checking the MPIDR_EL1.Aff* bits directly. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r--gic-v3.c4
-rw-r--r--gic.c3
-rw-r--r--include/cpu.h2
-rw-r--r--psci.c5
4 files changed, 6 insertions, 8 deletions
diff --git a/gic-v3.c b/gic-v3.c
index ae2d2bc..62f9676 100644
--- a/gic-v3.c
+++ b/gic-v3.c
@@ -101,8 +101,6 @@ void gic_secure_init_primary(void)
void gic_secure_init(void)
{
- uint32_t cpu = read_mpidr();
-
uint32_t sre;
/*
@@ -113,7 +111,7 @@ void gic_secure_init(void)
if (!has_gicv3_sysreg())
return;
- if (cpu == 0)
+ if (this_cpu_logical_id() == 0)
gic_secure_init_primary();
sre = gic_read_icc_sre();
diff --git a/gic.c b/gic.c
index a84779e..04d4289 100644
--- a/gic.c
+++ b/gic.c
@@ -31,14 +31,13 @@ void gic_secure_init(void)
{
unsigned int i;
- uint32_t cpu = read_mpidr();
void *gicd_base = (void *)GIC_DIST_BASE;
void *gicc_base = (void *)GIC_CPU_BASE;
/* Set local interrupts to Group 1 (those fields are banked) */
raw_writel(~0, gicd_base + GICD_IGROUPRn);
- if (cpu == 0) {
+ if (this_cpu_logical_id() == 0) {
uint32_t typer = raw_readl(gicd_base + GICD_TYPER);
/* Set SPIs to Group 1 */
diff --git a/include/cpu.h b/include/cpu.h
index 704d6d8..4bfb172 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -25,5 +25,7 @@
unsigned int find_logical_id(unsigned long mpidr);
+#define this_cpu_logical_id() find_logical_id(read_mpidr())
+
#endif /* !__ASSEMBLY__ */
#endif
diff --git a/psci.c b/psci.c
index e5d54b7..df5b0f2 100644
--- a/psci.c
+++ b/psci.c
@@ -35,7 +35,7 @@ static int psci_cpu_on(unsigned long target_mpidr, unsigned long address)
{
int ret;
unsigned int cpu = find_logical_id(target_mpidr);
- unsigned int this_cpu = find_logical_id(read_mpidr());
+ unsigned int this_cpu = this_cpu_logical_id();
if (cpu == MPIDR_INVALID)
return PSCI_RET_INVALID_PARAMETERS;
@@ -49,8 +49,7 @@ static int psci_cpu_on(unsigned long target_mpidr, unsigned long address)
static int psci_cpu_off(void)
{
- unsigned long mpidr = read_mpidr();
- unsigned int cpu = find_logical_id(mpidr);
+ unsigned int cpu = this_cpu_logical_id();
if (cpu == MPIDR_INVALID)
return PSCI_RET_DENIED;