Commit 54598087 authored by Jack Lange's avatar Jack Lange

bug fixes for VMX infrastructure

parent 0a8aeecc
......@@ -247,14 +247,17 @@ __enable_vmx( uintptr_t vmx_on_region )
} else {
DEBUG("VMX already enabled\n");
goto err;
goto already_enabled;
}
put_cpu();
return 1;
already_enabled:
put_cpu();
return 0;
err:
put_cpu();
return -1;
......@@ -296,24 +299,23 @@ covirt_setup_vmx_core(struct covirt_core_state * core_state)
preempt_disable();
vmx_was_enabled = covirt_is_vmx_enabled();
local_vmcs = allocate_vmcs();
if (local_vmcs == 0) {
ERROR("Could not Local VMCS\n");
goto err;
}
if (!vmx_was_enabled) {
local_vmcs = allocate_vmcs();
if (local_vmcs == 0) {
ERROR("Could not Local VMCS\n");
goto err;
}
ret = __enable_vmx(local_vmcs);
ret = __enable_vmx(local_vmcs);
if (ret == -1) {
ERROR("Could not enable VMX on local CPU\n");
goto err;
}
if (ret == 0) {
DEBUG("VMX Already enabled\n");
vmx_was_enabled = 1;
} else if (ret == -1) {
ERROR("Could not enable VMX on local CPU\n");
goto err;
}
......@@ -367,16 +369,16 @@ covirt_setup_vmx_core(struct covirt_core_state * core_state)
core_state->guest_vmcs_ptr = guest_vmcs;
core_state->host_vmcs_ptr = vmx_on_region;
if (local_vmcs != 0) free_pages(local_vmcs, 1);
if (local_vmcs != 0) pisces_free_pages(local_vmcs, 1);
return 0;
err:
preempt_enable();
if (local_vmcs != 0) free_pages(local_vmcs, 1);
if (vmx_on_region != 0) free_pages(vmx_on_region, 1);
if (guest_vmcs != 0) free_pages(guest_vmcs, 1);
if (local_vmcs != 0) pisces_free_pages(local_vmcs, 1);
if (vmx_on_region != 0) pisces_free_pages(vmx_on_region, 1);
if (guest_vmcs != 0) pisces_free_pages(guest_vmcs, 1);
return -1;
}
......@@ -385,7 +387,7 @@ covirt_setup_vmx_core(struct covirt_core_state * core_state)
#define VMX_FEATURE_CONTROL_MSR 0x0000003a
#define VMX_FEATURE_CONTROL_FLAGS 0x00000002
#define VMX_FEATURE_CONTROL_FLAGS 0x00000005
#define CPUID_VMX_FEATURES 0x00000005 /* LOCK and VMXON */
#define CPUID_1_ECX_VTXFLAG 0x00000020
......@@ -418,6 +420,7 @@ covirt_is_vmx_capable( void )
}
#if 0
int
covirt_is_vmx_enabled( void )
{
......@@ -433,3 +436,4 @@ covirt_is_vmx_enabled( void )
return 1;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment