feat(spm): add VM_ID macro to spm tests
Add helper macro to define an FF-A ID for a NWd VM. Replaced all found
instances in spm related tests.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I9605898a9cc8ebc90c783e590907ab1ec684c4f7
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index f4b5a75..91a3b8c 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -41,6 +41,7 @@
*/
#define SP_ID_MASK U(1 << 15)
#define SP_ID(x) ((x) | SP_ID_MASK)
+#define VM_ID(x) (x & ~SP_ID_MASK)
#define IS_SP_ID(x) ((x & SP_ID_MASK) != 0U)
struct ffa_features_test {
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
index 2fd8831..2eb53ed 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
@@ -127,13 +127,13 @@
* The following the tests are intended to test the handling of a
* direct message request with a VM's ID as a the sender.
*/
- result = send_cactus_req_echo_cmd(HYP_ID + 1, SP_ID(2), SP_ID(3),
+ result = send_cactus_req_echo_cmd(VM_ID(1), SP_ID(2), SP_ID(3),
ECHO_VAL2);
if (result != TEST_RESULT_SUCCESS) {
return result;
}
- result = send_cactus_req_echo_cmd(HYP_ID + 2, SP_ID(3), SP_ID(1),
+ result = send_cactus_req_echo_cmd(VM_ID(2), SP_ID(3), SP_ID(1),
ECHO_VAL3);
return result;
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
index 18cf4b4..cb1ccd4 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
@@ -75,7 +75,7 @@
*/
test_result_t test_ffa_notifications_bitmap_create_destroy(void)
{
- const ffa_id_t vm_id = HYP_ID + 1;
+ const ffa_id_t vm_id = VM_ID(1);
SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 1);
@@ -107,7 +107,7 @@
return TEST_RESULT_SKIPPED;
}
- smc_ret_values ret = ffa_notification_bitmap_destroy(HYP_ID + 1);
+ smc_ret_values ret = ffa_notification_bitmap_destroy(VM_ID(1));
if (!is_expected_ffa_error(ret, FFA_ERROR_DENIED)) {
return TEST_RESULT_FAIL;
@@ -123,7 +123,7 @@
test_result_t test_ffa_notifications_create_after_create(void)
{
smc_ret_values ret;
- const ffa_id_t vm_id = HYP_ID + 2;
+ const ffa_id_t vm_id = VM_ID(2);
SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 1);
@@ -256,7 +256,7 @@
test_result_t test_ffa_notifications_vm_bind_unbind(void)
{
CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
- const ffa_id_t vm_id = 1;
+ const ffa_id_t vm_id = VM_ID(1);
smc_ret_values ret;
if (!notifications_bitmap_create(vm_id, 1)) {
@@ -288,8 +288,8 @@
test_result_t test_ffa_notifications_vm_bind_vm(void)
{
CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
- const ffa_id_t vm_id = 1;
- const ffa_id_t sender_id = 2;
+ const ffa_id_t vm_id = VM_ID(1);
+ const ffa_id_t sender_id = VM_ID(2);
smc_ret_values ret;
if (!notifications_bitmap_create(vm_id, 1)) {
@@ -784,7 +784,7 @@
{
CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
const ffa_id_t sender = SP_ID(1);
- const ffa_id_t receiver = 1;
+ const ffa_id_t receiver = VM_ID(1);
uint32_t get_flags = FFA_NOTIFICATIONS_FLAG_BITMAP_SP;
smc_ret_values ret;
test_result_t result = TEST_RESULT_SUCCESS;
@@ -852,7 +852,7 @@
{
CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
const ffa_id_t receiver = SP_ID(1);
- const ffa_id_t sender = 1;
+ const ffa_id_t sender = VM_ID(1);
const ffa_notification_bitmap_t notifications = FFA_NOTIFICATION(30) |
FFA_NOTIFICATION(35);
uint32_t get_flags = FFA_NOTIFICATIONS_FLAG_BITMAP_VM;
@@ -1192,7 +1192,7 @@
test_result_t test_ffa_notifications_sp_signals_vm_per_vcpu(void)
{
/* Making a VM the receiver, and an SP the sender */
- per_vcpu_receiver = 1;
+ per_vcpu_receiver = VM_ID(1);
per_vcpu_sender = SP_ID(2);
/**