From: Wei Wang2 Subject: [PATCH] AMD IOMMU: add support for PV guest Date: Fri, 6 Jun 2008 14:50:13 +0200 Message-ID: <1212756613.5221.12.camel@gran.amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-cXfV6THYI0qzcHKAm+A3" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-cXfV6THYI0qzcHKAm+A3 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Attached patch enables AMD IOMMU for PV guest. It has been tested with PV guest being configured as both passthru domain and backend domain. Assuming iommu_populate_page_table() is only used for PV guest, a new check is added into assign_device() to avoid duplicating the work done by amd_iommu_sync_p2m() for hvm guest. Wei Signed-off-by: Wei Wang --=20 AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Gesch=C3=A4ftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplement=C3=A4r: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Gesch=C3=A4ftsf=C3=BChrer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy=20 --=-cXfV6THYI0qzcHKAm+A3 Content-Disposition: attachment; filename="pv_iommu.patch" Content-Type: text/x-patch; name="pv_iommu.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit diff -r 5603534c62f9 xen/drivers/passthrough/iommu.c --- a/xen/drivers/passthrough/iommu.c Tue Jun 03 09:41:19 2008 +0100 +++ b/xen/drivers/passthrough/iommu.c Fri Jun 06 11:06:30 2008 +0200 @@ -68,7 +68,7 @@ int assign_device(struct domain *d, u8 b if ( (rc = hd->platform_ops->assign_device(d, bus, devfn)) ) return rc; - if ( has_iommu_pdevs(d) && !need_iommu(d) ) + if ( has_iommu_pdevs(d) && !is_hvm_domain(d) && !need_iommu(d) ) { d->need_iommu = 1; return iommu_populate_page_table(d); @@ -114,6 +114,16 @@ void iommu_domain_destroy(struct domain if ( !iommu_enabled || !hd->platform_ops ) return; + if ( !is_hvm_domain(d) && !need_iommu(d) ) + return; + + if ( need_iommu(d) ) + { + d->need_iommu = 0; + hd->platform_ops->teardown(d); + return; + } + if ( hvm_irq_dpci != NULL ) { for ( i = 0; i < NR_IRQS; i++ ) @@ -207,10 +217,10 @@ static int iommu_setup(void) iommu_enabled = (rc == 0); out: - if ( !iommu_enabled || !vtd_enabled ) + if ( !iommu_enabled ) iommu_pv_enabled = 0; printk("I/O virtualisation %sabled\n", iommu_enabled ? "en" : "dis"); - if (iommu_enabled) + if ( iommu_enabled ) printk("I/O virtualisation for PV guests %sabled\n", iommu_pv_enabled ? "en" : "dis"); return rc; --=-cXfV6THYI0qzcHKAm+A3 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-cXfV6THYI0qzcHKAm+A3--