From patchwork Thu Apr 6 13:19:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 9667425 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 C0EEA601EB for ; Thu, 6 Apr 2017 13:40:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78DE127FAE for ; Thu, 6 Apr 2017 13:40:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D69A28159; Thu, 6 Apr 2017 13:40:20 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 0236828249 for ; Thu, 6 Apr 2017 13:40:19 +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 1cw7cB-0004ci-3d; Thu, 06 Apr 2017 13:38:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cw7c9-0004c9-Mi for xen-devel@lists.xen.org; Thu, 06 Apr 2017 13:38:17 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 8B/87-02172-8C446E85; Thu, 06 Apr 2017 13:38:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42I5YG5SoXvU5Vm EwZ318hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8afjc2sBZ95Ku5OaGNqYFzA1cXIxcEicItJ YtGtr6wgjpDAdEaJRWdWMHUxcnJICPBKHFk2gxXC9peY1XiPGaKonVHi07c7YAk2AW2JH6t/M 4LYIgLSEtc+XwazmQUkJNrWHgaq4eAQFgiTmHlQGCTMIqAq8f7QRyaQMK+Ap8TT+XIQ4+UkTh 6bDDaRU8BLYsu+nSwgthBQydd1S9kmMPItYGRYxahRnFpUllqka2Sml1SUmZ5RkpuYmaNraGC ql5taXJyYnpqTmFSsl5yfu4kRGCb1DAyMOxhvT/Y7xCjJwaQkyqvg8yRCiC8pP6UyI7E4I76o NCe1+BCjBgeHQO+a1RcYpVjy8vNSlSR4Jzo/ixASLEpNT61Iy8wBBjJMqQQHj5IIbw9Imre4I DG3ODMdInWKUVFKnPcASEIAJJFRmgfXBoueS4yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEec +ATOHJzCuBm/4KaDET0GKfW09BFpckIqSkGhhLDoYJJS/NX3xg3QzuOz1xyr6FP0NNaqqC983 c31gUto/fc0GwbQzXPO/51seEbUr8M64Ed5/ZycYf2JTWwvSxfvcKATfH1lnKfzd/Kz/Pyb4+ SHWCWs6up+fyFJsund+hEMaZ0bTq3H/eP52GXK0SpSp50iJ/a32NL/36erow8nR1W/HqAiWW4 oxEQy3mouJEACgkR6qZAgAA X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1491485890!74458322!2 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48879 invoked from network); 6 Apr 2017 13:38:13 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-11.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Apr 2017 13:38:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491485893; x=1523021893; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=SbQuVxXnthMcJz7xchVODHpT2tf97a9+ssJo5ggJYPs=; b=LPqer4SX4bcPfU+nBQEgbLSLjjNnn6gocR1lXtfzz0IiqFJSJmgBflll 6a0txG57ju9I5KrVbHwKNgvxQWfYnQ==; Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2017 06:38:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,159,1488873600"; d="scan'208";a="842691555" Received: from zhangyu-optiplex-9020.bj.intel.com ([10.238.135.159]) by FMSMGA003.fm.intel.com with ESMTP; 06 Apr 2017 06:38:09 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Thu, 6 Apr 2017 21:19:02 +0800 Message-Id: <1491484747-5133-2-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491484747-5133-1-git-send-email-yu.c.zhang@linux.intel.com> References: <1491484747-5133-1-git-send-email-yu.c.zhang@linux.intel.com> Cc: zhiyuan.lv@intel.com Subject: [Xen-devel] [PATCH v11 1/6] 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 --- xen/arch/x86/hvm/hvm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 2e76c23..d954d65 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1827,15 +1827,10 @@ 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 ( !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 */