From: Wei Wang2 Subject: [PATCH] AMD IOV: Fix dom0 initialization Date: Wed, 23 Apr 2008 15:51:56 +0200 Message-ID: <1208958716.10725.4.camel@gran.amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-KEG/yl/xVF/YDw1jsL34" 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: keir.fraser@eu.citrix.com Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-KEG/yl/xVF/YDw1jsL34 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Keir, This patch fixes dom0 initialization issue in the same way as c/s 17501.=20 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 --=-KEG/yl/xVF/YDw1jsL34 Content-Disposition: attachment; filename=fix_dom0.patch Content-Type: text/x-patch; name=fix_dom0.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit diff -r a5319f23db7c xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Apr 23 09:15:34 2008 +0100 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Apr 23 15:09:46 2008 +0200 @@ -290,9 +290,9 @@ static void amd_iommu_setup_domain_devic } } -static void __init amd_iommu_setup_dom0_devices(void) -{ - struct hvm_iommu *hd = domain_hvm_iommu(dom0); +static void amd_iommu_setup_dom0_devices(struct domain *d) +{ + struct hvm_iommu *hd = domain_hvm_iommu(d); struct amd_iommu *iommu; struct pci_dev *pdev; int bus, dev, func; @@ -322,7 +322,7 @@ static void __init amd_iommu_setup_dom0_ find_iommu_for_device(bus, pdev->devfn) : NULL; if ( iommu ) - amd_iommu_setup_domain_device(dom0, iommu, bdf); + amd_iommu_setup_domain_device(d, iommu, bdf); } } } @@ -330,7 +330,6 @@ static void __init amd_iommu_setup_dom0_ int amd_iov_detect(void) { - unsigned long i; int last_bus; struct amd_iommu *iommu, *next; @@ -372,14 +371,6 @@ int amd_iov_detect(void) goto error_out; } - if ( iommu_domain_init(dom0) != 0 ) - goto error_out; - - /* setup 1:1 page table for dom0 */ - for ( i = 0; i < max_page; i++ ) - amd_iommu_map_page(dom0, i, i); - - amd_iommu_setup_dom0_devices(); return 0; error_out: @@ -451,10 +442,18 @@ static int amd_iommu_domain_init(struct return -ENOMEM; } - if ( is_hvm_domain(domain) ) - hd->paging_mode = IOMMU_PAGE_TABLE_LEVEL_4; - else - hd->paging_mode = get_paging_mode(max_page); + hd->paging_mode = is_hvm_domain(domain)? + IOMMU_PAGE_TABLE_LEVEL_4 : get_paging_mode(max_page); + + if ( domain->domain_id == 0 ) + { + unsigned long i; + /* setup 1:1 page table for dom0 */ + for ( i = 0; i < max_page; i++ ) + amd_iommu_map_page(domain, i, i); + + amd_iommu_setup_dom0_devices(domain); + } hd->domain_id = domain->domain_id; --=-KEG/yl/xVF/YDw1jsL34 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 --=-KEG/yl/xVF/YDw1jsL34--