From ebeb6de6d1d566a950249bc104065c40878acf58 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@citrix.com>
Date: Wed, 25 Sep 2013 13:18:27 +0200
Subject: [PATCH 1/3] xen: initialize cpu_ops correctly

Current implementation has two problems, the first one being that the
initialization of cpu_ops races with the release of APs, because they
are both called at SI_SUB_SMP order SI_ORDER_FIRST, so under certain
circumstances the set of cpu_ops.cpu_init might happen after the AP
has already been launched. The second problem is that the cpu_ops
init/resume should be set even if we are not using Xen IPIs.
---
 sys/x86/xen/hvm.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c
index 2286cf0..8e7f8ad 100644
--- a/sys/x86/xen/hvm.c
+++ b/sys/x86/xen/hvm.c
@@ -116,12 +116,6 @@ struct xen_ipi_handler
 /*-------------------------------- Global Data -------------------------------*/
 enum xen_domain_type xen_domain_type = XEN_NATIVE;
 
-struct cpu_ops xen_hvm_cpu_ops = {
-	.ipi_vectored	= xen_ipi_vectored,
-	.cpu_init	= xen_hvm_cpu_init,
-	.cpu_resume	= xen_hvm_cpu_resume
-};
-
 static MALLOC_DEFINE(M_XENHVM, "xen_hvm", "Xen HVM PV Support");
 
 #ifdef SMP
@@ -535,7 +529,7 @@ xen_setup_cpus(void)
 		xen_cpu_ipi_init(i);
 
 	/* Set the xen pv ipi ops to replace the native ones */
-	cpu_ops = xen_hvm_cpu_ops;
+	cpu_ops.ipi_vectored = xen_ipi_vectored;
 }
 #endif
 
@@ -699,6 +693,8 @@ xen_hvm_init(enum xen_hvm_init_type init_type)
 			return;
 
 		setup_xen_features();
+		cpu_ops.cpu_init = xen_hvm_cpu_init;
+		cpu_ops.cpu_resume = xen_hvm_cpu_resume;
 		break;
 	case XEN_HVM_INIT_RESUME:
 		if (error != 0)
-- 
1.7.7.5 (Apple Git-26)

