From: "Jan Beulich" Subject: [PATCH 4/5] VT-d: widen NUMA nodes to be allocated from Date: Thu, 26 Feb 2015 13:55:28 +0000 Message-ID: <54EF33E00200007800064148@mail.emea.novell.com> References: <54EF315902000078000640FF@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part360380C0.2__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQyuY-0005fx-Mf for xen-devel@lists.xenproject.org; Thu, 26 Feb 2015 13:55:30 +0000 In-Reply-To: <54EF315902000078000640FF@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Yang Z Zhang , Dario Faggioli , Kevin Tian List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part360380C0.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/vtd/extern.h +++ b/xen/drivers/passthrough/vtd/extern.h @@ -67,7 +67,8 @@ unsigned int get_cache_line_size(void); void cacheline_flush(char *); void flush_all_cache(void); =20 -u64 alloc_pgtable_maddr(struct acpi_drhd_unit *drhd, unsigned long = npages); +u64 alloc_pgtable_maddr(struct acpi_drhd_unit *, unsigned int npages, + struct domain *); void free_pgtable_maddr(u64 maddr); void *map_vtd_domain_page(u64 maddr); void unmap_vtd_domain_page(void *va); --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -739,7 +739,8 @@ int enable_intremap(struct iommu *iommu, if ( ir_ctrl->iremap_maddr =3D=3D 0 ) { drhd =3D iommu_to_drhd(iommu); - ir_ctrl->iremap_maddr =3D alloc_pgtable_maddr(drhd, IREMAP_ARCH_PA= GE_NR); + ir_ctrl->iremap_maddr =3D alloc_pgtable_maddr(drhd, IREMAP_ARCH_PA= GE_NR, + NULL); if ( ir_ctrl->iremap_maddr =3D=3D 0 ) { dprintk(XENLOG_WARNING VTDPREFIX, --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -185,7 +185,8 @@ void iommu_flush_cache_page(void *addr,=20 } =20 /* Allocate page table, return its machine address */ -u64 alloc_pgtable_maddr(struct acpi_drhd_unit *drhd, unsigned long = npages) +u64 alloc_pgtable_maddr(struct acpi_drhd_unit *drhd, unsigned int npages, + struct domain *d) { struct acpi_rhsa_unit *rhsa; struct page_info *pg, *cur_pg; @@ -195,10 +196,10 @@ u64 alloc_pgtable_maddr(struct acpi_drhd =20 rhsa =3D drhd_to_rhsa(drhd); if ( rhsa ) - node =3D pxm_to_node(rhsa->proximity_domain); + node =3D pxm_to_node(rhsa->proximity_domain); =20 - pg =3D alloc_domheap_pages(NULL, get_order_from_pages(npages), - (node =3D=3D NUMA_NO_NODE) ? 0 : MEMF_node(no= de)); + pg =3D alloc_domheap_pages(d, get_order_from_pages(npages), + MEMF_node(node) | MEMF_no_owner); if ( !pg ) return 0; =20 @@ -223,7 +224,7 @@ void free_pgtable_maddr(u64 maddr) } =20 /* context entry handling */ -static u64 bus_to_context_maddr(struct iommu *iommu, u8 bus) +static u64 bus_to_context_maddr(struct iommu *iommu, u8 bus, struct = domain *d) { struct acpi_drhd_unit *drhd; struct root_entry *root, *root_entries; @@ -235,7 +236,7 @@ static u64 bus_to_context_maddr(struct i if ( !root_present(*root) ) { drhd =3D iommu_to_drhd(iommu); - maddr =3D alloc_pgtable_maddr(drhd, 1); + maddr =3D alloc_pgtable_maddr(drhd, 1, d); if ( maddr =3D=3D 0 ) { unmap_vtd_domain_page(root_entries); @@ -271,7 +272,9 @@ static u64 addr_to_dma_page_maddr(struct */ pdev =3D pci_get_pdev_by_domain(domain, -1, -1, -1); drhd =3D acpi_find_matched_drhd_unit(pdev); - if ( !alloc || ((hd->arch.pgd_maddr =3D alloc_pgtable_maddr(drhd, = 1)) =3D=3D 0) ) + if ( !alloc || + ((hd->arch.pgd_maddr =3D alloc_pgtable_maddr(drhd, 1, + domain)) =3D=3D = 0) ) goto out; } =20 @@ -289,7 +292,7 @@ static u64 addr_to_dma_page_maddr(struct =20 pdev =3D pci_get_pdev_by_domain(domain, -1, -1, -1); drhd =3D acpi_find_matched_drhd_unit(pdev); - pte_maddr =3D alloc_pgtable_maddr(drhd, 1); + pte_maddr =3D alloc_pgtable_maddr(drhd, 1, domain); if ( !pte_maddr ) break; =20 @@ -1119,7 +1122,7 @@ int __init iommu_alloc(struct acpi_drhd_ iommu->intel->drhd =3D drhd; drhd->iommu =3D iommu; =20 - if ( !(iommu->root_maddr =3D alloc_pgtable_maddr(drhd, 1)) ) + if ( !(iommu->root_maddr =3D alloc_pgtable_maddr(drhd, 1, NULL)) ) return -ENOMEM; =20 iommu->reg =3D ioremap(drhd->address, PAGE_SIZE); @@ -1270,7 +1273,7 @@ int domain_context_mapping_one( =20 ASSERT(spin_is_locked(&pcidevs_lock)); spin_lock(&iommu->lock); - maddr =3D bus_to_context_maddr(iommu, bus); + maddr =3D bus_to_context_maddr(iommu, bus, domain); context_entries =3D (struct context_entry *)map_vtd_domain_page(maddr)= ; context =3D &context_entries[devfn]; =20 @@ -1495,7 +1498,7 @@ int domain_context_unmap_one( ASSERT(spin_is_locked(&pcidevs_lock)); spin_lock(&iommu->lock); =20 - maddr =3D bus_to_context_maddr(iommu, bus); + maddr =3D bus_to_context_maddr(iommu, bus, domain); context_entries =3D (struct context_entry *)map_vtd_domain_page(maddr)= ; context =3D &context_entries[devfn]; =20 --- a/xen/drivers/passthrough/vtd/qinval.c +++ b/xen/drivers/passthrough/vtd/qinval.c @@ -374,7 +374,8 @@ int enable_qinval(struct iommu *iommu) if ( qi_ctrl->qinval_maddr =3D=3D 0 ) { drhd =3D iommu_to_drhd(iommu); - qi_ctrl->qinval_maddr =3D alloc_pgtable_maddr(drhd, QINVAL_ARCH_PA= GE_NR); + qi_ctrl->qinval_maddr =3D alloc_pgtable_maddr(drhd, QINVAL_ARCH_PA= GE_NR, + NULL); if ( qi_ctrl->qinval_maddr =3D=3D 0 ) { dprintk(XENLOG_WARNING VTDPREFIX, --=__Part360380C0.2__= Content-Type: text/plain; name="VT-d-alloc-for-domain.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="VT-d-alloc-for-domain.patch" VT-d: widen NUMA nodes to be allocated from=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/drivers/passthrough/vtd/extern.h= =0A+++ b/xen/drivers/passthrough/vtd/extern.h=0A@@ -67,7 +67,8 @@ unsigned = int get_cache_line_size(void);=0A void cacheline_flush(char *);=0A void = flush_all_cache(void);=0A =0A-u64 alloc_pgtable_maddr(struct acpi_drhd_unit= *drhd, unsigned long npages);=0A+u64 alloc_pgtable_maddr(struct acpi_drhd_= unit *, unsigned int npages,=0A+ struct domain = *);=0A void free_pgtable_maddr(u64 maddr);=0A void *map_vtd_domain_page(u64= maddr);=0A void unmap_vtd_domain_page(void *va);=0A--- a/xen/drivers/passt= hrough/vtd/intremap.c=0A+++ b/xen/drivers/passthrough/vtd/intremap.c=0A@@ = -739,7 +739,8 @@ int enable_intremap(struct iommu *iommu,=0A if ( = ir_ctrl->iremap_maddr =3D=3D 0 )=0A {=0A drhd =3D iommu_to_drhd= (iommu);=0A- ir_ctrl->iremap_maddr =3D alloc_pgtable_maddr(drhd, = IREMAP_ARCH_PAGE_NR);=0A+ ir_ctrl->iremap_maddr =3D alloc_pgtable_ma= ddr(drhd, IREMAP_ARCH_PAGE_NR,=0A+ = NULL);=0A if ( ir_ctrl->iremap_maddr =3D=3D 0 )=0A = {=0A dprintk(XENLOG_WARNING VTDPREFIX,=0A--- a/xen/drivers/p= assthrough/vtd/iommu.c=0A+++ b/xen/drivers/passthrough/vtd/iommu.c=0A@@ = -185,7 +185,8 @@ void iommu_flush_cache_page(void *addr, =0A }=0A =0A /* = Allocate page table, return its machine address */=0A-u64 alloc_pgtable_mad= dr(struct acpi_drhd_unit *drhd, unsigned long npages)=0A+u64 alloc_pgtable_= maddr(struct acpi_drhd_unit *drhd, unsigned int npages,=0A+ = struct domain *d)=0A {=0A struct acpi_rhsa_unit *rhsa;=0A = struct page_info *pg, *cur_pg;=0A@@ -195,10 +196,10 @@ u64 alloc_pgtable_ma= ddr(struct acpi_drhd=0A =0A rhsa =3D drhd_to_rhsa(drhd);=0A if ( = rhsa )=0A- node =3D pxm_to_node(rhsa->proximity_domain);=0A+ = node =3D pxm_to_node(rhsa->proximity_domain);=0A =0A- pg =3D alloc_domh= eap_pages(NULL, get_order_from_pages(npages),=0A- = (node =3D=3D NUMA_NO_NODE) ? 0 : MEMF_node(node));=0A+ pg =3D = alloc_domheap_pages(d, get_order_from_pages(npages),=0A+ = MEMF_node(node) | MEMF_no_owner);=0A if ( !pg )=0A = return 0;=0A =0A@@ -223,7 +224,7 @@ void free_pgtable_maddr(u64 maddr)=0A = }=0A =0A /* context entry handling */=0A-static u64 bus_to_context_maddr(st= ruct iommu *iommu, u8 bus)=0A+static u64 bus_to_context_maddr(struct iommu = *iommu, u8 bus, struct domain *d)=0A {=0A struct acpi_drhd_unit = *drhd;=0A struct root_entry *root, *root_entries;=0A@@ -235,7 +236,7 = @@ static u64 bus_to_context_maddr(struct i=0A if ( !root_present(*root= ) )=0A {=0A drhd =3D iommu_to_drhd(iommu);=0A- maddr = =3D alloc_pgtable_maddr(drhd, 1);=0A+ maddr =3D alloc_pgtable_maddr(= drhd, 1, d);=0A if ( maddr =3D=3D 0 )=0A {=0A = unmap_vtd_domain_page(root_entries);=0A@@ -271,7 +272,9 @@ static u64 = addr_to_dma_page_maddr(struct=0A */=0A pdev =3D pci_get_pd= ev_by_domain(domain, -1, -1, -1);=0A drhd =3D acpi_find_matched_drh= d_unit(pdev);=0A- if ( !alloc || ((hd->arch.pgd_maddr =3D alloc_pgta= ble_maddr(drhd, 1)) =3D=3D 0) )=0A+ if ( !alloc ||=0A+ = ((hd->arch.pgd_maddr =3D alloc_pgtable_maddr(drhd, 1,=0A+ = domain)) =3D=3D 0) )=0A = goto out;=0A }=0A =0A@@ -289,7 +292,7 @@ static u64 addr_to_dma_page_ma= ddr(struct=0A =0A pdev =3D pci_get_pdev_by_domain(domain, -1, = -1, -1);=0A drhd =3D acpi_find_matched_drhd_unit(pdev);=0A- = pte_maddr =3D alloc_pgtable_maddr(drhd, 1);=0A+ = pte_maddr =3D alloc_pgtable_maddr(drhd, 1, domain);=0A if ( = !pte_maddr )=0A break;=0A =0A@@ -1119,7 +1122,7 @@ int = __init iommu_alloc(struct acpi_drhd_=0A iommu->intel->drhd =3D = drhd;=0A drhd->iommu =3D iommu;=0A =0A- if ( !(iommu->root_maddr = =3D alloc_pgtable_maddr(drhd, 1)) )=0A+ if ( !(iommu->root_maddr =3D = alloc_pgtable_maddr(drhd, 1, NULL)) )=0A return -ENOMEM;=0A =0A = iommu->reg =3D ioremap(drhd->address, PAGE_SIZE);=0A@@ -1270,7 +1273,7 @@ = int domain_context_mapping_one(=0A =0A ASSERT(spin_is_locked(&pcidevs_l= ock));=0A spin_lock(&iommu->lock);=0A- maddr =3D bus_to_context_madd= r(iommu, bus);=0A+ maddr =3D bus_to_context_maddr(iommu, bus, = domain);=0A context_entries =3D (struct context_entry *)map_vtd_domain_= page(maddr);=0A context =3D &context_entries[devfn];=0A =0A@@ -1495,7 = +1498,7 @@ int domain_context_unmap_one(=0A ASSERT(spin_is_locked(&pcid= evs_lock));=0A spin_lock(&iommu->lock);=0A =0A- maddr =3D bus_to_con= text_maddr(iommu, bus);=0A+ maddr =3D bus_to_context_maddr(iommu, bus, = domain);=0A context_entries =3D (struct context_entry *)map_vtd_domain_= page(maddr);=0A context =3D &context_entries[devfn];=0A =0A--- = a/xen/drivers/passthrough/vtd/qinval.c=0A+++ b/xen/drivers/passthrough/vtd/= qinval.c=0A@@ -374,7 +374,8 @@ int enable_qinval(struct iommu *iommu)=0A = if ( qi_ctrl->qinval_maddr =3D=3D 0 )=0A {=0A drhd =3D = iommu_to_drhd(iommu);=0A- qi_ctrl->qinval_maddr =3D alloc_pgtable_ma= ddr(drhd, QINVAL_ARCH_PAGE_NR);=0A+ qi_ctrl->qinval_maddr =3D = alloc_pgtable_maddr(drhd, QINVAL_ARCH_PAGE_NR,=0A+ = NULL);=0A if ( qi_ctrl->qinval_maddr = =3D=3D 0 )=0A {=0A dprintk(XENLOG_WARNING VTDPREFIX,=0A --=__Part360380C0.2__= 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.xen.org http://lists.xen.org/xen-devel --=__Part360380C0.2__=--