Use VM ID offset for wait entries to avoid overflow.

Change-Id: I52a1c4a69eb65d7bd7b63988057aa7d4c254ea1e
diff --git a/src/api.c b/src/api.c
index 5a65f06..d131ca1 100644
--- a/src/api.c
+++ b/src/api.c
@@ -875,7 +875,7 @@
 		 */
 		if (notify) {
 			struct wait_entry *entry =
-				&from->wait_entries[to.vm->id];
+				vm_get_wait_entry(from, to.vm->id);
 
 			/* Append waiter only if it's not there yet. */
 			if (list_empty(&entry->wait_links)) {
@@ -1161,7 +1161,7 @@
 	entry = CONTAINER_OF(vm->mailbox.ready_list.next, struct wait_entry,
 			     ready_links);
 	list_remove(&entry->ready_links);
-	ret = entry - vm->wait_entries;
+	ret = vm_id_for_wait_entry(vm, entry);
 
 exit:
 	sl_unlock(&vm->lock);