From: Feng Wu Subject: [RFC v2 10/15] vmx: Define two per-cpu variables Date: Fri, 8 May 2015 17:07:13 +0800 Message-ID: <1431076038-7497-11-git-send-email-feng.wu@intel.com> References: <1431076038-7497-1-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431076038-7497-1-git-send-email-feng.wu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: kevin.tian@intel.com, keir@xen.org, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, jbeulich@suse.com, yang.z.zhang@intel.com, Feng Wu List-Id: xen-devel@lists.xenproject.org This patch defines two per-cpu variables: blocked_vcpu: A list storing the vCPUs which were blocked on this pCPU. blocked_vcpu_lock: The spinlock to protect blocked_vcpu. Signed-off-by: Feng Wu --- xen/arch/x86/hvm/vmx/vmcs.c | 3 +++ xen/arch/x86/hvm/vmx/vmx.c | 7 +++++++ xen/include/asm-x86/hvm/vmx/vmx.h | 3 +++ 3 files changed, 13 insertions(+) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index f60a454..8166f08 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -585,6 +585,9 @@ int vmx_cpu_up(void) if ( cpu_has_vmx_vpid ) vpid_sync_all(); + INIT_LIST_HEAD(&per_cpu(blocked_vcpu, cpu)); + spin_lock_init(&per_cpu(blocked_vcpu_lock, cpu)); + return 0; } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 6c4f78c..2451ca5 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -82,6 +82,13 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content); static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content); static void vmx_invlpg_intercept(unsigned long vaddr); +/* + * We maintian a per-CPU linked-list of vCPU, so in PI wakeup handler we + * can find which vCPU should be waken up. + */ +DEFINE_PER_CPU(struct list_head, blocked_vcpu); +DEFINE_PER_CPU(spinlock_t, blocked_vcpu_lock); + uint8_t __read_mostly posted_intr_vector; static int vmx_domain_initialise(struct domain *d) diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index e4292cc..0d11f9c 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -30,6 +30,9 @@ #include #include +DECLARE_PER_CPU(struct list_head, blocked_vcpu); +DECLARE_PER_CPU(spinlock_t, blocked_vcpu_lock); + extern uint8_t posted_intr_vector; typedef union { -- 2.1.0