#include <palacios/vmm_decoder.h>
#include <palacios/vmm_barrier.h>
#include <palacios/vmm_timeout.h>
+#include <palacios/vmm_debug.h>
#ifdef V3_CONFIG_CHECKPOINT
#include <palacios/vmm_checkpoint.h>
static addr_t allocate_vmcs() {
+ void *temp;
struct vmcs_data * vmcs_page = NULL;
PrintDebug("Allocating page\n");
- vmcs_page = (struct vmcs_data *)V3_VAddr(V3_AllocPages(1));
+ temp = V3_AllocPages(1);
+ if (!temp) {
+ PrintError("Cannot allocate VMCS\n");
+ return -1;
+ }
+ vmcs_page = (struct vmcs_data *)V3_VAddr(temp);
memset(vmcs_page, 0, 4096);
vmcs_page->revision = hw_info.basic_info.revision;
vmx_ret |= check_vmcs_write(VMCS_CR4_MASK, CR4_VMXE);
#define CR0_NE 0x00000020
vmx_ret |= check_vmcs_write(VMCS_CR0_MASK, CR0_NE);
- //((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->ne = 1;
+ ((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->ne = 1;
if (v3_init_ept(core, &hw_info) == -1) {
PrintError("Error initializing EPT\n");
int vmx_ret = 0;
vmx_state = (struct vmx_data *)V3_Malloc(sizeof(struct vmx_data));
+
+ if (!vmx_state) {
+ PrintError("Unable to allocate in initializing vmx vmcs\n");
+ return;
+ }
+
memset(vmx_state, 0, sizeof(struct vmx_data));
PrintDebug("vmx_data pointer: %p\n", (void *)vmx_state);
struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data);
// note that the vmcs pointer is an HPA, but we need an HVA
- v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE_4KB, V3_VAddr((void*)
- (vmx_info->vmcs_ptr_phys)));
+ if (v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE_4KB,
+ V3_VAddr((void*) (vmx_info->vmcs_ptr_phys))) ==-1) {
+ PrintError("Could not save vmcs data for VMX\n");
+ return -1;
+ }
return 0;
}
addr_t vmcs_page_paddr; //HPA
vmcs_page_paddr = (addr_t) V3_AllocPages(1);
+
+ if (!vmcs_page_paddr) {
+ PrintError("Could not allocate space for a vmcs in VMX\n");
+ return -1;
+ }
- v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB, V3_VAddr((void *)vmcs_page_paddr));
+ if (v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB,
+ V3_VAddr((void *)vmcs_page_paddr)) == -1) {
+ PrintError("Could not load vmcs data for VMX\n");
+ return -1;
+ }
vmcs_clear(vmx_info->vmcs_ptr_phys);
uint64_t guest_cycles = 0;
// Conditionally yield the CPU if the timeslice has expired
- v3_yield_cond(info);
+ v3_yield_cond(info,-1);
// Update timer devices late after being in the VM so that as much
// of the time in the VM is accounted for as possible. Also do it before
v3_enable_ints();
// Conditionally yield the CPU if the timeslice has expired
- v3_yield_cond(info);
+ v3_yield_cond(info,-1);
v3_advance_time(info, NULL);
v3_update_timers(info);
return 0;
}
- v3_yield(info);
+ v3_yield(info,-1);
//PrintDebug("VMX core %u: still waiting for INIT\n",info->vcpu_id);
}