From: Jack Lange Date: Tue, 20 Sep 2011 19:40:31 +0000 (-0400) Subject: fix barrier hang w/ unitialized secondary cores X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=94429f4b9268cf4d5f86dee5c3d929110811ac80 fix barrier hang w/ unitialized secondary cores --- diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index a52b4d0..115e19c 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -700,6 +700,9 @@ int v3_start_svm_guest(struct guest_info * info) { } 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", diff --git a/palacios/src/palacios/vmm_barrier.c b/palacios/src/palacios/vmm_barrier.c index ab0aae4..7718fc8 100644 --- a/palacios/src/palacios/vmm_barrier.c +++ b/palacios/src/palacios/vmm_barrier.c @@ -104,6 +104,14 @@ int v3_raise_barrier(struct v3_vm_info * vm_info, struct guest_info * local_core 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; @@ -157,6 +165,8 @@ int v3_wait_at_barrier(struct guest_info * core) { return 0; } + V3_Print("Core %d waiting at barrier\n", core->vcpu_id); + /* Barrier has been activated. * Wait here until it's lowered */ @@ -164,6 +174,7 @@ int v3_wait_at_barrier(struct guest_info * core) { // 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) { diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index c7c66c5..e733eb5 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -955,6 +955,9 @@ int v3_start_vmx_guest(struct guest_info * info) { } PrintDebug("VMX core %u initialized\n", info->vcpu_id); + + // We'll be paranoid about race conditions here + v3_wait_at_barrier(info); }