From patchwork Sat May 21 23:42:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 68315 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp556413qge; Sat, 21 May 2016 16:44:15 -0700 (PDT) X-Received: by 10.55.76.84 with SMTP id z81mr10058082qka.17.1463874255484; Sat, 21 May 2016 16:44:15 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b127si24201060qkg.198.2016.05.21.16.44.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 May 2016 16:44:15 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@amdcloud.onmicrosoft.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b4GXo-0001lc-7H; Sat, 21 May 2016 23:42:56 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b4GXn-0001l3-4e for xen-devel@lists.xen.org; Sat, 21 May 2016 23:42:55 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 30/63-21979-E72F0475; Sat, 21 May 2016 23:42:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHKsWRWlGSWpSXmKPExsXiaL7SU7f2k0O 4wcVePYslHxezODB6HN39mymAMYo1My8pvyKBNWPW6eWMBf/4KlZPmsfYwDiBp4uRi4NFoJ1Z YurU92wgDqNAP6PEnm1HWLoYOTmEBA4yShxd6QpiswmoSiy9u48dxBYRyJJ48W0mmM0s4Clxc sEVZhBbWCBW4mvHbUYQmwWo/uCTpUA1HBy8Aj4SDU2GIGEJATmJk8cms4LYnAK+Eu8aetggVv lIvN/8gAnE5hUQlDg58wkLxHgJiYMvXjBD9CpIbP/+HexOCYFWRonrfz4xQjRrSVw+cpANosh X4tW8PawQRd+ZJNqWL4bqdpM4/vMXVKKXTeLw/nZGCOciu8TOPz+YIKpyJHZ1fWSEsLUk1l39 yAxRtJNR4sHGZVCjZCTaN52FGjWPReL7jGVQzhUuiVv3j0HN/cAq8XnRF6i5EhLzTzdCtftLz FtyACpuJPHu3wLWCYyKs5C8PgvJ6wsYmVYxahSnFpWlFukamuolFWWmZ5TkJmbm6BoamOrlph YXJ6an5iQmFesl5+duYgSmBQYg2MHYsN3zEKMkB5OSKG9qt324EF9SfkplRmJxRnxRaU5q8SF GGQ4OJQneko8O4UKCRanpqRVpmTnABAWTluDgURLhfQWS5i0uSMwtzkyHSJ1i1OU4NPXeWiYh lrz8vFQpcd46kCIBkKKM0jy4EbBkeYlRVkqYlxHoKCGegtSi3MwSVPlXjOIcjErCvEdApvBk5 pXAbXoFdAQT0BEPpcGOKElESEk1MLrbz65uPBVXFT9x5zJhNbskqY3GLtY32f/lcfguEDx5aG H0TdHwG/oT/h+1MT13WFeMf+m/BlXJugZ9u0M+67verfXeIbHv+7zmy6+kg9RkO5+XyM267qb MrfFZ7jrXvw8PXRXXlDz/EXtRpqzmkXywzPJv2x4erhdNedh6Yk1Xtd+0aNc/LkosxRmJhlrM RcWJACjTOXKRAwAA X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1463874171!40621098!2 X-Originating-IP: [65.55.169.73] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8900 invoked from network); 21 May 2016 23:42:53 -0000 Received: from mail-bl2on0073.outbound.protection.outlook.com (HELO na01-bl2-obe.outbound.protection.outlook.com) (65.55.169.73) by server-6.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 21 May 2016 23:42:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bttQxBokcodSjUEavvM4KoE6QAd0MmEqOfiby0m6G5E=; b=SdIDHSEJG6M7c243sxjUbkJYqXbtUAvzv2jP4zK5BqHXiRad63bDGoD9wp4iThMzXSAb6SE8lE6CBLSRhDt6k3RpIWuWVURAq/2+ejK+0RL0Qs79xXLOjolfbexF8FKMQiWlQQAvJ5kgkxtPqMLz6HkHnsswYSeU93AZW85sYe4= Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by CY1PR12MB0444.namprd12.prod.outlook.com (10.163.91.22) with Microsoft SMTP Server (TLS) id 15.1.501.7; Sat, 21 May 2016 23:42:50 +0000 From: To: , , , Date: Sat, 21 May 2016 18:42:30 -0500 Message-ID: <1463874151-6950-3-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463874151-6950-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1463874151-6950-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR11CA0042.namprd11.prod.outlook.com (10.141.240.52) To CY1PR12MB0444.namprd12.prod.outlook.com (10.163.91.22) X-MS-Office365-Filtering-Correlation-Id: 6fc04ccb-f530-43bb-2a65-08d381d19fc0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 2:E3R903H+eIZYJzabeaNP2gF+RyoyxjfhPOQbPlF6q9pJNoG9JvNjRH0aNQghw2d21eEqw4zmwxMg746QVrYeDjVjjIMZCfUe051+rZawSX0i0VIHtDCl/3mkIcH2IEPRCQ43RH62/arWf5Y6VE3XSvhruQbDriI6rnLcsNG6RbnY31oFcOfPxtwLFZIS9dNf; 3:4n47GF66gxspb2odllXyiMdTruHIh2wBZ1h5+4TYXYPcj6bfUbfWFCMhx8pmBGr3IEzhzsWIQsfR1HUA97q0DHJxrGIETVRVTQI64nESJC/fdQl5E/Ep75v3nnWph0PL X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0444; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 25:kGkVTOGczBAL34u1by/bKFsn9aXv5KRYsl/YdS3Ns9TZORBi3TeEeNW2RUPS1kxFPCi2tRzKOkyW6Bwe5SyPDVonIuGIYZRNhdSxiIgs8JOIyp4DeRznBUZq6vAOEOjvnXtmPyBsJDyMsGLpWZZQyn+2lTn1EiRh/ofEbN8v4xtPpuIaoqg1RyG5vqPfEwNCt+cMtDdWlQcUushNTidD2BnFKAFLkjQ5zd9KwZUqKN+EM2PmLHthrzkhsbeFksAepyyGicqi7cwXCPeiKJfxDYroW5JSaICO+AOd1fqtCRy6kD+r+n0PRsVK9XN/ZtbvdnydynqwJx9ZmE77OkO0OnhLahlDYNVDAChdmKsB1hv9kMXj1CIwIaDa00rPftiS839cyjCw9OHYCPqMDjaZsPiMkzpTdnNaRMKTFHSJanl/9ZKXqxd1kzv0K41S+w0HIjaHq0yK1J5827A5xtPUJkgxEgqaFKjgd2T4kDRYA7rlg14Fd373I/A0rSHn/xGdGmpCG77mt8AeSrGIaRgb+tReb9PJSCCF9TsQkwItT1ymZV25tCqtagOYyAHdHRtJVWTK1ZG7sg2qnZM1TmVzlVujkWFKRkMz5SHB0PYGKRY3HAFALjQK9EYgF9Vh6Lt3Oe6UkrgImeNde2jDtR0Ts6AHocfoL/Jli/2x0clYkWJMimZdNLGRGTA6BHsQywg0lZXFG/U2LK41m3Toc23KIg== X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 20:KFDWPHrWlxWeLGtG5brBhnyeuYgZBdHO1oZJT8l+DHUTBjWvYDETAnjbH59RHAvfR0h5iTFfHyQbyeye+NIBiXImB3J9dg20E9/xyySFSALBC6Pq+ReWAHR/8agwZ1dFvS0G/JHEcbRA4q1yHqc1saxCFebXHx6TzWBe8g/fy8dKMG1UqEDzI6TXXxGoWof6UMmHZTToUA22xCVZzLJskJ98hywnnSA29w4F4vC1LUnPbHSy1P9V+45cs9wez7c7QQRh3MT2osUih4/08foKh78d2CNLQBqWjKjlqvZjAJ0HK2m0Z0c/bDraHwbPEfacIhJJCpmtVpzOBEFq0IL42vA+actEiJexDdyOusz4/mVi6I5IAhLqInhRo4yAntgshnTpDkglCwiBIewp9gRGMLsItDHsXHxsuA08LIQl+heAgtQDxJgdohP1pQT89bVx9s/h5GpT5fJiHSTMaIFeRR/xUGg1LUr2S2wgalUvvLTOaSa9SdhcLmzdJEaCis9t; 4:wrso07fJY/zv4L3irZsFx8v0+4mlgheO/sD+i7FVysEePj2enPB1aCclDXhh35/1B/6PZAGOavFwFjE4O0QDH2yQt0x+M2j9vAyyE1XEBV8G/0HNeuZeIWkh3sscHgsvAXcnf8hRRO1muEM2PrEr4+5cKEe55jKJTG2s65QknYUt12gCujaBfFIK7G1Lo5+aiTdqzRLBGBhDMGYQy1Hmy2HPJurlG36LbO2v9K2Df8FkUlWMSfEdqez+J2Ljo2B1eHH2eANoJlTcdZZEKG6AAfuoUqYMTRBNuspo2oMivKgc5XQLpef1HLOA1D8P7fUO4kZskfglH9GfWjFigBKfZRJPP5PuJjr4QDvNQqfzJKZ7WcQepp0iA7/ZzR+O+3dAf61izEpdHVc3N8RsP2r7FQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:CY1PR12MB0444; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0444; X-Forefront-PRVS: 09497C15EB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(53416004)(47776003)(50226002)(92566002)(86362001)(76176999)(81166006)(2906002)(586003)(50986999)(8676002)(33646002)(5004730100002)(48376002)(4326007)(2950100001)(3846002)(19580405001)(189998001)(5003940100001)(19580395003)(50466002)(5008740100001)(2876002)(229853001)(2201001)(86152002)(8666003)(77096005)(5001770100001)(36756003)(42186005)(66066001)(6116002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0444; H:ssuthiku-cz-dev.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0444; 23:iPWTagHcQ4mHs7K6dcH5c4ow1+wQtAZo448OvERob?= =?us-ascii?Q?HNf3vp4MqTZisIKtnVJHF/ki295k35LTtGfkJqf1k5EUvhiVVcjcVXAcMmni?= =?us-ascii?Q?WxkgqioNlexwI/hm4yUrIiWt349YpYF0ITL/FZ9JI8GiLcE+7e4Jph+WI+v9?= =?us-ascii?Q?1zdpwKfL+2yJpzvB6UFQapEUefq3TB8Ae571ywkLnNGzC5C3LvP1pLyPj5W5?= =?us-ascii?Q?C4RqGnHafgCMYembCeEirm/qk9WITqd+gja90S/ECXmSzSCUzQuvgw5Urvt/?= =?us-ascii?Q?PkhlffXWUkJUsvEFei1mKzUQc0MK2gtruzbbeoCPVrRAKD0fWKrfKvDxRkww?= =?us-ascii?Q?YLdxPJTzkjRuFubPATt0EirgJr+Ll8Y3pZ2uL9QEBajKEPygNGwMATFWJIsG?= =?us-ascii?Q?osTqRWp9qC0D5Kmql0W3mnpK4A3WQNNdlKmoRhxUNPdMIKxaV5lgUQzplPGQ?= =?us-ascii?Q?8VLpCvxwTIp9J140xs+8g/2tVDPptaPMq5n27t1Emb7OFsqjktEsYGTPdxz8?= =?us-ascii?Q?vYG6vD1y3jY23NcQO0zX7aUXv1zX+R3xHNoo1nf/fIg3H1TuQTBHpZq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QuOGf7PPt87Wm8YnqPRTclViJsXZyUmTBbAWE/1FJJ4aWHU8pVfqDatazn48UUXkhob+EbVvMAW+czwO+KDi/ji72SiiB9AiMMt018woQhMmL/L+GKpeGlwaiJffXJuBpezThwYZhLo2llsBIvIzHUXAlfypxOPbyq9aKiG2dmk/9lSpS4jSUqTmmRh4wX2z5sZ6YRkZOzeuEBcxFGiF0oA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2016 23:42:50.9721 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0444 Cc: keir@xen.org, Suravee Suthikulpanit Subject: [Xen-devel] [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain 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" From: Suravee Suthikulpanit The guest_iommu_init() is currently called by the following code path: arch/x86/domain.c: arch_domain_create() ]- drivers/passthrough/iommu.c: iommu_domain_init() |- drivers/passthrough/amd/pci_amd_iommu.c: amd_iommu_domain_init(); |- drivers/passthrough/amd/iommu_guest.c: guest_iommu_init() At this point, the hvm_domain_initialised() has not been called. So register_mmio_handler() in guest_iommu_init() silently fails. This patch moves the iommu_domain_init() to a later point after the hvm_domain_intialise() instead. Signed-off-by: Suravee Suthikulpanit --- xen/arch/x86/domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5af2cc5..0260e01 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -642,9 +642,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, if ( (rc = init_domain_irq_mapping(d)) != 0 ) goto fail; - - if ( (rc = iommu_domain_init(d)) != 0 ) - goto fail; } spin_lock_init(&d->arch.e820_lock); @@ -660,6 +657,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, /* 64-bit PV guest by default. */ d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; + if ( !is_idle_domain(d) && (rc = iommu_domain_init(d)) != 0 ) + goto fail_1; + /* initialize default tsc behavior in case tools don't */ tsc_set_info(d, TSC_MODE_DEFAULT, 0UL, 0, 0); spin_lock_init(&d->arch.vtsc_lock); @@ -675,6 +675,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, return 0; + fail_1: + if ( has_hvm_container_domain(d) ) + hvm_domain_destroy(d); fail: d->is_dying = DOMDYING_dead; psr_domain_free(d);