}
PrintDebug("SVM core %u(on %u) initialized\n", info->vcpu_id, info->pcpu_id);
+
+ // We'll be paranoid about race conditions here
+ v3_wait_at_barrier(info);
}
PrintDebug("SVM core %u(on %u): I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n",
all_blocked = 1;
for (i = 0; i < vm_info->num_cores; i++) {
+
+ // Tricky: If a core is not running then it is safe to ignore it.
+ // Whenever we transition a core to the RUNNING state we MUST immediately wait on the barrier.
+ // TODO: Wrap the state transitions in functions that do this automatically
+ if (vm_info->cores[i].core_run_state != CORE_RUNNING) {
+ continue;
+ }
+
if (v3_bitmap_check(&(barrier->cpu_map), i) == 0) {
// There is still a core that is not waiting at the barrier
all_blocked = 0;
return 0;
}
+ V3_Print("Core %d waiting at barrier\n", core->vcpu_id);
+
/* Barrier has been activated.
* Wait here until it's lowered
*/
// set cpu bit in barrier bitmap
v3_bitmap_set(&(barrier->cpu_map), core->vcpu_id);
+ V3_Print("Core %d bit set as waiting\n", core->vcpu_id);
// wait for cpu bit to clear
while (v3_bitmap_check(&(barrier->cpu_map), core->vcpu_id) == 1) {