From patchwork Fri Oct 28 02:37:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9400991 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 B5DAC605EE for ; Fri, 28 Oct 2016 03:12:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A41962A4DE for ; Fri, 28 Oct 2016 03:12:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 975612A4E0; Fri, 28 Oct 2016 03:12:11 +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 4398A2A4DE for ; Fri, 28 Oct 2016 03:12:11 +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 1bzxXj-0006Jz-BR; Fri, 28 Oct 2016 03:09:19 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bzxXi-0006JL-4N for xen-devel@lists.xen.org; Fri, 28 Oct 2016 03:09:18 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 4F/8B-21485-D51C2185; Fri, 28 Oct 2016 03:09:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsVywNwkQjfmoFC EwY8GW4slHxezODB6HN39mymAMYo1My8pvyKBNaN5VStjwUPeikvnNrE0MO7m7mLk5BASqJRY c3MTK4gtIcArcWTZDCCbA8gOkDh5K7uLkQuopI9RYvrKiywgNWwCihIHLx4CqxcRkJa49vkyI 0gRs8ACRonGi0eZQZqFBbwktq80A6lhEVCVmNd0jg3E5hVwkPi3/CobxC45iQ27/zOC2JwCjh I/D91hhLjHQWLOjlesExh5FzAyrGLUKE4tKkst0jU20EsqykzPKMlNzMzRNTQw08tNLS5OTE/ NSUwq1kvOz93ECAwGBiDYwfh3beAhRkkOJiVR3guThSKE+JLyUyozEosz4otKc1KLDzHKcHAo SfA+2Q+UEyxKTU+tSMvMAYYlTFqCg0dJhHf7PqA0b3FBYm5xZjpE6hSjopQ4r8YBoIQASCKjN A+uDRYLlxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMuxZkCk9mXgnc9FdAi5mAFk9PFwBZXJ KIkJJqYJRNyl6nIawgsP+95sSkjO92DlnP9bYEpMbvCmx6vvc4U6LZvYVnUt/8veGXzdzL47s zNWWlavb/3p71rhUfNq/4XHbw3QujukX33DaetXP5Fljmpr9W8nfW48OLZs6fzG6vPNP/kkhN 3y2m8/6P3usYfdU/tyNh9qJLMbErVq/elXm6VO609xElluKMREMt5qLiRABnP65fgAIAAA== X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1477624154!67798050!2 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31480 invoked from network); 28 Oct 2016 03:09:16 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-16.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 28 Oct 2016 03:09:16 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 27 Oct 2016 20:09:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,407,1473145200"; d="scan'208"; a="1077010803" Received: from unknown (HELO feng-bdw-de-pi.bj.intel.com) ([10.238.154.53]) by fmsmga002.fm.intel.com with ESMTP; 27 Oct 2016 20:09:11 -0700 From: Feng Wu To: xen-devel@lists.xen.org Date: Fri, 28 Oct 2016 10:37:33 +0800 Message-Id: <1477622259-3476-2-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1477622259-3476-1-git-send-email-feng.wu@intel.com> References: <1477622259-3476-1-git-send-email-feng.wu@intel.com> Cc: kevin.tian@intel.com, Feng Wu , george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v6 1/7] VMX: Permanently assign PI hook vmx_pi_switch_to() 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 PI hook vmx_pi_switch_to() is needed even when any previously assigned device is detached from the domain. Since 'SN' bit is also used to control the CPU side PI and we change the state of SN bit in these two functions, then evaluate this bit in vmx_deliver_posted_intr() when trying to deliver the interrupt in posted way via software. The problem is if we deassign the hooks while the vCPU is runnable in the runqueue with 'SN' set, all the furture notificaton event will be suppressed. This patch makes these two hooks statically assigned. Signed-off-by: Feng Wu --- v6: - Adjust the comments and wording. v5: - Zap "pi_switch_from" hook v4: - Don't zap vmx_pi_switch_from() and vmx_pi_switch_to() when any previously assigned device is detached from the domain. - Comments changes. xen/arch/x86/hvm/vmx/vmx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 3d330b6..faaa987 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -221,9 +221,14 @@ void vmx_pi_hooks_deassign(struct domain *d) ASSERT(d->arch.hvm_domain.vmx.vcpu_block); d->arch.hvm_domain.vmx.vcpu_block = NULL; - d->arch.hvm_domain.vmx.pi_switch_from = NULL; - d->arch.hvm_domain.vmx.pi_switch_to = NULL; d->arch.hvm_domain.vmx.pi_do_resume = NULL; + d->arch.hvm_domain.vmx.pi_switch_from = NULL; + + /* + * In fact, we can remove 'vmx_pi_switch_to' inside itself if no new device + * is in the process of getting assigned and "from" hook is NULL. However, + * it is not straightforward to find a clear solution, so just leave it here. + */ } static int vmx_domain_initialise(struct domain *d)