From patchwork Wed Jun 29 05:59:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9204339 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 1E82F6075F for ; Wed, 29 Jun 2016 06:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB0A285B9 for ; Wed, 29 Jun 2016 06:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0080028644; Wed, 29 Jun 2016 06:06:58 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 6173D285B9 for ; Wed, 29 Jun 2016 06:06: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 1bI8bv-0007kG-O2; Wed, 29 Jun 2016 06:04:31 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bI8bt-0007jw-Sy for xen-devel@lists.xen.org; Wed, 29 Jun 2016 06:04:29 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id C8/CC-09881-DE463775; Wed, 29 Jun 2016 06:04:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsXS1tYhofsmpTj c4NB3LYslHxezODB6HN39mymAMYo1My8pvyKBNWPl/oyCXomKSSsLGhjXC3UxcnIICVRK9D68 zQRiSwjwShxZNoO1i5EDyPaXuHqBD6KkRmL6nnlgJWwCKhIzmt+xg9giAtIS1z5fZuxi5OJgF vjLKLHs2xxmkISwgJlE/+aDYEUsAqoSM9ufgzXzCjhK/Fn2gw1il4LEsi9rweo5BZwktuyZzA KxzFHi8asT7BMYeRcwMqxi1ChOLSpLLdI1NNRLKspMzyjJTczMAfJM9HJTi4sT01NzEpOK9ZL zczcxAgOBAQh2MJ5Z4XyIUZKDSUmUd1pwcbgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd69yUA5 waLU9NSKtMwcYEjCpCU4eJREeP+CpHmLCxJzizPTIVKnGBWlxHlrQBICIImM0jy4NlgcXGKUl RLmZQQ6RIinILUoN7MEVf4VozgHo5Iw7z2QKTyZeSVw018BLWYCWsxanQ+yuCQRISXVwBhyVP rOhKm80esl4rbfirox877oI2mLb4cUZ1ftL17xS2VtLavaQaFJonu+SVT9OVgptVV9nc3X/Eo pncO6v2PiZocWbHVd1PZXM2edVo3UI//QDq2b/5d929VlsLzwzjzBTTvkta6fb7cyELizM/25 6YLlMtvaXBqbffI8Fj+9xSy8n2lh/n0lluKMREMt5qLiRABAMnfjfgIAAA== X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1467180267!49887210!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60499 invoked from network); 29 Jun 2016 06:04:28 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-4.tower-27.messagelabs.com with SMTP; 29 Jun 2016 06:04:28 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 28 Jun 2016 23:04:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,545,1459839600"; d="scan'208";a="130375131" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by fmsmga004.fm.intel.com with ESMTP; 28 Jun 2016 23:04:24 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Wed, 29 Jun 2016 13:59:33 +0800 Message-Id: <1467179974-57317-3-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1467179974-57317-1-git-send-email-quan.xu@intel.com> References: <1467179974-57317-1-git-send-email-quan.xu@intel.com> Cc: Kevin Tian , Feng Wu , Quan Xu , dario.faggioli@citrix.com, Julien Grall , Jan Beulich , Suravee Suthikulpanit Subject: [Xen-devel] [PATCH v13 2/3] IOMMU: add domain crash logic 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 From: Quan Xu Add domain crash logic to the generic IOMMU layer to benefit all platforms. No spamming of the log can occur. For DomU, we avoid logging any message for already dying domains. For Dom0, that'll still be more verbose than we'd really like, but it at least wouldn't outright flood the console. Signed-off-by: Quan Xu CC: Julien Grall CC: Kevin Tian CC: Feng Wu CC: Jan Beulich CC: Suravee Suthikulpanit Acked-by: Kevin Tian --- v13: enhance commit message --- xen/drivers/passthrough/iommu.c | 30 ++++++++++++++++++++++++++++-- xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 7656aeb..d793f5d 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -318,21 +318,47 @@ int iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count) { const struct domain_iommu *hd = dom_iommu(d); + int rc; if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush ) return 0; - return hd->platform_ops->iotlb_flush(d, gfn, page_count); + rc = hd->platform_ops->iotlb_flush(d, gfn, page_count); + if ( unlikely(rc) ) + { + if ( !d->is_shutting_down && printk_ratelimit() ) + printk(XENLOG_ERR + "d%d: IOMMU IOTLB flush failed: %d, gfn %#lx, page count %u\n", + d->domain_id, rc, gfn, page_count); + + if ( !is_hardware_domain(d) ) + domain_crash(d); + } + + return rc; } int iommu_iotlb_flush_all(struct domain *d) { const struct domain_iommu *hd = dom_iommu(d); + int rc; if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush_all ) return 0; - return hd->platform_ops->iotlb_flush_all(d); + rc = hd->platform_ops->iotlb_flush_all(d); + if ( unlikely(rc) ) + { + if ( !d->is_shutting_down && printk_ratelimit() ) + printk(XENLOG_ERR + "d%d: IOMMU IOTLB flush all failed: %d\n", + d->domain_id, rc); + + if ( !is_hardware_domain(d) ) + domain_crash(d); + } + + return rc; } int __init iommu_setup(void) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index cc34497..a02b4c40 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1847,6 +1847,17 @@ int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, } } + if ( unlikely(rc) ) + { + if ( !d->is_shutting_down && printk_ratelimit() ) + printk(XENLOG_ERR VTDPREFIX + " d%d: IOMMU pages flush failed: %d\n", + d->domain_id, rc); + + if ( !is_hardware_domain(d) ) + domain_crash(d); + } + return rc; }