From patchwork Mon Apr 18 14:00:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 8872471 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 686009F443 for ; Mon, 18 Apr 2016 14:08:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 74969201BC for ; Mon, 18 Apr 2016 14:08:58 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 8978120220 for ; Mon, 18 Apr 2016 14:08:57 +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 1as9p8-0002zu-GN; Mon, 18 Apr 2016 14:06:46 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1as9p7-0002zJ-2x for xen-devel@lists.xen.org; Mon, 18 Apr 2016 14:06:45 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id D5/10-03606-4F9E4175; Mon, 18 Apr 2016 14:06:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsVywNykWPfzS5F wg8bdShZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b3tV9YCtbxVLR96mdrYHzD2cXIySEkUCGx c+o1JhBbQoBX4siyGawQtr/EktsXmCBqaiR+HHnNBmKzCShKbLi4HCwuIiAtce3zZUYQm1kgV uJFw0ygOAeHsICPRMtlUZAwi4CqxLZ1t8BG8go4Srz9dQNqlYLEsi9rmUFsTgEniYOH3rBArH KU2PB3G+MERt4FjAyrGNWLU4vKUot0zfWSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M 3MQIDgQEIdjA2fnc6xCjJwaQkyjtplUi4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleK2BgCQkW paanVqRl5gBDEiYtwcGjJMJ75QVQmre4IDG3ODMdInWKUVFKnJcPpE8AJJFRmgfXBouDS4yyU sK8jECHCPEUpBblZpagyr9iFOdgVBLmvQkyniczrwRu+iugxUxAi63fCIIsLklESEk1MM6/3b e18riCTMCRyR8fzOer9EpT91450z/yzHlrBu+T7xqmNd8Lsi7YK/B94dZ9fBefRokfMAz/cu7 9j1uPxcVPsxSEaOxo/OIv6dUtyLv8zro3m1eUq9xZaxu0Jf/Y2xWSNq33JiqVTLh6vizb4Ln1 7fn22gr+a+Y5VQWc3mh6ukX+oVSjr6wSS3FGoqEWc1FxIgATVOJEfgIAAA== X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1460988402!9202384!1 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59749 invoked from network); 18 Apr 2016 14:06:43 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-11.tower-31.messagelabs.com with SMTP; 18 Apr 2016 14:06:43 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 18 Apr 2016 07:03:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,502,1455004800"; d="scan'208";a="934855409" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga001.jf.intel.com with ESMTP; 18 Apr 2016 07:03:27 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Mon, 18 Apr 2016 22:00:02 +0800 Message-Id: <1460988011-17758-3-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1460988011-17758-1-git-send-email-quan.xu@intel.com> References: <1460988011-17758-1-git-send-email-quan.xu@intel.com> Cc: dario.faggioli@citrix.com, Jan Beulich , Quan Xu Subject: [Xen-devel] [PATCH v2 02/11] IOMMU: handle IOMMU mapping and unmapping failures 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now IOMMU mapping and unmapping failures are treated as a fatal to the domain (with the exception of the hardware domain). If IOMMU mapping and unmapping failed, crash the domain (with the exception of the hardware domain) and propagate the error up to the call trees. Signed-off-by: Quan Xu CC: Jan Beulich Reviewed-by: Kevin Tian --- xen/drivers/passthrough/iommu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index b64676f..850101b 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -243,21 +243,33 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, unsigned int flags) { struct hvm_iommu *hd = domain_hvm_iommu(d); + int rc; if ( !iommu_enabled || !hd->platform_ops ) return 0; - return hd->platform_ops->map_page(d, gfn, mfn, flags); + rc = hd->platform_ops->map_page(d, gfn, mfn, flags); + + if ( rc && !is_hardware_domain(d) ) + domain_crash(d); + + return rc; } int iommu_unmap_page(struct domain *d, unsigned long gfn) { struct hvm_iommu *hd = domain_hvm_iommu(d); + int rc; if ( !iommu_enabled || !hd->platform_ops ) return 0; - return hd->platform_ops->unmap_page(d, gfn); + rc = hd->platform_ops->unmap_page(d, gfn); + + if ( rc && !is_hardware_domain(d) ) + domain_crash(d); + + return rc; } static void iommu_free_pagetables(unsigned long unused)