From patchwork Fri May 13 17:10:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 9092661 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 78D11BF440 for ; Fri, 13 May 2016 17:13:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A1922024C for ; Fri, 13 May 2016 17:13:06 +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 66A4C2020F for ; Fri, 13 May 2016 17:13:05 +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 1b1Gc1-00069i-LK; Fri, 13 May 2016 17:10:53 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1Gbz-00068Q-Ly for xen-devel@lists.xen.org; Fri, 13 May 2016 17:10:51 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id DA/EF-07120-B9A06375; Fri, 13 May 2016 17:10:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA1VSa0gUYRTt25nR8bE5rpq3RaNdEsNQ1MgkhMp E+pE9DLGkh7M17W7si5lVFAt8BJYiGhayq5lSGhiGWj4zzfWVj0CTpSgTKjPZIFSwFUxpZ3c0 +36d+51z7j0XLolJ1ggpyWQZGVZHa+RunviDWP2lcLNnTGpkVV1E7OPFR/gRdHzw5aroNEoj1 DqFPiudUNl7rMhQCVmfpmxYLlrxK0KeJE4VYtDdmo/zBaJKEXS3DTgLCWVB0JfX61aEPEg3Kg TqPve4FyGS9Keuw8qTHbwGo0oQmIfvIl7jR6WBuXLCqccd+uLCQpzHYuoEjHfdc2qA2gUjQ+U Ejz2oJKgqsbnzWOLQ/DZ1YS69L4yYZp1ejALom5/HXN7d0G63u7nwbQTN3zNd3jCYGugT/pNg 2lTtXAAouwhWXxcgPjRQiVC7lOj6XyZgrslGuIpOd+hsMAsTNHBnPldIGgbPrIuYIEJQujYnE EFQv74quOdxaH/eKhRTXjBUti5YFgh4Wl6BuywAD8fyhBmnoLd9UsDR8Gu9hihDMvOWxc1bFq 9BogYUyjFsJsOGR0UoWLVSZdTSak14VGRMhJbhOFrJaGgFF3FFr21BjlPY5ngdqPNHvAXtJEX yAPHh2QOpku0K/dVsFc2pLrMZGoazoCCSlIP4hkdMqsSXZZRM1jW1xnFPGzSQ3nJ/cQtPizkD reXUShc1isLJifszjSIJrtPrGGmg+BgvoniRKkO32WLjKt+hYKmfGDlCSbwNDKtVG//nbSiQR HI/8TrfxVutM25OsjlCiBwhct5H8yGM9D9KmouS8b39wd8u5rSfbZuMu1W1ZNHovffVNAXIZJ lRtfkf/zTGJ6CBiWxTQmmulP156It18oP1TP34sG/xwQV/Y8pIcXNOp/VodSQbMpiaooyxVdS lFJR8lZ7sfzXT5SWNfXMhTbl/TENIZB3pL87Jkvf4+HChmTcNo2+7p0fH45bPy3FORUeFYSxH /wUyFoOvkAMAAA== X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1463159449!14109618!1 X-Originating-IP: [157.56.111.94] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60990 invoked from network); 13 May 2016 17:10:50 -0000 Received: from mail-bn1bon0094.outbound.protection.outlook.com (HELO na01-bn1-obe.outbound.protection.outlook.com) (157.56.111.94) by server-6.tower-21.messagelabs.com with AES256-SHA256 encrypted SMTP; 13 May 2016 17:10:50 -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=hZhSc7tr4cSEOZctW5EQY73Uie8hUpqbX1tO/+vnn14=; b=0v1hKf/GCSXyTs9NTaaZTg4vnPhWIpQuA6mgQStdDQWqbI2Ws7KlFj1l0ajk8O6UuTI01W/8oCf8lqdQp206YzWD+jL3Vy0bLOj4DeGOPsFPuSwRHBg02ouyTJW6+XV2BlPNAx3xalqz0IolkprSwL9mL7Wkpugd6y/kM4zQnv4= Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by CY1PR12MB0441.namprd12.prod.outlook.com (10.163.91.19) with Microsoft SMTP Server (TLS) id 15.1.497.12; Fri, 13 May 2016 17:10:42 +0000 From: To: , , , Date: Fri, 13 May 2016 12:10:01 -0500 Message-ID: <1463159401-2015-3-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463159401-2015-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1463159401-2015-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR0401CA0014.namprd04.prod.outlook.com (10.162.114.152) To CY1PR12MB0441.namprd12.prod.outlook.com (10.163.91.19) X-MS-Office365-Filtering-Correlation-Id: 696ba10b-2aa6-4375-46e0-08d37b51874e X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0441; 2:roWde2xkP1N9+Yd230oJmtshJ1Az6/xkeeFO0TnGaHDC06jBMgEY+D48Hd9ZPrBzSzNr2ovYGJneMOo+Zai8GRNUwD8RaJZaK/EGktK+SM7VgHoKXnsItgunIifJqmN3ZwhGLbDYVye4WaM26B0SrCZ/m3qYTd3UaIz/QRbcEu5Zi+bHOFDv1irvJutPnUeA; 3:iRrPn4Ytb0m3jWS6lvf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nnavxx4DXcQAsexV/oEd09iEHjHb6ymSNPvV/j4C7Ae9Or4kNH9tpfPTr2YK2UI6VmIkJUiMLxoU7W0m68Rhayb98jXWNRS/xVLKafGGtHTboYOcXTpDhRqIOCkzB1tGnImPJ7P2wmt3fjzwNBvbAoib0xgBXNUgBr7MX/uBVTbC1aZhfEZjIIuKvO1JHvAQpcIKpXISL4goC2NDItJ1EKAdoJMJoWBdS1CyiuZ4/fLAIE/cXuu+rphVj5Sn7q4sSQICTY2AErFGwsBuM8ur5wNTdWil9XkOfhKoCQVtbgCN+49m35pVXDscmA1JCtf4ktYEnkjt3PNMX43LNP3Uq/5OMuDDYbxWl4t9YWtymj3pwDHs8X31yuOio0hCX9uszP+tNI2pYH940we; 4:nMPxrJHqfLtSQFin0Qhi0UqdX8dpsWM0viG7O+0Q9Zkzyc78LlCboxlvVpOB4YSn3IZadW7RBMFUShGPIwJZajYSxd8UcWOUcD2F1clguyhtEjGZcmxCcFwgYpESwqcaInYNrgG65oLDRl9x4tIqNaEH0vQTKja3Ih+mcE0gr3FY5SD5DF5UYCzGlWTKD0Pq4C4Wv67V04StU3kWn1JBT2OnZO3JjZt2l6itWFqQx4csK59JajuHaeIwIhz5aYj013ND8/gdNJrj7kZhZQUxTgMD3xN5rey2Ll8zJ/LcFnuzExEwvARKORHAXQADD5EyR3+Bf90Te4+XM4vSJz/J5iUR000hJ9nrhA/rU/2in+R8XmAfKbkgOlL89aDFL761 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR12MB0441; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0441; X-Forefront-PRVS: 0941B96580 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(5001770100001)(50986999)(76176999)(92566002)(229853001)(33646002)(2950100001)(48376002)(77096005)(2201001)(81166006)(86152002)(575784001)(5008740100001)(50466002)(86362001)(19580405001)(19580395003)(42186005)(53416004)(2876002)(66066001)(189998001)(47776003)(4326007)(2906002)(50226002)(36756003)(5004730100002)(5003940100001)(3846002)(586003)(6116002)(8676002)(7059030)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0441; H:ssuthiku-cz-dev.amd.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0441; 23:c9wPC5FUllukiLhfwKNmRpDkyB+LLRd4Z94sL8WwC?= =?us-ascii?Q?c86vHuhplCat8dIN2wyoJyG8fPg0nBHDOs2NbLAxRnD2Vg/G3w4cufM6BwkI?= =?us-ascii?Q?BbDqMaghRAnFkm+z8B3UdXM/VHnw6T3uffoRmZVAvF4CINio01I2vzmImnyK?= =?us-ascii?Q?pGbDv/ye6XNKVrM/bbw9Vgo1gVuIlKM0c6cguPC6+HlLlFlZFw5cX/a5dt5+?= =?us-ascii?Q?0JeuJo5XksRw3Gs5g208u7dXzuFxGSpR+oPwQdNnRMiXw0lk1zfdxpc4Re1i?= =?us-ascii?Q?k84xi1r8/87oIKEEIbOeMP1zxjwxAKyWViCRimK4MOGtCqNZQtNRuibzRmlJ?= =?us-ascii?Q?NldIe+HDL1WHS6AqH7WnpIVxpMefwUzRxGGif7BSFV/CR8Ai7WLeighBm86e?= =?us-ascii?Q?LVbKUYB00AhxigTsBHBY1UJVSQszTZZf7sWitARX9IeWyMcw7vsAHlgRpdOi?= =?us-ascii?Q?91nRWwCQTZR+ur6QnyA3sljspd9R2uEaLtAneBuS1X4zCIFJqWyB+6HWA8f/?= =?us-ascii?Q?gwUVcX9Dijo/RZnUTmooif/RuiK7Mnmng8QNKb+dUhNa9/6fYHhKQjzK5Evr?= =?us-ascii?Q?E1vYELpnb+laFT5VfXQfgSkn6pQTLV6D/tBZoiErP2V5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bNC7gCMcdE=; 20:VlYGxtdJ+X9iSMh+rcEc7h0pJYFazxv8/kNBWsAwuwHEXJ9NS0scxJ3ITjN6fSbkggyGpx9WhhveFDH3JjfYm7Pvq5Iv089s+QzjNUj1VXHmUi9jMBD3uBjf+ySdfgbKuI8mDIDpsn4XYSEx3YC2q6TNf7sGRHDq/9s5N4XR8zre3mGEEKHBYvTrV7uQ9ZEWxcjyyOpwnZ3HBqy7msZinEfTKc51sIFmcYSmgGwee09u+b5UKIAyoTKoo+DRBzab X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2016 17:10:42.3083 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0441 Cc: paul.durrant@citrix.com, Suravee Suthikulpanit Subject: [Xen-devel] [PATCH 2/2] 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" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID,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 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 call to guest_iommu_init/destroy() into the svm_domain_intialise/_destroy() instead. Signed-off-by: Suravee Suthikulpanit --- xen/arch/x86/hvm/svm/svm.c | 10 ++++++++++ xen/drivers/passthrough/amd/iommu_guest.c | 6 ++++++ xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 ---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index e62dfa1..0c4affc 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -1176,11 +1177,20 @@ void svm_host_osvw_init() static int svm_domain_initialise(struct domain *d) { + if ( is_hvm_domain(d) ) + /* + * This requires the hvm domain to be + * initialized first. + */ + return guest_iommu_init(d); + return 0; } static void svm_domain_destroy(struct domain *d) { + if ( is_hvm_domain(d) ) + guest_iommu_destroy(d); } static int svm_vcpu_initialise(struct vcpu *v) diff --git a/xen/drivers/passthrough/amd/iommu_guest.c b/xen/drivers/passthrough/amd/iommu_guest.c index b4e75ac..9f26765 100644 --- a/xen/drivers/passthrough/amd/iommu_guest.c +++ b/xen/drivers/passthrough/amd/iommu_guest.c @@ -891,6 +891,12 @@ int guest_iommu_init(struct domain* d) !has_viommu(d) ) return 0; + if ( d->arch.hvm_domain.io_handler == NULL ) + { + AMD_IOMMU_DEBUG("Error: uninitalized hvm io handler\n"); + return 1; + } + iommu = xzalloc(struct guest_iommu); if ( !iommu ) { diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index c1c0b6b..f791618 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -274,9 +274,6 @@ static int amd_iommu_domain_init(struct domain *d) hd->arch.paging_mode = is_hvm_domain(d) ? IOMMU_PAGING_MODE_LEVEL_2 : get_paging_mode(max_page); - - guest_iommu_init(d); - return 0; } @@ -476,7 +473,6 @@ static void deallocate_iommu_page_tables(struct domain *d) static void amd_iommu_domain_destroy(struct domain *d) { - guest_iommu_destroy(d); deallocate_iommu_page_tables(d); amd_iommu_flush_all_pages(d); }