]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Fix error handling of MMCONFIG setup
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 22 Jul 2014 16:48:19 +0000 (18:48 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Sat, 26 Jul 2014 11:00:12 +0000 (13:00 +0200)
If we have an MMCONFIG region, we must either successfully map it or
fail the initialization. Succeeding without setting up pci_space will
cause crashes later on when accessing it on behalf of a cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/pci.c

index ecd0e7d3f5db797a236abb05dfc8960b1d6a178d..c9acca24a8469c30dc1904a9830b6303cfbf1b52 100644 (file)
@@ -173,14 +173,14 @@ int pci_init(void)
        pci_mmcfg_size = (mcfg->alloc_structs[0].end_bus -
                          mcfg->alloc_structs[0].start_bus) * 256 * 4096;
        pci_space = page_alloc(&remap_pool, pci_mmcfg_size / PAGE_SIZE);
-       if (pci_space)
-               page_map_create(&hv_paging_structs,
-                               mcfg->alloc_structs[0].base_addr,
-                               pci_mmcfg_size, (unsigned long)pci_space,
-                               PAGE_DEFAULT_FLAGS | PAGE_FLAG_UNCACHED,
-                               PAGE_MAP_NON_COHERENT);
-
-       return 0;
+       if (!pci_space)
+               return -ENOMEM;
+
+       return page_map_create(&hv_paging_structs,
+                              mcfg->alloc_structs[0].base_addr,
+                              pci_mmcfg_size, (unsigned long)pci_space,
+                              PAGE_DEFAULT_FLAGS | PAGE_FLAG_UNCACHED,
+                              PAGE_MAP_NON_COHERENT);
 }
 
 /**