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.


Do we need to save and restore the guests GS/FS regs?
Jack Lange [Sat, 14 Feb 2009 00:18:26 +0000 (18:18 -0600)]
palacios/include/palacios/vm_guest.h
palacios/src/palacios/svm.c
palacios/src/palacios/svm_lowlevel.S

index 46fe9f9..1eb4de6 100644 (file)
@@ -104,7 +104,7 @@ struct v3_segments {
   struct v3_segment gdtr;
   struct v3_segment idtr;
   struct v3_segment tr;
-} ;
+};
 
 struct shadow_page_state;
 struct v3_intr_state;
@@ -170,6 +170,12 @@ struct guest_info {
   v3_msr_t guest_syscall_mask;
   v3_msr_t guest_gs_base;
 
+
+  uint64_t fs;
+  uint64_t gs;
+
+
+
 };
 
 
index c2c7a12..18c78e1 100644 (file)
@@ -45,6 +45,7 @@
 
 extern void v3_stgi();
 extern void v3_clgi();
+//extern int v3_svm_launch(vmcb_t * vmcb, struct v3_gprs * vm_regs, uint64_t * fs, uint64_t * gs);
 extern int v3_svm_launch(vmcb_t * vmcb, struct v3_gprs * vm_regs);
 
 
@@ -299,6 +300,11 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) {
   }
 
 
+  /* Safety locations for fs/gs */
+  vm_info->fs = 0;
+  vm_info->gs = 0;
+
+
 
 }
 
@@ -361,12 +367,15 @@ static int start_svm_guest(struct guest_info *info) {
 #define MSR_CSTAR     0xc0000083
 #define MSR_SF_MASK   0xc0000084
 #define MSR_GS_BASE   0xc0000101
+#define MSR_KERNGS_BASE   0xc0000102
+
 
     struct v3_msr host_cstar;
     struct v3_msr host_star;
     struct v3_msr host_lstar;
     struct v3_msr host_syscall_mask;
     struct v3_msr host_gs_base;
+    struct v3_msr host_kerngs_base;
 
     v3_enable_ints();
     v3_clgi();
@@ -384,10 +393,13 @@ static int start_svm_guest(struct guest_info *info) {
     v3_get_msr(MSR_CSTAR, &(host_cstar.hi), &(host_cstar.lo));
     v3_get_msr(MSR_SF_MASK, &(host_syscall_mask.hi), &(host_syscall_mask.lo));
     v3_get_msr(MSR_GS_BASE, &(host_gs_base.hi), &(host_gs_base.lo));
+    v3_get_msr(MSR_KERNGS_BASE, &(host_kerngs_base.hi), &(host_kerngs_base.lo));
+
 
     rdtscll(info->time_state.cached_host_tsc);
     guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc;
 
+    //v3_svm_launch((vmcb_t*)V3_PAddr(info->vmm_data), &(info->vm_regs), &(info->fs), &(info->gs));
     v3_svm_launch((vmcb_t*)V3_PAddr(info->vmm_data), &(info->vm_regs));
 
     rdtscll(tmp_tsc);
@@ -397,6 +409,7 @@ static int start_svm_guest(struct guest_info *info) {
     v3_set_msr(MSR_CSTAR, host_cstar.hi, host_cstar.lo);
     v3_set_msr(MSR_SF_MASK, host_syscall_mask.hi, host_syscall_mask.lo);
     v3_set_msr(MSR_GS_BASE, host_gs_base.hi, host_gs_base.lo);
+    v3_set_msr(MSR_KERNGS_BASE, host_kerngs_base.hi, host_kerngs_base.lo);
 
     //PrintDebug("SVM Returned\n");
 
index 151e54b..975fe98 100644 (file)
@@ -158,6 +158,8 @@ v3_svm_launch:
 
 // VMCB => RDI
 // vm_regs => RSI
+// ptr to fs => RDX
+// ptr to gs => RCX
 
 v3_svm_launch:
        pushf;
@@ -165,7 +167,20 @@ v3_svm_launch:
        push    %gs;
        PUSHA
 
-       pushq %rsi
+
+
+//     pushq   %rdx // fs
+//     pushq   %rcx // gs
+
+
+//     pushq   (%rdx)
+//     pop     %fs
+//     pushq   (%rcx)
+//     pop     %gs
+
+
+
+       pushq   %rsi
 
        movq    %rdi, %rax
        Restore_SVM_Registers(%rsi);
@@ -180,6 +195,18 @@ v3_svm_launch:
 
        addq $8, %rsp
 
+//     popq    %rcx
+//     popq    %rdx
+
+//     push    %fs
+//     popq    %rax
+//     movq    %rax, (%rdx)
+
+//     push    %gs
+//     popq    %rax
+//     movq    %rax, (%rcx)
+
+
        POPA
        pop     %gs;
        pop     %fs;