Skip to content

Commit

Permalink
xen/iommu: x86: Don't try to free page tables is the IOMMU is not ena…
Browse files Browse the repository at this point in the history
…bled

When using CONFIG_BIGMEM=y, the page_list cannot be accessed whilst it
is is unitialized. However, iommu_free_pgtables() will be called even if
the domain is not using an IOMMU.

Consequently, Xen will try to go through the page list and deference a
NULL pointer.

Bail out early if the domain is not using an IOMMU.

Fixes: 15bc9a1 ("x86/iommu: add common page-table allocator")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
  • Loading branch information
Julien Grall committed Mar 2, 2021
1 parent 29fae90 commit f4cf483
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xen/drivers/passthrough/x86/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ int iommu_free_pgtables(struct domain *d)
struct page_info *pg;
unsigned int done = 0;

if ( !is_iommu_enabled(d) )
return 0;

while ( (pg = page_list_remove_head(&hd->arch.pgtables.list)) )
{
free_domheap_page(pg);
Expand Down

0 comments on commit f4cf483

Please sign in to comment.