From patchwork Fri Apr 29 09:25:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 8979031 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35991BF29F for ; Fri, 29 Apr 2016 09:30:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C2EF20251 for ; Fri, 29 Apr 2016 09:30:38 +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 7E55F201FA for ; Fri, 29 Apr 2016 09:30:37 +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 1aw4jB-00007b-WC; Fri, 29 Apr 2016 09:28:49 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aw4jA-00005Y-H8 for xen-devel@lists.xen.org; Fri, 29 Apr 2016 09:28:48 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id FF/C7-09532-05923275; Fri, 29 Apr 2016 09:28:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsVywNwkQtdfUzn cYOMCa4slHxezODB6HN39mymAMYo1My8pvyKBNeP810XsBT/5KzonHGJuYPzG3cXIySEkUCGx f8o7dhBbQoBX4siyGawQtr/ElXlP2SBqaiT23v7NCGKzCShKbLi4nAnEFhGQlrj2+TJYnFkgV uJFw0ywuLCAj0Tb73tgcRYBVYlVfS/A4rwCjhKf556A2qUgsezLWmYQm1PASeL69fdQuxwlPn T/YJ3AyLuAkWEVo3pxalFZapGukV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmA oMADBDsZlf50OMUpyMCmJ8oZwKocL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCN0wDKCRalpqdW pGXmAIMSJi3BwaMkwmsEkuYtLkjMLc5Mh0idYlSUEufVAkkIgCQySvPg2mCRcIlRVkqYlxHoE CGegtSi3MwSVPlXjOIcjErCvB0gU3gy80rgpr8CWswEtFhgkyLI4pJEhJRUA2NWYPS/PmZ9hg +upzwm5pcdTCj1OR5S7LJ3Q5+C94/49vbPB9ZxvLh/W9a54UTV0bg/jc9qpub1sy5jzmfVOPG mXFnmtNFc710G6sJJhjP07S/WNO//KvUu9bCwKPsLzsO566Xvf34dYHbCmrvUSmPZHcWNtQqy 4jt+dvNo8OVmK84WUzpjrcRSnJFoqMVcVJwIALS8tPd/AgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1461922125!2123467!3 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44829 invoked from network); 29 Apr 2016 09:28:47 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-2.tower-21.messagelabs.com with SMTP; 29 Apr 2016 09:28:47 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 29 Apr 2016 02:28:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,551,1455004800"; d="scan'208";a="965266392" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 29 Apr 2016 02:28:46 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Fri, 29 Apr 2016 17:25:09 +0800 Message-Id: <1461921917-48394-3-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1461921917-48394-1-git-send-email-quan.xu@intel.com> References: <1461921917-48394-1-git-send-email-quan.xu@intel.com> Cc: dario.faggioli@citrix.com, Jan Beulich , Quan Xu Subject: [Xen-devel] [PATCH v3 02/10] 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 Treat IOMMU mapping and unmapping failures 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 Reviewed-by: Kevin Tian CC: Jan Beulich --- xen/drivers/passthrough/iommu.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index b64676f..a0003ac 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -243,21 +243,47 @@ 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 ) + { + if ( is_hardware_domain(d) ) + printk(XENLOG_ERR + "iommu_map_page: IOMMU mapping gfn %#lx mfn %#lx failed for dom%d.", + gfn, mfn, d->domain_id); + else + 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 ) + { + if ( is_hardware_domain(d) ) + printk(XENLOG_ERR + "iommu_unmap_page: IOMMU unmapping gfn %#lx failed for dom%d.", + gfn, d->domain_id); + else + domain_crash(d); + } + + return rc; } static void iommu_free_pagetables(unsigned long unused)