From patchwork Fri May 6 08:54:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9030401 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 E00DABF29F for ; Fri, 6 May 2016 09:00:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F0C020221 for ; Fri, 6 May 2016 09:00:49 +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 2E12B20389 for ; Fri, 6 May 2016 09:00:48 +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 1aybaW-0004Me-Br; Fri, 06 May 2016 08:58:20 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aybaV-0004MD-6y for xen-devel@lists.xen.org; Fri, 06 May 2016 08:58:19 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id DA/1F-02869-AAC5C275; Fri, 06 May 2016 08:58:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsXS1tYhorsqRif c4M8bVoslHxezODB6HN39mymAMYo1My8pvyKBNePVseeMBZ0CFR/3GDQwruDpYuTkEBKokLj7 cSUriC0hwCtxZNkMKNtfYs35fYwQNTUSlzddYwKx2QQUJTZcXA5miwhIS1z7fBmohouDWaCRU aL142ywZmEBH4m5t1vBilgEVCU6b19mB7F5BRwlpszZBrVAQWLZl7XMIDangJNE29R2dohljh I/pm1jmsDIu4CRYRWjRnFqUVlqka6hkV5SUWZ6RkluYmaOrqGhiV5uanFxYnpqTmJSsV5yfu4 mRmAwMADBDsaz05wPMUpyMCmJ8q76px0uxJeUn1KZkVicEV9UmpNafIhRhoNDSYI3J1onXEiw KDU9tSItMwcYljBpCQ4eJRHevyBp3uKCxNzizHSI1ClGRSlx3gUgCQGQREZpHlwbLBYuMcpKC fMyAh0ixFOQWpSbWYIq/4pRnINRSZh3GsgUnsy8Erjpr4AWMwEtfj9XE2RxSSJCSqqBMVCp5M Nd7e3px6fdV33jz3P4vYWk0TnFSRys7QqKhh3u59bKJZWVMc2o4fkgtd9qQrfLqv9+Nln8kRf 8H6lfmxT1+fbxTXPms557nTdrCcMTy9Co9j0rWo43ZDy/uu34150M+mdmhfT8/fFgb/bvv0Ky TenZUjXv+L59M27g4LzqvTbu+dNpr5VYijMSDbWYi4oTATLyuiGAAgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1462525094!39896475!3 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45267 invoked from network); 6 May 2016 08:58:17 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-9.tower-27.messagelabs.com with SMTP; 6 May 2016 08:58:17 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 06 May 2016 01:58:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,586,1455004800"; d="scan'208";a="969963778" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 06 May 2016 01:58:16 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Fri, 6 May 2016 16:54:32 +0800 Message-Id: <1462524880-67205-3-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1462524880-67205-1-git-send-email-quan.xu@intel.com> References: <1462524880-67205-1-git-send-email-quan.xu@intel.com> Cc: Kevin Tian , dario.faggioli@citrix.com, Jan Beulich , Quan Xu Subject: [Xen-devel] [PATCH v4 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 CC: Kevin Tian --- 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 c59b2ab..09560c0 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -240,21 +240,47 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, unsigned int flags) { const struct domain_iommu *hd = dom_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 ( unlikely(rc) ) + { + printk(XENLOG_ERR + "iommu_map_page: IOMMU mapping gfn %#lx mfn %#lx failed for dom%d.", + gfn, mfn, d->domain_id); + + if ( !is_hardware_domain(d) ) + domain_crash(d); + } + + return rc; } int iommu_unmap_page(struct domain *d, unsigned long gfn) { const struct domain_iommu *hd = dom_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 ( unlikely(rc) ) + { + printk(XENLOG_ERR + "iommu_unmap_page: IOMMU unmapping gfn %#lx failed for dom%d.", + gfn, d->domain_id); + + if ( !is_hardware_domain(d) ) + domain_crash(d); + } + + return rc; } static void iommu_free_pagetables(unsigned long unused)