Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 1 | From fa73d885be85eee4369b292ec601e7b024a68807 Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Jaxson Han <jaxson.han@arm.com> |
| 3 | Date: Tue, 2 Nov 2021 10:48:39 +0800 |
| 4 | Subject: [PATCH] PSCI: Apply flush cache after setting branch_data |
| 5 | |
| 6 | For v8-R64, Hypervisor calls boot-wrapper's PSCI service using simple |
| 7 | function call (instead of hvc). |
| 8 | |
| 9 | In this case, hypervisor's main core has enabled MPU and cache, but |
| 10 | the secondary cores which are spinning have not enabled cache. |
| 11 | That means if the main core set the branch_data to 1 to boot other |
| 12 | cores, the secondary cores cannot see the change of branch_data and |
| 13 | also cannot break the spin. |
| 14 | |
| 15 | Thus, the PSCI service in boot-wrapper needs a cache flush after |
| 16 | setting branch_data in order to let other cores see the change. |
| 17 | |
| 18 | Issue-ID: SCM-3816 |
| 19 | Upstream-Status: Inappropriate [other] |
| 20 | Implementation pending further discussion |
| 21 | Signed-off-by: Jaxson Han <jaxson.han@arm.com> |
| 22 | Change-Id: Ifc282091c54d8fb2ffdb8cfa7fd3ffc1f4be717e |
| 23 | --- |
| 24 | common/psci.c | 6 ++++++ |
| 25 | 1 file changed, 6 insertions(+) |
| 26 | |
| 27 | diff --git a/common/psci.c b/common/psci.c |
| 28 | index 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 | |