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 endianness, dead code, unchecked returns (Coverity...
Peter Dinda [Tue, 1 Sep 2015 20:51:01 +0000 (15:51 -0500)]
palacios/src/devices/rtl8139.c
palacios/src/devices/vga.c
palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32.h
palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32pae.h
palacios/src/palacios/mmu/vmm_shdw_pg_tlb_64.h
palacios/src/palacios/svm.c
palacios/src/palacios/vmm_debug.c
palacios/src/palacios/vmx.c

index 9d4e7c7..e8e10e3 100644 (file)
@@ -895,7 +895,10 @@ static void rtl8139_rxbuf_write(struct rtl8139_state * nic_state,
     addr_t guestpa, host_rxbuf;
 
     guestpa = (addr_t)regs->rbstart;
-    v3_gpa_to_hva(&(nic_state->vm->cores[0]), guestpa, &host_rxbuf);   
+    if (v3_gpa_to_hva(&(nic_state->vm->cores[0]), guestpa, &host_rxbuf)) { 
+       PrintError(VM_NONE, VCORE_NONE, "RTL8139: cannot translate address\n");
+       return;
+    }
 
     //wrap to the front of rx buffer
     if (regs->cbr + size > nic_state->rx_bufsize){
@@ -1173,7 +1176,11 @@ static int tx_one_packet(struct rtl8139_state * nic_state, int descriptor){
 
     PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: sending %d bytes from guest memory at 0x%08x\n", txsize, regs->tsad[descriptor]);
        
-    v3_gpa_to_hva(&(nic_state->vm->cores[0]), (addr_t)pkt_gpa, &hostva);
+    if (v3_gpa_to_hva(&(nic_state->vm->cores[0]), (addr_t)pkt_gpa, &hostva)) {     
+       PrintError(VM_NONE, VCORE_NONE, "RTL8139: Cannot translate address\n");
+       return -1;
+    }
+
     pkt = (uchar_t *)hostva;
 
 #ifdef V3_CONFIG_DEBUG_RTL8139
index 037223e..1cf1179 100644 (file)
@@ -710,7 +710,6 @@ static void render_graphics(struct vga_internal *vga, void *fb)
                            db[2] <<= 2;
                            db[0] <<= 2;
                        }
-                       break;
                        
                        // next 4 pixels use planes 1 and 3
                        for (p=4;p<8;p++) { 
index 4940993..d7796e9 100644 (file)
@@ -745,9 +745,6 @@ static int invalidation_cb32_64(struct guest_info * info, page_type_t type,
                        if (pdpe->vmm_info == V3_LARGE_PG) {
                                PrintError(info->vm_info, info, "1 Gigabyte pages not supported\n");
                                return -1;
-
-                               pdpe->present = 0;
-                               return 1;
                        }
 
                        return 0;
index dd2f88b..492d5a1 100644 (file)
@@ -727,9 +727,6 @@ static int invalidation_cb32pae_64(struct guest_info * info, page_type_t type,
                        if (pdpe->vmm_info == V3_LARGE_PG) {
                                PrintError(info->vm_info, info, "1 Gigabyte pages not supported\n");
                                return -1;
-
-                               pdpe->present = 0;
-                               return 1;
                        }
 
                        return 0;
index 334c675..0a8bc6d 100644 (file)
@@ -778,9 +778,6 @@ static int invalidation_cb_64(struct guest_info * info, page_type_t type,
                if (pdpe->vmm_info == V3_LARGE_PG) {
                    PrintError(info->vm_info, info, "1 Gigabyte pages not supported\n");
                    return -1;
-
-                   pdpe->present = 0;
-                   return 1;
                }
 
                return 0;
index d78a1dc..7be8f8e 100644 (file)
@@ -1145,9 +1145,15 @@ int v3_start_svm_guest(struct guest_info * info) {
            linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs));
            
            if (info->mem_mode == PHYSICAL_MEM) {
-               v3_gpa_to_hva(info, linear_addr, &host_addr);
+               if (v3_gpa_to_hva(info, linear_addr, &host_addr)) {
+                   PrintError(info->vm_info, info, "Cannot translate address\n");
+                   break;
+               }
            } else if (info->mem_mode == VIRTUAL_MEM) {
-               v3_gva_to_hva(info, linear_addr, &host_addr);
+               if (v3_gva_to_hva(info, linear_addr, &host_addr)) {
+                   PrintError(info->vm_info, info, "Cannot translate address\n");
+                   break;
+               }
            }
            
            V3_Print(info->vm_info, info, "SVM core %u: Host Address of rip = 0x%p\n", info->vcpu_id, (void *)host_addr);
index 85bd8d2..8e1819e 100644 (file)
@@ -487,14 +487,20 @@ void v3_print_idt(struct guest_info * core, addr_t idtr_base) {
        
 
     if (core->mem_mode == PHYSICAL_MEM) {
-        v3_gpa_to_hva(core, 
-                      get_addr_linear(core, idtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gpa_to_hva(core, 
+                         get_addr_linear(core, idtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
         PrintError(core->vm_info, core, "Kind of weird that we got here.... physical mem?\n");
     } else if (core->mem_mode == VIRTUAL_MEM) {
-        v3_gva_to_hva(core, 
-                      get_addr_linear(core, idtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gva_to_hva(core, 
+                         get_addr_linear(core, idtr_base, &(core->segments.cs)),
+                         &base_hva)) { 
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     }
 
     // SANITY CHECK
@@ -537,14 +543,20 @@ void v3_print_gdt(struct guest_info * core, addr_t gdtr_base) {
     }
 
     if (core->mem_mode == PHYSICAL_MEM) {
-        v3_gpa_to_hva(core, 
-                      get_addr_linear(core, gdtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gpa_to_hva(core, 
+                         get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
         PrintError(core->vm_info, core, "Kind of weird that we got here.... physical mem?\n");
     } else if (core->mem_mode == VIRTUAL_MEM) {
-        v3_gva_to_hva(core, 
-                      get_addr_linear(core, gdtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gva_to_hva(core, 
+                         get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     }
 
     // SANITY CHECK
@@ -610,13 +622,19 @@ void v3_print_idt(struct guest_info * core, addr_t idtr_base) {
     }
 
     if (core->mem_mode == PHYSICAL_MEM) {
-        v3_gpa_to_hva(core, 
-                      get_addr_linear(core, idtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gpa_to_hva(core, 
+                         get_addr_linear(core, idtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     } else if (core->mem_mode == VIRTUAL_MEM) {
-        v3_gva_to_hva(core, 
-                      get_addr_linear(core, idtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gva_to_hva(core, 
+                         get_addr_linear(core, idtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     }
 
     // SANITY CHECK
@@ -660,13 +678,19 @@ void v3_print_gdt(struct guest_info * core, addr_t gdtr_base) {
     }
 
     if (core->mem_mode == PHYSICAL_MEM) {
-        v3_gpa_to_hva(core, 
-                      get_addr_linear(core, gdtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gpa_to_hva(core,
+                         get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+                         &base_hva)) { 
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     } else if (core->mem_mode == VIRTUAL_MEM) {
-        v3_gva_to_hva(core, 
-                      get_addr_linear(core, gdtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gva_to_hva(core, 
+                         get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     }
 
     // SANITY CHECK
@@ -713,13 +737,19 @@ void v3_print_ldt(struct guest_info * core, addr_t ldtr_base) {
     } 
 
     if (core->mem_mode == PHYSICAL_MEM) {
-        v3_gpa_to_hva(core, 
-                      get_addr_linear(core, ldtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gpa_to_hva(core, 
+                         get_addr_linear(core, ldtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     } else if (core->mem_mode == VIRTUAL_MEM) {
-        v3_gva_to_hva(core, 
-                      get_addr_linear(core, ldtr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gva_to_hva(core, 
+                         get_addr_linear(core, ldtr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     }
 
     // SANITY CHECK
@@ -766,13 +796,19 @@ void v3_print_tss(struct guest_info * core, addr_t tr_base) {
     } 
 
     if (core->mem_mode == PHYSICAL_MEM) {
-        v3_gpa_to_hva(core, 
-                      get_addr_linear(core, tr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gpa_to_hva(core, 
+                         get_addr_linear(core, tr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     } else if (core->mem_mode == VIRTUAL_MEM) {
-        v3_gva_to_hva(core, 
-                      get_addr_linear(core, tr_base, &(core->segments.cs)),
-                      &base_hva);
+        if (v3_gva_to_hva(core, 
+                         get_addr_linear(core, tr_base, &(core->segments.cs)),
+                         &base_hva)) {
+           PrintError(core->vm_info, core, "Cannot translate address\n");
+           return;
+       }
     }
 
     // SANITY CHECK
index 80a52a3..2984de8 100644 (file)
@@ -1306,9 +1306,15 @@ int v3_start_vmx_guest(struct guest_info * info) {
             linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs));
             
             if (info->mem_mode == PHYSICAL_MEM) {
-                v3_gpa_to_hva(info, linear_addr, &host_addr);
+                if (v3_gpa_to_hva(info, linear_addr, &host_addr)) {
+                   PrintError(info->vm_info, info, "Cannot translate address\n");
+                   return -1;
+               }
             } else if (info->mem_mode == VIRTUAL_MEM) {
-                v3_gva_to_hva(info, linear_addr, &host_addr);
+                if (v3_gva_to_hva(info, linear_addr, &host_addr)) {
+                   PrintError(info->vm_info, info, "Cannot translate address\n");
+                   return -1;
+               }
             }
             
             V3_Print(info->vm_info, info, "VMX core %u: Host Address of rip = 0x%p\n", info->vcpu_id, (void *)host_addr);