From patchwork Fri May 13 08:04:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9089311 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 A7CFA9F441 for ; Fri, 13 May 2016 08:06:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2551A20218 for ; Fri, 13 May 2016 08:06:28 +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 92F33201BC for ; Fri, 13 May 2016 08:06:22 +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 1b184v-00019q-Gy; Fri, 13 May 2016 08:04:09 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b184u-00019k-ET for xen-devel@lists.xen.org; Fri, 13 May 2016 08:04:08 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id F8/8D-03512-77A85375; Fri, 13 May 2016 08:04:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGKsWRWlGSWpSXmKPExsXS1tbhqFveZRp ucHIbu8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmjFtdzdbQYtgxbofZxgbGLdzdzFycggJVEjs W3SeDcSWEOCVOLJsBiuE7S/x4OtFxi5GLqCaBkaJW8f/sUI4exkl5qydwATh7GaUuHr7KjOEs 45RYvv9TWCz2ARUJGY0v2MHsUUElCV6f/1mASliFpjOKDHxwWGwImGBQImj3YuhioIklnc+Y4 KwwyTuHfkDVsMioCqx9fcUsBpegWCJNXt+Q61exizxsekeI0iCU8Be4s+LE2BFjAJiEt9PrQE bxCwgLnHryXwmiI8EJJbsOc8MYYtKvHwM8ZCEwFxmid6D26ES0hLH1l2HBoGixN/1rYwQg3Qk Fuz+xAZha0ssW/iaGeIiQYmTM58AvcYBdJGcxMYfXBMYZWYhWT0LSfcsJN2zkHQvYGRZxahen FpUllqka6iXVJSZnlGSm5iZo2toaKKXm1pcnJiempOYVKyXnJ+7iREY3wxAsIPxaKfzIUZJDi YlUd6mQtNwIb6k/JTKjMTijPii0pzU4kOMMhwcShK8WZ1AOcGi1PTUirTMHGCigUlLcPAoifB +6QBK8xYXJOYWZ6ZDpE4xKkqJ85qD9AmAJDJK8+DaYMntEqOslDAvI9AhQjwFqUW5mSWo8q8Y xTkYlYR5C0Cm8GTmlcBNfwW0mAlocfV1I5DFJYkIKakGRruDWn+3N7+JnBj8rOWq5QS2t/O/f Fn3mjH2aK9MqQVbTvI2M0Fmq2+v5tVs+vxld8FX07VqPky/n9qmBD8KTLXgSb8WYrPE5qdxxY lDrYp/RXsEvqxZdH77kktL3TPr74j2H/h8yndFEo+DkalbyJnSGAk74Q6eiycdZl3bEbhgdpr 8nwsnTiixFGckGmoxFxUnAgAoDaG8aQMAAA== X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1463126646!29111877!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.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49012 invoked from network); 13 May 2016 08:04:06 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-14.tower-27.messagelabs.com with SMTP; 13 May 2016 08:04:06 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 13 May 2016 01:04:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,613,1455004800"; d="scan'208";a="805409068" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 13 May 2016 01:04:05 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 13 May 2016 01:04:04 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 13 May 2016 01:04:04 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.148]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0248.002; Fri, 13 May 2016 16:04:02 +0800 From: "Xu, Quan" To: Jan Beulich Thread-Topic: [PATCH v4 02/10] IOMMU: handle IOMMU mapping and unmapping failures Thread-Index: AQHRp3V6Acur+0nPMkqk1KLg7bccxp+wRneAgAEzkGD//8JlAIAEIcDA//+MfQCAAZ+/oA== Date: Fri, 13 May 2016 08:04:01 +0000 Message-ID: <945CA011AD5F084CBEA3E851C0AB28894B8AE02F@SHSMSX101.ccr.corp.intel.com> References: <1462524880-67205-1-git-send-email-quan.xu@intel.com> <1462524880-67205-3-git-send-email-quan.xu@intel.com> <5730D35302000078000E9ABC@prv-mh.provo.novell.com> <945CA011AD5F084CBEA3E851C0AB28894B8AB4C9@SHSMSX101.ccr.corp.intel.com> <5731A1A602000078000E9D65@prv-mh.provo.novell.com> <945CA011AD5F084CBEA3E851C0AB28894B8ADA7A@SHSMSX101.ccr.corp.intel.com> <5734B80E02000078000EAFD4@prv-mh.provo.novell.com> In-Reply-To: <5734B80E02000078000EAFD4@prv-mh.provo.novell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTEzZTA0MGMtZjI4My00MTY0LTkyNGEtMDJkYzdmYWY5MjFiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImI3SGtjdXNyVjZ2NlphVFJEeFluZGd1dVVmTHE1SW53OW5pSjlmaEg2am89In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Cc: "dario.faggioli@citrix.com" , "Tian, Kevin" , "xen-devel@lists.xen.org" Subject: Re: [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: , 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 On May 12, 2016 11:06 PM, Jan Beulich wrote: > >>> On 12.05.16 at 16:28, wrote: > > On May 10, 2016 2:54 PM, Jan Beulich wrote: > >> >>> On 10.05.16 at 05:41, wrote: > >> > On May 10, 2016 12:14 AM, Jan Beulich wrote: > >> >> >>> On 06.05.16 at 10:54, wrote: Jan, Try it again, I hope I have got it. If not, could you write some sample code for me as an exception? :) Thanks again!! Quan --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -240,21 +240,63 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, unsigned int flags) { const struct domain_iommu *hd = dom_iommu(d); + static int printed = 0; + 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) ) + { + if ( is_hardware_domain(d) ) + { + if ( !printed ) + { + printk(XENLOG_ERR + "d%d: IOMMU mapping gfn %#lx mfn %#lx failed %d.", + d->domain_id, gfn, mfn, rc); + + printed = 1; + } + } + else + domain_crash(d); + } + + return rc; } int iommu_unmap_page(struct domain *d, unsigned long gfn) { const struct domain_iommu *hd = dom_iommu(d); + static int printed = 0; + 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) ) + { + if ( is_hardware_domain(d) ) + { + if ( !printed ) + { + printk(XENLOG_ERR + "d%d: IOMMU unmapping gfn %#lx failed %d.", + d->domain_id, gfn, rc); + + printed = 1; + } + } + else + domain_crash(d); + } + + return rc; }