From patchwork Fri Nov 18 01:57:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9435661 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 DFA1E60238 for ; Fri, 18 Nov 2016 02:32:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C74132972B for ; Fri, 18 Nov 2016 02:32:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB78929735; Fri, 18 Nov 2016 02:32:46 +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 6F23F2972B for ; Fri, 18 Nov 2016 02:32:45 +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 1c7Ywd-00045H-Gx; Fri, 18 Nov 2016 02:30:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7Ywb-00044u-Sc for xen-devel@lists.xen.org; Fri, 18 Nov 2016 02:30:25 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 4B/71-28694-1C76E285; Fri, 18 Nov 2016 02:30:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsVywNykWPdAul6 EwfoDKhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8afnoOMBb18FYdnGjYw3uXuYuTkEBKolLh/ fQUjiC0hwCtxZNkMVgg7QOLWhA1ANhdQTR+jROer7WBFbAKKEgcvHgIrEhGQlrj2+TIjSBGzw AJGicaLR5lBEsICXhKXV9xlA7FZBFQlJm/6wARi8wo4SrQ/2Ai1QU5iw+7/YEM5BZwkjq++zQ JxkaPE/qkfWCYw8i5gZFjFqFGcWlSWWqRraKSXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKy XnJ+7iREYDgxAsIPx8saAQ4ySHExKorzt0XoRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4P6UB 5QSLUtNTK9Iyc4CBCZOW4OBREuG9kQqU5i0uSMwtzkyHSJ1iVJQS5+0B6RMASWSU5sG1waLhE qOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5t4BM4cnMK4Gb/gpoMRPQ4j0COiCLSxIRUlINjH Lha3cvMHgt/MI76HxRksYKXzUT3bbwTpGPd5R3Waj8/XRQXzlg17ku7/f+O3dtzt159sqKkM+ GHy5cONnJZxC0XnMJtzWHnPLiHJMjxy4/1AwusnEMs/tz7dSOxfZOBY9trxsL5J+St4xs//Pw aWHQ7RquA/lHF+g+VXkieWvOlnSBrTNSlZRYijMSDbWYi4oTAZI/ItCBAgAA X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1479436221!60052313!2 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58701 invoked from network); 18 Nov 2016 02:30:24 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Nov 2016 02:30:24 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 17 Nov 2016 18:30:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,655,1473145200"; d="scan'208"; a="1070084826" Received: from unknown (HELO feng-bdw-de-pi.bj.intel.com) ([10.238.154.55]) by fmsmga001.fm.intel.com with ESMTP; 17 Nov 2016 18:30:17 -0800 From: Feng Wu To: xen-devel@lists.xen.org Date: Fri, 18 Nov 2016 09:57:18 +0800 Message-Id: <1479434244-10223-2-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1479434244-10223-1-git-send-email-feng.wu@intel.com> References: <1479434244-10223-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 v8 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 the hook permanently assigned. Signed-off-by: Feng Wu Reviewed-by: Konrad Rzeszutek Wilk --- v8: - Comments changes v7: - comments changes. 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 3d330b6..f3911f2 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -222,8 +222,14 @@ void vmx_pi_hooks_deassign(struct domain *d) 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; + + /* + * In fact, we could set 'd->arch.hvm_domain.vmx.pi_switch_to' to NULL + * in vmx_pi_switch_to() 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)