PrintDebug(vm, VCORE_NONE, "Creating virtual core %u on logical core %u\n",
vcore_id, core->pcpu_id);
- sprintf(core->exec_name, "%s-%u", vm->name, vcore_id);
+ sprintf(core->exec_name, "%s-%d", vm->name, vcore_id);
PrintDebug(vm, VCORE_NONE, "run: core=%u, func=0x%p, arg=0x%p, name=%s\n",
core->pcpu_id, start_core, core, core->exec_name);
#endif
break;
case V3_VM_RESET_CORE_RANGE:
- start = ((uint32_t*)data)[0];
- end = ((uint32_t*)data)[1];
+ if (data) {
+ start = ((uint32_t*)data)[0];
+ end = ((uint32_t*)data)[1];
+ } else {
+ return -1;
+ }
break;
default:
PrintError(vm,VCORE_NONE,"Unsupported reset type %d for this VM\n",t);
int v3_chkpt_save(struct v3_chkpt_ctx * ctx, char * tag, uint64_t len, void * buf) {
- struct v3_chkpt * chkpt = ctx->chkpt;
+ struct v3_chkpt * chkpt;
int rc;
if (!ctx) {
return -1;
}
+ chkpt = ctx->chkpt;
+
if (chkpt->current_ctx != ctx) {
PrintError(VM_NONE, VCORE_NONE, "Attempt to save on context that is not the current context for the store\n");
return -1;
int v3_chkpt_load(struct v3_chkpt_ctx * ctx, char * tag, uint64_t len, void * buf) {
- struct v3_chkpt * chkpt = ctx->chkpt;
+ struct v3_chkpt * chkpt;
int rc;
if (!ctx) {
PrintError(VM_NONE, VCORE_NONE, "Attempt to load tag %s from null context\n",tag);
return -1;
}
+
+ chkpt = ctx->chkpt;
if (chkpt->current_ctx != ctx) {
PrintError(VM_NONE, VCORE_NONE, "Attempt to load from context that is not the current context for the store\n");
} else {
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
} else {
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
-
+
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
+
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
return -1;
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
+
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
return -1;
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
+
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
return -1;
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
+
+
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
return -1;
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
+
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
return -1;
ret = v3_read_gva_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr);
}
+ if (ret!=15) {
+ PrintError(info->vm_info, info, "Could not read instruction\n");
+ return -1;
+ }
+
if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) {
PrintError(info->vm_info, info, "Could not decode instruction\n");
return -1;
}
}
+ if (prime_index==prime_table_length) {
+ return NULL;
+ }
+
htable = (struct hashtable *)V3_Malloc(sizeof(struct hashtable));
if (htable == NULL) {
}
return 0;
case PT_ENTRY_PAGE:
- if ((ret = callback(info, PAGE_PT32, vaddr, (addr_t)V3_VAddr((void *)host_pte_pa), host_pte_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PT32, vaddr, (addr_t)V3_VAddr((void *)host_pte_pa), host_pte_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PT32;
}
return -1;
case PT_ENTRY_PAGE:
- if ((ret = callback(info, PAGE_PD32PAE, vaddr, (addr_t)V3_VAddr((void *)host_pde_pa), host_pde_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PD32PAE, vaddr, (addr_t)V3_VAddr((void *)host_pde_pa), host_pde_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PD32PAE;
}
}
return 0;
case PT_ENTRY_PAGE:
- if ((ret = callback(info, PAGE_PT32PAE, vaddr, (addr_t)V3_VAddr((void *)host_pte_pa), host_pte_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PT32PAE, vaddr, (addr_t)V3_VAddr((void *)host_pte_pa), host_pte_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PT32PAE;
}
return 0;
case PT_ENTRY_PAGE:
- if ((ret = callback(info, PAGE_PD64, vaddr, (addr_t)V3_VAddr((void *)host_pde_pa), host_pde_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PD64, vaddr, (addr_t)V3_VAddr((void *)host_pde_pa), host_pde_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PD64;
}
return 0;
case PT_ENTRY_PAGE:
- if ((ret = callback(info, PAGE_PT64, vaddr, (addr_t)V3_VAddr((void *)host_pte_pa), host_pte_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PT64, vaddr, (addr_t)V3_VAddr((void *)host_pte_pa), host_pte_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PT64;
}
return -1;
}
- if ((ret = callback(info, PAGE_PT32, vaddr, (addr_t)guest_pte, guest_pte_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PT32, vaddr, (addr_t)guest_pte, guest_pte_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PT32;
}
return -1;
}
- if ((ret = callback(info, PAGE_PT32PAE, vaddr, (addr_t)guest_pte, guest_pte_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PT32PAE, vaddr, (addr_t)guest_pte, guest_pte_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PT32PAE;
}
return -1;
}
- if ((ret = callback(info, PAGE_PT64, vaddr, (addr_t)guest_pte, guest_pte_pa, private_data) != 0)) {
+ if ((ret = callback(info, PAGE_PT64, vaddr, (addr_t)guest_pte, guest_pte_pa, private_data)) != 0) {
return (ret == -1) ? -1 : PAGE_PT64;
}
int v3_init_time_vm(struct v3_vm_info * vm) {
v3_cfg_tree_t * cfg_tree = vm->cfg_data->cfg;
- int ret;
+ int ret=0;
PrintDebug(vm, VCORE_NONE, "Installing TSC MSR hook.\n");
ret = v3_hook_msr(vm, TSC_MSR,
PrintDebug(vm, VCORE_NONE, "Registering TIME_CPUFREQ hypercall.\n");
ret = v3_register_hypercall(vm, TIME_CPUFREQ_HCALL,
handle_cpufreq_hcall, NULL);
+
+ if (ret!=0) {
+ return ret;
+ }
+
PrintDebug(vm, VCORE_NONE, "Registering TIME_RDHTSC hypercall.\n");
ret = v3_register_hypercall(vm, TIME_RDHTSC_HCALL,
handle_rdhtsc_hcall, NULL);
+ if (ret!=0) {
+ return ret;
+ }
+
handle_time_configuration(vm, v3_cfg_subtree(cfg_tree, "time"));
return ret;
*len += sprintf(*s + *len, "</%s>", xml->name); // close tag
- while (txt[off] && off < xml->off) off++; // make sure off is within bounds
+ while (off < xml->off && txt[off]) off++; // make sure off is within bounds
return (xml->ordered) ? toxml_r(xml->ordered, s, len, max, off)
: ampencode(txt + off, -1, s, len, max, 0);
}
vmx_ret |= check_vmcs_write(VMCS_LINK_PTR_HIGH, (addr_t)0xffffffffUL);
#endif
-
+ if (vmx_ret != VMX_SUCCESS) {
+ PrintError(core->vm_info, core, "Error configuring VMX\n");
+ return -1;
+ }
PrintDebug(core->vm_info, core, "Serializing VMCS: %p\n", (void *)vmx_state->vmcs_ptr_phys);
vmx_ret = vmcs_clear(vmx_state->vmcs_ptr_phys);
+ if (vmx_ret != VMX_SUCCESS) {
+ PrintError(core->vm_info,core,"VMCS Clear failed\n");
+ return;
+ }
+
core->core_run_state = CORE_STOPPED;
return;
}
/* Get secondary PROCBASED controls if secondary controls are available (optional or required) */
/* Intel Manual 3B. Sect. G.3.3 */
- if ( ((hw_info->proc_ctrls.req_mask & 0x80000000) == 0) ||
- ((hw_info->proc_ctrls.req_val & 0x80000000) == 1) ) {
+ if ( (!(hw_info->proc_ctrls.req_mask & 0x80000000)) ||
+ (hw_info->proc_ctrls.req_val & 0x80000000) ) {
get_ctrl_caps(&(hw_info->sec_proc_ctrls), VMX_PROCBASED_CTLS2_MSR);