From patchwork Sun Apr 2 12:24:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhang X-Patchwork-Id: 9658441 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 A09EF602BA for ; Sun, 2 Apr 2017 12:46:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 813E72835B for ; Sun, 2 Apr 2017 12:46:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75DDC284BC; Sun, 2 Apr 2017 12:46:13 +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 CE514284A5 for ; Sun, 2 Apr 2017 12:46:11 +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 1cuer7-000324-Bh; Sun, 02 Apr 2017 12:43:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuer5-00031v-SF for xen-devel@lists.xen.org; Sun, 02 Apr 2017 12:43:39 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 7B/8D-03705-BF1F0E85; Sun, 02 Apr 2017 12:43:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42I5YG5Sofvr44M Ig1UbFSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxrW5cwFZzlq1jUltfAeJO7i5GLg0XgFpPE 7VdPWEAcIYFpjBKbHs5l6mLk5JAQ4JU4smwGK4TtJ7Hs3CFWiKJ2RokfW2czgyTYBLQlfqz+z QhiiwhIS1z7fJkRpIhZoJ9RYt6jJqAODg5hgTCJ3TecQUwWAVWJjV95QUxeAQ+Jtou1EOPlJE 4emwy2ilPAU+Lp8g1gthBQyY7/i9knMPItYGRYxahenFpUllqka6KXVJSZnlGSm5iZo2toYKy Xm1pcnJiempOYVKyXnJ+7iREYIgxAsIOx8YvTIUZJDiYlUd7vxfcihPiS8lMqMxKLM+KLSnNS iw8xanBwCPSuWX2BUYolLz8vVUmCd/KHBxFCgkWp6akVaZk5wCCGKZXg4FES4S0ESfMWFyTmF memQ6ROMSpKifNWgSQEQBIZpXlwbbDIucQoKyXMywh0lBBPQWpRbmYJqvwrRnEORiVhXgmQKT yZeSVw018BLWYCWmzx9S7I4pJEhJRUAyPfnCrX+jm6b/Q/399q9fHxQZtzXN8duretqXMQPX1 tgeK+45a3+3mVPSXP6s1XePZ4kk51r+bD+qSXh2uzw/69OVxfkhNb8fHflBWvroUzJh1dYTsl w2XnL8eyxpkuC1Pzzz+s3LdQy+x4U0T//tvca4tPrvHSYXQRfftcgcfriJkSZzZH9RMlluKMR EMt5qLiRABOHoQflwIAAA== X-Env-Sender: yu.c.zhang@linux.intel.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1491137016!59079992!1 X-Originating-IP: [192.55.52.120] 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 10304 invoked from network); 2 Apr 2017 12:43:38 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Apr 2017 12:43:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491137018; x=1522673018; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=AYhiDFannB3QdbtL52ZkTFeN3WRGqcaHo82xvHRI9/g=; b=LCKD3p5SAxArcvvjW5YEwzUzkRyHeKVeSuPUYpA38wXHa9pLBPBhnw8Y E1WK+tkF1OLk6K7ZLs3fsPdXMddxfQ==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Apr 2017 05:43:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,263,1486454400"; d="scan'208";a="81958873" Received: from zhangyu-optiplex-9020.bj.intel.com ([10.238.135.159]) by orsmga005.jf.intel.com with ESMTP; 02 Apr 2017 05:43:34 -0700 From: Yu Zhang To: xen-devel@lists.xen.org Date: Sun, 2 Apr 2017 20:24:22 +0800 Message-Id: <1491135867-623-2-git-send-email-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491135867-623-1-git-send-email-yu.c.zhang@linux.intel.com> References: <1491135867-623-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 v10 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 --- Cc: Paul Durrant Cc: Jan Beulich Cc: Andrew Cooper changes in v4: - According to comments from Jan: remove the redundant "rc = 0" code. --- 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 0282986..bd18d8e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1815,15 +1815,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 */