diff mbox series

[2/3] VT-d: correct off-by-1 in fault register range check

Message ID c3627c85-916a-40eb-9601-9aba87eaf8ad@suse.com (mailing list archive)
State New, archived
Headers show
Series VT-d: further small corrections | expand

Commit Message

Jan Beulich Nov. 23, 2021, 1:40 p.m. UTC
All our present implementation requires is that the range fully fits
in a single page. No need to exclude the case of the last register
extending right to the end of that page.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Tian, Kevin Nov. 24, 2021, 1:23 a.m. UTC | #1
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Tuesday, November 23, 2021 9:40 PM
> 
> All our present implementation requires is that the range fully fits
> in a single page. No need to exclude the case of the last register
> extending right to the end of that page.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -1229,7 +1229,7 @@ int __init iommu_alloc(struct acpi_drhd_
>      quirk_iommu_caps(iommu);
> 
>      if ( cap_fault_reg_offset(iommu->cap) +
> -         cap_num_fault_regs(iommu->cap) * PRIMARY_FAULT_REG_LEN >=
> PAGE_SIZE ||
> +         cap_num_fault_regs(iommu->cap) * PRIMARY_FAULT_REG_LEN >
> PAGE_SIZE ||
>           ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )
>      {
>          printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported\n");
diff mbox series

Patch

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1229,7 +1229,7 @@  int __init iommu_alloc(struct acpi_drhd_
     quirk_iommu_caps(iommu);
 
     if ( cap_fault_reg_offset(iommu->cap) +
-         cap_num_fault_regs(iommu->cap) * PRIMARY_FAULT_REG_LEN >= PAGE_SIZE ||
+         cap_num_fault_regs(iommu->cap) * PRIMARY_FAULT_REG_LEN > PAGE_SIZE ||
          ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )
     {
         printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported\n");