From: Feng Wu Subject: [RFC v1 10/15] vmx: Define two per-cpu variants Date: Wed, 25 Mar 2015 20:31:52 +0800 Message-ID: <1427286717-4093-11-git-send-email-feng.wu@intel.com> References: <1427286717-4093-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: <1427286717-4093-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: yang.z.zhang@intel.com, Feng Wu , kevin.tian@intel.com, keir@xen.org, JBeulich@suse.com List-Id: xen-devel@lists.xenproject.org This patch defines two per-cpu variants: blocked_vcpu_on_cpu: A list storing the vCPUs which were blocked on this pCPU. blocked_vcpu_on_cpu_lock: The spinlock to protect blocked_vcpu_on_cpu. 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 942f4b7..1345e69 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_on_cpu, cpu)); + spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu)); + return 0; } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index e1c55ce..ff5544d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -81,6 +81,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_on_cpu); +DEFINE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_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 3cd75eb..e643c3c 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_on_cpu); +DECLARE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock); + extern uint8_t posted_intr_vector; typedef union { -- 2.1.0