Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Cleanup and sanity-checking of before/after null-check and copy+paste errors (Coverit...
Peter Dinda [Tue, 1 Sep 2015 16:47:14 +0000 (11:47 -0500)]
linux_module/iface-keyed-stream.c
palacios/src/devices/apic.c
palacios/src/palacios/vmm_config.c
palacios/src/palacios/vmm_extensions.c
palacios/src/palacios/vmm_paging.c
palacios/src/palacios/vmm_rbtree.c
palacios/src/palacios/vmm_time.c
palacios/src/palacios/vmm_xml.c

index 365a9c7..a6fb960 100644 (file)
@@ -2780,7 +2780,7 @@ static sint64_t write_key_net(v3_keyed_stream_t stream, v3_keyed_stream_key_t ke
            ERROR("Could not send tag length in write_key_net\n");
            return -1;
        } 
-       if (send_msg(nks->ns,tag,taglen)!=len) { 
+       if (send_msg(nks->ns,tag,taglen)!=taglen) { 
            ERROR("Could not send tag in write_key_net\n");
            return -1;
        }
index e44c9b0..a325006 100644 (file)
@@ -894,6 +894,11 @@ static int deliver_ipi(struct apic_state * src_apic,
            }
 
 
+           if (!src_apic) { 
+               PrintError(VM_NONE, VCORE_NONE, "Attempting to INIT from somewhere other than an APIC...  Ignoring\n");
+               break;
+           }
+
            if (dst_apic->ipi_state != INIT_ST) { 
                v3_raise_barrier(dst_core->vm_info, src_apic->core);
                dst_core->core_run_state = CORE_STOPPED;
index 9e73d11..e4c9b4f 100644 (file)
@@ -640,7 +640,7 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) {
     vm = allocate_guest(num_cores);    
 
     if (!vm) {
-       PrintError(VM_NONE, VCORE_NONE, "Could not allocate %d core guest\n", vm->num_cores);
+       PrintError(VM_NONE, VCORE_NONE, "Could not allocate %d core guest\n", num_cores);
        return NULL;
     }
 
index e9f4a71..af2c0e2 100644 (file)
@@ -58,6 +58,12 @@ int V3_init_extensions() {
     ext_table = v3_create_htable(0, ext_hash_fn, ext_eq_fn);
 
     while (tmp_ext != __stop__v3_extensions) {
+
+        if ((*tmp_ext) && (*tmp_ext)->init && ((*tmp_ext)->init() != 0)) {
+           PrintError(VM_NONE, VCORE_NONE, "Could not initialize extension (%s)\n", (*tmp_ext)->name);
+           return -1;
+       } 
+
         V3_Print(VM_NONE, VCORE_NONE, "Registering Extension (%s)\n", (*tmp_ext)->name);
 
        if (v3_htable_search(ext_table, (addr_t)((*tmp_ext)->name))) {
@@ -70,11 +76,6 @@ int V3_init_extensions() {
            return -1;
        }
 
-        if ((*tmp_ext) && (*tmp_ext)->init && ((*tmp_ext)->init() != 0)) {
-           PrintError(VM_NONE, VCORE_NONE, "Could not initialize extension (%s)\n", (*tmp_ext)->name);
-           return -1;
-       } 
-
        tmp_ext = &(__start__v3_extensions[++i]);
     }
 
@@ -115,22 +116,24 @@ int v3_deinit_ext_manager(struct v3_vm_info * vm)  {
     list_for_each_entry_safe(ext, tmp, &(ext_state->extensions), node) {
         
        V3_Print(vm, VCORE_NONE, "Cleaning up Extension (%s)\n", ext->impl->name);
-       if ((ext->impl) && (ext->impl->vm_deinit)) {
-           if (ext->impl->vm_deinit(vm, ext->priv_data) == -1) {
-               PrintError(vm, VCORE_NONE, "Error cleaning up extension (%s)\n", ext->impl->name);
-               return -1;
+       if (ext->impl) { 
+           if (ext->impl->vm_deinit) {
+               if (ext->impl->vm_deinit(vm, ext->priv_data) == -1) {
+                   PrintError(vm, VCORE_NONE, "Error cleaning up extension (%s)\n", ext->impl->name);
+                   return -1;
+               }
            }
-       }
-
-        if (ext->impl->on_exit)
-            list_del(&ext->exit_node);
-
-        if (ext->impl->on_entry)
-            list_del(&ext->entry_node);
-
-        list_del(&ext->node);
-        V3_Free(ext);
 
+           if (ext->impl->on_exit)
+               list_del(&ext->exit_node);
+           
+           if (ext->impl->on_entry)
+               list_del(&ext->entry_node);
+       }
+           
+       list_del(&ext->node);
+       V3_Free(ext);
+           
     }
 
     return 0;
index c44f461..85c0874 100644 (file)
@@ -357,7 +357,7 @@ static int check_pt_32_cb(struct guest_info * info, page_type_t type, addr_t vad
            return -1;
     }
 
-    if (chk_data->access_status != PT_ACCESS_OK) {
+    if (*(chk_data->access_status) != PT_ACCESS_OK) {
        return 1;
     }
 
@@ -386,7 +386,7 @@ static int check_pt_32pae_cb(struct guest_info * info, page_type_t type, addr_t
            return -1;
     }
 
-    if (chk_data->access_status != PT_ACCESS_OK) {
+    if (*(chk_data->access_status) != PT_ACCESS_OK) {
        return 1;
     }
 
@@ -419,7 +419,7 @@ static int check_pt_64_cb(struct guest_info * info, page_type_t type, addr_t vad
            return -1;
     }
 
-    if (chk_data->access_status != PT_ACCESS_OK) {
+    if (*(chk_data->access_status) != PT_ACCESS_OK) {
        return 1;
     }
 
index 3b15bcf..ff63faa 100644 (file)
@@ -287,7 +287,10 @@ void v3_rb_erase(struct rb_node *node, struct rb_root *root)
        root->rb_node = child;
 
  color:
-    if (color == RB_BLACK)
+    // parent check here is because a possible
+    // codepath here has parent=null, which would
+    // be a disaster in kernel
+    if (color == RB_BLACK && parent) 
        __rb_erase_color(child, parent, root);
 }
 
index a88b978..dff562b 100644 (file)
@@ -346,7 +346,7 @@ handle_time_configuration(struct v3_vm_info * vm, v3_cfg_tree_t *cfg) {
        } else {
            PrintDebug(vm, VCORE_NONE,"VM time slaved to host TSC.\n");
        }
-    }
+    }  
 
     // Should we make a separate TSC device that handles this sort of thing?
     tsc = v3_cfg_val(cfg, "tsc");
@@ -356,7 +356,7 @@ handle_time_configuration(struct v3_vm_info * vm, v3_cfg_tree_t *cfg) {
                PrintError(vm, VCORE_NONE, "WARNING: Guest TSC set to passthrough host TSC, but guest time not slaved to host time.");
            }
            vm->time_state.flags |= V3_TIME_TSC_PASSTHROUGH;
-       } else if (strcasecmp(source, "guest") != 0) {
+       } else if (!source || (strcasecmp(source, "guest") != 0)) {
            PrintError(vm, VCORE_NONE, "ERROR: Unknown TSC configuration in time configuration.\n");
        }
     }
index 755ed59..c2213ca 100644 (file)
@@ -516,6 +516,10 @@ static struct v3_xml * parse_str(char * buf, size_t len) {
     char ** attr; 
     int attr_idx;
 
+    if (!buf) {
+       return NULL;
+    }
+
     root->str_ptr = buf;
 
     if (len == 0) {