]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Instrument relevant return paths for error tracing
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 18 Mar 2015 07:50:25 +0000 (08:50 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Sat, 21 Mar 2015 14:15:08 +0000 (15:15 +0100)
This instruments return paths so that the origin of important errors can
be tracked down. Two so far explicit error outputs are replaced with
trace_error.

We do not instrument -ENOMEM cases unless they relate to allocations
from the remapping pool. All other -ENOMEM cases boil down to a too
small hypervisor region.

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

index b06792a64c319df8124b9479c05dc65f7ff63633..8de3e07613eb97a53caf458ad26c1d801426d718 100644 (file)
@@ -179,7 +179,7 @@ int cell_init(struct cell *cell)
        cell->id = get_free_cell_id();
 
        if (cpu_set_size > PAGE_SIZE)
-               return -EINVAL;
+               return trace_error(-EINVAL);
        if (cpu_set_size > sizeof(cell->small_cpu_set.bitmap)) {
                cpu_set = page_alloc(&mem_pool, 1);
                if (!cpu_set)
@@ -221,12 +221,8 @@ int check_mem_regions(const struct jailhouse_cell_desc *config)
                if (mem->phys_start & ~PAGE_MASK ||
                    mem->virt_start & ~PAGE_MASK ||
                    mem->size & ~PAGE_MASK ||
-                   mem->flags & ~JAILHOUSE_MEM_VALID_FLAGS) {
-                       printk("FATAL: Invalid memory bar (%p, %p, %p, %x)\n",
-                              mem->phys_start, mem->virt_start, mem->size,
-                              mem->flags);
-                       return -EINVAL;
-               }
+                   mem->flags & ~JAILHOUSE_MEM_VALID_FLAGS)
+                       return trace_error(-EINVAL);
        }
        return 0;
 }
@@ -386,7 +382,7 @@ static int cell_create(struct per_cpu *cpu_data, unsigned long config_address)
        cfg_total_size = jailhouse_cell_config_size(cfg);
        cfg_pages = PAGES(cfg_page_offs + cfg_total_size);
        if (cfg_pages > NUM_TEMPORARY_PAGES) {
-               err = -E2BIG;
+               err = trace_error(-E2BIG);
                goto err_resume;
        }
 
@@ -417,14 +413,14 @@ static int cell_create(struct per_cpu *cpu_data, unsigned long config_address)
 
        /* don't assign the CPU we are currently running on */
        if (cell_owns_cpu(cell, cpu_data->cpu_id)) {
-               err = -EBUSY;
+               err = trace_error(-EBUSY);
                goto err_free_cpu_set;
        }
 
        /* the root cell's cpu set must be super-set of new cell's set */
        for_each_cpu(cpu, cell->cpu_set)
                if (!cell_owns_cpu(&root_cell, cpu)) {
-                       err = -EBUSY;
+                       err = trace_error(-EBUSY);
                        goto err_free_cpu_set;
                }
 
index fee26394a9035013a6325fb77426164919c3da10..efbef812ef2fbce78b136c0a679fffff0865b172 100644 (file)
@@ -513,11 +513,11 @@ int paging_init(void)
 
        if (system_config->debug_uart.flags & JAILHOUSE_MEM_IO) {
                vaddr = (unsigned long)hypervisor_header.debug_uart_base;
+               /* check if UART overlaps remapping region */
                if (vaddr + system_config->debug_uart.size >= REMAP_BASE &&
-                   vaddr < REMAP_BASE + remap_pool.pages * PAGE_SIZE) {
-                       printk("FATAL: UART overlaps remapping region\n");
-                       return -EINVAL;
-               }
+                   vaddr < REMAP_BASE + remap_pool.pages * PAGE_SIZE)
+                       return trace_error(-EINVAL);
+
                err = paging_create(&hv_paging_structs,
                                    system_config->debug_uart.phys_start,
                                    system_config->debug_uart.size, vaddr,
index 49d8ad9fe70567c28865b96451d3ecb8eace5fad..cb671df63f07ea1813cf44fd7e396141c1ef60d9 100644 (file)
@@ -321,7 +321,7 @@ int pci_init(void)
 
        pci_space = page_alloc(&remap_pool, mmcfg_size / PAGE_SIZE);
        if (!pci_space)
-               return -ENOMEM;
+               return trace_error(-ENOMEM);
 
        return paging_create(&hv_paging_structs, mmcfg_start, mmcfg_size,
                             (unsigned long)pci_space,
@@ -552,7 +552,7 @@ static int pci_add_device(struct cell *cell, struct pci_device *device)
        if (!err && device->info->msix_address) {
                device->msix_table = page_alloc(&remap_pool, size / PAGE_SIZE);
                if (!device->msix_table) {
-                       err = -ENOMEM;
+                       err = trace_error(-ENOMEM);
                        goto error_remove_dev;
                }
 
@@ -650,7 +650,7 @@ int pci_cell_init(struct cell *cell)
         */
        for (ndev = 0; ndev < cell->config->num_pci_devices; ndev++) {
                if (dev_infos[ndev].num_msix_vectors > PCI_MAX_MSIX_VECTORS) {
-                       err = -ERANGE;
+                       err = trace_error(-ERANGE);
                        goto error;
                }
 
index 4f6e52da7e71ae411d8e35f536161c686523785b..c3e71c47c264e41c5cfd074d4dc27eb2606e1a41 100644 (file)
@@ -553,10 +553,10 @@ int pci_ivshmem_init(struct cell *cell, struct pci_device *dev)
        struct pci_device *dev0;
 
        if (dev->info->num_msix_vectors != 1)
-               return -EINVAL;
+               return trace_error(-EINVAL);
 
        if (dev->info->shmem_region >= cell->config->num_memory_regions)
-               return -EINVAL;
+               return trace_error(-EINVAL);
 
        mem = jailhouse_cell_mem_regions(cell->config)
                + dev->info->shmem_region;
@@ -570,7 +570,7 @@ int pci_ivshmem_init(struct cell *cell, struct pci_device *dev)
                if ((mem0->phys_start == mem->phys_start) &&
                    (mem0->size == mem->size)) {
                        if ((*ivp)->eps[1].device)
-                               return -EBUSY;
+                               return trace_error(-EBUSY);
                        ivshmem_connect_cell(*ivp, dev, mem, 1);
                        printk("Virtual PCI connection established "
                                "\"%s\" <--> \"%s\"\n",