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.


*** empty log message ***
[palacios.git] / palacios / src / geekos / svm.c
index fcf5a00..88ab002 100644 (file)
@@ -1,16 +1,18 @@
 #include <geekos/svm.h>
 
 
+extern struct vmm_os_hooks * os_hooks;
+
 extern uint_t cpuid_ecx(uint_t op);
 extern uint_t cpuid_edx(uint_t op);
-extern void Get_MSR(uint_t MSR, ulong_t * high_byte, ulong_t * low_byte); 
-extern void Set_MSR(uint_t MSR, ulong_t high_byte, ulong_t low_byte);
+extern void Get_MSR(uint_t MSR, uint_t * high_byte, uint_t * low_byte); 
+extern void Set_MSR(uint_t MSR, uint_t high_byte, uint_t low_byte);
 
 /* Checks machine SVM capability */
 /* Implemented from: AMD Arch Manual 3, sect 15.4 */ 
 int is_svm_capable() {
   uint_t ret =  cpuid_ecx(CPUID_FEATURE_IDS);
-  ulong_t vm_cr_low = 0, vm_cr_high = 0;
+  uint_t vm_cr_low = 0, vm_cr_high = 0;
 
 
   if ((ret & CPUID_FEATURE_IDS_ecx_svm_avail) == 0) {
@@ -35,14 +37,39 @@ int is_svm_capable() {
   return 0;
 }
 
+
+
 void Init_SVM() {
-  ulong_t msr_val_low = 0, msr_val_high = 0;
+  reg_ex_t msr;
+  void * host_state;
+
 
-  Get_MSR(EFER_MSR, &msr_val_high, &msr_val_low);
-  msr_val_low |= EFER_MSR_svm_enable;
-  Set_MSR(EFER_MSR, 0, msr_val_low);
+  // setup 
+  Get_MSR(EFER_MSR, &(msr.e_reg.high), &(msr.e_reg.low));
+  msr.e_reg.low |= EFER_MSR_svm_enable;
+  Set_MSR(EFER_MSR, 0, msr.e_reg.low);
   
-  PrintDebug("SVM Inited\n");
+  PrintDebug("SVM Enabled\n");
+
+
+  // Setup the host state save area
+  host_state = os_hooks->Allocate_Pages(1);
+  
+  msr.e_reg.high = 0;
+  msr.e_reg.low = (uint_t)host_state;
+
+  Set_MSR(SVM_VM_HSAVE_PA_MSR, msr.e_reg.high, msr.e_reg.low);
+
 
   return;
 }
+
+
+
+
+void Allocate_VMCB() {
+  void * vmcb_page = os_hooks->Allocate_Pages(1);
+
+
+  memset(vmcb_page, 0, 4096);
+}