X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx.c;h=90ff06057432b23208f410ebef914170f1204272;hp=4f8abecfb6e24381e991e4b4a929a5455d72bad3;hb=c06413341bf1dca02f22c0502fa5c2d1c2c11eab;hpb=cfcceed5890430afedcc544bd7dbb69e29dfd65a diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 4f8abec..90ff060 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -32,7 +32,9 @@ #include #include -static addr_t vmxon_ptr_phys; +static addr_t host_vmcs_ptrs[CONFIG_MAX_CPUS] = {0}; + + extern int v3_vmx_exit_handler(); extern int v3_vmx_vmlaunch(struct v3_gprs * vm_regs, struct guest_info * info, struct v3_ctrl_regs * ctrl_regs); @@ -454,11 +456,11 @@ static int start_vmx_guest(struct guest_info* info) { int v3_is_vmx_capable() { v3_msr_t feature_msr; - addr_t eax = 0, ebx = 0, ecx = 0, edx = 0; + uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; v3_cpuid(0x1, &eax, &ebx, &ecx, &edx); - PrintDebug("ECX: %p\n", (void*)ecx); + PrintDebug("ECX: 0x%x\n", ecx); if (ecx & CPUID_1_ECX_VTXFLAG) { v3_get_msr(VMX_FEATURE_CONTROL_MSR, &(feature_msr.hi), &(feature_msr.lo)); @@ -484,8 +486,8 @@ static int has_vmx_nested_paging() { -void v3_init_vmx(struct v3_ctrl_ops * vm_ops) { - extern v3_cpu_arch_t v3_cpu_type; +void v3_init_vmx_cpu(int cpu_id) { + extern v3_cpu_arch_t v3_cpu_types[]; struct v3_msr tmp_msr; uint64_t ret = 0; @@ -524,11 +526,11 @@ void v3_init_vmx(struct v3_ctrl_ops * vm_ops) { // Setup VMXON Region - vmxon_ptr_phys = allocate_vmcs(); + host_vmcs_ptrs[cpu_id] = allocate_vmcs(); - PrintDebug("VMXON pointer: 0x%p\n", (void *)vmxon_ptr_phys); + PrintDebug("VMXON pointer: 0x%p\n", (void *)host_vmcs_ptrs[cpu_id]); - if (v3_enable_vmx(vmxon_ptr_phys) == VMX_SUCCESS) { + if (v3_enable_vmx(host_vmcs_ptrs[cpu_id]) == VMX_SUCCESS) { PrintDebug("VMX Enabled\n"); } else { PrintError("VMX initialization failure\n"); @@ -537,11 +539,16 @@ void v3_init_vmx(struct v3_ctrl_ops * vm_ops) { if (has_vmx_nested_paging() == 1) { - v3_cpu_type = V3_VMX_EPT_CPU; + v3_cpu_types[cpu_id] = V3_VMX_EPT_CPU; } else { - v3_cpu_type = V3_VMX_CPU; + v3_cpu_types[cpu_id] = V3_VMX_CPU; } +} + + +void v3_init_vmx_hooks(struct v3_ctrl_ops * vm_ops) { + // Setup the VMX specific vmm operations vm_ops->init_guest = &init_vmx_guest; vm_ops->start_guest = &start_vmx_guest;