From: Jan Kiszka <[email protected]>

Wait for all expected CPUs to leave arch_entry. This allows to
collect CPU-specific information in arch_entry, such as parange
on ARM64, which will be needed early.

Signed-off-by: Jan Kiszka <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
---

V3:
 None
V2:
 Refine commit log

 hypervisor/setup.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/hypervisor/setup.c b/hypervisor/setup.c
index 9eaac20f..cb0ca7b1 100644
--- a/hypervisor/setup.c
+++ b/hypervisor/setup.c
@@ -28,7 +28,7 @@ static const __attribute__((aligned(PAGE_SIZE))) u8 
empty_page[PAGE_SIZE];
 
 static DEFINE_SPINLOCK(init_lock);
 static unsigned int master_cpu_id = -1;
-static volatile unsigned int initialized_cpus;
+static volatile unsigned int entered_cpus, initialized_cpus;
 static volatile int error;
 
 static void init_early(unsigned int cpu_id)
@@ -177,6 +177,21 @@ int entry(unsigned int cpu_id, struct per_cpu *cpu_data)
 
        spin_lock(&init_lock);
 
+       /*
+        * If this CPU is last, make sure everything was committed before we
+        * signal the other CPUs spinning on entered_cpus that they can
+        * continue.
+        */
+       memory_barrier();
+       entered_cpus++;
+
+       spin_unlock(&init_lock);
+
+       while (entered_cpus < hypervisor_header.online_cpus)
+               cpu_relax();
+
+       spin_lock(&init_lock);
+
        if (master_cpu_id == -1) {
                /* Only the master CPU, the first to enter this
                 * function, performs system-wide initializations. */
-- 
2.14.1

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to