Remove legacy hf_vm_get_count and hf_vcpu_get_count calls.
These are now covered by FFA_PARTITION_INFO_GET.
Change-Id: I1bfb0eff1b1eeaf1f2c0cfefcef3596fa771ed71
diff --git a/driver/linux b/driver/linux
index 58ea3b7..6b79619 160000
--- a/driver/linux
+++ b/driver/linux
@@ -1 +1 @@
-Subproject commit 58ea3b738a67467f77b29fb35f607837536a6793
+Subproject commit 6b79619296a241689ac8bf894196326f79e4f7c7
diff --git a/inc/hf/api.h b/inc/hf/api.h
index f9f8cca..6db4783 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -16,9 +16,6 @@
#include "vmapi/hf/ffa.h"
void api_init(struct mpool *ppool);
-ffa_vm_count_t api_vm_get_count(void);
-ffa_vcpu_count_t api_vcpu_get_count(ffa_vm_id_t vm_id,
- const struct vcpu *current);
void api_regs_state_saved(struct vcpu *vcpu);
int64_t api_mailbox_writable_get(const struct vcpu *current);
int64_t api_mailbox_waiter_get(ffa_vm_id_t vm_id, const struct vcpu *current);
diff --git a/inc/vmapi/hf/abi.h b/inc/vmapi/hf/abi.h
index 66f09fd..b537d1c 100644
--- a/inc/vmapi/hf/abi.h
+++ b/inc/vmapi/hf/abi.h
@@ -15,17 +15,15 @@
/* clang-format off */
/* TODO: Define constants below according to spec. */
-#define HF_VM_GET_COUNT 0xff01
-#define HF_VCPU_GET_COUNT 0xff02
-#define HF_MAILBOX_WRITABLE_GET 0xff03
-#define HF_MAILBOX_WAITER_GET 0xff04
-#define HF_INTERRUPT_ENABLE 0xff05
-#define HF_INTERRUPT_GET 0xff06
-#define HF_INTERRUPT_INJECT 0xff07
+#define HF_MAILBOX_WRITABLE_GET 0xff01
+#define HF_MAILBOX_WAITER_GET 0xff02
+#define HF_INTERRUPT_ENABLE 0xff03
+#define HF_INTERRUPT_GET 0xff04
+#define HF_INTERRUPT_INJECT 0xff05
/* Custom FF-A-like calls returned from FFA_RUN. */
-#define HF_FFA_RUN_WAIT_FOR_INTERRUPT 0xff09
-#define HF_FFA_RUN_WAKE_UP 0xff0a
+#define HF_FFA_RUN_WAIT_FOR_INTERRUPT 0xff06
+#define HF_FFA_RUN_WAKE_UP 0xff07
/* This matches what Trusty and its ATF module currently use. */
#define HF_DEBUG_LOG 0xbd000000
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 8a29933..71f579f 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -61,22 +61,6 @@
}
/**
- * Returns the number of secondary VMs.
- */
-static inline ffa_vm_count_t hf_vm_get_count(void)
-{
- return hf_call(HF_VM_GET_COUNT, 0, 0, 0);
-}
-
-/**
- * Returns the number of vCPUs configured in the given secondary VM.
- */
-static inline ffa_vcpu_count_t hf_vcpu_get_count(ffa_vm_id_t vm_id)
-{
- return hf_call(HF_VCPU_GET_COUNT, vm_id, 0, 0);
-}
-
-/**
* Runs the given vCPU of the given VM.
*/
static inline struct ffa_value ffa_run(ffa_vm_id_t vm_id,
diff --git a/src/BUILD.gn b/src/BUILD.gn
index cd1b8e8..5bcfa25 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -190,7 +190,6 @@
executable("unit_tests") {
testonly = true
sources = [
- "api_test.cc",
"fdt_handler_test.cc",
"fdt_test.cc",
"manifest_test.cc",
diff --git a/src/api.c b/src/api.c
index 04c9de9..180bb1b 100644
--- a/src/api.c
+++ b/src/api.c
@@ -342,36 +342,6 @@
}
/**
- * Returns the number of VMs configured to run.
- */
-ffa_vm_count_t api_vm_get_count(void)
-{
- return vm_get_count();
-}
-
-/**
- * Returns the number of vCPUs configured in the given VM, or 0 if there is no
- * such VM or the caller is not the primary VM.
- */
-ffa_vcpu_count_t api_vcpu_get_count(ffa_vm_id_t vm_id,
- const struct vcpu *current)
-{
- struct vm *vm;
-
- /* Only the primary VM needs to know about vCPUs for scheduling. */
- if (current->vm->id != HF_PRIMARY_VM_ID) {
- return 0;
- }
-
- vm = vm_find(vm_id);
- if (vm == NULL) {
- return 0;
- }
-
- return vm->vcpu_count;
-}
-
-/**
* This function is called by the architecture-specific context switching
* function to indicate that register state for the given vCPU has been saved
* and can therefore be used by other pCPUs.
diff --git a/src/api_test.cc b/src/api_test.cc
deleted file mode 100644
index b666bc4..0000000
--- a/src/api_test.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2018 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-/*
- * This order of headers works around a libc++ issue which prevents
- * "atomic" being included before "stdatomic.h".
- */
-#include <gmock/gmock.h>
-
-extern "C" {
-#include "hf/api.h"
-}
-
-namespace
-{
-using ::testing::Eq;
-
-TEST(api, vm_get_count)
-{
- EXPECT_THAT(api_vm_get_count(), Eq(0));
-}
-
-} /* namespace */
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index e1f0329..aac5303 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -646,14 +646,6 @@
}
switch (args.func) {
- case HF_VM_GET_COUNT:
- vcpu->regs.r[0] = api_vm_get_count();
- break;
-
- case HF_VCPU_GET_COUNT:
- vcpu->regs.r[0] = api_vcpu_get_count(args.arg1, vcpu);
- break;
-
case HF_MAILBOX_WRITABLE_GET:
vcpu->regs.r[0] = api_mailbox_writable_get(vcpu);
break;
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index 0ba8727..adcbcec 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -32,52 +32,6 @@
}
/**
- * Confirm there is only the primary VM.
- */
-TEST(hf_vm_get_count, no_secondary_vms)
-{
- EXPECT_EQ(hf_vm_get_count(), 1);
-}
-
-/**
- * Confirm the primary has at least one vCPU.
- */
-TEST(hf_vcpu_get_count, primary_has_at_least_one)
-{
- EXPECT_GE(hf_vcpu_get_count(HF_PRIMARY_VM_ID), 0);
-}
-
-/**
- * Confirm an error is returned when getting the vCPU count of a non-existent
- * VM.
- */
-TEST(hf_vcpu_get_count, no_secondary_vms)
-{
- EXPECT_EQ(hf_vcpu_get_count(HF_VM_ID_OFFSET + 1), 0);
-}
-
-/**
- * Confirm an error is returned when getting the vCPU count for a reserved ID.
- */
-TEST(hf_vcpu_get_count, reserved_vm_id)
-{
- ffa_vm_id_t id;
-
- for (id = 0; id < HF_VM_ID_OFFSET; ++id) {
- EXPECT_EQ(hf_vcpu_get_count(id), 0);
- }
-}
-
-/**
- * Confirm an error is returned when getting the vCPU count of a VM with an ID
- * that is likely to be far outside the resource limit.
- */
-TEST(hf_vcpu_get_count, large_invalid_vm_id)
-{
- EXPECT_EQ(hf_vcpu_get_count(0xffff), 0);
-}
-
-/**
* Confirm it is an error when running a vCPU from the primary VM.
*/
TEST(ffa_run, cannot_run_primary)
@@ -348,9 +302,11 @@
/* Check that the expected partition information is returned. */
ret = ffa_partition_info_get(&uuid);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- EXPECT_EQ(ret.arg2, hf_vm_get_count());
+ /* There should only be the primary VM in this test. */
+ EXPECT_EQ(ret.arg2, 1);
EXPECT_EQ(partitions[0].vm_id, hf_vm_get_id());
- EXPECT_EQ(partitions[0].vcpu_count, hf_vcpu_get_count(hf_vm_get_id()));
+ /* The primary should have at least one vCPU. */
+ EXPECT_GE(partitions[0].vcpu_count, 1);
/*
* Check that the partition information cannot be requested if the RX
@@ -385,13 +341,15 @@
* Get some numbers that the compiler can't tell are constants, so it
* can't optimise them away.
*/
- double a = hf_vm_get_count();
- double b = hf_vcpu_get_count(HF_PRIMARY_VM_ID);
- double result = a * b;
- dlog("VM count: %d\n", hf_vm_get_count());
- dlog("vCPU count: %d\n", hf_vcpu_get_count(HF_PRIMARY_VM_ID));
- dlog("result: %d\n", (int)result);
+ ffa_vm_id_t ai = hf_vm_get_id();
+ ffa_vm_id_t bi = hf_vm_get_id();
+ double a = ai;
+ double b = bi;
+ double result = a * b * 8.0;
+ dlog("a: %d\n", ai);
+ dlog("b: %d\n", bi);
+ dlog("a * b * 1.0: %d\n", (int)result);
EXPECT_TRUE(a == 1.0);
- EXPECT_TRUE(b == 8.0);
+ EXPECT_TRUE(b == 1.0);
EXPECT_TRUE(result == 8.0);
}
diff --git a/test/vmapi/primary_with_secondaries/ffa.c b/test/vmapi/primary_with_secondaries/ffa.c
index cadb38f..5ac042d 100644
--- a/test/vmapi/primary_with_secondaries/ffa.c
+++ b/test/vmapi/primary_with_secondaries/ffa.c
@@ -137,15 +137,17 @@
struct ffa_value ret;
const struct ffa_partition_info *partitions = mb.recv;
struct ffa_uuid uuid;
+ ffa_vm_count_t vm_count;
/* A Null UUID requests information for all partitions. */
ffa_uuid_init(0, 0, 0, 0, &uuid);
ret = ffa_partition_info_get(&uuid);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- EXPECT_EQ(ret.arg2, hf_vm_get_count());
+ vm_count = ret.arg2;
+ EXPECT_EQ(vm_count, 4);
- for (uint16_t index = 0; index < hf_vm_get_count(); ++index) {
+ for (uint16_t index = 0; index < vm_count; ++index) {
ffa_vm_id_t vm_id = partitions[index].vm_id;
EXPECT_GE(vm_id, (ffa_vm_id_t)HF_PRIMARY_VM_ID);
EXPECT_LE(vm_id, (ffa_vm_id_t)SERVICE_VM3);
@@ -157,8 +159,7 @@
*/
EXPECT_EQ(vm_id, index + 1);
- EXPECT_EQ(partitions[index].vcpu_count,
- hf_vcpu_get_count(vm_id));
+ EXPECT_GE(partitions[index].vcpu_count, 1);
}
ret = ffa_rx_release();
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 6b80d01..aa8f632 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -35,41 +35,61 @@
EXPECT_EQ(hf_vm_get_id(), HF_PRIMARY_VM_ID);
}
-/**
- * Confirm there are 3 secondary VMs as well as this primary VM.
- */
-TEST(hf_vm_get_count, three_secondary_vms)
+TEAR_DOWN(ffa_partition_info_get)
{
- EXPECT_EQ(hf_vm_get_count(), 4);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
- * Confirm that secondary VM has 1 vCPU.
+ * Confirm there are 3 secondary VMs as well as this primary VM, and that they
+ * have the expected number of vCPUs.
*/
-TEST(hf_vcpu_get_count, secondary_has_one_vcpu)
+TEST(ffa_partition_info_get, three_secondary_vms)
{
- EXPECT_EQ(hf_vcpu_get_count(SERVICE_VM1), 1);
+ struct mailbox_buffers mb;
+ struct ffa_value ret;
+ const struct ffa_partition_info *partitions;
+ struct ffa_uuid uuid;
+
+ /* A Null UUID requests information for all partitions. */
+ ffa_uuid_init(0, 0, 0, 0, &uuid);
+
+ /* Try to get partition information before the RX buffer is setup. */
+ ret = ffa_partition_info_get(&uuid);
+ EXPECT_FFA_ERROR(ret, FFA_BUSY);
+
+ /* Setup the mailbox (which holds the RX buffer). */
+ mb = set_up_mailbox();
+ partitions = mb.recv;
+
+ /* Check that the expected partition information is returned. */
+ ret = ffa_partition_info_get(&uuid);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+ /* Confirm there are 3 secondary VMs as well as this primary VM. */
+ EXPECT_EQ(ret.arg2, 4);
+ EXPECT_EQ(partitions[0].vm_id, hf_vm_get_id());
+
+ /* The first two secondary VMs should have 1 vCPU, the other one 2. */
+ EXPECT_EQ(partitions[1].vcpu_count, 1);
+ EXPECT_EQ(partitions[2].vcpu_count, 1);
+ EXPECT_EQ(partitions[3].vcpu_count, 2);
+
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
- * Confirm an error is returned when getting the vCPU count for a reserved ID.
+ * Confirm that it is an error to get partition info for a nonexistent VM.
*/
-TEST(hf_vcpu_get_count, reserved_vm_id)
+TEST(ffa_partition_info_get, invalid_vm_uuid)
{
- ffa_vm_id_t id;
+ struct ffa_value ret;
+ struct ffa_uuid uuid;
- for (id = 0; id < HF_VM_ID_OFFSET; ++id) {
- EXPECT_EQ(hf_vcpu_get_count(id), 0);
- }
-}
+ /* Try to get partition information for an unrecognized UUID. */
+ ffa_uuid_init(0, 0, 0, 1, &uuid);
-/**
- * Confirm it is an error to query how many vCPUs are assigned to a nonexistent
- * secondary VM.
- */
-TEST(hf_vcpu_get_count, large_invalid_vm_id)
-{
- EXPECT_EQ(hf_vcpu_get_count(0xffff), 0);
+ ret = ffa_partition_info_get(&uuid);
+ EXPECT_FFA_ERROR(ret, FFA_INVALID_PARAMETERS);
}
/**