From patchwork Fri Sep 2 10:47:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 9310711 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 4721060760 for ; Fri, 2 Sep 2016 11:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 388522978A for ; Fri, 2 Sep 2016 11:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CE132978D; Fri, 2 Sep 2016 11:07:10 +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 169332978A for ; Fri, 2 Sep 2016 11:07:09 +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 1bfmHB-0004jh-50; Fri, 02 Sep 2016 11:04:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfmH9-0004ik-Ut for xen-devel@lists.xen.org; Fri, 02 Sep 2016 11:04:48 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 1D/24-13744-FCC59C75; Fri, 02 Sep 2016 11:04:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGLMWRWlGSWpSXmKPExsVywNwkVvdMzMl wg93TDCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyTy4+xFGzgq+h7GdfAuIK7i5GDQ0igUmLZ 6rwuRk4OCQFeiSPLZrBC2L4Sxz/eYwexhQTqJQ49+MYMYrMJaEv8WP2bEcQWEZCWuPb5MpDNx cEs0M8oMe9REyvITGGBUIlDH11AalgEVCU2P13GBmLzCnhJfFv2gQVivpzEyWOTwXZxCnhLdJ 16wAaxy0viw5NTrBMYeRcwMqxiVC9OLSpLLdI110sqykzPKMlNzMzRNTQw08tNLS5OTE/NSUw q1kvOz93ECAwDBiDYwTjzsv8hRkkOJiVR3gcBJ8OF+JLyUyozEosz4otKc1KLDzFqcHAI9K5Z fYFRiiUvPy9VSYJXABhuQoJFqempFWmZOcBAhSmV4OBREuG9HA2U5i0uSMwtzkyHSJ1iVJQS5 90BkhAASWSU5sG1waLjEqOslDAvI9BRQjwFqUW5mSWo8q8YxTkYlYR5b4NM4cnMK4Gb/gpoMR PQ4pJrx0EWlyQipKQaGGd6RddOuPhk1wRhM/cFqWf3BLgtNni21Hn6A/OF25zyOu5cv52sslf xUcuemwo6h39WH/ju7b8nc3/TokVblznPKtLfwiL4oPpn/f+n4mt2cPKaffZOPdMSu01BJFxx flYWy7o26WOPnP6GSQlNm+2/W4x3fqtfxKot3afv/p/JsvhOYuNk1hglluKMREMt5qLiRABL9 fcbiQIAAA== X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1472814280!31243322!3 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30366 invoked from network); 2 Sep 2016 11:04:44 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-15.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 2 Sep 2016 11:04:44 -0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP; 02 Sep 2016 04:04:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,270,1470726000"; d="scan'208";a="3948350" Received: from zhangyu-xengt.bj.intel.com ([10.238.154.168]) by fmsmga006.fm.intel.com with ESMTP; 02 Sep 2016 04:04:42 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Fri, 2 Sep 2016 18:47:18 +0800 Message-Id: <1472813240-11011-3-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1472813240-11011-1-git-send-email-yu.c.zhang@linux.intel.com> References: <1472813240-11011-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 v6 2/4] 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 e969735..9b419d2 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1865,18 +1865,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 */