From patchwork Wed Mar 8 15:33:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 9611471 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 66C3460414 for ; Wed, 8 Mar 2017 15:54:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 667402846A for ; Wed, 8 Mar 2017 15:54:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B5C02857C; Wed, 8 Mar 2017 15:54:43 +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 21A912846A for ; Wed, 8 Mar 2017 15:54:42 +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 1cldtK-0003Og-4b; Wed, 08 Mar 2017 15:52:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cldtI-0003OM-M4 for xen-devel@lists.xen.org; Wed, 08 Mar 2017 15:52:40 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 83/A4-27678-7C820C85; Wed, 08 Mar 2017 15:52:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXS1tYhr3tM40C EwdR3ghZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8acMx9YCu7yVSw+uIqtgfEidxcjJ4eQQIXE tN+vWEBsCQFeiSPLZrBC2H4STb2rgeJcQDXtjBJ77+9iBkmwCWhL/Fj9mxHEFhGQlrj2+TIjS BGzQD+jxLxHTWDdwgKhEo/fTmYHsVkEVCVad3eBNfAKeElsnX6TEWKDnMTJY5PB6jkFvCWauq 4wQlzkJfF79U6mCYy8CxgZVjFqFKcWlaUW6Rob6CUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCY V6yXn525iBAYEAxDsYPy7NvAQoyQHk5Io71XVAxFCfEn5KZUZicUZ8UWlOanFhxg1ODgEetes vsAoxZKXn5eqJMG7WB2oTrAoNT21Ii0zBxiyMKUSHDxKIrwPQdK8xQWJucWZ6RCpU4yKUuK85 0ESAiCJjNI8uDZYnFxilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMO9ykCk8mXklcNNfAS1mAl qs7boXZHFJIkJKqoFRXy54T9+Nii9idw4turN654dZTT+1fLmXC7sdqe1/NSfHO+Gk2v4L4oq z/Pr8f5x53FO1ozhkqsbHgLiZEguvHI9TsjqpeviKxFPrEzuP1jlz+whuufN79jKPx6x6KWvn +pz79+UXU10CU2prx587ckd8jjlFzMzf5uS4yf3qCh/9pH037hScU2Ipzkg01GIuKk4EAG5Fd MCOAgAA X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1488988356!57815375!1 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8220 invoked from network); 8 Mar 2017 15:52:37 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-3.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Mar 2017 15:52:37 -0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP; 08 Mar 2017 07:52:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,264,1486454400"; d="scan'208";a="65498295" Received: from zhangyu-optiplex-9020.bj.intel.com ([10.238.135.159]) by orsmga004.jf.intel.com with ESMTP; 08 Mar 2017 07:52:34 -0800 From: Yu Zhang To: xen-devel@lists.xen.org Date: Wed, 8 Mar 2017 23:33:48 +0800 Message-Id: <1488987232-12349-2-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1488987232-12349-1-git-send-email-yu.c.zhang@linux.intel.com> References: <1488987232-12349-1-git-send-email-yu.c.zhang@linux.intel.com> Cc: Andrew Cooper , Paul Durrant , zhiyuan.lv@intel.com, Jan Beulich Subject: [Xen-devel] [PATCH v7 1/5] x86/ioreq server: Release the p2m lock after mmio is handled. 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 Routine hvmemul_do_io() may need to peek the p2m type of a gfn to select the ioreq server. For example, operations on gfns with p2m_ioreq_server type will be delivered to a corresponding ioreq server, and this requires that the p2m type not be switched back to p2m_ram_rw during the emulation process. To avoid this race condition, we delay the release of p2m lock in hvm_hap_nested_page_fault() until mmio is handled. Note: previously in hvm_hap_nested_page_fault(), put_gfn() was moved before the handling of mmio, due to a deadlock risk between the p2m lock and the event lock(in commit 77b8dfe). Later, a per-event channel lock was introduced in commit de6acb7, to send events. So we do not need to worry about the deadlock issue. Signed-off-by: Yu Zhang Reviewed-by: Jan Beulich --- Cc: Paul Durrant Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/hvm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index ccfae4f..a9db7f7 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1870,18 +1870,14 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, (npfec.write_access && (p2m_is_discard_write(p2mt) || (p2mt == p2m_ioreq_server))) ) { - __put_gfn(p2m, gfn); - if ( ap2m_active ) - __put_gfn(hostp2m, gfn); - rc = 0; if ( unlikely(is_pvh_domain(currd)) ) - goto out; + goto out_put_gfn; if ( !handle_mmio_with_translation(gla, gpa >> PAGE_SHIFT, npfec) ) hvm_inject_hw_exception(TRAP_gp_fault, 0); rc = 1; - goto out; + goto out_put_gfn; } /* Check if the page has been paged out */