v3_cpu_arch_t v3_cpu_types[V3_CONFIG_MAX_CPUS];
+v3_cpu_arch_t v3_mach_type = V3_INVALID_CPU;
+
struct v3_os_hooks * os_hooks = NULL;
int v3_dbg_enable = 0;
// Set global variables.
os_hooks = hooks;
+ // Determine the global machine type
+ v3_mach_type = V3_INVALID_CPU;
+
for (i = 0; i < V3_CONFIG_MAX_CPUS; i++) {
v3_cpu_types[i] = V3_INVALID_CPU;
}
if ((hooks) && (hooks->call_on_cpu)) {
-
for (i = 0; i < num_cpus; i++) {
V3_Print("Initializing VMM extensions on cpu %d\n", i);
hooks->call_on_cpu(i, &init_cpu, (void *)(addr_t)i);
+
+ if (v3_mach_type == V3_INVALID_CPU) {
+ v3_mach_type = v3_cpu_types[i];
+ }
+
}
}
PrintDebug("virtual core %u (on logical core %u): in start_core (RIP=%p)\n",
core->vcpu_id, core->pcpu_id, (void *)(addr_t)core->rip);
- switch (v3_cpu_types[0]) {
+ switch (v3_mach_type) {
#ifdef V3_CONFIG_SVM
case V3_SVM_CPU:
case V3_SVM_REV3_CPU:
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);
int v3_vm_enter(struct guest_info * info) {
- switch (v3_cpu_types[0]) {
+ switch (v3_mach_type) {
#ifdef V3_CONFIG_SVM
case V3_SVM_CPU:
case V3_SVM_REV3_CPU: