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.


fixed svm entry launch
Jack Lange [Wed, 22 Oct 2008 01:09:51 +0000 (20:09 -0500)]
added debugging

palacios/src/palacios/svm.c
palacios/src/palacios/svm_handler.c
palacios/src/palacios/svm_lowlevel.S

index 28eadc7..00a9ebd 100644 (file)
@@ -133,6 +133,10 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) {
   guest_state->cs.attrib.raw = 0xf3;
 
   
+  /* DEBUG FOR RETURN CODE */
+  ctrl_area->exit_code = 1;
+
+
   struct vmcb_selector *segregs [] = {&(guest_state->ss), &(guest_state->ds), &(guest_state->es), &(guest_state->fs), &(guest_state->gs), NULL};
   for ( i = 0; segregs[i] != NULL; i++) {
     struct vmcb_selector * seg = segregs[i];
@@ -302,7 +306,7 @@ static int start_svm_guest(struct guest_info *info) {
     v3_enable_ints();
     v3_clgi();
 
-    //    PrintDebug("SVM Entry to rip=%x...\n", info->rip);
+    PrintDebug("SVM Entry to rip=%x...\n", info->rip);
 
     rdtscll(info->time_state.cached_host_tsc);
     guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc;
@@ -310,17 +314,23 @@ static int start_svm_guest(struct guest_info *info) {
     v3_svm_launch((vmcb_t*)V3_PAddr(info->vmm_data), &(info->vm_regs));
 
     rdtscll(tmp_tsc);
-    //PrintDebug("SVM Returned\n");
+    PrintDebug("SVM Returned\n");
+    
+    {
+      uint_t x = 0;
+      PrintDebug("RSP=%p\n", &x);
+    }
 
 
     v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
     num_exits++;
 
+    PrintDebug("Turning on global interrupts\n");
     v3_stgi();
 
-    if ((num_exits % 25) == 0) {
-      PrintDebug("SVM Exit number %d\n", num_exits);
-    }
+
+    PrintDebug("SVM Exit number %d\n", num_exits);
+
 
      
     if (v3_handle_svm_exit(info) != 0) {
@@ -338,15 +348,15 @@ static int start_svm_guest(struct guest_info *info) {
       linear_addr = get_addr_linear(info, guest_state->rip, &(info->segments.cs));
 
 
-      PrintDebug("RIP Linear: %x\n", linear_addr);
+      PrintDebug("RIP Linear: %\n", linear_addr);
       v3_print_segments(info);
       v3_print_ctrl_regs(info);
       v3_print_GPRs(info);
       
       if (info->mem_mode == PHYSICAL_MEM) {
-       guest_pa_to_host_pa(info, linear_addr, &host_addr);
+       guest_pa_to_host_va(info, linear_addr, &host_addr);
       } else if (info->mem_mode == VIRTUAL_MEM) {
-       guest_va_to_host_pa(info, linear_addr, &host_addr);
+       guest_va_to_host_va(info, linear_addr, &host_addr);
       }
 
 
index cc9a8ab..2cfe74e 100644 (file)
@@ -373,9 +373,9 @@ int v3_handle_svm_exit(struct guest_info * info) {
     PrintError("Reading instruction stream in guest\n", rip_addr);
     
     if (info->mem_mode == PHYSICAL_MEM) {
-      read_guest_pa_memory(info, rip_addr-16, 32, buf);
+      read_guest_pa_memory(info, rip_addr - 16, 32, buf);
     } else {
-      read_guest_va_memory(info, rip_addr-16, 32, buf);
+      read_guest_va_memory(info, rip_addr - 16, 32, buf);
     }
     
     PrintDebug("16 bytes before Rip\n");
index 3a17df4..e01f069 100644 (file)
@@ -31,7 +31,7 @@
        movl    %edx, 40(%eax);         \
        movl    %ecx, 48(%eax);         \
        pushl   %ebx;                   \
-       movl    4(%esp), %ebx;          \
+       movl    8(%esp), %ebx;          \
        movl    %ebx, 56(%eax);         \
        popl    %ebx;                   \
        popl    %eax;                   
@@ -83,37 +83,85 @@ v3_svm_launch:
 #elif __V3_64BIT__
 
 #define Save_SVM_Registers(location)   \
-       pushl   %eax;                   \
-       movl    location, %eax;         \
-       movl    %edi, (%eax);           \
-       movl    %esi, 8(%eax);          \
-       movl    %ebp, 16(%eax);         \
-       movl    $0, 24(%eax);           \
-       movl    %ebx, 32(%eax);         \
-       movl    %edx, 40(%eax);         \
-       movl    %ecx, 48(%eax);         \
-       pushl   %ebx;                   \
-       movl    4(%esp), %ebx;          \
-       movl    %ebx, 56(%eax);         \
-       popl    %ebx;                   \
-       popl    %eax;                   
+       push    %rax;                   \
+       mov     location, %rax;         \
+       mov     %rdi, (%rax);           \
+       mov     %rsi, 8(%rax);          \
+       mov     %rbp, 16(%rax);         \
+       movq    $0, 24(%rax);           \
+       mov     %rbx, 32(%rax);         \
+       mov     %rdx, 40(%rax);         \
+       mov     %rcx, 48(%rax);         \
+       push    %rbx;                   \
+       mov     16(%rsp), %rbx;         \
+       mov     %rbx, 56(%rax);         \
+       pop     %rbx;                   \
+       pop     %rax;                   
        
 
 #define Restore_SVM_Registers(location) \
-       pushl   %eax;                   \
-       movl    location, %eax;         \
-       movl    (%eax), %edi;           \
-       movl    8(%eax), %esi;          \
-       movl    16(%eax), %ebp;         \
-       movl    32(%eax), %ebx;         \
-       movl    40(%eax), %edx;         \
-       movl    48(%eax), %ecx;         \
-       popl    %eax;
+       push    %rax;                   \
+       mov     location, %rax;         \
+       mov     (%rax), %rdi;           \
+       mov     8(%rax), %rsi;          \
+       mov     16(%rax), %rbp;         \
+       mov     32(%rax), %rbx;         \
+       mov     40(%rax), %rdx;         \
+       mov     48(%rax), %rcx;         \
+       pop     %rax;
+
+
 
 
+#define PUSHA                          \
+       pushq %rbp;                     \
+       pushq %rbx;                     \
+       pushq %r12;                     \
+       pushq %r13;                     \
+       pushq %r14;                     \
+       pushq %r15;                     
+
+
+#define POPA                           \
+       popq %r15;                      \
+       popq %r14;                      \
+       popq %r13;                      \
+       popq %r12;                      \
+       popq %rbx;                      \
+       popq %rbp;                      
+
+// VMCB => RDI
+// vm_regs => RSI
 
 v3_svm_launch:
+       pushf;
+       push    %fs;
+       push    %gs;
+       PUSHA
+
+
+       pushq %rsi
+
+       movq    %rdi, %rax
+       Restore_SVM_Registers(%rsi);
+
+
+
 
+       vmload;
+       vmrun;
+       vmsave;
+
+
+       
+       Save_SVM_Registers(8(%rsp));
+
+       addq $8, %rsp
+
+       POPA
+       pop     %gs;
+       pop     %fs;
+       popf;
        ret