Make yield a noop for the primary.

Change-Id: Idc5f650928eef5185dfa604a52f2a580acaf514a
diff --git a/src/api.c b/src/api.c
index 031c07f..ffb431b 100644
--- a/src/api.c
+++ b/src/api.c
@@ -93,20 +93,6 @@
 }
 
 /**
- * Returns to the primary vm to allow this cpu to be used for other tasks as the
- * vcpu does not have work to do at this moment. The current vcpu is marked as
- * ready to be scheduled again.
- */
-struct vcpu *api_yield(struct vcpu *current)
-{
-	struct hf_vcpu_run_return ret = {
-		.code = HF_VCPU_RUN_YIELD,
-	};
-
-	return api_switch_to_primary(current, ret, vcpu_state_ready);
-}
-
-/**
  * Puts the current vcpu in wait for interrupt mode, and returns to the primary
  * vm.
  */
@@ -121,6 +107,25 @@
 }
 
 /**
+ * Returns to the primary vm to allow this cpu to be used for other tasks as the
+ * vcpu does not have work to do at this moment. The current vcpu is marked as
+ * ready to be scheduled again.
+ */
+struct vcpu *api_yield(struct vcpu *current)
+{
+	struct hf_vcpu_run_return ret = {
+		.code = HF_VCPU_RUN_YIELD,
+	};
+
+	if (current->vm->id == HF_PRIMARY_VM_ID) {
+		/* Noop on the primary as it makes the scheduling decisions.  */
+		return NULL;
+	}
+
+	return api_switch_to_primary(current, ret, vcpu_state_ready);
+}
+
+/**
  * Aborts the vCPU and triggers its VM to abort fully.
  */
 struct vcpu *api_abort(struct vcpu *current)