From patchwork Thu May 26 13:39:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9137009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C083607D7 for ; Thu, 26 May 2016 14:05:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6099827984 for ; Thu, 26 May 2016 14:05:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55825282F2; Thu, 26 May 2016 14:05:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 12CF627984 for ; Thu, 26 May 2016 14:05:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5vsr-0006iG-He; Thu, 26 May 2016 14:03:33 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5vsp-0006fE-O0 for xen-devel@lists.xen.org; Thu, 26 May 2016 14:03:31 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id F9/82-02835-33207475; Thu, 26 May 2016 14:03:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsVywNykQteYyT3 cYPZXNoslHxezODB6HN39mymAMYo1My8pvyKBNePT2f3MBQd4Kx59PcDcwPiPq4uRg0NIoFLi 0oWoLkZODgkBXokjy2awQtj+Eqd+zWMGsYUE6iU+zZrNAmKzCShKHLx4CKxGREBa4trny4xdj FwczAInGCV+T5kJlhAWCJU4/+QBmM0ioCqx6dMZsEG8Ag4SLxuWMkMskJPYsPs/I4jNKeAo8e /7aUaIZQ4SD+aeYZzAyLuAkWEVo3pxalFZapGusV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJ SsV5yfu4mRmAoMADBDsaOf06HGCU5mJREecXF3cKF+JLyUyozEosz4otKc1KLDzHKcHAoSfBe OgCUEyxKTU+tSMvMAQYlTFqCg0dJhHc/g3u4EG9xQWJucWY6ROoUo6KUOO9akIQASCKjNA+uD RYJlxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMewdkCk9mXgnc9FdAi5mAFvt/cQZZXJKIkJ JqYNRoeaVh3xzZWGa5xIb96PmXD+doBi15YZu7to354f5nZRu8OhRCVmz79/865/v4/Mxa19N B+2++e/T+waNsCfvW/4teR3RPzvkVx6HuPOmbAJtiYNuhtY/+GBYlTNabktEvrGk9NXTKosul 72fx7X/R+XeaS/ONm7GrlHWOFcVEd4cbhYY2tyixFGckGmoxFxUnAgD+J54XfwIAAA== X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1464271404!16005351!4 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22762 invoked from network); 26 May 2016 14:03:30 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-9.tower-21.messagelabs.com with SMTP; 26 May 2016 14:03:30 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 26 May 2016 07:03:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,367,1459839600"; d="scan'208";a="110948268" Received: from feng-bdw-de-pi.bj.intel.com ([10.238.154.60]) by fmsmga004.fm.intel.com with ESMTP; 26 May 2016 07:03:28 -0700 From: Feng Wu To: xen-devel@lists.xen.org Date: Thu, 26 May 2016 21:39:13 +0800 Message-Id: <1464269954-8056-4-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1464269954-8056-1-git-send-email-feng.wu@intel.com> References: <1464269954-8056-1-git-send-email-feng.wu@intel.com> Cc: kevin.tian@intel.com, keir@xen.org, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, jbeulich@suse.com, Feng Wu Subject: [Xen-devel] [PATCH v2 3/4] VMX: Assign the right value to 'NDST' field in a concern case X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Normally, in vmx_cpu_block() 'NDST' filed should have the same value with 'dest' or 'MASK_INSR(dest, PI_xAPIC_NDST_MASK)' depending on whether x2apic is enabled. However, in the following scenario, 'NDST' has different value: 'vcpu_block' hook gets assigned in vmx_pi_hooks_assign(), but all other three PI hooks have not been assigned or not been excuted yet. And during this interval, we are running in vmx_vcpu_block(), then 'NDST' may have different value. This patch fix this concern case. Signed-off-by: Feng Wu --- xen/arch/x86/hvm/vmx/vmx.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b01128a..662b38d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -146,8 +146,19 @@ static void vmx_vcpu_block(struct vcpu *v) dest = cpu_physical_id(v->processor); - ASSERT(pi_desc->ndst == - (x2apic_enabled ? dest : MASK_INSR(dest, PI_xAPIC_NDST_MASK))); + /* + * Normally, 'NDST' filed should have the same value with dest or + * MASK_INSR(dest, PI_xAPIC_NDST_MASK) depending on whether x2apic is + * enabled. However, in the following scenario, 'NDST' has different + * value: + * + * 'vcpu_block' hook gets assigned in vmx_pi_hooks_assign(), but all + * other three PI hooks have not been assigned or not been excuted yet. + * And during this interval, we get here in this function, then 'NDST' + * may have different value. + */ + write_atomic(&pi_desc->ndst, + x2apic_enabled ? dest : MASK_INSR(dest, PI_xAPIC_NDST_MASK)); write_atomic(&pi_desc->nv, pi_wakeup_vector); }