VT-d: prune SAGAW recognition

Bit 0 of SAGAW in the capability register has become reserved at or
before spec version 2.2. Treat it as such. Replace the effective open-
coding of find_first_set_bit(). Adjust local variable types.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
Jan Beulich committed 2021-11-24 11:11:24 +01:00
1 parent 8c6ea4a784
commit 859d11b279
1 file changed
+7 -9
+7 -9
View File
@@ -401,7 +401,7 @@ static uint64_t domain_pgd_maddr(struct domain *d, unsigned int nr_pt_levels)
pgd_maddr = hd->arch.vtd.pgd_maddr;
}
/* Skip top levels of page tables for 2- and 3-level DRHDs. */
/* Skip top level(s) of page tables for less-than-maximum level DRHDs. */
for ( agaw = level_to_agaw(4);
agaw != level_to_agaw(nr_pt_levels);
agaw-- )
@@ -1228,8 +1228,7 @@ static int __init iommu_set_interrupt(struct acpi_drhd_unit *drhd)
int __init iommu_alloc(struct acpi_drhd_unit *drhd)
{
struct vtd_iommu *iommu;
unsigned long sagaw, nr_dom;
int agaw;
unsigned int sagaw, agaw = 0, nr_dom;
iommu = xzalloc(struct vtd_iommu);
if ( iommu == NULL )
@@ -1282,14 +1281,13 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd)
return -ENODEV;
}
/* Calculate number of pagetable levels: between 2 and 4. */
/* Calculate number of pagetable levels: 3 or 4. */
sagaw = cap_sagaw(iommu->cap);
for ( agaw = level_to_agaw(4); agaw >= 0; agaw-- )
if ( test_bit(agaw, &sagaw) )
break;
if ( agaw < 0 )
if ( sagaw & 6 )
agaw = find_first_set_bit(sagaw & 6);
if ( !agaw )
{
printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported sagaw %lx\n", sagaw);
printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported sagaw %x\n", sagaw);
print_iommu_regs(drhd);
return -ENODEV;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.