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.


increment rip after a successfull hypercall
[palacios.git] / palacios / src / palacios / svm_handler.c
index a4b0597..5c85a56 100644 (file)
@@ -31,6 +31,7 @@
 #include <palacios/vmm_emulator.h>
 #include <palacios/svm_msr.h>
 #include <palacios/vmm_profiler.h>
+#include <palacios/vmm_hypercall.h>
 
 
 
@@ -271,6 +272,25 @@ int v3_handle_svm_exit(struct guest_info * info) {
       */
       break;
     }
+
+
+
+  case VMEXIT_VMMCALL: 
+    { 
+      /* 
+       * Hypercall 
+       */
+
+      if (v3_handle_hypercall(info) == -1) {
+       return -1;
+      }
+
+      // VMMCALL is a 3 byte op
+      info->rip += 3;
+      break;
+    } 
+
+
   case VMEXIT_INTR: 
     {
       // handled by interrupt dispatch earlier
@@ -300,56 +320,6 @@ int v3_handle_svm_exit(struct guest_info * info) {
     break;
 
 
-#if 0
-    // Emulation handlers currently not used
-  case VMEXIT_EXCP1: 
-    {
-#ifdef DEBUG_EMULATOR
-      PrintDebug("DEBUG EXCEPTION\n");
-#endif
-      if (info->run_state == VM_EMULATING) {
-       if (v3_emulation_exit_handler(info) == -1) {
-         return -1;
-       }
-      } else {
-       PrintError("VMMCALL with not emulator...\n");
-       return -1;
-      }
-      break;
-    } 
-    
-
-  case VMEXIT_VMMCALL: 
-    {
-#ifdef DEBUG_EMULATOR
-      PrintDebug("VMMCALL\n");
-#endif
-      if (info->run_state == VM_EMULATING) {
-       if (v3_emulation_exit_handler(info) == -1) {
-         return -1;
-       }
-      } else {
-       /*
-       ulong_t tsc_spread = 0;
-       ullong_t exit_tsc = 0;
-
-       ulong_t rax = (ulong_t)info->vm_regs.rbx;
-       ulong_t rdx = (ulong_t)info->vm_regs.rcx;
-
-       *(ulong_t *)(&exit_tsc) = rax;
-       *(((ulong_t *)(&exit_tsc)) + 1) = rdx; 
-
-       tsc_spread = info->exit_tsc - exit_tsc;
-
-       PrintError("VMMCALL tsc diff = %lu\n",tsc_spread); 
-       info->rip += 3;
-       */
-       PrintError("VMMCALL with not emulator...\n");
-       return -1;
-      }
-      break;
-    } 
-#endif
 
 
   case VMEXIT_WBINVD: 
@@ -357,7 +327,7 @@ int v3_handle_svm_exit(struct guest_info * info) {
 #ifdef DEBUG_EMULATOR
       PrintDebug("WBINVD\n");
 #endif
-      if (!v3_handle_svm_wbinvd(info)) { 
+      if (v3_handle_svm_wbinvd(info) == -1) { 
        return -1;
       }
       break;
@@ -369,38 +339,39 @@ int v3_handle_svm_exit(struct guest_info * info) {
     /* Exits Following this line are NOT HANDLED */
     /*=======================================================================*/
 
-  default: {
-
-    addr_t rip_addr;
-
-    PrintDebug("Unhandled SVM Exit: %s\n", vmexit_code_to_str(exit_code));
-
-    rip_addr = get_addr_linear(info, guest_state->rip, &(info->segments.cs));
-
-
-    PrintError("SVM Returned:(VMCB=%p)\n", (void *)(info->vmm_data)); 
-    PrintError("RIP: %p\n", (void *)(addr_t)(guest_state->rip));
-    PrintError("RIP Linear: %p\n", (void *)(addr_t)(rip_addr));
-    
-    PrintError("SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code); 
-    
-    PrintError("io_info1 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info1));
-    PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info1)) + 4));
-    
-    PrintError("io_info2 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info2));
-    PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4));
-
+  default: 
+    {
 
-    if (info->shdw_pg_mode == SHADOW_PAGING) {
-      PrintHostPageTables(info, info->ctrl_regs.cr3);
-      //PrintGuestPageTables(info, info->shdw_pg_state.guest_cr3);
+      addr_t rip_addr;
+      
+      PrintDebug("Unhandled SVM Exit: %s\n", vmexit_code_to_str(exit_code));
+      
+      rip_addr = get_addr_linear(info, guest_state->rip, &(info->segments.cs));
+      
+      
+      PrintError("SVM Returned:(VMCB=%p)\n", (void *)(info->vmm_data)); 
+      PrintError("RIP: %p\n", (void *)(addr_t)(guest_state->rip));
+      PrintError("RIP Linear: %p\n", (void *)(addr_t)(rip_addr));
+      
+      PrintError("SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code); 
+      
+      PrintError("io_info1 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info1));
+      PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info1)) + 4));
+      
+      PrintError("io_info2 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info2));
+      PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4));
+      
+      
+      if (info->shdw_pg_mode == SHADOW_PAGING) {
+       PrintHostPageTables(info, info->ctrl_regs.cr3);
+       //PrintGuestPageTables(info, info->shdw_pg_state.guest_cr3);
+      }
+      
+      return -1;
+      
     }
-
-    return -1;
-
-  }
     break;
-
+    
   }
   // END OF SWITCH (EXIT_CODE)