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.


additions for syscall hijacking
[palacios.git] / palacios / src / palacios / svm_handler.c
index dbca7a8..62fe695 100644 (file)
 #include <palacios/vmm_hypercall.h>
 #include <palacios/vmm_cpuid.h>
 #include <palacios/vmm_direct_paging.h>
+#include <palacios/vmm_syscall_hijack.h>
 
+#ifndef CONFIG_DEBUG_SVM
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
 
 #ifdef CONFIG_TELEMETRY
 #include <palacios/vmm_telemetry.h>
 #endif
 
 
+
 int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_info1, addr_t exit_info2) {
 
 #ifdef CONFIG_TELEMETRY
-    if (info->enable_telemetry) {
+    if (info->vm_info->enable_telemetry) {
        v3_telemetry_start_exit(info);
     }
 #endif
@@ -188,6 +194,26 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i
                    }
            break;
            }
+#ifdef CONFIG_SYSCALL_HIJACK
+    case VMEXIT_IDTR_WRITE: // KCH: syscall interposition
+#ifdef CONFIG_DEBUG_SYSCALL_HIJACK
+        PrintDebug("IDTR Write\n");
+#endif
+        if (v3_handle_idtr_write(info) == -1) {
+            PrintError("Error handling IDTR write\n");
+            return -1;
+        }
+        break;
+    case VMEXIT_SWINT:
+#ifdef CONFIG_DEBUG_SYSCALL_HIJACK
+        PrintDebug("Intercepting SW Interrupt\n");
+#endif
+        if (v3_handle_swint(info) == -1) {
+            PrintError("Error handling software interrupt\n");
+            return -1;
+        }
+        break;
+#endif
        case VMEXIT_INVLPG: 
            if (info->shdw_pg_mode == SHADOW_PAGING) {
 #ifdef CONFIG_DEBUG_SHADOW_PAGING
@@ -241,9 +267,32 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i
                return -1;
            }
            break;
-       
+        case VMEXIT_RDTSC:
+#ifdef CONFIG_DEBUG_TIME
+           PrintDebug("RDTSC/RDTSCP\n");
+#endif 
+           if (v3_handle_rdtsc(info) == -1) {
+               PrintError("Error Handling RDTSC instruction\n");
+               return -1;
+           }
+           break;
+        case VMEXIT_RDTSCP:
+#ifdef CONFIG_DEBUG_TIME
+           PrintDebug("RDTSCP\n");
+#endif 
+           if (v3_handle_rdtscp(info) == -1) {
+               PrintError("Error Handling RDTSCP instruction\n");
+               return -1;
+           }
+           break;
+       case VMEXIT_SHUTDOWN:
+           PrintDebug("Guest-initiated shutdown\n");
+
+           info->vm_info->run_state = VM_STOPPED;
 
+           // Force exit on other cores
 
+           break;
 
 
            /* Exits Following this line are NOT HANDLED */
@@ -253,7 +302,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i
 
            addr_t rip_addr;
            
-           PrintDebug("Unhandled SVM Exit: %s\n", vmexit_code_to_str(exit_code));
+           PrintError("Unhandled SVM Exit: %s\n", vmexit_code_to_str(exit_code));
            
            rip_addr = get_addr_linear(info, info->rip, &(info->segments.cs));
            
@@ -282,7 +331,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i
     // END OF SWITCH (EXIT_CODE)
 
 #ifdef CONFIG_TELEMETRY
-    if (info->enable_telemetry) {
+    if (info->vm_info->enable_telemetry) {
        v3_telemetry_end_exit(info, exit_code);
     }
 #endif