blob: b63d8d1d3f947b0bd0a67906e8f4e1569bc3b538 [file] [log] [blame]
Andrew Geissler9347dd42023-03-03 12:38:41 -06001From fa73d885be85eee4369b292ec601e7b024a68807 Mon Sep 17 00:00:00 2001
Brad Bishopbec4ebc2022-08-03 09:55:16 -04002From: Jaxson Han <jaxson.han@arm.com>
3Date: Tue, 2 Nov 2021 10:48:39 +0800
4Subject: [PATCH] PSCI: Apply flush cache after setting branch_data
5
6For v8-R64, Hypervisor calls boot-wrapper's PSCI service using simple
7function call (instead of hvc).
8
9In this case, hypervisor's main core has enabled MPU and cache, but
10the secondary cores which are spinning have not enabled cache.
11That means if the main core set the branch_data to 1 to boot other
12cores, the secondary cores cannot see the change of branch_data and
13also cannot break the spin.
14
15Thus, the PSCI service in boot-wrapper needs a cache flush after
16setting branch_data in order to let other cores see the change.
17
18Issue-ID: SCM-3816
19Upstream-Status: Inappropriate [other]
20 Implementation pending further discussion
21Signed-off-by: Jaxson Han <jaxson.han@arm.com>
22Change-Id: Ifc282091c54d8fb2ffdb8cfa7fd3ffc1f4be717e
23---
24 common/psci.c | 6 ++++++
25 1 file changed, 6 insertions(+)
26
27diff --git a/common/psci.c b/common/psci.c
28index 945780b..6efc695 100644
29--- a/common/psci.c
30+++ b/common/psci.c
31@@ -24,12 +24,18 @@ static unsigned long branch_table[NR_CPUS];
32
33 bakery_ticket_t branch_table_lock[NR_CPUS];
34
35+static inline void flush_per_cpu_data(void *data)
36+{
37+ asm volatile ("dc cvac, %0" : : "r" (data));
38+}
39+
40 static int psci_store_address(unsigned int cpu, unsigned long address)
41 {
42 if (branch_table[cpu] != PSCI_ADDR_INVALID)
43 return PSCI_RET_ALREADY_ON;
44
45 branch_table[cpu] = address;
46+ flush_per_cpu_data((void*)&(branch_table[cpu]));
47 return PSCI_RET_SUCCESS;
48 }
49