]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Make arch_unmap_memory_region return error codes
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 6 Apr 2014 08:53:37 +0000 (10:53 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Sun, 6 Apr 2014 09:23:11 +0000 (11:23 +0200)
We are going to use arch_unmap_memory_region also for scenarios we
hugepages might require breakups, thus we will need to handle potential
errors. Prepare arch_unmap_memory_region and its implementations for
this by propagating the error of page_map_destroy.

We can still ignore the return code in cell_destroy, so move the
corresponding comment.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/arm/setup.c
hypervisor/arch/x86/control.c
hypervisor/arch/x86/include/asm/vmx.h
hypervisor/arch/x86/include/asm/vtd.h
hypervisor/arch/x86/vmx.c
hypervisor/arch/x86/vtd.c
hypervisor/control.c
hypervisor/include/jailhouse/control.h

index f88a6e84d6879eae190a431bfef4e8dcc7c265ca..846fb8a0920f23673bf5043acded7fd67a857bfa 100644 (file)
@@ -54,8 +54,9 @@ int arch_cell_create(struct per_cpu *cpu_data, struct cell *new_cell)
 int arch_map_memory_region(struct cell *cell,
                           const struct jailhouse_memory *mem)
 { return -ENOSYS; }
-void arch_unmap_memory_region(struct cell *cell,
-                             const struct jailhouse_memory *mem) {}
+int arch_unmap_memory_region(struct cell *cell,
+                            const struct jailhouse_memory *mem)
+{ return -ENOSYS; }
 void arch_cell_destroy(struct per_cpu *cpu_data, struct cell *new_cell) {}
 void *memcpy(void *dest, const void *src, unsigned long n) { return NULL; }
 void arch_dbg_write(const char *msg) {}
index bd2ded68d66317d3a790369c40be504b5524aadb..e8c0a3a7591b55ab1f1a0ea814cb87c345b18ad8 100644 (file)
@@ -74,11 +74,16 @@ int arch_map_memory_region(struct cell *cell,
        return err;
 }
 
-void arch_unmap_memory_region(struct cell *cell,
-                             const struct jailhouse_memory *mem)
+int arch_unmap_memory_region(struct cell *cell,
+                            const struct jailhouse_memory *mem)
 {
-       vtd_unmap_memory_region(cell, mem);
-       vmx_unmap_memory_region(cell, mem);
+       int err;
+
+       err = vtd_unmap_memory_region(cell, mem);
+       if (!err)
+               return err;
+
+       return vmx_unmap_memory_region(cell, mem);
 }
 
 void arch_cell_destroy(struct per_cpu *cpu_data, struct cell *cell)
index 360f57dc1c7f19b0c6cf87d34ff33857ff63a201..108c63142569079ee39ac44360fd821cd9d21a5f 100644 (file)
@@ -290,8 +290,8 @@ int vmx_cell_init(struct cell *cell);
 int vmx_root_cell_shrink(struct jailhouse_cell_desc *config);
 int vmx_map_memory_region(struct cell *cell,
                          const struct jailhouse_memory *mem);
-void vmx_unmap_memory_region(struct cell *cell,
-                            const struct jailhouse_memory *mem);
+int vmx_unmap_memory_region(struct cell *cell,
+                           const struct jailhouse_memory *mem);
 void vmx_cell_exit(struct cell *cell);
 
 int vmx_cpu_init(struct per_cpu *cpu_data);
index f3837b4e1633b14522f969deb2b2afaf3c7cf40c..1111dde89a0dd334395a787668a5c0350296b8cf 100644 (file)
@@ -140,8 +140,8 @@ int vtd_cell_init(struct cell *cell);
 int vtd_root_cell_shrink(struct jailhouse_cell_desc *config);
 int vtd_map_memory_region(struct cell *cell,
                          const struct jailhouse_memory *mem);
-void vtd_unmap_memory_region(struct cell *cell,
-                            const struct jailhouse_memory *mem);
+int vtd_unmap_memory_region(struct cell *cell,
+                           const struct jailhouse_memory *mem);
 void vtd_cell_exit(struct cell *cell);
 
 void vtd_shutdown(void);
index 8a2647c8a19f57e138714df7a63c46ba2cf7df1e..4aeb898425e587233c9fa5d1da2e121f590c1c48 100644 (file)
@@ -258,13 +258,11 @@ int vmx_map_memory_region(struct cell *cell,
                               mem->virt_start, flags, PAGE_MAP_NON_COHERENT);
 }
 
-void vmx_unmap_memory_region(struct cell *cell,
-                            const struct jailhouse_memory *mem)
+int vmx_unmap_memory_region(struct cell *cell,
+                           const struct jailhouse_memory *mem)
 {
-       /* This cannot fail. The region was mapped as a whole before, thus no
-        * hugepages need to be broken up to unmap it. */
-       page_map_destroy(&cell->vmx.ept_structs, mem->virt_start, mem->size,
-                        PAGE_MAP_NON_COHERENT);
+       return page_map_destroy(&cell->vmx.ept_structs, mem->virt_start,
+                               mem->size, PAGE_MAP_NON_COHERENT);
 }
 
 unsigned long arch_page_map_gphys2phys(struct per_cpu *cpu_data,
index c324abb7358870ed3e34879817909d4f00d522ed..17b81cb460a672c77f024d08485f0f50bc5e1ce9 100644 (file)
@@ -470,18 +470,18 @@ int vtd_map_memory_region(struct cell *cell,
                               PAGE_MAP_COHERENT);
 }
 
-void vtd_unmap_memory_region(struct cell *cell,
-                            const struct jailhouse_memory *mem)
+int vtd_unmap_memory_region(struct cell *cell,
+                           const struct jailhouse_memory *mem)
 {
        // HACK for QEMU
        if (dmar_units == 0)
-               return;
+               return 0;
+
+       if (!(mem->flags & JAILHOUSE_MEM_DMA))
+               return 0;
 
-       if (mem->flags & JAILHOUSE_MEM_DMA)
-               /* This cannot fail. The region was mapped as a whole before,
-                * thus no hugepages need to be broken up to unmap it. */
-               page_map_destroy(&cell->vtd.pg_structs, mem->virt_start,
-                                mem->size, PAGE_MAP_COHERENT);
+       return page_map_destroy(&cell->vtd.pg_structs, mem->virt_start,
+                               mem->size, PAGE_MAP_COHERENT);
 }
 
 static bool
index 21f615fe8050928f28fd29b2c43d372612cdf054..d2ead73c038912501e4e17639174beb307b4488f 100644 (file)
@@ -369,6 +369,10 @@ int cell_destroy(struct per_cpu *cpu_data, unsigned long id)
 
        mem = jailhouse_cell_mem_regions(cell->config);
        for (n = 0; n < cell->config->num_memory_regions; n++, mem++) {
+               /*
+                * This cannot fail. The region was mapped as a whole before,
+                * thus no hugepages need to be broken up to unmap it.
+                */
                arch_unmap_memory_region(cell, mem);
                if (!(mem->flags & JAILHOUSE_MEM_COMM_REGION))
                        remap_to_root_cell(mem);
index eda923dec8733ba4a6d9f14fee470fc74988909d..9181f87682940c66120010b4ed8570f0eb7dd570 100644 (file)
@@ -60,8 +60,8 @@ void arch_shutdown_cpu(unsigned int cpu_id);
 
 int arch_map_memory_region(struct cell *cell,
                           const struct jailhouse_memory *mem);
-void arch_unmap_memory_region(struct cell *cell,
-                             const struct jailhouse_memory *mem);
+int arch_unmap_memory_region(struct cell *cell,
+                            const struct jailhouse_memory *mem);
 
 int arch_cell_create(struct per_cpu *cpu_data, struct cell *cell);
 void arch_cell_destroy(struct per_cpu *cpu_data, struct cell *cell);