From patchwork Mon Jul 4 09:11:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9212047 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 3D5BF6086B for ; Mon, 4 Jul 2016 09:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 282E0285FB for ; Mon, 4 Jul 2016 09:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AA732860A; Mon, 4 Jul 2016 09:20:01 +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 89000285F4 for ; Mon, 4 Jul 2016 09:20:00 +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 1bJzzq-0004ZE-7l; Mon, 04 Jul 2016 09:16:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJzzp-0004Yc-M6 for xen-devel@lists.xen.org; Mon, 04 Jul 2016 09:16:53 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 95/24-07949-4892A775; Mon, 04 Jul 2016 09:16:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsXS1tbhqNuiWRV ucG+xuMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvH2qUvBDImK7b1JDYx7hLoYOTiEBColbm3K 6mLk5JAQ4JU4smwGK4TtL/H1/VlmEFtIoEZi1e5TbCA2m4CKxIzmd+wgtoiAtMS1z5cZuxi5O JgFJjNJzF14FqxZWMBMYubF84wg81kEVCX6/guChHkFHCXObn3GAjFfQWLZl7Vg8zkFnCSOrb 7JArHLUaL12AW2CYy8CxgZVjGqF6cWlaUW6VrqJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhX rJefnbmIEBkE9AwPjDsbXP50OMUpyMCmJ8mpyVIUL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBt 1wDKCRalpqdWpGXmAMMRJi3BwaMkwvtTHSjNW1yQmFucmQ6ROsWoKCXOOwWkTwAkkVGaB9cGi 4FLjLJSwryMDAwMQjwFqUW5mSWo8q8YxTkYlYR5z4JM4cnMK4Gb/gpoMRPQYtbYcpDFJYkIKa kGxokHZSJLjabwOanwa+2y2ZYkvLCqfF15o3qDlWyDSt1cVemPPblHV03sPud+Njb3z+ZpBzc GBc2TW7Dt9saESaWO7orf9f9ySJ+fufj1BM2kH196Uy6lySZK/fuyJ6Ymfcbkn3mMrBUrZp99 FyZw8rmQ39q5Jqv6J67cXuTt49V2hfvA61Sn80osxRmJhlrMRcWJAHmf05x8AgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1467623811!32000969!1 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48112 invoked from network); 4 Jul 2016 09:16:52 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-12.tower-31.messagelabs.com with SMTP; 4 Jul 2016 09:16:52 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 04 Jul 2016 02:16:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,574,1459839600"; d="scan'208";a="133433646" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by fmsmga004.fm.intel.com with ESMTP; 04 Jul 2016 02:16:39 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Mon, 4 Jul 2016 17:11:41 +0800 Message-Id: <1467623502-59531-3-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1467623502-59531-1-git-send-email-quan.xu@intel.com> References: <1467623502-59531-1-git-send-email-quan.xu@intel.com> Cc: Kevin Tian , Feng Wu , Jan Beulich , dario.faggioli@citrix.com, Julien Grall , Quan Xu , quan.xu2@aliyun.com, Suravee Suthikulpanit Subject: [Xen-devel] [PATCH v14 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 Acked-by: Kevin Tian CC: Julien Grall CC: Kevin Tian CC: Feng Wu CC: Jan Beulich CC: Suravee Suthikulpanit --- 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; }