int minor = i % 8;
if (core_mask[major] & (0x1 << minor)) {
- avail_cores++;
+ if (v3_cpu_types[i] == V3_INVALID_CPU) {
+ core_mask[major] &= ~(0x1 << minor);
+ } else {
+ avail_cores++;
+ }
}
}
return -1;
}
+ vm->run_state = VM_RUNNING;
+
// Spawn off threads for each core.
// We work backwards, so that core 0 is always started last.
for (i = 0, vcore_id = vm->num_cores - 1; (i < MAX_CORES) && (vcore_id >= 0); i++) {
PrintDebug("run: core=%u, func=0x%p, arg=0x%p, name=%s\n",
core_idx, start_core, core, core->exec_name);
+ core->core_run_state = CORE_STOPPED; // core zero will turn itself on
core->pcpu_id = core_idx;
core->core_thread = V3_CREATE_THREAD_ON_CPU(core_idx, start_core, core, core->exec_name);
vcore_id--;
}
+ if (vcore_id >= 0) {
+ PrintError("Error starting VM: Not enough available CPU cores\n");
+ v3_stop_vm(vm);
+ return -1;
+ }
+
return 0;
V3_Print("Moving Core\n");
+
+#ifdef V3_CONFIG_VMX
+ switch (v3_cpu_types[core->pcpu_id]) {
+ case V3_VMX_CPU:
+ case V3_VMX_EPT_CPU:
+ case V3_VMX_EPT_UG_CPU:
+ PrintDebug("Flushing VMX Guest CPU %d\n", core->vcpu_id);
+ V3_Call_On_CPU(core->pcpu_id, (void (*)(void *))v3_flush_vmx_vm_core, (void *)core);
+ break;
+ default:
+ break;
+ }
+#endif
+
if (V3_MOVE_THREAD_TO_CPU(target_cpu, core->core_thread) != 0) {
PrintError("Failed to move Vcore %d to CPU %d\n",
core->vcpu_id, target_cpu);
*/
core->pcpu_id = target_cpu;
- V3_Print("core now at %d\n", core->pcpu_id);
-
+ V3_Print("core now at %d\n", core->pcpu_id);
}
-
-
-
v3_lower_barrier(vm);
return 0;
cur_cycle = v3_get_host_time(&info->time_state);
if (cur_cycle > (info->yield_start_cycle + info->vm_info->yield_cycle_period)) {
-
- /*
- PrintDebug("Conditional Yield (cur_cyle=%p, start_cycle=%p, period=%p)\n",
- (void *)cur_cycle, (void *)info->yield_start_cycle, (void *)info->yield_cycle_period);
- */
+ //PrintDebug("Conditional Yield (cur_cyle=%p, start_cycle=%p, period=%p)\n",
+ // (void *)cur_cycle, (void *)info->yield_start_cycle,
+ // (void *)info->yield_cycle_period);
+
V3_Yield();
info->yield_start_cycle = v3_get_host_time(&info->time_state);
}