[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] xen/iommu: x86: Don't try to free page tables is the IOMMU is not enabled



commit f4cf483e2a1aec2b359347f0a34abd6bf2f208c2
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Fri Feb 26 10:56:38 2021 +0000
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Tue Mar 2 09:51:14 2021 +0000

    xen/iommu: x86: Don't try to free page tables is the IOMMU is not enabled
    
    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: 15bc9a1ef51c ("x86/iommu: add common page-table allocator")
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
 xen/drivers/passthrough/x86/iommu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/drivers/passthrough/x86/iommu.c 
b/xen/drivers/passthrough/x86/iommu.c
index cea1032b3d..58a330e822 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -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);
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.