diff mbox series

[v2,1/6] iommu/vt-d: do not assume page table levels for quarantine domain

Message ID 20231204094305.59267-2-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series x86/iommu: improve setup time of hwdom IOMMU | expand

Commit Message

Roger Pau Monné Dec. 4, 2023, 9:43 a.m. UTC
Like XSA-445, do not assume IOMMU page table levels on VT-d are always set
based on DEFAULT_DOMAIN_ADDRESS_WIDTH and instead fetch the value set by
intel_iommu_hwdom_init() from the domain iommu structure.  This prevents
changes to intel_iommu_hwdom_init() possibly getting the levels out of sync
with what intel_iommu_quarantine_init() expects.

No functional change, since on Intel domains are hardcoded to use
DEFAULT_DOMAIN_ADDRESS_WIDTH.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - New in this version.
---
 xen/drivers/passthrough/vtd/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Beulich Dec. 5, 2023, 2:24 p.m. UTC | #1
On 04.12.2023 10:43, Roger Pau Monne wrote:
> Like XSA-445, do not assume IOMMU page table levels on VT-d are always set
> based on DEFAULT_DOMAIN_ADDRESS_WIDTH and instead fetch the value set by
> intel_iommu_hwdom_init() from the domain iommu structure.  This prevents
> changes to intel_iommu_hwdom_init() possibly getting the levels out of sync

In both cases, don't you mean intel_iommu_domain_init() instead? Only if
so
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(and happy to adjust while committing).

Otherwise I must be missing something.

Jan

> with what intel_iommu_quarantine_init() expects.
> 
> No functional change, since on Intel domains are hardcoded to use
> DEFAULT_DOMAIN_ADDRESS_WIDTH.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Changes since v1:
>  - New in this version.
> ---
>  xen/drivers/passthrough/vtd/iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
> index e13b7d99db40..bc6181c9f911 100644
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -3162,7 +3162,7 @@ static int cf_check intel_iommu_quarantine_init(struct pci_dev *pdev,
>  {
>      struct domain_iommu *hd = dom_iommu(dom_io);
>      struct page_info *pg;
> -    unsigned int agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH);
> +    unsigned int agaw = hd->arch.vtd.agaw;
>      unsigned int level = agaw_to_level(agaw);
>      const struct acpi_drhd_unit *drhd;
>      const struct acpi_rmrr_unit *rmrr;
Roger Pau Monné Dec. 5, 2023, 2:30 p.m. UTC | #2
On Tue, Dec 05, 2023 at 03:24:46PM +0100, Jan Beulich wrote:
> On 04.12.2023 10:43, Roger Pau Monne wrote:
> > Like XSA-445, do not assume IOMMU page table levels on VT-d are always set
> > based on DEFAULT_DOMAIN_ADDRESS_WIDTH and instead fetch the value set by
> > intel_iommu_hwdom_init() from the domain iommu structure.  This prevents
> > changes to intel_iommu_hwdom_init() possibly getting the levels out of sync
> 
> In both cases, don't you mean intel_iommu_domain_init() instead? Only if

Indeed, sorry.

> so
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> (and happy to adjust while committing).

Thanks.

> Otherwise I must be missing something.

No, you are right.

Roger.
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index e13b7d99db40..bc6181c9f911 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -3162,7 +3162,7 @@  static int cf_check intel_iommu_quarantine_init(struct pci_dev *pdev,
 {
     struct domain_iommu *hd = dom_iommu(dom_io);
     struct page_info *pg;
-    unsigned int agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH);
+    unsigned int agaw = hd->arch.vtd.agaw;
     unsigned int level = agaw_to_level(agaw);
     const struct acpi_drhd_unit *drhd;
     const struct acpi_rmrr_unit *rmrr;