refactor: add helper functions for checking if VM is UP/MP
The call `vm_is_up(current->vm)` makes the intention more clear to the
reader than `current->vm->vcpu_count == 1`.
Change-Id: I709c89cd5878f2125509bacc5d23dfb05ee8d2bd
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/src/api.c b/src/api.c
index fad3c3f..f813873 100644
--- a/src/api.c
+++ b/src/api.c
@@ -102,7 +102,7 @@
CHECK((vm != NULL) && (current != NULL));
- if (vm->vcpu_count == 1) {
+ if (vm_is_up(vm)) {
vcpu = vm_get_vcpu(vm, 0);
} else if (current_cpu_index < vm->vcpu_count) {
vcpu = vm_get_vcpu(vm, current_cpu_index);
@@ -3983,7 +3983,7 @@
* (DEN0077A FF-A v1.1 Beta0 Table 18.29) or the VM is UP.
*/
if (!plat_ffa_is_secondary_ep_register_supported() ||
- current->vm->vcpu_count == 1) {
+ vm_is_up(current->vm)) {
return ffa_error(FFA_NOT_SUPPORTED);
}
@@ -4328,8 +4328,7 @@
CHECK(receiver_locked.vm != NULL);
if (receiver_locked.vm->vcpu_count <= vcpu_id ||
- (receiver_locked.vm->vcpu_count != 1 &&
- cpu_index(current->cpu) != vcpu_id)) {
+ (vm_is_mp(current->vm) && cpu_index(current->cpu) != vcpu_id)) {
dlog_verbose(
"Invalid VCPU ID %u. vcpu count %u current core: "
"%zu!\n",