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.


split the vmm from the internal geekos
[palacios.git] / palacios / src / geekos / svm.c
1 #include <geekos/svm.h>
2
3
4 extern uint_t cpuid_ecx(uint_t op);
5 extern uint_t cpuid_edx(uint_t op);
6 extern void Get_MSR(uint_t MSR, ulong_t * high_byte, ulong_t * low_byte); 
7 extern void Set_MSR(uint_t MSR, ulong_t high_byte, ulong_t low_byte);
8
9 /* Checks machine SVM capability */
10 /* Implemented from: AMD Arch Manual 3, sect 15.4 */ 
11 int is_svm_capable() {
12   uint_t ret =  cpuid_ecx(CPUID_FEATURE_IDS);
13   ulong_t vm_cr_low = 0, vm_cr_high = 0;
14
15
16   if ((ret & CPUID_FEATURE_IDS_ecx_svm_avail) == 0) {
17     PrintDebug("SVM Not Available\n");
18     return 0;
19   } 
20
21   Get_MSR(SVM_VM_CR_MSR, &vm_cr_high, &vm_cr_low);
22
23   if ((vm_cr_low & SVM_VM_CR_MSR_svmdis) == 0) {
24     return 1;
25   }
26
27   ret = cpuid_edx(CPUID_SVM_REV_AND_FEATURE_IDS);
28   
29   if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_svml) == 0) {
30     PrintDebug("SVM BIOS Disabled, not unlockable\n");
31   } else {
32     PrintDebug("SVM is locked with a key\n");
33   }
34
35   return 0;
36 }
37
38 void Init_SVM() {
39   ulong_t msr_val_low = 0, msr_val_high = 0;
40
41   Get_MSR(EFER_MSR, &msr_val_high, &msr_val_low);
42   msr_val_low |= EFER_MSR_svm_enable;
43   Set_MSR(EFER_MSR, 0, msr_val_low);
44   
45   PrintDebug("SVM Inited\n");
46
47   return;
48 }