From patchwork Sat Mar 18 10:53:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 9632117 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 A1A94602D6 for ; Sat, 18 Mar 2017 11:14:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93A0128450 for ; Sat, 18 Mar 2017 11:14:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 864FB28451; Sat, 18 Mar 2017 11:14:54 +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 0BC8928449 for ; Sat, 18 Mar 2017 11:14:53 +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 1cpCHv-0001Z7-75; Sat, 18 Mar 2017 11:12:47 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpCHt-0001Yo-R7 for xen-devel@lists.xen.org; Sat, 18 Mar 2017 11:12:45 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 53/CE-27751-D261DC85; Sat, 18 Mar 2017 11:12:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXS1tYhr6sjdjb CYO8hFYslHxezODB6HN39mymAMYo1My8pvyKBNWPOmQ8sBXf5KhYfXMXWwHiRu4uRk0NIoFJi 1o9NLCC2hACvxJFlM1i7GDmAbD+Jkx+zuxi5gEraGSVuT/zMCFLDJqAt8WP1bzBbREBa4trny 4wgRcwC/YwS8x41gTULC4RK/H9WD1LDIqAqMevJJDYQm1fAU+L+1RY2iF1yEiePTWYFsTkFvC RO3HjFDHGPp8T+dR/YJjDyLmBkWMWoXpxaVJZapGuql1SUmZ5RkpuYmaNraGCml5taXJyYnpq TmFSsl5yfu4kRGAoMQLCDcfpl/0OMkhxMSqK81jJnIoT4kvJTKjMSizPii0pzUosPMWpwcAj0 rll9gVGKJS8/L1VJgjdB5GyEkGBRanpqRVpmDjBYYUolOHiURHgPgaR5iwsSc4sz0yFSpxgVp cR5r4IkBEASGaV5cG2wCLnEKCslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYV5BUaApPJl5JXDTXw EtZgJavOzGGZDFJYkIKakGxkXL5izia58iu1HIffKKY8/XLq1YKaC690b7po9/19T7HD8Xd1E w5tXN8hSpeyUXbj2643B7f+/BwFzGx2cDrf9XNzTY9T+xtnguv8VeZ6/YNPfLWZPMDvDN4lF2 VbwYsEbwpbvKrsKzPbX/d//ZzLnFLV5jQ9wFFeWUmVkMEmmn6kXY0q6tOabEUpyRaKjFXFScC AD9dYy5iwIAAA== X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1489835562!87827913!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 61785 invoked from network); 18 Mar 2017 11:12:44 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-7.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Mar 2017 11:12:44 -0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP; 18 Mar 2017 04:12:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,182,1486454400"; d="scan'208";a="77904810" Received: from zhangyu-optiplex-9020.bj.intel.com ([10.238.135.159]) by fmsmga005.fm.intel.com with ESMTP; 18 Mar 2017 04:12:40 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Sat, 18 Mar 2017 18:53:51 +0800 Message-Id: <1489834435-6166-2-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489834435-6166-1-git-send-email-yu.c.zhang@linux.intel.com> References: <1489834435-6166-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 v8 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 */