[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] VT-d: limit page table population in domain_pgd_maddr()
commit 4e977a70adb1b9036d5fa7705d73ab5dd087faa4 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Fri Apr 22 14:53:13 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri Apr 22 14:53:13 2022 +0200 VT-d: limit page table population in domain_pgd_maddr() I have to admit that I never understood why domain_pgd_maddr() wants to populate all page table levels for DFN 0. I can only assume that despite the comment there what is needed is population just down to the smallest possible nr_pt_levels that the loop later in the function may need to run to. Hence what is needed is the minimum of all possible iommu->nr_pt_levels, to then be passed into addr_to_dma_page_maddr() instead of literal 1. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> --- xen/drivers/passthrough/vtd/iommu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 4400f56459..f68d960d75 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -61,6 +61,7 @@ bool __read_mostly iommu_snoop = true; #endif static unsigned int __read_mostly nr_iommus; +static unsigned int __ro_after_init min_pt_levels = UINT_MAX; static struct tasklet vtd_fault_tasklet; @@ -439,8 +440,11 @@ static paddr_t domain_pgd_maddr(struct domain *d, paddr_t pgd_maddr, { if ( !hd->arch.vtd.pgd_maddr ) { - /* Ensure we have pagetables allocated down to leaf PTE. */ - addr_to_dma_page_maddr(d, 0, 1, NULL, true); + /* + * Ensure we have pagetables allocated down to the smallest + * level the loop below may need to run to. + */ + addr_to_dma_page_maddr(d, 0, min_pt_levels, NULL, true); if ( !hd->arch.vtd.pgd_maddr ) return 0; @@ -1349,6 +1353,8 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd) goto free; } iommu->nr_pt_levels = agaw_to_level(agaw); + if ( min_pt_levels > iommu->nr_pt_levels ) + min_pt_levels = iommu->nr_pt_levels; if ( !ecap_coherent(iommu->ecap) ) iommu_non_coherent = true; -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |