From patchwork Fri May 13 19:36:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 67799 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp430330qge; Fri, 13 May 2016 12:39:08 -0700 (PDT) X-Received: by 10.140.234.130 with SMTP id f124mr17924474qhc.65.1463168348163; Fri, 13 May 2016 12:39:08 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 137si12969590qhr.116.2016.05.13.12.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 May 2016 12:39:08 -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 1b1Ity-00060u-IY; Fri, 13 May 2016 19:37:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1Itx-00060o-B5 for xen-devel@lists.xen.org; Fri, 13 May 2016 19:37:33 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id D3/AD-26575-CFC26375; Fri, 13 May 2016 19:37:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA1VSbSxVcRjvf88512FOOy7myTBu04swrMyXWlv rZWvS9IGUci6He7d7LzvnKq0+YOvtmrzNGpUYoaYaM2ndWaSM3Bjz0gtmQ5ckJm55q3OcS/p/ +j37vTy///aQmGKVcCfZNAPL6RmtUu6APwjTxwas+IdGBZnr8bCKuXL8MDrx9tWy7DSKITR6V XJaHKG2NvWhlHuQ9rl3CktHv5yNyIHE6ZsYlIz2yMQB0TkITA2tuDgo6BYEdc2ldkZkT8ppX3 g01LSOXehTUGTKwkQRRmcjKG7LQyLhTMdC3dKi3IhIIdcXpuvPipCiw6GtRCcqgPaC9ncFhIj thZjMT2a5iBWC5OvS9fUUinaC9qIxXMQYDdBssWCS1xteWK1ycS3QNxCUmQaQZPaD3tZmuSQK h4K6GZvIKoMv3ZXrfYA+BiPD/pJmgYCVuUOS5qUdmH+3EBKhhYGuPDsJ+8GzvjnMJkLQVz9mq +EBlWvLhESU4pDf2GFbN+EAFZnfbZZZAkwLQ7hkAXj4PsNmj4CqPxNIwiEws1ZK5CKf4i0fL9 7y8VIke4L28Cx3ieUCgoMCVZwmSW3QMRqtMB0I1LE8zySxWkbFB8Yn6+qQcArbhNeIagqPtKA dpEzpSsn2hUYptquSE66oGV59kUvVsnwL8iBJJVCjIufEsUlsWqJGK9zTBg2ko9KFMos0xacw Ol6TJFEdKIDsLhx+KlPg+mQ96+5GDYsiWhSpU/WbERtX2YM83Z0pJJRSOKawnE5j+J+fQm4kU jpT/WKKo0Zv2Nw0JZSQCSWuDoSIJQzMP8o9He3OaOsced3gU43/eLMzHua9YrLiBhOq2nMbrk 0OrmbtWi6Y9G4YX013VRzfu9h1zvH2h0ivkIkUaw1xsmcu8GA+jB/NPm8aehwdbbTU1lbfNar 2J96aPvPzQklERE5+Vgll6Zr/OMvERXam3nk+Qznd1+fbeZaVD10e4fp138xRSpxXM8F+GMcz fwFCCUoUkAMAAA== X-Env-Sender: Suravee.Suthikulpanit@amd.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1463168250!39560775!1 X-Originating-IP: [157.56.110.93] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13807 invoked from network); 13 May 2016 19:37:31 -0000 Received: from mail-bn1on0093.outbound.protection.outlook.com (HELO na01-bn1-obe.outbound.protection.outlook.com) (157.56.110.93) by server-5.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 13 May 2016 19:37:31 -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=xRU48CZFUBiAmKCD3FHcVrxR+O8mQVaUiST307uGCn+V5tnh2KnNOwAaHU6n05vevIIH4m4SiQl3J7o81Flxrw+7Yk9nyPiLr9yyHAYmK6eVhZN3s+ML8e/YxLPByAtFkwVeWh8iY1jdmTkBvTRipoD78a7n9OaeNMfotHUM2E8= Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) with Microsoft SMTP Server (TLS) id 15.1.492.11; Fri, 13 May 2016 19:37:23 +0000 From: To: , , Date: Fri, 13 May 2016 14:36:57 -0500 Message-ID: <1463168217-16080-3-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463168217-16080-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1463168217-16080-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR07CA0001.namprd07.prod.outlook.com (10.162.170.139) To BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) X-MS-Office365-Filtering-Correlation-Id: 6b73c49e-23c9-44c1-9aef-08d37b660528 X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 2:kFYfG53HSiG82UnvXA3Ji5qoJv56iJh3mfWAeLq2jK/C9HPU7XLOQZT/cD4eh/+ngzCZX0sZP9rWpeWjWvrqKJvtWT+zYXsVdmZ+2YGZekL2Xq+v4qEh22UTg9q8j35fEgnho27Jszx9uBuhSInGkHt2OI9NPQx1i960e1JzLB6aHnpgwY7XtY6sEF8flXPt; 3:+JTC6dSk6TkKl6MPQnoNxE6mmK6vBIyixoUXrERSOjeA/82QP6dZBlHur5gkJfzSInqg5SWS0vwXx4qju7jmf8boEvinQgJfbUy33Mkt5hmaVXrKh19FWs0NDINI6XUz X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0434; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 25:sk2aCMVVPBqXmPSauI5UB00iFjTAjRtgBMIqFqJtFoIWDrCIlqfm3OHQ6x2wRjM2oOLGJkQGPohieUVhcCoK3Lr5+/VJF42CPglieUZuLSzBTY3reLtxmQ3Q0Nc6IohGmXQZFISaTSPUklTW5AFEDEf9TZXJablG6PPADZ7dQkc3sgDKkOOY8MBozPL0rFm5bG76kbJz0ZQhksvlFmvPOCN0wTNIEcHSjEJzz457wsWx96vL9l2wegAzozk8p6QOOTMjDIYDEsg92Un/QKXtL7Tce50F4P880Xdop9D8omsZXmZlK/iHpkBbkTj3qV5NnWF0AKVDtY+t51I3HYb208+E+ZGuMz+BxHu9DXOITZWN9Uzal4ad82aJ+6uwE/W5ze+xmwLapIYtYomz3N7tt5uniOudb3mhJi9D4DQVZ8cTznhXicNWqwEjMY83uCFBlauo128ugjz4US0V3Bglzd9iJQGku1HCM6JvdJ+EDGo+REWV+kwK3VV0XwpBXMwxF3EOFU0i57JpQZTvXTg/ti7lqUxRLr/uqd0wORvWxr4E2UmXkLaJj1OKGFcCri7sJp4X/HikxkqdQDkFccl0IQ4KQNfjA9b95zVSNSqMid2ZR4n862vYT6OgnJL1JrtsAMFyi7ipTZ2R3TedWd/E8nrTiLSv+fkWuDOylpv9Hi5eAREk7WUKr9daqN/jVBvv X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 20:kLqFFtAa8/JXsZb7n+6sZWpDo3KMoJMnMf9hS9XK7bE93YWrstPcdtItRgFj9jIwAAtHUFNT5lFUFbnZyAOSgvS7g7+5Z0hQ15KrIz/PSFj8t5umGRZ1QEQl7yw3axvL6xQbhXlVSQgfAPnM5+VDOrtwBC6LPEVEqTec1FNNmmxKczHVfOgPHHrq9gYsss/0H9He9Q9ArDlY3U6v4n3uernxI64kZmVmgaY+YueTREbD5IA/l/E9bluAOhL83oFRmQBZVJwmt7gbRFwBcHUyalSk8gF8hZmKGkt5BiXVXOnZQLwHiHHSc67I75g3RvqT+xNBEevEqlnaOryrW3rqibIg/4EHSoHqhvrsfXevmI3xFQCF/4fui6o9J/0bSDh1ekchQaCae1YdX8/T/J+CEgb+pv6tkn2ULeUGmmbpmw76+fnCBy78zmOvC7xad2fVnfDrhkC8rSuYk2dpic1+8O/j7NAGJadJkd1n4sOzT6/k/8km2oUvQN6jZUkgGC7l; 4:45+Ebk5yalmzyudboKL5EdAS6oqQebxReNf9Mrr3mkR4j8Hy2aULzluO/jmYWm9EMuMac5PgHZ8RbjT5hbs94bk7g8gC03SnSY7OQIT6JE7a0q3wRRr93Pw+KO3NaYokrB/urqjbn1IvsqRLv5Lk+dDTYg8rdO5U8IzCtFWEHhTFxxl2PVYHZt6YUJkWddMkv3NCwsmc0TWHF97od7S9AUpvqQnvX1LSaDNprcV6qMeWVY3lCP3sww0rgG335aj7a8rhCBj81NlJIkzM+FWoseoNxysaVVcoRtKQEwNiBYhD0h04QokoFiAb+E5Xey4F0i+r35yi30CSn1IrMK3mJJuuocruNqQtSQUPNZpATJ9pMFg+zqaod6WrYDAjCH7G 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:BLUPR12MB0434; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0434; X-Forefront-PRVS: 0941B96580 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(8676002)(86362001)(2950100001)(42186005)(575784001)(2906002)(92566002)(5004730100002)(4326007)(2876002)(33646002)(229853001)(81166006)(50466002)(76176999)(189998001)(5001770100001)(48376002)(50986999)(6116002)(3846002)(50226002)(66066001)(5003940100001)(586003)(53416004)(86152002)(2201001)(19580405001)(19580395003)(77096005)(5008740100001)(36756003)(47776003)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0434; H:ssuthiku-cz-dev.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR12MB0434; 23:zz9uhSPaYF/dFs6HPOYhnaLOldcqHSeVakZOqORSm?= =?us-ascii?Q?uBADAn9lP7xh9ZWfov2KONJTzkRJpBABmj8JZetUYc+A3EmgaS5AVx0HGCpI?= =?us-ascii?Q?iQyB5r9bXuJJnlEOx/61Gdb8GE5lJnq/v4BYQxhs8Tj/gEp2TnjLaHS6qHX8?= =?us-ascii?Q?jwL4dh1S1vmLfaX5Jbnk8KVHa598d8tifkXoGC8s1MB0ZdUctVHHbREoyaLW?= =?us-ascii?Q?iGrPByDTTrEvesOf9CTOlBN3Ad7uxn49dprHUwiid8ZOdFywR/dBrrngLw8L?= =?us-ascii?Q?BlshrwF6MqjLmevoiysBHxh89uuCPuzNmTy/26Ls8dyjnr/5EZmzKUGXeEKU?= =?us-ascii?Q?1U0dpM66gKsjfWoWYaLQUsDN0gW91LX7W4HMNalnuknQ9rv/41na+3+X3NIv?= =?us-ascii?Q?BF50x93SNstvzvYLhfO8U/D+v4A4PSKBLzEbSJu2x+nb3xYQrCvSv1yr0oJ9?= =?us-ascii?Q?RRLGS3jkyJIcEJ1+0zhuH2kXSDj9anOAcdpm1Yt1J/+6mqESedVIw9ahJkSc?= =?us-ascii?Q?MGvYDuZCNj2/AIE6ndkKIcr6YIy4+jjdnPe0UNbi67EDFq+5efwJstVjT3zf?= =?us-ascii?Q?/0u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qf86Udwcj3c+7flow0IDvudj7XjuQNgypGerIyNqu9S7paFBkP9Mqg1QGiC11M/cLQvQX600Yx/px9dl6pYv+iq+xCsZWmlil8+FyxxprH3ZukwWm5jBH76ehrqIAWgFPNjQj3nBiBEZ197MPPwfwNOqKUZo9JQxSFwusSo6nKjiPnPwjppRRZ+164/fQHC1IE+Q1FoVHP7MN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2016 19:37:23.8267 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0434 Cc: paul.durrant@citrix.com, Suravee Suthikulpanit Subject: [Xen-devel] [PATCH V2 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" 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); }