SPCI is now called PSA FF-A.
Change-Id: Iaa10e0449edf5f6493ab21e648219392b17cc5ec
diff --git a/test/arch/aarch64/tee_test.c b/test/arch/aarch64/tee_test.c
index 1b07a3c..b369adb 100644
--- a/test/arch/aarch64/tee_test.c
+++ b/test/arch/aarch64/tee_test.c
@@ -19,32 +19,32 @@
#include <stdint.h>
#include "hf/addr.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/types.h"
#include "smc.h"
#include "test/hftest.h"
-alignas(SPCI_PAGE_SIZE) static uint8_t tee_send_buffer[HF_MAILBOX_SIZE];
-alignas(SPCI_PAGE_SIZE) static uint8_t tee_recv_buffer[HF_MAILBOX_SIZE];
+alignas(FFA_PAGE_SIZE) static uint8_t tee_send_buffer[HF_MAILBOX_SIZE];
+alignas(FFA_PAGE_SIZE) static uint8_t tee_recv_buffer[HF_MAILBOX_SIZE];
/**
- * Make sure SPCI_RXTX_MAP to EL3 works.
+ * Make sure FFA_RXTX_MAP to EL3 works.
*/
TEST(arch_tee, init)
{
- struct spci_value ret = arch_tee_call((struct spci_value){
- .func = SPCI_RXTX_MAP_64,
+ struct ffa_value ret = arch_tee_call((struct ffa_value){
+ .func = FFA_RXTX_MAP_64,
.arg1 = pa_addr(pa_from_va(va_from_ptr(tee_recv_buffer))),
.arg2 = pa_addr(pa_from_va(va_from_ptr(tee_send_buffer))),
- .arg3 = HF_MAILBOX_SIZE / SPCI_PAGE_SIZE});
+ .arg3 = HF_MAILBOX_SIZE / FFA_PAGE_SIZE});
uint32_t func = ret.func & ~SMCCC_CONVENTION_MASK;
/*
* TODO(qwandor): Remove this UNKNOWN check once we have a build of TF-A
- * which supports SPCI memory sharing.
+ * which supports FF-A memory sharing.
*/
if (ret.func != SMCCC_ERROR_UNKNOWN) {
- ASSERT_EQ(func, SPCI_SUCCESS_32);
+ ASSERT_EQ(func, FFA_SUCCESS_32);
}
}
diff --git a/test/hftest/service.c b/test/hftest/service.c
index afbf6f6..2765cfb 100644
--- a/test/hftest/service.c
+++ b/test/hftest/service.c
@@ -17,9 +17,9 @@
#include <stdalign.h>
#include <stdint.h>
+#include "hf/ffa.h"
#include "hf/memiter.h"
#include "hf/mm.h"
-#include "hf/spci.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
@@ -82,7 +82,7 @@
struct memiter args;
hftest_test_fn service;
struct hftest_context *ctx;
- struct spci_value ret;
+ struct ffa_value ret;
/*
* Initialize the stage-1 MMU and identity-map the entire address space.
@@ -98,14 +98,14 @@
/* Prepare the context. */
/* Set up the mailbox. */
- spci_rxtx_map(send_addr, recv_addr);
+ ffa_rxtx_map(send_addr, recv_addr);
/* Receive the name of the service to run. */
- ret = spci_msg_wait();
- ASSERT_EQ(ret.func, SPCI_MSG_SEND_32);
- memiter_init(&args, recv, spci_msg_send_size(ret));
+ ret = ffa_msg_wait();
+ ASSERT_EQ(ret.func, FFA_MSG_SEND_32);
+ memiter_init(&args, recv, ffa_msg_send_size(ret));
service = find_service(&args);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Check the service was found. */
if (service == NULL) {
@@ -126,7 +126,7 @@
ctx->memory_size = memory_size;
/* Pause so the next time cycles are given the service will be run. */
- spci_yield();
+ ffa_yield();
/* Let the service run. */
service();
diff --git a/test/inc/test/hftest_impl.h b/test/inc/test/hftest_impl.h
index 55bb88c..1806258 100644
--- a/test/inc/test/hftest_impl.h
+++ b/test/inc/test/hftest_impl.h
@@ -19,10 +19,10 @@
#include <stdnoreturn.h>
#include "hf/fdt.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/std.h"
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
#define HFTEST_MAX_TESTS 50
@@ -284,7 +284,7 @@
*/
#define HFTEST_SERVICE_SELECT(vm_id, service, send_buffer) \
do { \
- struct spci_value run_res; \
+ struct ffa_value run_res; \
uint32_t msg_length = \
strnlen_s(service, SERVICE_NAME_MAX_LENGTH); \
\
@@ -292,19 +292,19 @@
* Let the service configure its mailbox and wait for a \
* message. \
*/ \
- run_res = spci_run(vm_id, 0); \
- ASSERT_EQ(run_res.func, SPCI_MSG_WAIT_32); \
- ASSERT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE); \
+ run_res = ffa_run(vm_id, 0); \
+ ASSERT_EQ(run_res.func, FFA_MSG_WAIT_32); \
+ ASSERT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE); \
\
/* Send the selected service to run and let it be handled. */ \
- memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, service, \
+ memcpy_s(send_buffer, FFA_MSG_PAYLOAD_MAX, service, \
msg_length); \
\
- ASSERT_EQ(spci_msg_send(hf_vm_get_id(), vm_id, msg_length, 0) \
+ ASSERT_EQ(ffa_msg_send(hf_vm_get_id(), vm_id, msg_length, 0) \
.func, \
- SPCI_SUCCESS_32); \
- run_res = spci_run(vm_id, 0); \
- ASSERT_EQ(run_res.func, SPCI_YIELD_32); \
+ FFA_SUCCESS_32); \
+ run_res = ffa_run(vm_id, 0); \
+ ASSERT_EQ(run_res.func, FFA_YIELD_32); \
} while (0)
#define HFTEST_SERVICE_SEND_BUFFER() hftest_get_context()->send
diff --git a/test/inc/test/vmapi/exception_handler.h b/test/inc/test/vmapi/exception_handler.h
index 47de143..1a15bdc 100644
--- a/test/inc/test/vmapi/exception_handler.h
+++ b/test/inc/test/vmapi/exception_handler.h
@@ -16,7 +16,7 @@
#pragma once
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
bool exception_handler_skip_instruction(void);
@@ -33,5 +33,5 @@
void exception_handler_send_exception_count(void);
int exception_handler_receive_exception_count(
- const struct spci_value *send_res,
- const struct spci_memory_region *recv_buf);
+ const struct ffa_value *send_res,
+ const struct ffa_memory_region *recv_buf);
diff --git a/test/inc/test/vmapi/ffa.h b/test/inc/test/vmapi/ffa.h
new file mode 100644
index 0000000..c01008e
--- /dev/null
+++ b/test/inc/test/vmapi/ffa.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "vmapi/hf/ffa.h"
+
+#define EXPECT_FFA_ERROR(value, ffa_error) \
+ do { \
+ struct ffa_value v = (value); \
+ EXPECT_EQ(v.func, FFA_ERROR_32); \
+ EXPECT_EQ(v.arg2, (ffa_error)); \
+ } while (0)
+
+struct mailbox_buffers {
+ void *send;
+ void *recv;
+};
+
+struct mailbox_buffers set_up_mailbox(void);
+ffa_memory_handle_t send_memory_and_retrieve_request(
+ uint32_t share_func, void *tx_buffer, ffa_vm_id_t sender,
+ ffa_vm_id_t recipient,
+ struct ffa_memory_region_constituent constituents[],
+ uint32_t constituent_count, ffa_memory_region_flags_t flags,
+ enum ffa_data_access send_data_access,
+ enum ffa_data_access retrieve_data_access,
+ enum ffa_instruction_access send_instruction_access,
+ enum ffa_instruction_access retrieve_instruction_access);
+ffa_vm_id_t retrieve_memory_from_message(void *recv_buf, void *send_buf,
+ struct ffa_value msg_ret,
+ ffa_memory_handle_t *handle);
+ffa_vm_id_t retrieve_memory_from_message_expect_fail(void *recv_buf,
+ void *send_buf,
+ struct ffa_value msg_ret,
+ int32_t expected_error);
diff --git a/test/inc/test/vmapi/spci.h b/test/inc/test/vmapi/spci.h
deleted file mode 100644
index bab7f81..0000000
--- a/test/inc/test/vmapi/spci.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2018 The Hafnium Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "vmapi/hf/spci.h"
-
-#define EXPECT_SPCI_ERROR(value, spci_error) \
- do { \
- struct spci_value v = (value); \
- EXPECT_EQ(v.func, SPCI_ERROR_32); \
- EXPECT_EQ(v.arg2, (spci_error)); \
- } while (0)
-
-struct mailbox_buffers {
- void *send;
- void *recv;
-};
-
-struct mailbox_buffers set_up_mailbox(void);
-spci_memory_handle_t send_memory_and_retrieve_request(
- uint32_t share_func, void *tx_buffer, spci_vm_id_t sender,
- spci_vm_id_t recipient,
- struct spci_memory_region_constituent constituents[],
- uint32_t constituent_count, spci_memory_region_flags_t flags,
- enum spci_data_access send_data_access,
- enum spci_data_access retrieve_data_access,
- enum spci_instruction_access send_instruction_access,
- enum spci_instruction_access retrieve_instruction_access);
-spci_vm_id_t retrieve_memory_from_message(void *recv_buf, void *send_buf,
- struct spci_value msg_ret,
- spci_memory_handle_t *handle);
-spci_vm_id_t retrieve_memory_from_message_expect_fail(void *recv_buf,
- void *send_buf,
- struct spci_value msg_ret,
- int32_t expected_error);
diff --git a/test/linux/hftest_socket.c b/test/linux/hftest_socket.c
index b25691f..0c34c21 100644
--- a/test/linux/hftest_socket.c
+++ b/test/linux/hftest_socket.c
@@ -17,15 +17,15 @@
#include <stdalign.h>
#include <stdint.h>
+#include "hf/ffa.h"
#include "hf/memiter.h"
-#include "hf/spci.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
#include "vmapi/hf/transport.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
alignas(4096) uint8_t kstack[4096];
@@ -67,9 +67,9 @@
/* Prepare the context. */
/* Set up the mailbox. */
- spci_rxtx_map(send_addr, recv_addr);
+ ffa_rxtx_map(send_addr, recv_addr);
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
/* Clean the context. */
ctx = hftest_get_context();
@@ -80,29 +80,29 @@
ctx->memory_size = memory_size;
for (;;) {
- struct spci_value ret;
+ struct ffa_value ret;
/* Receive the packet. */
- ret = spci_msg_wait();
- EXPECT_EQ(ret.func, SPCI_MSG_SEND_32);
- EXPECT_LE(spci_msg_send_size(ret), SPCI_MSG_PAYLOAD_MAX);
+ ret = ffa_msg_wait();
+ EXPECT_EQ(ret.func, FFA_MSG_SEND_32);
+ EXPECT_LE(ffa_msg_send_size(ret), FFA_MSG_PAYLOAD_MAX);
/* Echo the message back to the sender. */
- memcpy_s(send, SPCI_MSG_PAYLOAD_MAX, recv,
- spci_msg_send_size(ret));
+ memcpy_s(send, FFA_MSG_PAYLOAD_MAX, recv,
+ ffa_msg_send_size(ret));
/* Swap the socket's source and destination ports */
struct hf_msg_hdr *hdr = (struct hf_msg_hdr *)send;
swap(&(hdr->src_port), &(hdr->dst_port));
/* Swap the destination and source ids. */
- spci_vm_id_t dst_id = spci_msg_send_sender(ret);
- spci_vm_id_t src_id = spci_msg_send_receiver(ret);
+ ffa_vm_id_t dst_id = ffa_msg_send_sender(ret);
+ ffa_vm_id_t src_id = ffa_msg_send_receiver(ret);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_msg_send(src_id, dst_id, spci_msg_send_size(ret),
- 0)
- .func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(
+ ffa_msg_send(src_id, dst_id, ffa_msg_send_size(ret), 0)
+ .func,
+ FFA_SUCCESS_32);
}
}
diff --git a/test/linux/linux.c b/test/linux/linux.c
index 2124f3f..32d7db7 100644
--- a/test/linux/linux.c
+++ b/test/linux/linux.c
@@ -83,7 +83,7 @@
*/
TEST(linux, socket_echo_hafnium)
{
- spci_vm_id_t vm_id = HF_VM_ID_OFFSET + 1;
+ ffa_vm_id_t vm_id = HF_VM_ID_OFFSET + 1;
int port = 10;
int socket_id;
struct hf_sockaddr addr;
diff --git a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
index 8e39a2e..0fdb0db 100644
--- a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
@@ -18,7 +18,7 @@
#include "hf/arch/vm/interrupts_gicv3.h"
#include "hf/dlog.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
@@ -38,15 +38,15 @@
SET_UP(busy_secondary)
{
system_setup();
- EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
SERVICE_SELECT(SERVICE_VM1, "busy", send_buffer);
}
TEST(busy_secondary, virtual_timer)
{
const char message[] = "loop";
- struct spci_value run_res;
+ struct ffa_value run_res;
interrupt_enable(VIRTUAL_TIMER_IRQ, true);
interrupt_set_priority(VIRTUAL_TIMER_IRQ, 0x80);
@@ -63,9 +63,9 @@
arch_irq_enable();
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Check that no interrupts are active or pending to start with. */
EXPECT_EQ(io_read32_array(GICD_ISPENDR, 0), 0);
@@ -80,13 +80,13 @@
/* Let secondary start looping. */
dlog("Telling secondary to loop.\n");
- memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(send_buffer, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_INTERRUPT_32);
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_INTERRUPT_32);
dlog("Waiting for interrupt\n");
while (last_interrupt_id == 0) {
@@ -112,7 +112,7 @@
TEST(busy_secondary, physical_timer)
{
const char message[] = "loop";
- struct spci_value run_res;
+ struct ffa_value run_res;
interrupt_enable(PHYSICAL_TIMER_IRQ, true);
interrupt_set_priority(PHYSICAL_TIMER_IRQ, 0x80);
@@ -121,9 +121,9 @@
arch_irq_enable();
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Check that no interrupts are active or pending to start with. */
EXPECT_EQ(io_read32_array(GICD_ISPENDR, 0), 0);
@@ -138,13 +138,13 @@
/* Let secondary start looping. */
dlog("Telling secondary to loop.\n");
- memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(send_buffer, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_INTERRUPT_32);
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_INTERRUPT_32);
dlog("Waiting for interrupt\n");
while (last_interrupt_id == 0) {
diff --git a/test/vmapi/arch/aarch64/gicv3/gicv3.c b/test/vmapi/arch/aarch64/gicv3/gicv3.c
index 13c4565..e1fbf24 100644
--- a/test/vmapi/arch/aarch64/gicv3/gicv3.c
+++ b/test/vmapi/arch/aarch64/gicv3/gicv3.c
@@ -87,14 +87,14 @@
*/
TEST(system, icc_ctlr_access_trapped_secondary)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
- EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
SERVICE_SELECT(SERVICE_VM1, "access_systemreg_ctlr", send_buffer);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/*
@@ -103,12 +103,12 @@
*/
TEST(system, icc_sre_write_trapped_secondary)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
- EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
SERVICE_SELECT(SERVICE_VM1, "write_systemreg_sre", send_buffer);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
diff --git a/test/vmapi/arch/aarch64/gicv3/services/busy.c b/test/vmapi/arch/aarch64/gicv3/services/busy.c
index fece9f6..154ce67 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/busy.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/busy.c
@@ -31,7 +31,7 @@
{
dlog("Secondary waiting for message...\n");
mailbox_receive_retry();
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
dlog("Secondary received message, looping forever.\n");
for (;;) {
}
diff --git a/test/vmapi/arch/aarch64/gicv3/services/common.c b/test/vmapi/arch/aarch64/gicv3/services/common.c
index ba18d39..7644d8b 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/common.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/common.c
@@ -24,14 +24,14 @@
* Try to receive a message from the mailbox, blocking if necessary, and
* retrying if interrupted.
*/
-struct spci_value mailbox_receive_retry(void)
+struct ffa_value mailbox_receive_retry(void)
{
- struct spci_value received;
+ struct ffa_value received;
do {
- received = spci_msg_wait();
- } while (received.func == SPCI_ERROR_32 &&
- received.arg2 == SPCI_INTERRUPTED);
+ received = ffa_msg_wait();
+ } while (received.func == FFA_ERROR_32 &&
+ received.arg2 == FFA_INTERRUPTED);
return received;
}
diff --git a/test/vmapi/arch/aarch64/gicv3/services/common.h b/test/vmapi/arch/aarch64/gicv3/services/common.h
index ced8baf..36ecd37 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/common.h
+++ b/test/vmapi/arch/aarch64/gicv3/services/common.h
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
-struct spci_value mailbox_receive_retry(void);
+struct ffa_value mailbox_receive_retry(void);
diff --git a/test/vmapi/arch/aarch64/gicv3/services/systemreg.c b/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
index 214300b..bbe9ec8 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
@@ -45,7 +45,7 @@
EXPECT_EQ(exception_handler_get_num(), 2);
/* Yield after catching the exceptions. */
- spci_yield();
+ ffa_yield();
}
TEST_SERVICE(write_systemreg_sre)
@@ -69,5 +69,5 @@
ASSERT_EQ(read_msr(ICC_SRE_EL1), 0x7);
}
- spci_yield();
+ ffa_yield();
}
diff --git a/test/vmapi/arch/aarch64/gicv3/services/timer.c b/test/vmapi/arch/aarch64/gicv3/services/timer.c
index f62aa80..c66898c 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/timer.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/timer.c
@@ -28,7 +28,7 @@
#include "common.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/*
* Secondary VM that sets timers in response to messages, and sends messages
@@ -48,8 +48,8 @@
}
buffer[8] = '0' + interrupt_id / 10;
buffer[9] = '0' + interrupt_id % 10;
- memcpy_s(SERVICE_SEND_BUFFER(), SPCI_MSG_PAYLOAD_MAX, buffer, size);
- spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, size, 0);
+ memcpy_s(SERVICE_SEND_BUFFER(), FFA_MSG_PAYLOAD_MAX, buffer, size);
+ ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, size, 0);
dlog("secondary IRQ %d ended\n", interrupt_id);
event_send_local();
}
@@ -67,13 +67,12 @@
bool receive;
bool disable_interrupts;
uint32_t ticks;
- struct spci_value ret = mailbox_receive_retry();
+ struct ffa_value ret = mailbox_receive_retry();
- if (spci_msg_send_sender(ret) != HF_PRIMARY_VM_ID ||
- spci_msg_send_size(ret) != sizeof("**** xxxxxxx")) {
+ if (ffa_msg_send_sender(ret) != HF_PRIMARY_VM_ID ||
+ ffa_msg_send_size(ret) != sizeof("**** xxxxxxx")) {
FAIL("Got unexpected message from VM %d, size %d.\n",
- spci_msg_send_sender(ret),
- spci_msg_send_size(ret));
+ ffa_msg_send_sender(ret), ffa_msg_send_size(ret));
}
/*
@@ -90,7 +89,7 @@
(message[9] - '0') * 100 + (message[10] - '0') * 10 +
(message[11] - '0');
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
dlog("Starting timer for %d ticks.\n", ticks);
@@ -110,9 +109,9 @@
event_wait();
}
} else if (receive) {
- struct spci_value res = spci_msg_wait();
+ struct ffa_value res = ffa_msg_wait();
- EXPECT_SPCI_ERROR(res, SPCI_INTERRUPTED);
+ EXPECT_FFA_ERROR(res, FFA_INTERRUPTED);
} else {
/* Busy wait until the timer fires. */
while (!timer_fired) {
diff --git a/test/vmapi/arch/aarch64/gicv3/timer_secondary.c b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
index 1e5c107..563a20b 100644
--- a/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
@@ -19,18 +19,18 @@
#include "hf/abi.h"
#include "hf/call.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "gicv3.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
SET_UP(timer_secondary)
{
system_setup();
- EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
SERVICE_SELECT(SERVICE_VM1, "timer", send_buffer);
interrupt_enable(VIRTUAL_TIMER_IRQ, true);
@@ -41,51 +41,51 @@
TEAR_DOWN(timer_secondary)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
static void timer_busywait_secondary()
{
const char message[] = "loop 0099999";
const char expected_response[] = "Got IRQ 03.";
- struct spci_value run_res;
+ struct ffa_value run_res;
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Send the message for the secondary to set a timer. */
- memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(send_buffer, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
+ FFA_SUCCESS_32);
/*
* Let the secondary handle the message and set the timer. It will loop
* until the hardware interrupt fires, at which point we'll get and
- * ignore the interrupt, and see a SPCI_YIELD return code.
+ * ignore the interrupt, and see a FFA_YIELD return code.
*/
dlog("running secondary after sending timer message.\n");
last_interrupt_id = 0;
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_INTERRUPT_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_INTERRUPT_32);
dlog("secondary yielded after receiving timer message\n");
EXPECT_EQ(last_interrupt_id, VIRTUAL_TIMER_IRQ);
/*
- * Now that the timer has expired, when we call spci_run again Hafnium
+ * Now that the timer has expired, when we call ffa_run again Hafnium
* should inject a virtual timer interrupt into the secondary, which
* should get it and respond.
*/
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(recv_buffer, expected_response,
sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -106,40 +106,38 @@
{
const char expected_response[] = "Got IRQ 03.";
size_t message_length = strnlen_s(message, 64) + 1;
- struct spci_value run_res;
+ struct ffa_value run_res;
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Send the message for the secondary to set a timer. */
- memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, message_length);
- EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, message_length, 0)
- .func,
- SPCI_SUCCESS_32);
+ memcpy_s(send_buffer, FFA_MSG_PAYLOAD_MAX, message, message_length);
+ EXPECT_EQ(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, message_length, 0)
+ .func,
+ FFA_SUCCESS_32);
/* Let the secondary handle the message and set the timer. */
last_interrupt_id = 0;
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
/*
* There's a race for whether the secondary manages to block and switch
* to the primary before the hardware timer fires, so we need to handle
* three cases:
- * 1. The (hardware) timer fires immediately, we get SPCI_INTERRUPT.
+ * 1. The (hardware) timer fires immediately, we get FFA_INTERRUPT.
* 2. The secondary blocks and switches back, we get expected_code until
* the timer fires.
* 2a. The timer then expires while we are in the primary, so Hafnium
- * can inject the timer interrupt the next time we call spci_run.
+ * can inject the timer interrupt the next time we call ffa_run.
* 2b. The timer fires while the secondary is running, so we get
- * SPCI_INTERRUPT as in case 1.
+ * FFA_INTERRUPT as in case 1.
*/
- if (run_res.func != expected_code &&
- run_res.func != SPCI_INTERRUPT_32) {
- FAIL("Expected run to return SPCI_INTERRUPT or %#x, but "
+ if (run_res.func != expected_code && run_res.func != FFA_INTERRUPT_32) {
+ FAIL("Expected run to return FFA_INTERRUPT or %#x, but "
"got %#x",
expected_code, run_res.func);
}
@@ -151,37 +149,37 @@
* switch to the primary before the timer fires.
*/
dlog("Primary looping until timer fires\n");
- if (expected_code == HF_SPCI_RUN_WAIT_FOR_INTERRUPT ||
- expected_code == SPCI_MSG_WAIT_32) {
- EXPECT_NE(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ if (expected_code == HF_FFA_RUN_WAIT_FOR_INTERRUPT ||
+ expected_code == FFA_MSG_WAIT_32) {
+ EXPECT_NE(run_res.arg2, FFA_SLEEP_INDEFINITE);
dlog("%d ns remaining\n", run_res.arg2);
}
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
}
dlog("Primary done looping\n");
- if (run_res.func == SPCI_INTERRUPT_32) {
+ if (run_res.func == FFA_INTERRUPT_32) {
/*
* This case happens if the (hardware) timer fires before the
* secondary blocks and switches to the primary, either
* immediately after setting the timer or during the loop above.
* Then we get the interrupt to the primary, ignore it, and see
- * a SPCI_INTERRUPT code from the spci_run call, so we should
+ * a FFA_INTERRUPT code from the ffa_run call, so we should
* call it again for the timer interrupt to be injected
* automatically by Hafnium.
*/
EXPECT_EQ(last_interrupt_id, VIRTUAL_TIMER_IRQ);
dlog("Preempted by timer interrupt, running again\n");
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
}
/* Once we wake it up it should get the timer interrupt and respond. */
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(recv_buffer, expected_response,
sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -197,8 +195,8 @@
* Run the test twice in a row, to check that the state doesn't get
* messed up.
*/
- timer_secondary("WFI 0000001", HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
- timer_secondary("WFI 0000001", HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
+ timer_secondary("WFI 0000001", HF_FFA_RUN_WAIT_FOR_INTERRUPT);
+ timer_secondary("WFI 0000001", HF_FFA_RUN_WAIT_FOR_INTERRUPT);
}
TEST(timer_secondary, wfi_long)
@@ -207,8 +205,8 @@
* Run the test twice in a row, to check that the state doesn't get
* messed up.
*/
- timer_secondary("WFI 0099999", HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
- timer_secondary("WFI 0099999", HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
+ timer_secondary("WFI 0099999", HF_FFA_RUN_WAIT_FOR_INTERRUPT);
+ timer_secondary("WFI 0099999", HF_FFA_RUN_WAIT_FOR_INTERRUPT);
}
TEST(timer_secondary, wfe_short)
@@ -217,8 +215,8 @@
* Run the test twice in a row, to check that the state doesn't get
* messed up.
*/
- timer_secondary("WFE 0000001", SPCI_YIELD_32);
- timer_secondary("WFE 0000001", SPCI_YIELD_32);
+ timer_secondary("WFE 0000001", FFA_YIELD_32);
+ timer_secondary("WFE 0000001", FFA_YIELD_32);
}
TEST(timer_secondary, wfe_long)
@@ -227,8 +225,8 @@
* Run the test twice in a row, to check that the state doesn't get
* messed up.
*/
- timer_secondary("WFE 0099999", SPCI_YIELD_32);
- timer_secondary("WFE 0099999", SPCI_YIELD_32);
+ timer_secondary("WFE 0099999", FFA_YIELD_32);
+ timer_secondary("WFE 0099999", FFA_YIELD_32);
}
TEST(timer_secondary, receive_short)
@@ -237,8 +235,8 @@
* Run the test twice in a row, to check that the state doesn't get
* messed up.
*/
- timer_secondary("RECV 0000001", SPCI_MSG_WAIT_32);
- timer_secondary("RECV 0000001", SPCI_MSG_WAIT_32);
+ timer_secondary("RECV 0000001", FFA_MSG_WAIT_32);
+ timer_secondary("RECV 0000001", FFA_MSG_WAIT_32);
}
TEST(timer_secondary, receive_long)
@@ -247,8 +245,8 @@
* Run the test twice in a row, to check that the state doesn't get
* messed up.
*/
- timer_secondary("RECV 0099999", SPCI_MSG_WAIT_32);
- timer_secondary("RECV 0099999", SPCI_MSG_WAIT_32);
+ timer_secondary("RECV 0099999", FFA_MSG_WAIT_32);
+ timer_secondary("RECV 0099999", FFA_MSG_WAIT_32);
}
/**
@@ -258,27 +256,26 @@
{
const char message[] = "WFI 9999999";
size_t message_length = strnlen_s(message, 64) + 1;
- struct spci_value run_res;
+ struct ffa_value run_res;
/* Let the secondary get started and wait for our message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Send the message for the secondary to set a timer. */
- memcpy_s(send_buffer, SPCI_MSG_PAYLOAD_MAX, message, message_length);
- EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, message_length, 0)
- .func,
- SPCI_SUCCESS_32);
+ memcpy_s(send_buffer, FFA_MSG_PAYLOAD_MAX, message, message_length);
+ EXPECT_EQ(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, message_length, 0)
+ .func,
+ FFA_SUCCESS_32);
/*
* Let the secondary handle the message and set the timer.
*/
last_interrupt_id = 0;
for (int i = 0; i < 20; ++i) {
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, HF_FFA_RUN_WAIT_FOR_INTERRUPT);
dlog("Primary looping until timer fires; %d ns "
"remaining\n",
run_res.arg2);
diff --git a/test/vmapi/arch/aarch64/smc_whitelist.c b/test/vmapi/arch/aarch64/smc_whitelist.c
index fe0c664..7604b25 100644
--- a/test/vmapi/arch/aarch64/smc_whitelist.c
+++ b/test/vmapi/arch/aarch64/smc_whitelist.c
@@ -22,7 +22,7 @@
TEST(smc_whitelist, not_whitelisted_unknown)
{
const uint32_t non_whitelisted_ta_call = 0x3000f00d;
- struct spci_value smc_res = smc_forward(
+ struct ffa_value smc_res = smc_forward(
non_whitelisted_ta_call, 0x1111111111111111, 0x2222222222222222,
0x3333333333333333, 0x4444444444444444, 0x5555555555555555,
0x6666666666666666, 0x77777777);
diff --git a/test/vmapi/arch/aarch64/smccc.c b/test/vmapi/arch/aarch64/smccc.c
index d42cc16..3442627 100644
--- a/test/vmapi/arch/aarch64/smccc.c
+++ b/test/vmapi/arch/aarch64/smccc.c
@@ -17,14 +17,14 @@
#include <stdint.h>
#include "vmapi/hf/call.h"
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
#include "smc.h"
#include "test/hftest.h"
-static struct spci_value hvc(uint32_t func, uint64_t arg0, uint64_t arg1,
- uint64_t arg2, uint64_t arg3, uint64_t arg4,
- uint64_t arg5, uint32_t caller_id)
+static struct ffa_value hvc(uint32_t func, uint64_t arg0, uint64_t arg1,
+ uint64_t arg2, uint64_t arg3, uint64_t arg4,
+ uint64_t arg5, uint32_t caller_id)
{
register uint64_t r0 __asm__("x0") = func;
register uint64_t r1 __asm__("x1") = arg0;
@@ -41,19 +41,19 @@
"+r"(r0), "+r"(r1), "+r"(r2), "+r"(r3), "+r"(r4), "+r"(r5),
"+r"(r6), "+r"(r7));
- return (struct spci_value){.func = r0,
- .arg1 = r1,
- .arg2 = r2,
- .arg3 = r3,
- .arg4 = r4,
- .arg5 = r5,
- .arg6 = r6,
- .arg7 = r7};
+ return (struct ffa_value){.func = r0,
+ .arg1 = r1,
+ .arg2 = r2,
+ .arg3 = r3,
+ .arg4 = r4,
+ .arg5 = r5,
+ .arg6 = r6,
+ .arg7 = r7};
}
TEST(smccc, hf_debug_log_smc_zero_or_unchanged)
{
- struct spci_value smc_res =
+ struct ffa_value smc_res =
smc_forward(HF_DEBUG_LOG, '\n', 0x2222222222222222,
0x3333333333333333, 0x4444444444444444,
0x5555555555555555, 0x6666666666666666, 0x77777777);
@@ -70,7 +70,7 @@
TEST(smccc, hf_debug_log_hvc_zero_or_unchanged)
{
- struct spci_value smc_res =
+ struct ffa_value smc_res =
hvc(HF_DEBUG_LOG, '\n', 0x2222222222222222, 0x3333333333333333,
0x4444444444444444, 0x5555555555555555, 0x6666666666666666,
0x77777777);
@@ -86,15 +86,15 @@
}
/**
- * Checks that calling SPCI_FEATURES via an SMC works as expected.
- * The spci_features helper function uses an HVC, but an SMC should also work.
+ * Checks that calling FFA_FEATURES via an SMC works as expected.
+ * The ffa_features helper function uses an HVC, but an SMC should also work.
*/
-TEST(smccc, spci_features_smc)
+TEST(smccc, ffa_features_smc)
{
- struct spci_value ret;
+ struct ffa_value ret;
- ret = smc32(SPCI_FEATURES_32, SPCI_VERSION_32, 0, 0, 0, 0, 0, 0);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = smc32(FFA_FEATURES_32, FFA_VERSION_32, 0, 0, 0, 0, 0, 0);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
EXPECT_EQ(ret.arg1, 0);
EXPECT_EQ(ret.arg2, 0);
EXPECT_EQ(ret.arg3, 0);
diff --git a/test/vmapi/common/BUILD.gn b/test/vmapi/common/BUILD.gn
index 081c90e..c9a6eea 100644
--- a/test/vmapi/common/BUILD.gn
+++ b/test/vmapi/common/BUILD.gn
@@ -19,7 +19,7 @@
public_configs = [ "//test/hftest:hftest_config" ]
sources = [
"exception_handler.c",
- "spci.c",
+ "ffa.c",
]
include_dirs = [ "//src/arch/aarch64" ]
}
diff --git a/test/vmapi/common/exception_handler.c b/test/vmapi/common/exception_handler.c
index 14fe1e1..82ca679 100644
--- a/test/vmapi/common/exception_handler.c
+++ b/test/vmapi/common/exception_handler.c
@@ -36,27 +36,27 @@
dlog("Sending exception_count %d to primary VM\n",
exception_handler_exception_count);
- memcpy_s(send_buf, SPCI_MSG_PAYLOAD_MAX,
+ memcpy_s(send_buf, FFA_MSG_PAYLOAD_MAX,
(const void *)&exception_handler_exception_count,
sizeof(exception_handler_exception_count));
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID,
- sizeof(exception_handler_exception_count), 0)
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID,
+ sizeof(exception_handler_exception_count), 0)
.func,
- SPCI_SUCCESS_32);
+ FFA_SUCCESS_32);
}
/**
* Receives the number of exceptions handled.
*/
int exception_handler_receive_exception_count(
- const struct spci_value *send_res,
- const struct spci_memory_region *recv_buf)
+ const struct ffa_value *send_res,
+ const struct ffa_memory_region *recv_buf)
{
int exception_count = *((const int *)recv_buf);
- EXPECT_EQ(send_res->func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(*send_res), sizeof(exception_count));
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(send_res->func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(*send_res), sizeof(exception_count));
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
return exception_count;
}
diff --git a/test/vmapi/common/ffa.c b/test/vmapi/common/ffa.c
new file mode 100644
index 0000000..a7048b1
--- /dev/null
+++ b/test/vmapi/common/ffa.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2018 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hf/ffa.h"
+
+#include "hf/mm.h"
+#include "hf/static_assert.h"
+
+#include "vmapi/hf/call.h"
+
+#include "test/hftest.h"
+#include "test/vmapi/ffa.h"
+
+static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
+static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
+static_assert(sizeof(send_page) == PAGE_SIZE, "Send page is not a page.");
+static_assert(sizeof(recv_page) == PAGE_SIZE, "Recv page is not a page.");
+
+static hf_ipaddr_t send_page_addr = (hf_ipaddr_t)send_page;
+static hf_ipaddr_t recv_page_addr = (hf_ipaddr_t)recv_page;
+
+struct mailbox_buffers set_up_mailbox(void)
+{
+ ASSERT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
+ return (struct mailbox_buffers){
+ .send = send_page,
+ .recv = recv_page,
+ };
+}
+
+/*
+ * Helper function to send memory to a VM then send a message with the retrieve
+ * request it needs to retrieve it.
+ */
+ffa_memory_handle_t send_memory_and_retrieve_request(
+ uint32_t share_func, void *tx_buffer, ffa_vm_id_t sender,
+ ffa_vm_id_t recipient,
+ struct ffa_memory_region_constituent constituents[],
+ uint32_t constituent_count, ffa_memory_region_flags_t flags,
+ enum ffa_data_access send_data_access,
+ enum ffa_data_access retrieve_data_access,
+ enum ffa_instruction_access send_instruction_access,
+ enum ffa_instruction_access retrieve_instruction_access)
+{
+ uint32_t msg_size;
+ struct ffa_value ret;
+ ffa_memory_handle_t handle;
+
+ /* Send the memory. */
+ msg_size = ffa_memory_region_init(
+ tx_buffer, sender, recipient, constituents, constituent_count,
+ 0, flags, send_data_access, send_instruction_access,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ switch (share_func) {
+ case FFA_MEM_DONATE_32:
+ ret = ffa_mem_donate(msg_size, msg_size);
+ break;
+ case FFA_MEM_LEND_32:
+ ret = ffa_mem_lend(msg_size, msg_size);
+ break;
+ case FFA_MEM_SHARE_32:
+ ret = ffa_mem_share(msg_size, msg_size);
+ break;
+ default:
+ FAIL("Invalid share_func %#x.\n", share_func);
+ /* Never reached, but needed to keep clang-analyser happy. */
+ return 0;
+ }
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+ handle = ffa_mem_success_handle(ret);
+
+ /*
+ * Send the appropriate retrieve request to the VM so that it can use it
+ * to retrieve the memory.
+ */
+ msg_size = ffa_memory_retrieve_request_init(
+ tx_buffer, handle, sender, recipient, 0, 0,
+ retrieve_data_access, retrieve_instruction_access,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_EQ(ffa_msg_send(sender, recipient, msg_size, 0).func,
+ FFA_SUCCESS_32);
+
+ return handle;
+}
+
+/*
+ * Use the retrieve request from the receive buffer to retrieve a memory region
+ * which has been sent to us. Returns the sender, and the handle via a return
+ * parameter.
+ */
+ffa_vm_id_t retrieve_memory_from_message(void *recv_buf, void *send_buf,
+ struct ffa_value msg_ret,
+ ffa_memory_handle_t *handle)
+{
+ uint32_t msg_size;
+ struct ffa_value ret;
+ struct ffa_memory_region *memory_region;
+ ffa_vm_id_t sender;
+
+ EXPECT_EQ(msg_ret.func, FFA_MSG_SEND_32);
+ msg_size = ffa_msg_send_size(msg_ret);
+ sender = ffa_msg_send_sender(msg_ret);
+
+ if (handle != NULL) {
+ struct ffa_memory_region *retrieve_request =
+ (struct ffa_memory_region *)recv_buf;
+ *handle = retrieve_request->handle;
+ }
+ memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
+ ffa_rx_release();
+ ret = ffa_mem_retrieve_req(msg_size, msg_size);
+ EXPECT_EQ(ret.func, FFA_MEM_RETRIEVE_RESP_32);
+ memory_region = (struct ffa_memory_region *)recv_buf;
+ EXPECT_EQ(memory_region->receiver_count, 1);
+ EXPECT_EQ(memory_region->receivers[0].receiver_permissions.receiver,
+ hf_vm_get_id());
+
+ return sender;
+}
+
+/*
+ * Use the retrieve request from the receive buffer to retrieve a memory region
+ * which has been sent to us, expecting it to fail with the given error code.
+ * Returns the sender.
+ */
+ffa_vm_id_t retrieve_memory_from_message_expect_fail(void *recv_buf,
+ void *send_buf,
+ struct ffa_value msg_ret,
+ int32_t expected_error)
+{
+ uint32_t msg_size;
+ struct ffa_value ret;
+ ffa_vm_id_t sender;
+
+ EXPECT_EQ(msg_ret.func, FFA_MSG_SEND_32);
+ msg_size = ffa_msg_send_size(msg_ret);
+ sender = ffa_msg_send_sender(msg_ret);
+
+ memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
+ ffa_rx_release();
+ ret = ffa_mem_retrieve_req(msg_size, msg_size);
+ EXPECT_FFA_ERROR(ret, expected_error);
+
+ return sender;
+}
diff --git a/test/vmapi/common/spci.c b/test/vmapi/common/spci.c
deleted file mode 100644
index 0bc3380..0000000
--- a/test/vmapi/common/spci.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2018 The Hafnium Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "hf/spci.h"
-
-#include "hf/mm.h"
-#include "hf/static_assert.h"
-
-#include "vmapi/hf/call.h"
-
-#include "test/hftest.h"
-#include "test/vmapi/spci.h"
-
-static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
-static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
-static_assert(sizeof(send_page) == PAGE_SIZE, "Send page is not a page.");
-static_assert(sizeof(recv_page) == PAGE_SIZE, "Recv page is not a page.");
-
-static hf_ipaddr_t send_page_addr = (hf_ipaddr_t)send_page;
-static hf_ipaddr_t recv_page_addr = (hf_ipaddr_t)recv_page;
-
-struct mailbox_buffers set_up_mailbox(void)
-{
- ASSERT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
- return (struct mailbox_buffers){
- .send = send_page,
- .recv = recv_page,
- };
-}
-
-/*
- * Helper function to send memory to a VM then send a message with the retrieve
- * request it needs to retrieve it.
- */
-spci_memory_handle_t send_memory_and_retrieve_request(
- uint32_t share_func, void *tx_buffer, spci_vm_id_t sender,
- spci_vm_id_t recipient,
- struct spci_memory_region_constituent constituents[],
- uint32_t constituent_count, spci_memory_region_flags_t flags,
- enum spci_data_access send_data_access,
- enum spci_data_access retrieve_data_access,
- enum spci_instruction_access send_instruction_access,
- enum spci_instruction_access retrieve_instruction_access)
-{
- uint32_t msg_size;
- struct spci_value ret;
- spci_memory_handle_t handle;
-
- /* Send the memory. */
- msg_size = spci_memory_region_init(
- tx_buffer, sender, recipient, constituents, constituent_count,
- 0, flags, send_data_access, send_instruction_access,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- switch (share_func) {
- case SPCI_MEM_DONATE_32:
- ret = spci_mem_donate(msg_size, msg_size);
- break;
- case SPCI_MEM_LEND_32:
- ret = spci_mem_lend(msg_size, msg_size);
- break;
- case SPCI_MEM_SHARE_32:
- ret = spci_mem_share(msg_size, msg_size);
- break;
- default:
- FAIL("Invalid share_func %#x.\n", share_func);
- /* Never reached, but needed to keep clang-analyser happy. */
- return 0;
- }
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
- handle = spci_mem_success_handle(ret);
-
- /*
- * Send the appropriate retrieve request to the VM so that it can use it
- * to retrieve the memory.
- */
- msg_size = spci_memory_retrieve_request_init(
- tx_buffer, handle, sender, recipient, 0, 0,
- retrieve_data_access, retrieve_instruction_access,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_msg_send(sender, recipient, msg_size, 0).func,
- SPCI_SUCCESS_32);
-
- return handle;
-}
-
-/*
- * Use the retrieve request from the receive buffer to retrieve a memory region
- * which has been sent to us. Returns the sender, and the handle via a return
- * parameter.
- */
-spci_vm_id_t retrieve_memory_from_message(void *recv_buf, void *send_buf,
- struct spci_value msg_ret,
- spci_memory_handle_t *handle)
-{
- uint32_t msg_size;
- struct spci_value ret;
- struct spci_memory_region *memory_region;
- spci_vm_id_t sender;
-
- EXPECT_EQ(msg_ret.func, SPCI_MSG_SEND_32);
- msg_size = spci_msg_send_size(msg_ret);
- sender = spci_msg_send_sender(msg_ret);
-
- if (handle != NULL) {
- struct spci_memory_region *retrieve_request =
- (struct spci_memory_region *)recv_buf;
- *handle = retrieve_request->handle;
- }
- memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
- spci_rx_release();
- ret = spci_mem_retrieve_req(msg_size, msg_size);
- EXPECT_EQ(ret.func, SPCI_MEM_RETRIEVE_RESP_32);
- memory_region = (struct spci_memory_region *)recv_buf;
- EXPECT_EQ(memory_region->receiver_count, 1);
- EXPECT_EQ(memory_region->receivers[0].receiver_permissions.receiver,
- hf_vm_get_id());
-
- return sender;
-}
-
-/*
- * Use the retrieve request from the receive buffer to retrieve a memory region
- * which has been sent to us, expecting it to fail with the given error code.
- * Returns the sender.
- */
-spci_vm_id_t retrieve_memory_from_message_expect_fail(void *recv_buf,
- void *send_buf,
- struct spci_value msg_ret,
- int32_t expected_error)
-{
- uint32_t msg_size;
- struct spci_value ret;
- spci_vm_id_t sender;
-
- EXPECT_EQ(msg_ret.func, SPCI_MSG_SEND_32);
- msg_size = spci_msg_send_size(msg_ret);
- sender = spci_msg_send_sender(msg_ret);
-
- memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
- spci_rx_release();
- ret = spci_mem_retrieve_req(msg_size, msg_size);
- EXPECT_SPCI_ERROR(ret, expected_error);
-
- return sender;
-}
diff --git a/test/vmapi/primary_only/faults.c b/test/vmapi/primary_only/faults.c
index 34b7e15..52cfa03 100644
--- a/test/vmapi/primary_only/faults.c
+++ b/test/vmapi/primary_only/faults.c
@@ -70,8 +70,8 @@
sl_lock(&s.lock);
/* Configure the VM's buffers. */
- EXPECT_EQ(spci_rxtx_map((hf_ipaddr_t)&tx[0], (hf_ipaddr_t)&rx[0]).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rxtx_map((hf_ipaddr_t)&tx[0], (hf_ipaddr_t)&rx[0]).func,
+ FFA_SUCCESS_32);
/* Tell other CPU to stop and wait for it. */
s.done = true;
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index 1be94a9..ea42c86 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -23,7 +23,7 @@
#include "vmapi/hf/call.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/*
* TODO: Some of these tests are duplicated between 'primary_only' and
@@ -69,7 +69,7 @@
*/
TEST(hf_vcpu_get_count, reserved_vm_id)
{
- spci_vm_id_t id;
+ ffa_vm_id_t id;
for (id = 0; id < HF_VM_ID_OFFSET; ++id) {
EXPECT_EQ(hf_vcpu_get_count(id), 0);
@@ -88,27 +88,27 @@
/**
* Confirm it is an error when running a vCPU from the primary VM.
*/
-TEST(spci_run, cannot_run_primary)
+TEST(ffa_run, cannot_run_primary)
{
- struct spci_value res = spci_run(HF_PRIMARY_VM_ID, 0);
- EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
+ struct ffa_value res = ffa_run(HF_PRIMARY_VM_ID, 0);
+ EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
/**
* Confirm it is an error when running a vCPU from a non-existent secondary VM.
*/
-TEST(spci_run, cannot_run_absent_secondary)
+TEST(ffa_run, cannot_run_absent_secondary)
{
- struct spci_value res = spci_run(1, 0);
- EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
+ struct ffa_value res = ffa_run(1, 0);
+ EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
/**
* Yielding from the primary is a noop.
*/
-TEST(spci_yield, yield_is_noop_for_primary)
+TEST(ffa_yield, yield_is_noop_for_primary)
{
- EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_yield().func, FFA_SUCCESS_32);
}
/**
@@ -198,8 +198,8 @@
dlog("Second CPU stopped.\n");
}
-/** Ensures that the Hafnium SPCI version is reported as expected. */
-TEST(spci, spci_version)
+/** Ensures that the Hafnium FF-A version is reported as expected. */
+TEST(ffa, ffa_version)
{
const int32_t major_revision = 1;
const int32_t major_revision_offset = 16;
@@ -207,119 +207,119 @@
const int32_t current_version =
(major_revision << major_revision_offset) | minor_revision;
- EXPECT_EQ(spci_version(current_version), current_version);
- EXPECT_EQ(spci_version(0x0), current_version);
- EXPECT_EQ(spci_version(0x1), current_version);
- EXPECT_EQ(spci_version(0x10003), current_version);
- EXPECT_EQ(spci_version(0xffff), current_version);
- EXPECT_EQ(spci_version(0xfffffff), current_version);
+ EXPECT_EQ(ffa_version(current_version), current_version);
+ EXPECT_EQ(ffa_version(0x0), current_version);
+ EXPECT_EQ(ffa_version(0x1), current_version);
+ EXPECT_EQ(ffa_version(0x10003), current_version);
+ EXPECT_EQ(ffa_version(0xffff), current_version);
+ EXPECT_EQ(ffa_version(0xfffffff), current_version);
}
-/** Ensures that an invalid call to SPCI_VERSION gets an error back. */
-TEST(spci, spci_version_invalid)
+/** Ensures that an invalid call to FFA_VERSION gets an error back. */
+TEST(ffa, ffa_version_invalid)
{
- int32_t ret = spci_version(0x80000000);
+ int32_t ret = ffa_version(0x80000000);
- EXPECT_EQ(ret, SPCI_NOT_SUPPORTED);
+ EXPECT_EQ(ret, FFA_NOT_SUPPORTED);
}
-/** Ensures that SPCI_FEATURES is reporting the expected interfaces. */
-TEST(spci, spci_features)
+/** Ensures that FFA_FEATURES is reporting the expected interfaces. */
+TEST(ffa, ffa_features)
{
- struct spci_value ret;
+ struct ffa_value ret;
- ret = spci_features(SPCI_ERROR_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_ERROR_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_SUCCESS_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_SUCCESS_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_INTERRUPT_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_INTERRUPT_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_VERSION_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_VERSION_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_FEATURES_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_FEATURES_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_RX_RELEASE_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_RX_RELEASE_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_RXTX_MAP_64);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_RXTX_MAP_64);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_ID_GET_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_ID_GET_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MSG_POLL_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MSG_POLL_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MSG_WAIT_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MSG_WAIT_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_YIELD_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_YIELD_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_RUN_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_RUN_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MSG_SEND_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MSG_SEND_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_DONATE_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_DONATE_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_LEND_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_LEND_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_SHARE_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_SHARE_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_RETRIEVE_REQ_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_RETRIEVE_REQ_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_RETRIEVE_RESP_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_RETRIEVE_RESP_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_RELINQUISH_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_RELINQUISH_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = spci_features(SPCI_MEM_RECLAIM_32);
- EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
+ ret = ffa_features(FFA_MEM_RECLAIM_32);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
}
/**
- * Ensures that SPCI_FEATURES returns not supported for a bogus FID or
+ * Ensures that FFA_FEATURES returns not supported for a bogus FID or
* currently non-implemented interfaces.
*/
-TEST(spci, spci_features_not_supported)
+TEST(ffa, ffa_features_not_supported)
{
- struct spci_value ret;
+ struct ffa_value ret;
- ret = spci_features(0);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(0);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(0x84000000);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(0x84000000);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(SPCI_RXTX_UNMAP_32);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(FFA_RXTX_UNMAP_32);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(SPCI_PARTITION_INFO_GET_32);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(FFA_PARTITION_INFO_GET_32);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(SPCI_MSG_SEND_DIRECT_RESP_32);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(FFA_MSG_SEND_DIRECT_RESP_32);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(SPCI_MSG_SEND_DIRECT_REQ_32);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(FFA_MSG_SEND_DIRECT_REQ_32);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(SPCI_MSG_SEND_DIRECT_REQ_32);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(FFA_MSG_SEND_DIRECT_REQ_32);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
- ret = spci_features(SPCI_MSG_SEND_DIRECT_RESP_32);
- EXPECT_SPCI_ERROR(ret, SPCI_NOT_SUPPORTED);
+ ret = ffa_features(FFA_MSG_SEND_DIRECT_RESP_32);
+ EXPECT_FFA_ERROR(ret, FFA_NOT_SUPPORTED);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/BUILD.gn b/test/vmapi/primary_with_secondaries/BUILD.gn
index b0c3885..908a54c 100644
--- a/test/vmapi/primary_with_secondaries/BUILD.gn
+++ b/test/vmapi/primary_with_secondaries/BUILD.gn
@@ -30,6 +30,7 @@
sources = [
"boot.c",
"debug_el1.c",
+ "ffa.c",
"floating_point.c",
"interrupts.c",
"mailbox.c",
@@ -38,7 +39,6 @@
"perfmon.c",
"run_race.c",
"smp.c",
- "spci.c",
"sysregs.c",
"unmapped.c",
]
diff --git a/test/vmapi/primary_with_secondaries/boot.c b/test/vmapi/primary_with_secondaries/boot.c
index e098538..fa4839d 100644
--- a/test/vmapi/primary_with_secondaries/boot.c
+++ b/test/vmapi/primary_with_secondaries/boot.c
@@ -21,20 +21,20 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
#include "test/vmapi/exception_handler.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/**
* The VM gets its memory size on boot, and can access it all.
*/
TEST(boot, memory_size)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "boot_memory", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
@@ -42,12 +42,12 @@
*/
TEST(boot, beyond_memory_size)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "boot_memory_overrun", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -57,12 +57,12 @@
*/
TEST(boot, memory_before_image)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "boot_memory_underrun", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
diff --git a/test/vmapi/primary_with_secondaries/debug_el1.c b/test/vmapi/primary_with_secondaries/debug_el1.c
index 381c2c6..8580195 100644
--- a/test/vmapi/primary_with_secondaries/debug_el1.c
+++ b/test/vmapi/primary_with_secondaries/debug_el1.c
@@ -16,7 +16,7 @@
#include "primary_with_secondary.h"
#include "sysregs.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/**
* QEMU does not properly handle the trapping of certain system register
@@ -27,13 +27,13 @@
TEST(debug_el1, secondary_basic)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "debug_el1_secondary_basic", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/ffa.c b/test/vmapi/primary_with_secondaries/ffa.c
new file mode 100644
index 0000000..4bda05a
--- /dev/null
+++ b/test/vmapi/primary_with_secondaries/ffa.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2019 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hf/ffa.h"
+
+#include <stdint.h>
+
+#include "hf/std.h"
+
+#include "vmapi/hf/call.h"
+
+#include "primary_with_secondary.h"
+#include "test/hftest.h"
+#include "test/vmapi/ffa.h"
+
+/**
+ * Send a message to a secondary VM which checks the validity of the received
+ * header.
+ */
+TEST(ffa, msg_send)
+{
+ const char message[] = "ffa_msg_send";
+ struct ffa_value run_res;
+ struct mailbox_buffers mb = set_up_mailbox();
+
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check", mb.send);
+
+ /* Set the payload, init the message header and send the message. */
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
+ EXPECT_EQ(
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ .func,
+ FFA_SUCCESS_32);
+
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
+}
+
+/**
+ * Send a message to a secondary VM spoofing the source VM id.
+ */
+TEST(ffa, msg_send_spoof)
+{
+ const char message[] = "ffa_msg_send";
+ struct mailbox_buffers mb = set_up_mailbox();
+
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check", mb.send);
+
+ /* Set the payload, init the message header and send the message. */
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
+ EXPECT_FFA_ERROR(
+ ffa_msg_send(SERVICE_VM2, SERVICE_VM1, sizeof(message), 0),
+ FFA_INVALID_PARAMETERS);
+}
+
+/**
+ * Send a message to a secondary VM with incorrect destination id.
+ */
+TEST(ffa, ffa_invalid_destination_id)
+{
+ const char message[] = "fail to send";
+ struct mailbox_buffers mb = set_up_mailbox();
+
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check", mb.send);
+ /* Set the payload, init the message header and send the message. */
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
+ EXPECT_FFA_ERROR(ffa_msg_send(HF_PRIMARY_VM_ID, -1, sizeof(message), 0),
+ FFA_INVALID_PARAMETERS);
+}
+
+/**
+ * Ensure that the length parameter is respected when sending messages.
+ */
+TEST(ffa, ffa_incorrect_length)
+{
+ const char message[] = "this should be truncated";
+ struct ffa_value run_res;
+ struct mailbox_buffers mb = set_up_mailbox();
+
+ SERVICE_SELECT(SERVICE_VM1, "ffa_length", mb.send);
+
+ /* Send the message and compare if truncated. */
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
+ /* Hard code incorrect length. */
+ EXPECT_EQ(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 16, 0).func,
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
+}
+
+/**
+ * Attempt to send a message larger than what is supported.
+ */
+TEST(ffa, ffa_large_message)
+{
+ const char message[] = "fail to send";
+ struct mailbox_buffers mb = set_up_mailbox();
+
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
+ /* Send a message that is larger than the mailbox supports (4KB). */
+ EXPECT_FFA_ERROR(
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 4 * 1024 + 1, 0),
+ FFA_INVALID_PARAMETERS);
+}
+
+/**
+ * Verify secondary VM non blocking recv.
+ */
+TEST(ffa, ffa_recv_non_blocking)
+{
+ struct mailbox_buffers mb = set_up_mailbox();
+ struct ffa_value run_res;
+
+ /* Check is performed in secondary VM. */
+ SERVICE_SELECT(SERVICE_VM1, "ffa_recv_non_blocking", mb.send);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
+}
diff --git a/test/vmapi/primary_with_secondaries/floating_point.c b/test/vmapi/primary_with_secondaries/floating_point.c
index 1904d68..0cb2c21 100644
--- a/test/vmapi/primary_with_secondaries/floating_point.c
+++ b/test/vmapi/primary_with_secondaries/floating_point.c
@@ -17,14 +17,14 @@
#include "hf/arch/std.h"
#include "hf/arch/vm/registers.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "vmapi/hf/call.h"
#include "../msr.h"
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/**
* Test that floating point registers are saved and restored by
@@ -35,18 +35,18 @@
{
const double first = 1.2;
const double second = -2.3;
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
fill_fp_registers(first);
SERVICE_SELECT(SERVICE_VM1, "fp_fill", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
EXPECT_EQ(check_fp_register(first), true);
fill_fp_registers(second);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
EXPECT_EQ(check_fp_register(second), true);
}
@@ -57,17 +57,17 @@
TEST(floating_point, fp_fpcr)
{
uintreg_t value = 0;
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
EXPECT_EQ(read_msr(fpcr), value);
SERVICE_SELECT(SERVICE_VM1, "fp_fpcr", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
EXPECT_EQ(read_msr(fpcr), value);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
EXPECT_EQ(read_msr(fpcr), value);
}
diff --git a/test/vmapi/primary_with_secondaries/interrupts.c b/test/vmapi/primary_with_secondaries/interrupts.c
index dce89ab..13e573b 100644
--- a/test/vmapi/primary_with_secondaries/interrupts.c
+++ b/test/vmapi/primary_with_secondaries/interrupts.c
@@ -22,11 +22,11 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
TEAR_DOWN(interrupts)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
@@ -37,27 +37,27 @@
{
const char message[] = "Ping";
const char expected_response[] = "Got IRQ 05.";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Set the message, echo it and wait for a response. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -68,32 +68,32 @@
TEST(interrupts, inject_interrupt_twice)
{
const char expected_response[] = "Got IRQ 07.";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Inject the interrupt again, and wait for the same message. */
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -104,33 +104,33 @@
{
const char expected_response[] = "Got IRQ 07.";
const char expected_response_2[] = "Got IRQ 08.";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Inject a different interrupt and wait for a different message. */
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_B);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_2));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response_2));
EXPECT_EQ(memcmp(mb.recv, expected_response_2,
sizeof(expected_response_2)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -143,41 +143,41 @@
const char expected_response[] = "Got IRQ 07.";
const char message[] = "Ping";
const char expected_response_2[] = "Got IRQ 05.";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Now send a message to the secondary. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_2));
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response_2));
EXPECT_EQ(memcmp(mb.recv, expected_response_2,
sizeof(expected_response_2)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -189,32 +189,32 @@
{
const char expected_response[] = "Got IRQ 09.";
const char message[] = "Enable interrupt C";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "interruptible", mb.send);
/* Inject the interrupt and expect not to get a message. */
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_C);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/*
* Now send a message to the secondary to enable the interrupt ID, and
* expect the response from the interrupt we sent before.
*/
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -225,7 +225,7 @@
TEST(interrupts, pending_interrupt_no_blocking_receive)
{
const char expected_response[] = "Done waiting";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "receive_block", mb.send);
@@ -236,12 +236,12 @@
* back after failing to receive a message a few times.
*/
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -252,7 +252,7 @@
TEST(interrupts, pending_interrupt_wfi_not_trapped)
{
const char expected_response[] = "Done waiting";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "wfi", mb.send);
@@ -263,12 +263,12 @@
* back after running WFI a few times.
*/
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/*
@@ -278,24 +278,24 @@
TEST(interrupts, deliver_interrupt_and_message)
{
const char message[] = "I\'ll see you again.";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "interruptible_echo", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
+ FFA_SUCCESS_32);
hf_interrupt_inject(SERVICE_VM1, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
diff --git a/test/vmapi/primary_with_secondaries/mailbox.c b/test/vmapi/primary_with_secondaries/mailbox.c
index b96c595..b7085ae 100644
--- a/test/vmapi/primary_with_secondaries/mailbox.c
+++ b/test/vmapi/primary_with_secondaries/mailbox.c
@@ -16,14 +16,14 @@
#include <stdint.h>
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/**
* Reverses the order of the elements in the given array.
@@ -65,7 +65,7 @@
TEAR_DOWN(mailbox)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
@@ -73,9 +73,9 @@
*/
TEST(mailbox, clear_empty)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
@@ -84,26 +84,26 @@
TEST(mailbox, echo)
{
const char message[] = "Echo this back to me!";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "echo", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Set the message, echo it and check it didn't change. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -112,7 +112,7 @@
TEST(mailbox, repeated_echo)
{
char message[] = "Echo this back to me!";
- struct spci_value run_res;
+ struct ffa_value run_res;
uint8_t i;
struct mailbox_buffers mb = set_up_mailbox();
@@ -120,23 +120,23 @@
for (i = 0; i < 100; i++) {
/* Run secondary until it reaches the wait for messages. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Set the message, echo it and check it didn't change. */
next_permutation(message, sizeof(message) - 1);
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message,
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message,
sizeof(message));
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1,
- sizeof(message), 0)
+ EXPECT_EQ(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1,
+ sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
}
@@ -147,54 +147,53 @@
TEST(mailbox, relay)
{
const char message[] = "Send this round the relay!";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "relay", mb.send);
SERVICE_SELECT(SERVICE_VM2, "relay", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
- run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/*
* Build the message chain so the message is sent from here to
* SERVICE_VM1, then to SERVICE_VM2 and finally back to here.
*/
{
- spci_vm_id_t *chain = (spci_vm_id_t *)mb.send;
+ ffa_vm_id_t *chain = (ffa_vm_id_t *)mb.send;
*chain++ = htole32(SERVICE_VM2);
*chain++ = htole32(HF_PRIMARY_VM_ID);
- memcpy_s(chain,
- SPCI_MSG_PAYLOAD_MAX - (2 * sizeof(spci_vm_id_t)),
+ memcpy_s(chain, FFA_MSG_PAYLOAD_MAX - (2 * sizeof(ffa_vm_id_t)),
message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(
+ ffa_msg_send(
HF_PRIMARY_VM_ID, SERVICE_VM1,
- sizeof(message) + (2 * sizeof(spci_vm_id_t)), 0)
+ sizeof(message) + (2 * sizeof(ffa_vm_id_t)), 0)
.func,
- SPCI_SUCCESS_32);
+ FFA_SUCCESS_32);
}
/* Let SERVICE_VM1 forward the message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_receiver(run_res), SERVICE_VM2);
- EXPECT_EQ(spci_msg_send_size(run_res), 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_receiver(run_res), SERVICE_VM2);
+ EXPECT_EQ(ffa_msg_send_size(run_res), 0);
/* Let SERVICE_VM2 forward the message. */
- run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ run_res = ffa_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
/* Ensure the message is intact. */
- EXPECT_EQ(spci_msg_send_receiver(run_res), HF_PRIMARY_VM_ID);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ EXPECT_EQ(ffa_msg_send_receiver(run_res), HF_PRIMARY_VM_ID);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -203,19 +202,19 @@
*/
TEST(mailbox, no_primary_to_secondary_notification_on_configure)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
set_up_mailbox();
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0),
- SPCI_BUSY);
+ EXPECT_FFA_ERROR(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0),
+ FFA_BUSY);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0).func,
+ FFA_SUCCESS_32);
}
/**
@@ -224,28 +223,28 @@
*/
TEST(mailbox, secondary_to_primary_notification_on_configure)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
set_up_mailbox();
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0,
- SPCI_MSG_SEND_NOTIFY),
- SPCI_BUSY);
+ EXPECT_FFA_ERROR(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0,
+ FFA_MSG_SEND_NOTIFY),
+ FFA_BUSY);
/*
* Run first VM for it to configure itself. It should result in
* notifications having to be issued.
*/
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_RX_RELEASE_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_RX_RELEASE_32);
/* A single waiter is returned. */
EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), HF_PRIMARY_VM_ID);
EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), -1);
/* Send should now succeed. */
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 0, 0).func,
+ FFA_SUCCESS_32);
}
/**
@@ -256,46 +255,46 @@
TEST(mailbox, primary_to_secondary)
{
char message[] = "not ready echo";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "echo_with_notification", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Send a message to echo service, and get response back. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
/* Let secondary VM continue running so that it will wait again. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Without clearing our mailbox, send message again. */
reverse(message, strnlen_s(message, sizeof(message)));
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
/* Message should be dropped since the mailbox was not cleared. */
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ FFA_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, HF_FFA_RUN_WAIT_FOR_INTERRUPT);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Clear the mailbox. We expect to be told there are pending waiters. */
- EXPECT_EQ(spci_rx_release().func, SPCI_RX_RELEASE_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_RX_RELEASE_32);
/* Retrieve a single waiter. */
EXPECT_EQ(hf_mailbox_waiter_get(HF_PRIMARY_VM_ID), SERVICE_VM1);
@@ -308,11 +307,11 @@
EXPECT_EQ(
hf_interrupt_inject(SERVICE_VM1, 0, HF_MAILBOX_WRITABLE_INTID),
1);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/**
@@ -323,35 +322,35 @@
TEST(mailbox, secondary_to_primary_notification)
{
const char message[] = "not ready echo";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "echo_with_notification", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
/* Send a message to echo service twice. The second should fail. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
+ memcpy_s(mb.send, FFA_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
- EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1,
- sizeof(message), SPCI_MSG_SEND_NOTIFY),
- SPCI_BUSY);
+ FFA_SUCCESS_32);
+ EXPECT_FFA_ERROR(ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1,
+ sizeof(message), FFA_MSG_SEND_NOTIFY),
+ FFA_BUSY);
/* Receive a reply for the first message. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Run VM again so that it clears its mailbox. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_RX_RELEASE_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_RX_RELEASE_32);
/* Retrieve a single waiter. */
EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM1), HF_PRIMARY_VM_ID);
@@ -359,7 +358,7 @@
/* Send should now succeed. */
EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
+ ffa_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
.func,
- SPCI_SUCCESS_32);
+ FFA_SUCCESS_32);
}
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index f1a0aae..1b3c1d9 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -24,7 +24,7 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
#include "test/vmapi/exception_handler.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
alignas(PAGE_SIZE) static uint8_t pages[4 * PAGE_SIZE];
@@ -33,27 +33,26 @@
*/
static void check_cannot_send_memory(
struct mailbox_buffers mb,
- struct spci_value (*send_function)(uint32_t, uint32_t),
- struct spci_memory_region_constituent constituents[],
+ struct ffa_value (*send_function)(uint32_t, uint32_t),
+ struct ffa_memory_region_constituent constituents[],
int constituent_count, int32_t avoid_vm)
{
- enum spci_data_access data_access[] = {
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RW, SPCI_DATA_ACCESS_RESERVED};
- enum spci_instruction_access instruction_access[] = {
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX, SPCI_INSTRUCTION_ACCESS_X,
- SPCI_INSTRUCTION_ACCESS_RESERVED};
- enum spci_memory_cacheability cacheability[] = {
- SPCI_MEMORY_CACHE_RESERVED, SPCI_MEMORY_CACHE_NON_CACHEABLE,
- SPCI_MEMORY_CACHE_RESERVED_1, SPCI_MEMORY_CACHE_WRITE_BACK};
- enum spci_memory_cacheability device[] = {
- SPCI_MEMORY_DEV_NGNRNE, SPCI_MEMORY_DEV_NGNRE,
- SPCI_MEMORY_DEV_NGRE, SPCI_MEMORY_DEV_GRE};
- enum spci_memory_shareability shareability[] = {
- SPCI_MEMORY_SHARE_NON_SHAREABLE, SPCI_MEMORY_SHARE_RESERVED,
- SPCI_MEMORY_OUTER_SHAREABLE, SPCI_MEMORY_INNER_SHAREABLE};
+ enum ffa_data_access data_access[] = {
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RW, FFA_DATA_ACCESS_RESERVED};
+ enum ffa_instruction_access instruction_access[] = {
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_NX,
+ FFA_INSTRUCTION_ACCESS_X, FFA_INSTRUCTION_ACCESS_RESERVED};
+ enum ffa_memory_cacheability cacheability[] = {
+ FFA_MEMORY_CACHE_RESERVED, FFA_MEMORY_CACHE_NON_CACHEABLE,
+ FFA_MEMORY_CACHE_RESERVED_1, FFA_MEMORY_CACHE_WRITE_BACK};
+ enum ffa_memory_cacheability device[] = {
+ FFA_MEMORY_DEV_NGNRNE, FFA_MEMORY_DEV_NGNRE,
+ FFA_MEMORY_DEV_NGRE, FFA_MEMORY_DEV_GRE};
+ enum ffa_memory_shareability shareability[] = {
+ FFA_MEMORY_SHARE_NON_SHAREABLE, FFA_MEMORY_SHARE_RESERVED,
+ FFA_MEMORY_OUTER_SHAREABLE, FFA_MEMORY_INNER_SHAREABLE};
uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
size_t i = 0;
@@ -74,7 +73,7 @@
m < ARRAY_SIZE(cacheability);
++m) {
uint32_t msg_size =
- spci_memory_region_init(
+ ffa_memory_region_init(
mb.send,
HF_PRIMARY_VM_ID,
vms[i],
@@ -84,26 +83,26 @@
data_access[j],
instruction_access
[k],
- SPCI_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_NORMAL_MEM,
cacheability[m],
shareability
[l]);
- struct spci_value ret =
+ struct ffa_value ret =
send_function(msg_size,
msg_size);
EXPECT_EQ(ret.func,
- SPCI_ERROR_32);
+ FFA_ERROR_32);
EXPECT_TRUE(
ret.arg2 ==
- SPCI_DENIED ||
+ FFA_DENIED ||
ret.arg2 ==
- SPCI_INVALID_PARAMETERS);
+ FFA_INVALID_PARAMETERS);
}
for (m = 0; m < ARRAY_SIZE(device);
++m) {
uint32_t msg_size =
- spci_memory_region_init(
+ ffa_memory_region_init(
mb.send,
HF_PRIMARY_VM_ID,
vms[i],
@@ -113,21 +112,21 @@
data_access[j],
instruction_access
[k],
- SPCI_MEMORY_DEVICE_MEM,
+ FFA_MEMORY_DEVICE_MEM,
device[m],
shareability
[l]);
- struct spci_value ret =
+ struct ffa_value ret =
send_function(msg_size,
msg_size);
EXPECT_EQ(ret.func,
- SPCI_ERROR_32);
+ FFA_ERROR_32);
EXPECT_TRUE(
ret.arg2 ==
- SPCI_DENIED ||
+ FFA_DENIED ||
ret.arg2 ==
- SPCI_INVALID_PARAMETERS);
+ FFA_INVALID_PARAMETERS);
}
}
}
@@ -140,11 +139,11 @@
*/
static void check_cannot_lend_memory(
struct mailbox_buffers mb,
- struct spci_memory_region_constituent constituents[],
+ struct ffa_memory_region_constituent constituents[],
int constituent_count, int32_t avoid_vm)
{
- check_cannot_send_memory(mb, spci_mem_lend, constituents,
+ check_cannot_send_memory(mb, ffa_mem_lend, constituents,
constituent_count, avoid_vm);
}
@@ -153,11 +152,11 @@
*/
static void check_cannot_share_memory(
struct mailbox_buffers mb,
- struct spci_memory_region_constituent constituents[],
+ struct ffa_memory_region_constituent constituents[],
int constituent_count, int32_t avoid_vm)
{
- check_cannot_send_memory(mb, spci_mem_share, constituents,
+ check_cannot_send_memory(mb, ffa_mem_share, constituents,
constituent_count, avoid_vm);
}
@@ -168,7 +167,7 @@
*/
static void check_cannot_donate_memory(
struct mailbox_buffers mb,
- struct spci_memory_region_constituent constituents[],
+ struct ffa_memory_region_constituent constituents[],
int constituent_count, int32_t avoid_vm)
{
uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
@@ -176,21 +175,21 @@
size_t i;
for (i = 0; i < ARRAY_SIZE(vms); ++i) {
uint32_t msg_size;
- struct spci_value ret;
+ struct ffa_value ret;
/* Optionally skip one VM as the donate would succeed. */
if (vms[i] == avoid_vm) {
continue;
}
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, vms[i], constituents,
- constituent_count, 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- ret = spci_mem_donate(msg_size, msg_size);
- EXPECT_EQ(ret.func, SPCI_ERROR_32);
- EXPECT_TRUE(ret.arg2 == SPCI_DENIED ||
- ret.arg2 == SPCI_INVALID_PARAMETERS);
+ constituent_count, 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ ret = ffa_mem_donate(msg_size, msg_size);
+ EXPECT_EQ(ret.func, FFA_ERROR_32);
+ EXPECT_TRUE(ret.arg2 == FFA_DENIED ||
+ ret.arg2 == FFA_INVALID_PARAMETERS);
}
}
@@ -199,26 +198,25 @@
* it will fail.
*/
static void check_cannot_relinquish_memory(struct mailbox_buffers mb,
- spci_memory_handle_t handle)
+ ffa_memory_handle_t handle)
{
uint32_t vms[] = {HF_PRIMARY_VM_ID, SERVICE_VM1, SERVICE_VM2};
size_t i;
for (i = 0; i < ARRAY_SIZE(vms); ++i) {
- struct spci_mem_relinquish *relinquish_req =
- (struct spci_mem_relinquish *)mb.send;
+ struct ffa_mem_relinquish *relinquish_req =
+ (struct ffa_mem_relinquish *)mb.send;
- *relinquish_req = (struct spci_mem_relinquish){
+ *relinquish_req = (struct ffa_mem_relinquish){
.handle = handle, .endpoint_count = 1};
relinquish_req->endpoints[0] = vms[i];
- EXPECT_SPCI_ERROR(spci_mem_relinquish(),
- SPCI_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_mem_relinquish(), FFA_INVALID_PARAMETERS);
}
}
TEAR_DOWN(memory_sharing)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
@@ -227,10 +225,10 @@
*/
TEST(memory_sharing, concurrent)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
@@ -239,21 +237,21 @@
memset_s(ptr, sizeof(pages), 'a', PAGE_SIZE);
send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
pages[i] = i;
}
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
uint8_t value = i + 1;
@@ -267,35 +265,35 @@
*/
TEST(memory_sharing, share_concurrently_and_get_back)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish", mb.send);
/* Dirty the memory before sharing it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
handle = send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 'c');
}
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -306,12 +304,12 @@
TEST(memory_sharing, cannot_share_device_memory)
{
struct mailbox_buffers mb = set_up_mailbox();
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)PAGE_SIZE, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_return", mb.send);
check_cannot_lend_memory(mb, constituents, ARRAY_SIZE(constituents),
-1);
@@ -326,40 +324,40 @@
*/
TEST(memory_sharing, lend_relinquish)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE, .page_count = 2},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
/* Let the memory be returned. */
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Ensure that the secondary VM accessed the region. */
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 'c');
}
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -369,32 +367,31 @@
*/
TEST(memory_sharing, donate_relinquish)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_donate_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_donate_relinquish", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE, .page_count = 2},
};
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
/*
* Let the service access the memory, and try and fail to relinquish it.
*/
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
@@ -402,36 +399,35 @@
*/
TEST(memory_sharing, give_and_get_back)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_return", mb.send);
/* Dirty the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be returned, and retrieve it. */
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(retrieve_memory_from_message(mb.recv, mb.send, run_res, NULL),
SERVICE_VM1);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 'c');
}
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -441,35 +437,35 @@
*/
TEST(memory_sharing, lend_and_get_back)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish", mb.send);
/* Dirty the memory before lending it. */
memset_s(ptr, sizeof(pages), 'c', PAGE_SIZE);
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 'd');
}
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -479,40 +475,40 @@
*/
TEST(memory_sharing, relend_after_return)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish", mb.send);
/* Lend the memory initially. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Lend the memory again after it has been returned. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Observe the service doesn't fault when accessing the memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
}
/**
@@ -520,37 +516,37 @@
*/
TEST(memory_sharing, lend_elsewhere_after_return)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_lend_relinquish", mb.send);
/* Lend the memory initially. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be returned. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Share the memory with a different VM after it has been returned. */
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -560,32 +556,32 @@
*/
TEST(memory_sharing, give_memory_and_lose_access)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
uint8_t *ptr;
SERVICE_SELECT(SERVICE_VM1, "give_memory_and_fault", mb.send);
/* Have the memory be given. */
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(retrieve_memory_from_message(mb.recv, mb.send, run_res, NULL),
SERVICE_VM1);
/* Check the memory was cleared. */
- memory_region = (struct spci_memory_region *)mb.recv;
+ memory_region = (struct ffa_memory_region *)mb.recv;
ASSERT_EQ(memory_region->receiver_count, 1);
ASSERT_NE(memory_region->receivers[0].composite_memory_region_offset,
0);
- composite = spci_memory_region_get_composite(memory_region, 0);
+ composite = ffa_memory_region_get_composite(memory_region, 0);
ptr = (uint8_t *)composite->constituents[0].address;
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -595,32 +591,32 @@
*/
TEST(memory_sharing, lend_memory_and_lose_access)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
uint8_t *ptr;
SERVICE_SELECT(SERVICE_VM1, "lend_memory_and_fault", mb.send);
/* Have the memory be lent. */
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(retrieve_memory_from_message(mb.recv, mb.send, run_res, NULL),
SERVICE_VM1);
/* Check the memory was cleared. */
- memory_region = (struct spci_memory_region *)mb.recv;
+ memory_region = (struct ffa_memory_region *)mb.recv;
ASSERT_EQ(memory_region->receiver_count, 1);
ASSERT_NE(memory_region->receivers[0].composite_memory_region_offset,
0);
- composite = spci_memory_region_get_composite(memory_region, 0);
+ composite = ffa_memory_region_get_composite(memory_region, 0);
ptr = (uint8_t *)composite->constituents[0].address;
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -630,18 +626,18 @@
*/
TEST(memory_sharing, donate_check_upper_bounds)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_check_upper_bound", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_check_upper_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check_upper_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_check_upper_bound", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', 4 * PAGE_SIZE);
/* Specify non-contiguous memory regions. */
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE * 2, .page_count = 1},
};
@@ -653,13 +649,12 @@
pages[0] = 0;
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
@@ -678,13 +673,12 @@
* exception loop.
*/
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM2, 0);
+ run_res = ffa_run(SERVICE_VM2, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -694,18 +688,18 @@
*/
TEST(memory_sharing, donate_check_lower_bounds)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_check_lower_bound", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_check_lower_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check_lower_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_check_lower_bound", mb.send);
/* Initialise the memory before donating it. */
memset_s(ptr, sizeof(pages), 'b', 4 * PAGE_SIZE);
/* Specify non-contiguous memory regions. */
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE * 2, .page_count = 1},
};
@@ -717,13 +711,12 @@
pages[0] = 0;
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
@@ -742,13 +735,12 @@
* exception loop.
*/
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM2, 0);
+ run_res = ffa_run(SERVICE_VM2, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -759,43 +751,41 @@
*/
TEST(memory_sharing, donate_elsewhere_after_return)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_return", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', 1 * PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
/* Let the memory be returned. */
EXPECT_EQ(retrieve_memory_from_message(mb.recv, mb.send, run_res, NULL),
SERVICE_VM1);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Share the memory with another VM. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -806,49 +796,48 @@
*/
TEST(memory_sharing, donate_vms)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_donate_secondary_and_fault", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_receive", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_donate_secondary_and_fault", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_receive", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', 1 * PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
/* Set up VM2 to wait for message. */
- run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ run_res = ffa_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_WAIT_32);
/* Donate memory. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be sent from VM1 to VM2. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_receiver(run_res), SERVICE_VM2);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_receiver(run_res), SERVICE_VM2);
/* Receive memory in VM2. */
- run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Try to access memory in VM1. */
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
/* Ensure that memory in VM2 remains the same. */
- run_res = spci_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
@@ -856,32 +845,31 @@
*/
TEST(memory_sharing, donate_twice)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_donate_twice", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_receive", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_donate_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_receive", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', 1 * PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
/* Donate memory to VM1. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be received. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Fail to share memory again with any VM. */
check_cannot_share_memory(mb, constituents, ARRAY_SIZE(constituents),
@@ -894,17 +882,17 @@
check_cannot_relinquish_memory(mb, handle);
/* Let the memory be sent from VM1 to PRIMARY (returned). */
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(retrieve_memory_from_message(mb.recv, mb.send, run_res, NULL),
SERVICE_VM1);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Check we have access again. */
ptr[0] = 'f';
/* Try and fail to donate memory from VM1 to VM2. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
@@ -918,18 +906,18 @@
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, HF_PRIMARY_VM_ID, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
}
/**
@@ -943,17 +931,17 @@
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, HF_PRIMARY_VM_ID, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_lend(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
}
/**
@@ -967,17 +955,17 @@
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, HF_PRIMARY_VM_ID, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_share(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
}
/**
@@ -985,62 +973,61 @@
*/
TEST(memory_sharing, donate_invalid_source)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM1, "spci_donate_invalid_source", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_receive", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_donate_invalid_source", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_receive", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
/* Try invalid configurations. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, SERVICE_VM1, HF_PRIMARY_VM_ID, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, SERVICE_VM1, SERVICE_VM1, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, SERVICE_VM2, SERVICE_VM1, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
/* Successfully donate to VM1. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_DONATE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
/* Receive and return memory from VM1. */
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(retrieve_memory_from_message(mb.recv, mb.send, run_res, NULL),
SERVICE_VM1);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Use VM1 to fail to donate memory from the primary to VM2. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
@@ -1050,7 +1037,7 @@
{
struct mailbox_buffers mb = set_up_mailbox();
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_return", mb.send);
/* Check for unaligned pages for either constituent. */
for (int i = 0; i < PAGE_SIZE; i++) {
@@ -1059,32 +1046,32 @@
if (i == 0 && j == 0) {
continue;
}
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages + i,
.page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE + j,
.page_count = 1},
};
- uint32_t msg_size = spci_memory_region_init(
+ uint32_t msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
- msg_size = spci_memory_region_init(
+ FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents), 0, 0,
- SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_lend(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
}
}
}
@@ -1094,45 +1081,45 @@
*/
TEST(memory_sharing, lend_invalid_source)
{
- struct spci_value run_res;
- spci_memory_handle_t handle;
+ struct ffa_value run_res;
+ ffa_memory_handle_t handle;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM1, "spci_lend_invalid_source", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_lend_invalid_source", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
/* Check cannot swap VM IDs. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, SERVICE_VM1, HF_PRIMARY_VM_ID, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_lend(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
/* Lend memory to VM1. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Receive and return memory from VM1. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Try to lend memory from primary in VM1. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
@@ -1141,50 +1128,50 @@
*/
TEST(memory_sharing, lend_relinquish_X_RW)
{
- struct spci_value run_res;
- spci_memory_handle_t handle;
+ struct ffa_value run_res;
+ ffa_memory_handle_t handle;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Let service write to and return memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1195,30 +1182,30 @@
*/
TEST(memory_sharing, share_X_RW)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_share_fail", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_share_fail", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the secondary VM fail to retrieve the memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1227,21 +1214,21 @@
}
/* Reclaim the memory. */
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the secondary VM fail to retrieve the memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1250,7 +1237,7 @@
}
/* Reclaim the memory. */
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
}
/**
@@ -1259,29 +1246,29 @@
*/
TEST(memory_sharing, share_relinquish_NX_RW)
{
- struct spci_value run_res;
- spci_memory_handle_t handle;
+ struct ffa_value run_res;
+ ffa_memory_handle_t handle;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1289,23 +1276,23 @@
}
/* Let service write to and return memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1313,7 +1300,7 @@
ptr[i]++;
}
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1325,31 +1312,31 @@
{
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
size_t i;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_share_relinquish_clear",
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_share_relinquish_clear",
mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages) * 2, 'b', PAGE_SIZE * 2);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
/* Let the memory be received, fail to be cleared, and then returned. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
/* Check that it has not been cleared. */
for (i = 0; i < PAGE_SIZE * 2; ++i) {
@@ -1362,12 +1349,12 @@
*/
TEST(memory_sharing, lend_relinquish_RW_X)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_X", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish_X", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 0, PAGE_SIZE);
@@ -1376,29 +1363,29 @@
/* Set memory to contain the RET instruction to attempt to execute. */
*ptr2 = 0xD65F03C0;
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Attempt to execute from memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1408,12 +1395,12 @@
*/
TEST(memory_sharing, lend_relinquish_RO_X)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_X", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish_X", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 0, PAGE_SIZE);
@@ -1422,29 +1409,29 @@
/* Set memory to contain the RET instruction to attempt to execute. */
*ptr2 = 0xD65F03C0;
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Attempt to execute from memory. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_mem_reclaim(handle, 0).func, SPCI_SUCCESS_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_reclaim(handle, 0).func, FFA_SUCCESS_32);
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -1454,54 +1441,54 @@
*/
TEST(memory_sharing, lend_donate)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages) * 2, 'b', PAGE_SIZE * 2);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
};
/* Lend memory to VM1. */
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Ensure we can't donate any sub section of memory to another VM. */
constituents[0].page_count = 1;
for (int i = 1; i < PAGE_SIZE * 2; i++) {
constituents[0].address = (uint64_t)pages + PAGE_SIZE;
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2, constituents,
ARRAY_SIZE(constituents), 0, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_DENIED);
+ FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_DENIED);
}
/* Ensure we can't donate to the only borrower. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size), SPCI_DENIED);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size), FFA_DENIED);
}
/**
@@ -1509,31 +1496,31 @@
*/
TEST(memory_sharing, share_donate)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_relinquish_RW", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_relinquish_RW", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_lend_relinquish_RW", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE * 4);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
{.address = (uint64_t)pages + PAGE_SIZE * 2, .page_count = 2},
};
send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Attempt to share the same area of memory. */
check_cannot_share_memory(mb, constituents, ARRAY_SIZE(constituents),
@@ -1543,24 +1530,24 @@
constituents[0].page_count = 1;
for (int i = 1; i < PAGE_SIZE * 2; i++) {
constituents[0].address = (uint64_t)pages + PAGE_SIZE;
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2, constituents,
ARRAY_SIZE(constituents), 0, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_DENIED);
+ FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_DENIED);
}
/* Ensure we can't donate to the only borrower. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size), SPCI_DENIED);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size), FFA_DENIED);
}
/**
@@ -1568,33 +1555,33 @@
*/
TEST(memory_sharing, lend_twice)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_twice", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_lend_twice", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE * 4);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
{.address = (uint64_t)pages + PAGE_SIZE * 3, .page_count = 1},
};
/* Lend memory to VM1. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/* Attempt to lend the same area of memory. */
check_cannot_lend_memory(mb, constituents, ARRAY_SIZE(constituents),
@@ -1609,7 +1596,7 @@
check_cannot_relinquish_memory(mb, handle);
/* Now attempt to share only a portion of the same area of memory. */
- struct spci_memory_region_constituent constituents_subsection[] = {
+ struct ffa_memory_region_constituent constituents_subsection[] = {
{.address = (uint64_t)pages + PAGE_SIZE * 3, .page_count = 1},
};
check_cannot_lend_memory(mb, constituents_subsection,
@@ -1622,14 +1609,13 @@
constituents[0].page_count = 1;
for (int i = 0; i < 2; i++) {
constituents[0].address = (uint64_t)pages + i * PAGE_SIZE;
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_RO,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size),
- SPCI_DENIED);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_RO,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_lend(msg_size, msg_size), FFA_DENIED);
}
}
@@ -1638,31 +1624,31 @@
*/
TEST(memory_sharing, share_twice)
{
- spci_memory_handle_t handle;
- struct spci_value run_res;
+ ffa_memory_handle_t handle;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
uint32_t msg_size;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_lend_twice", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_memory_lend_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_lend_twice", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_memory_lend_twice", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages) * 2, 'b', PAGE_SIZE * 2);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
};
handle = send_memory_and_retrieve_request(
- SPCI_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NX);
+ FFA_MEM_SHARE_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NX);
/* Let the memory be accessed. */
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
/*
* Attempting to share or lend the same area of memory with any VM
@@ -1682,14 +1668,13 @@
constituents[0].page_count = 1;
for (int i = 0; i < 2; i++) {
constituents[0].address = (uint64_t)pages + i * PAGE_SIZE;
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_RO,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size),
- SPCI_DENIED);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_RO,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_share(msg_size, msg_size), FFA_DENIED);
}
}
@@ -1700,27 +1685,27 @@
{
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
size_t i;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_return", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages) * 2, 'b', PAGE_SIZE * 2);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
};
/* Lend memory with clear flag. */
handle = send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
constituents, ARRAY_SIZE(constituents),
- SPCI_MEMORY_REGION_FLAG_CLEAR, SPCI_DATA_ACCESS_RO,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEMORY_REGION_FLAG_CLEAR, FFA_DATA_ACCESS_RO,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Take it back again. */
- spci_mem_reclaim(handle, 0);
+ ffa_mem_reclaim(handle, 0);
/* Check that it has not been cleared. */
for (i = 0; i < PAGE_SIZE * 2; ++i) {
@@ -1738,23 +1723,23 @@
uint32_t msg_size;
size_t i;
- SERVICE_SELECT(SERVICE_VM1, "spci_memory_return", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_memory_return", mb.send);
/* Initialise the memory before giving it. */
memset_s(ptr, sizeof(pages) * 2, 'b', PAGE_SIZE * 2);
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 2},
};
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1, constituents,
- ARRAY_SIZE(constituents), 0, SPCI_MEMORY_REGION_FLAG_CLEAR,
- SPCI_DATA_ACCESS_RO, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ ARRAY_SIZE(constituents), 0, FFA_MEMORY_REGION_FLAG_CLEAR,
+ FFA_DATA_ACCESS_RO, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_share(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
/* Check that it has not been cleared. */
for (i = 0; i < PAGE_SIZE * 2; ++i) {
@@ -1763,22 +1748,22 @@
}
/**
- * SPCI: Verify past the upper bound of the lent region cannot be accessed.
+ * FF-A: Verify past the upper bound of the lent region cannot be accessed.
*/
-TEST(memory_sharing, spci_lend_check_upper_bounds)
+TEST(memory_sharing, ffa_lend_check_upper_bounds)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_check_upper_bound", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_check_upper_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check_upper_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_check_upper_bound", mb.send);
/* Initialise the memory before lending it. */
memset_s(ptr, sizeof(pages), 'b', 4 * PAGE_SIZE);
/* Specify non-contiguous memory regions. */
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE * 2, .page_count = 1},
};
@@ -1790,12 +1775,12 @@
pages[0] = 0;
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
@@ -1814,33 +1799,33 @@
* exception loop.
*/
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM2, 0);
+ run_res = ffa_run(SERVICE_VM2, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
/**
- * SPCI: Verify past the lower bound of the lent region cannot be accessed.
+ * FF-A: Verify past the lower bound of the lent region cannot be accessed.
*/
-TEST(memory_sharing, spci_lend_check_lower_bounds)
+TEST(memory_sharing, ffa_lend_check_lower_bounds)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = pages;
- SERVICE_SELECT(SERVICE_VM1, "spci_check_lower_bound", mb.send);
- SERVICE_SELECT(SERVICE_VM2, "spci_check_lower_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM1, "ffa_check_lower_bound", mb.send);
+ SERVICE_SELECT(SERVICE_VM2, "ffa_check_lower_bound", mb.send);
/* Initialise the memory before lending it. */
memset_s(ptr, sizeof(pages), 'b', 4 * PAGE_SIZE);
/* Specify non-contiguous memory regions. */
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)pages, .page_count = 1},
{.address = (uint64_t)pages + PAGE_SIZE * 2, .page_count = 1},
};
@@ -1852,12 +1837,12 @@
pages[0] = 0;
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
@@ -1876,12 +1861,12 @@
* exception loop.
*/
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
- constituents, ARRAY_SIZE(constituents), 0, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_LEND_32, mb.send, HF_PRIMARY_VM_ID, SERVICE_VM2,
+ constituents, ARRAY_SIZE(constituents), 0, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
- run_res = spci_run(SERVICE_VM2, 0);
+ run_res = ffa_run(SERVICE_VM2, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 2757df2..956d5bf 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -25,7 +25,7 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
@@ -64,7 +64,7 @@
*/
TEST(hf_vcpu_get_count, reserved_vm_id)
{
- spci_vm_id_t id;
+ ffa_vm_id_t id;
for (id = 0; id < HF_VM_ID_OFFSET; ++id) {
EXPECT_EQ(hf_vcpu_get_count(id), 0);
@@ -83,42 +83,42 @@
/**
* The primary can't be run by the hypervisor.
*/
-TEST(spci_run, cannot_run_primary)
+TEST(ffa_run, cannot_run_primary)
{
- struct spci_value res = spci_run(HF_PRIMARY_VM_ID, 0);
- EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
+ struct ffa_value res = ffa_run(HF_PRIMARY_VM_ID, 0);
+ EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
/**
* Can only run a VM that exists.
*/
-TEST(spci_run, cannot_run_absent_secondary)
+TEST(ffa_run, cannot_run_absent_secondary)
{
- struct spci_value res = spci_run(1234, 0);
- EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
+ struct ffa_value res = ffa_run(1234, 0);
+ EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
/**
* Can only run a vCPU that exists.
*/
-TEST(spci_run, cannot_run_absent_vcpu)
+TEST(ffa_run, cannot_run_absent_vcpu)
{
- struct spci_value res = spci_run(SERVICE_VM1, 1234);
- EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
+ struct ffa_value res = ffa_run(SERVICE_VM1, 1234);
+ EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
/**
* The configured send/receive addresses can't be device memory.
*/
-TEST(spci_rxtx_map, fails_with_device_memory)
+TEST(ffa_rxtx_map, fails_with_device_memory)
{
- EXPECT_SPCI_ERROR(spci_rxtx_map(PAGE_SIZE, PAGE_SIZE * 2), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(PAGE_SIZE, PAGE_SIZE * 2), FFA_DENIED);
}
/**
* The configured send/receive addresses can't be unaligned.
*/
-TEST(spci_rxtx_map, fails_with_unaligned_pointer)
+TEST(ffa_rxtx_map, fails_with_unaligned_pointer)
{
uint8_t maybe_aligned[2];
hf_ipaddr_t unaligned_addr = (hf_ipaddr_t)&maybe_aligned[1];
@@ -127,60 +127,60 @@
/* Check that the address is unaligned. */
ASSERT_EQ(unaligned_addr & 1, 1);
- EXPECT_SPCI_ERROR(spci_rxtx_map(aligned_addr, unaligned_addr),
- SPCI_INVALID_PARAMETERS);
- EXPECT_SPCI_ERROR(spci_rxtx_map(unaligned_addr, aligned_addr),
- SPCI_INVALID_PARAMETERS);
- EXPECT_SPCI_ERROR(spci_rxtx_map(unaligned_addr, unaligned_addr),
- SPCI_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(aligned_addr, unaligned_addr),
+ FFA_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(unaligned_addr, aligned_addr),
+ FFA_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(unaligned_addr, unaligned_addr),
+ FFA_INVALID_PARAMETERS);
}
/**
* The configured send/receive addresses can't be the same page.
*/
-TEST(spci_rxtx_map, fails_with_same_page)
+TEST(ffa_rxtx_map, fails_with_same_page)
{
- EXPECT_SPCI_ERROR(spci_rxtx_map(send_page_addr, send_page_addr),
- SPCI_INVALID_PARAMETERS);
- EXPECT_SPCI_ERROR(spci_rxtx_map(recv_page_addr, recv_page_addr),
- SPCI_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(send_page_addr, send_page_addr),
+ FFA_INVALID_PARAMETERS);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(recv_page_addr, recv_page_addr),
+ FFA_INVALID_PARAMETERS);
}
/**
* The configuration of the send/receive addresses can only happen once.
*/
-TEST(spci_rxtx_map, fails_if_already_succeeded)
+TEST(ffa_rxtx_map, fails_if_already_succeeded)
{
- EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
- EXPECT_SPCI_ERROR(spci_rxtx_map(send_page_addr, recv_page_addr),
- SPCI_DENIED);
+ EXPECT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
+ EXPECT_FFA_ERROR(ffa_rxtx_map(send_page_addr, recv_page_addr),
+ FFA_DENIED);
}
/**
* The configuration of the send/receive address is successful with valid
* arguments.
*/
-TEST(spci_rxtx_map, succeeds)
+TEST(ffa_rxtx_map, succeeds)
{
- EXPECT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+ FFA_SUCCESS_32);
}
/**
- * The primary receives messages from spci_run().
+ * The primary receives messages from ffa_run().
*/
TEST(hf_mailbox_receive, cannot_receive_from_primary_blocking)
{
- struct spci_value res = spci_msg_wait();
- EXPECT_NE(res.func, SPCI_SUCCESS_32);
+ struct ffa_value res = ffa_msg_wait();
+ EXPECT_NE(res.func, FFA_SUCCESS_32);
}
/**
- * The primary receives messages from spci_run().
+ * The primary receives messages from ffa_run().
*/
TEST(hf_mailbox_receive, cannot_receive_from_primary_non_blocking)
{
- struct spci_value res = spci_msg_poll();
- EXPECT_NE(res.func, SPCI_SUCCESS_32);
+ struct ffa_value res = ffa_msg_poll();
+ EXPECT_NE(res.func, FFA_SUCCESS_32);
}
diff --git a/test/vmapi/primary_with_secondaries/perfmon.c b/test/vmapi/primary_with_secondaries/perfmon.c
index 5d62250..3e1fcb4 100644
--- a/test/vmapi/primary_with_secondaries/perfmon.c
+++ b/test/vmapi/primary_with_secondaries/perfmon.c
@@ -19,17 +19,17 @@
#include "../../src/arch/aarch64/sysregs.h"
#include "primary_with_secondary.h"
#include "sysregs.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
TEST(perfmon, secondary_basic)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "perfmon_secondary_basic", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, FFA_YIELD_32);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/run_race.c b/test/vmapi/primary_with_secondaries/run_race.c
index eba3536..2ea1bd6 100644
--- a/test/vmapi/primary_with_secondaries/run_race.c
+++ b/test/vmapi/primary_with_secondaries/run_race.c
@@ -26,7 +26,7 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
struct cpu_state {
struct mailbox_buffers *mb;
@@ -39,32 +39,32 @@
*/
static bool run_loop(struct mailbox_buffers *mb)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
bool ok = false;
for (;;) {
/* Run until it manages to schedule vCPU on this CPU. */
do {
- run_res = spci_run(SERVICE_VM1, 0);
- } while (run_res.func == SPCI_ERROR_32 &&
- run_res.arg2 == SPCI_BUSY);
+ run_res = ffa_run(SERVICE_VM1, 0);
+ } while (run_res.func == FFA_ERROR_32 &&
+ run_res.arg2 == FFA_BUSY);
/* Break out if we received a message with non-zero length. */
- if (run_res.func == SPCI_MSG_SEND_32 &&
- spci_msg_send_size(run_res) != 0) {
+ if (run_res.func == FFA_MSG_SEND_32 &&
+ ffa_msg_send_size(run_res) != 0) {
break;
}
/* Clear mailbox so that next message can be received. */
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
/* Copies the contents of the received boolean to the return value. */
- if (spci_msg_send_size(run_res) == sizeof(ok)) {
+ if (ffa_msg_send_size(run_res) == sizeof(ok)) {
ok = *(bool *)mb->recv;
}
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
return ok;
}
@@ -83,7 +83,7 @@
TEAR_DOWN(vcpu_state)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/services/BUILD.gn b/test/vmapi/primary_with_secondaries/services/BUILD.gn
index d4a78c2..72de3fc 100644
--- a/test/vmapi/primary_with_secondaries/services/BUILD.gn
+++ b/test/vmapi/primary_with_secondaries/services/BUILD.gn
@@ -205,7 +205,7 @@
}
# Service to receive messages in a secondary VM and ensure that the header fields are correctly set.
-source_set("spci_check") {
+source_set("ffa_check") {
testonly = true
public_configs = [
"..:config",
@@ -216,7 +216,7 @@
]
sources = [
- "spci_check.c",
+ "ffa_check.c",
]
}
@@ -231,13 +231,13 @@
":debug_el1",
":echo",
":echo_with_notification",
+ ":ffa_check",
":floating_point",
":interruptible",
":memory",
":perfmon",
":receive_block",
":relay",
- ":spci_check",
":unmapped",
":wfi",
"//test/hftest:hftest_secondary_vm",
diff --git a/test/vmapi/primary_with_secondaries/services/boot.c b/test/vmapi/primary_with_secondaries/services/boot.c
index 6314c1b..d6d1f08 100644
--- a/test/vmapi/primary_with_secondaries/services/boot.c
+++ b/test/vmapi/primary_with_secondaries/services/boot.c
@@ -50,7 +50,7 @@
ASSERT_NE(checksum, 0);
dlog("Checksum of all memory is %d\n", checksum);
- spci_yield();
+ ffa_yield();
}
TEST_SERVICE(boot_memory_underrun)
diff --git a/test/vmapi/primary_with_secondaries/services/check_state.c b/test/vmapi/primary_with_secondaries/services/check_state.c
index da27cc6..4fd71f0 100644
--- a/test/vmapi/primary_with_secondaries/services/check_state.c
+++ b/test/vmapi/primary_with_secondaries/services/check_state.c
@@ -22,14 +22,14 @@
#include "test/hftest.h"
-void send_with_retry(spci_vm_id_t sender_vm_id, spci_vm_id_t target_vm_id,
+void send_with_retry(ffa_vm_id_t sender_vm_id, ffa_vm_id_t target_vm_id,
uint32_t size)
{
- struct spci_value res;
+ struct ffa_value res;
do {
- res = spci_msg_send(sender_vm_id, target_vm_id, size, 0);
- } while (res.func != SPCI_SUCCESS_32);
+ res = ffa_msg_send(sender_vm_id, target_vm_id, size, 0);
+ } while (res.func != FFA_SUCCESS_32);
}
/**
@@ -64,7 +64,7 @@
}
/* Send two replies, one for each physical CPU. */
- memcpy_s(SERVICE_SEND_BUFFER(), SPCI_MSG_PAYLOAD_MAX, &ok, sizeof(ok));
+ memcpy_s(SERVICE_SEND_BUFFER(), FFA_MSG_PAYLOAD_MAX, &ok, sizeof(ok));
send_with_retry(hf_vm_get_id(), HF_PRIMARY_VM_ID, sizeof(ok));
send_with_retry(hf_vm_get_id(), HF_PRIMARY_VM_ID, sizeof(ok));
}
diff --git a/test/vmapi/primary_with_secondaries/services/debug_el1.c b/test/vmapi/primary_with_secondaries/services/debug_el1.c
index 1e09f76..f4373c0 100644
--- a/test/vmapi/primary_with_secondaries/services/debug_el1.c
+++ b/test/vmapi/primary_with_secondaries/services/debug_el1.c
@@ -33,5 +33,5 @@
TRY_READ(DBGWVR0_EL1);
EXPECT_EQ(exception_handler_get_num(), 5);
- spci_yield();
+ ffa_yield();
}
diff --git a/test/vmapi/primary_with_secondaries/services/echo.c b/test/vmapi/primary_with_secondaries/services/echo.c
index b1c99d9..81a42d2 100644
--- a/test/vmapi/primary_with_secondaries/services/echo.c
+++ b/test/vmapi/primary_with_secondaries/services/echo.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
@@ -25,18 +25,18 @@
{
/* Loop, echo messages back to the sender. */
for (;;) {
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t target_vm_id = spci_msg_send_receiver(ret);
- spci_vm_id_t source_vm_id = spci_msg_send_sender(ret);
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t target_vm_id = ffa_msg_send_receiver(ret);
+ ffa_vm_id_t source_vm_id = ffa_msg_send_sender(ret);
void *send_buf = SERVICE_SEND_BUFFER();
void *recv_buf = SERVICE_RECV_BUFFER();
- ASSERT_EQ(ret.func, SPCI_MSG_SEND_32);
- memcpy_s(send_buf, SPCI_MSG_PAYLOAD_MAX, recv_buf,
- spci_msg_send_size(ret));
+ ASSERT_EQ(ret.func, FFA_MSG_SEND_32);
+ memcpy_s(send_buf, FFA_MSG_PAYLOAD_MAX, recv_buf,
+ ffa_msg_send_size(ret));
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- spci_msg_send(target_vm_id, source_vm_id,
- spci_msg_send_size(ret), 0);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ ffa_msg_send(target_vm_id, source_vm_id, ffa_msg_send_size(ret),
+ 0);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/echo_with_notification.c b/test/vmapi/primary_with_secondaries/services/echo_with_notification.c
index a74391b..984c6a3 100644
--- a/test/vmapi/primary_with_secondaries/services/echo_with_notification.c
+++ b/test/vmapi/primary_with_secondaries/services/echo_with_notification.c
@@ -17,7 +17,7 @@
#include "hf/arch/irq.h"
#include "hf/arch/vm/interrupts.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
@@ -55,20 +55,19 @@
for (;;) {
void *send_buf = SERVICE_SEND_BUFFER();
void *recv_buf = SERVICE_RECV_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t target_vm_id = spci_msg_send_receiver(ret);
- spci_vm_id_t source_vm_id = spci_msg_send_sender(ret);
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t target_vm_id = ffa_msg_send_receiver(ret);
+ ffa_vm_id_t source_vm_id = ffa_msg_send_sender(ret);
- memcpy_s(send_buf, SPCI_MSG_PAYLOAD_MAX, recv_buf,
- spci_msg_send_size(ret));
+ memcpy_s(send_buf, FFA_MSG_PAYLOAD_MAX, recv_buf,
+ ffa_msg_send_size(ret));
- while (spci_msg_send(target_vm_id, source_vm_id,
- spci_msg_send_size(ret),
- SPCI_MSG_SEND_NOTIFY)
- .func != SPCI_SUCCESS_32) {
+ while (ffa_msg_send(target_vm_id, source_vm_id,
+ ffa_msg_send_size(ret), FFA_MSG_SEND_NOTIFY)
+ .func != FFA_SUCCESS_32) {
wait_for_vm(source_vm_id);
}
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/spci_check.c b/test/vmapi/primary_with_secondaries/services/ffa_check.c
similarity index 65%
rename from test/vmapi/primary_with_secondaries/services/spci_check.c
rename to test/vmapi/primary_with_secondaries/services/ffa_check.c
index 9e342ba..ef39716 100644
--- a/test/vmapi/primary_with_secondaries/services/spci_check.c
+++ b/test/vmapi/primary_with_secondaries/services/ffa_check.c
@@ -14,62 +14,62 @@
* limitations under the License.
*/
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "hf/std.h"
#include "vmapi/hf/call.h"
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
-TEST_SERVICE(spci_check)
+TEST_SERVICE(ffa_check)
{
void *recv_buf = SERVICE_RECV_BUFFER();
- const char message[] = "spci_msg_send";
+ const char message[] = "ffa_msg_send";
/* Wait for single message to be sent by the primary VM. */
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
- EXPECT_EQ(ret.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(ret.func, FFA_MSG_SEND_32);
/* Ensure message header has all fields correctly set. */
- EXPECT_EQ(spci_msg_send_size(ret), sizeof(message));
- EXPECT_EQ(spci_msg_send_receiver(ret), hf_vm_get_id());
- EXPECT_EQ(spci_msg_send_sender(ret), HF_PRIMARY_VM_ID);
+ EXPECT_EQ(ffa_msg_send_size(ret), sizeof(message));
+ EXPECT_EQ(ffa_msg_send_receiver(ret), hf_vm_get_id());
+ EXPECT_EQ(ffa_msg_send_sender(ret), HF_PRIMARY_VM_ID);
/* Ensure that the payload was correctly transmitted. */
EXPECT_EQ(memcmp(recv_buf, message, sizeof(message)), 0);
- spci_yield();
+ ffa_yield();
}
-TEST_SERVICE(spci_length)
+TEST_SERVICE(ffa_length)
{
void *recv_buf = SERVICE_RECV_BUFFER();
const char message[] = "this should be truncated";
/* Wait for single message to be sent by the primary VM. */
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
- EXPECT_EQ(ret.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(ret.func, FFA_MSG_SEND_32);
/* Verify the length is as expected. */
- EXPECT_EQ(16, spci_msg_send_size(ret));
+ EXPECT_EQ(16, ffa_msg_send_size(ret));
/* Check only part of the message is sent correctly. */
EXPECT_NE(memcmp(recv_buf, message, sizeof(message)), 0);
- EXPECT_EQ(memcmp(recv_buf, message, spci_msg_send_size(ret)), 0);
+ EXPECT_EQ(memcmp(recv_buf, message, ffa_msg_send_size(ret)), 0);
- spci_yield();
+ ffa_yield();
}
-TEST_SERVICE(spci_recv_non_blocking)
+TEST_SERVICE(ffa_recv_non_blocking)
{
/* Wait for single message to be sent by the primary VM. */
- struct spci_value ret = spci_msg_poll();
+ struct ffa_value ret = ffa_msg_poll();
- EXPECT_SPCI_ERROR(ret, SPCI_RETRY);
+ EXPECT_FFA_ERROR(ret, FFA_RETRY);
- spci_yield();
+ ffa_yield();
}
diff --git a/test/vmapi/primary_with_secondaries/services/floating_point.c b/test/vmapi/primary_with_secondaries/services/floating_point.c
index f5c0bcc..7fcf1aa 100644
--- a/test/vmapi/primary_with_secondaries/services/floating_point.c
+++ b/test/vmapi/primary_with_secondaries/services/floating_point.c
@@ -17,7 +17,7 @@
#include "hf/arch/std.h"
#include "hf/arch/vm/registers.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "vmapi/hf/call.h"
@@ -28,18 +28,18 @@
{
const double value = 0.75;
fill_fp_registers(value);
- EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_yield().func, FFA_SUCCESS_32);
ASSERT_TRUE(check_fp_register(value));
- spci_yield();
+ ffa_yield();
}
TEST_SERVICE(fp_fpcr)
{
uintreg_t value = 3 << 22; /* Set RMode to RZ */
write_msr(fpcr, value);
- EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_yield().func, FFA_SUCCESS_32);
ASSERT_EQ(read_msr(fpcr), value);
- spci_yield();
+ ffa_yield();
}
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible.c b/test/vmapi/primary_with_secondaries/services/interruptible.c
index fc79d20..73a8d35 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible.c
@@ -21,7 +21,7 @@
#include "hf/std.h"
#include "vmapi/hf/call.h"
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
#include "primary_with_secondary.h"
#include "test/hftest.h"
@@ -39,8 +39,8 @@
dlog("secondary IRQ %d from current\n", interrupt_id);
buffer[8] = '0' + interrupt_id / 10;
buffer[9] = '0' + interrupt_id % 10;
- memcpy_s(SERVICE_SEND_BUFFER(), SPCI_MSG_PAYLOAD_MAX, buffer, size);
- spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, size, 0);
+ memcpy_s(SERVICE_SEND_BUFFER(), FFA_MSG_PAYLOAD_MAX, buffer, size);
+ ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, size, 0);
dlog("secondary IRQ %d ended\n", interrupt_id);
}
@@ -48,21 +48,21 @@
* Try to receive a message from the mailbox, blocking if necessary, and
* retrying if interrupted.
*/
-struct spci_value mailbox_receive_retry()
+struct ffa_value mailbox_receive_retry()
{
- struct spci_value received;
+ struct ffa_value received;
do {
- received = spci_msg_wait();
- } while (received.func == SPCI_ERROR_32 &&
- received.arg2 == SPCI_INTERRUPTED);
+ received = ffa_msg_wait();
+ } while (received.func == FFA_ERROR_32 &&
+ received.arg2 == FFA_INTERRUPTED);
return received;
}
TEST_SERVICE(interruptible)
{
- spci_vm_id_t this_vm_id = hf_vm_get_id();
+ ffa_vm_id_t this_vm_id = hf_vm_get_id();
void *recv_buf = SERVICE_RECV_BUFFER();
exception_setup(irq, NULL);
@@ -75,26 +75,25 @@
const char ping_message[] = "Ping";
const char enable_message[] = "Enable interrupt C";
- struct spci_value ret = mailbox_receive_retry();
+ struct ffa_value ret = mailbox_receive_retry();
- ASSERT_EQ(ret.func, SPCI_MSG_SEND_32);
- if (spci_msg_send_sender(ret) == HF_PRIMARY_VM_ID &&
- spci_msg_send_size(ret) == sizeof(ping_message) &&
+ ASSERT_EQ(ret.func, FFA_MSG_SEND_32);
+ if (ffa_msg_send_sender(ret) == HF_PRIMARY_VM_ID &&
+ ffa_msg_send_size(ret) == sizeof(ping_message) &&
memcmp(recv_buf, ping_message, sizeof(ping_message)) == 0) {
/* Interrupt ourselves */
hf_interrupt_inject(this_vm_id, 0, SELF_INTERRUPT_ID);
- } else if (spci_msg_send_sender(ret) == HF_PRIMARY_VM_ID &&
- spci_msg_send_size(ret) == sizeof(enable_message) &&
+ } else if (ffa_msg_send_sender(ret) == HF_PRIMARY_VM_ID &&
+ ffa_msg_send_size(ret) == sizeof(enable_message) &&
memcmp(recv_buf, enable_message,
sizeof(enable_message)) == 0) {
/* Enable interrupt ID C. */
hf_interrupt_enable(EXTERNAL_INTERRUPT_ID_C, true);
} else {
dlog("Got unexpected message from VM %d, size %d.\n",
- spci_msg_send_sender(ret),
- spci_msg_send_size(ret));
+ ffa_msg_send_sender(ret), ffa_msg_send_size(ret));
FAIL("Unexpected message");
}
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible_echo.c b/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
index 8903990..f09e0a7 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
@@ -38,23 +38,23 @@
arch_irq_enable();
for (;;) {
- struct spci_value res = spci_msg_wait();
+ struct ffa_value res = ffa_msg_wait();
void *message = SERVICE_SEND_BUFFER();
void *recv_message = SERVICE_RECV_BUFFER();
/* Retry if interrupted but made visible with the yield. */
- while (res.func == SPCI_ERROR_32 &&
- res.arg2 == SPCI_INTERRUPTED) {
- spci_yield();
- res = spci_msg_wait();
+ while (res.func == FFA_ERROR_32 &&
+ res.arg2 == FFA_INTERRUPTED) {
+ ffa_yield();
+ res = ffa_msg_wait();
}
- ASSERT_EQ(res.func, SPCI_MSG_SEND_32);
- memcpy_s(message, SPCI_MSG_PAYLOAD_MAX, recv_message,
- spci_msg_send_size(res));
+ ASSERT_EQ(res.func, FFA_MSG_SEND_32);
+ memcpy_s(message, FFA_MSG_PAYLOAD_MAX, recv_message,
+ ffa_msg_send_size(res));
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- spci_msg_send(SERVICE_VM1, HF_PRIMARY_VM_ID,
- spci_msg_send_size(res), 0);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ ffa_msg_send(SERVICE_VM1, HF_PRIMARY_VM_ID,
+ ffa_msg_send_size(res), 0);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/memory.c b/test/vmapi/primary_with_secondaries/services/memory.c
index 2c07835..2c598d0 100644
--- a/test/vmapi/primary_with_secondaries/services/memory.c
+++ b/test/vmapi/primary_with_secondaries/services/memory.c
@@ -25,7 +25,7 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
#include "test/vmapi/exception_handler.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
alignas(PAGE_SIZE) static uint8_t page[PAGE_SIZE];
@@ -37,13 +37,13 @@
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender = retrieve_memory_from_message(
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender = retrieve_memory_from_message(
recv_buf, send_buf, ret, NULL);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
uint8_t *ptr = (uint8_t *)composite->constituents[0].address;
ASSERT_EQ(memory_region->receiver_count, 1);
@@ -52,7 +52,7 @@
0);
/* Allow the memory to be populated. */
- EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_yield().func, FFA_SUCCESS_32);
/* Increment each byte of memory. */
for (i = 0; i < PAGE_SIZE; ++i) {
@@ -60,25 +60,25 @@
}
/* Signal completion and reset. */
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- spci_msg_send(hf_vm_get_id(), sender, sizeof(ptr), 0);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ ffa_msg_send(hf_vm_get_id(), sender, sizeof(ptr), 0);
}
}
TEST_SERVICE(give_memory_and_fault)
{
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)&page, .page_count = 1},
};
/* Give memory to the primary. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, send_buf, hf_vm_get_id(), HF_PRIMARY_VM_ID,
+ FFA_MEM_DONATE_32, send_buf, hf_vm_get_id(), HF_PRIMARY_VM_ID,
constituents, ARRAY_SIZE(constituents),
- SPCI_MEMORY_REGION_FLAG_CLEAR, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEMORY_REGION_FLAG_CLEAR, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
exception_setup(NULL, exception_handler_yield_data_abort);
@@ -91,17 +91,17 @@
TEST_SERVICE(lend_memory_and_fault)
{
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)&page, .page_count = 1},
};
/* Lend memory to the primary. */
send_memory_and_retrieve_request(
- SPCI_MEM_LEND_32, send_buf, hf_vm_get_id(), HF_PRIMARY_VM_ID,
+ FFA_MEM_LEND_32, send_buf, hf_vm_get_id(), HF_PRIMARY_VM_ID,
constituents, ARRAY_SIZE(constituents),
- SPCI_MEMORY_REGION_FLAG_CLEAR, SPCI_DATA_ACCESS_RW,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEMORY_REGION_FLAG_CLEAR, FFA_DATA_ACCESS_RW,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
exception_setup(NULL, exception_handler_yield_data_abort);
@@ -111,9 +111,9 @@
FAIL("Exception not generated by invalid access.");
}
-TEST_SERVICE(spci_memory_return)
+TEST_SERVICE(ffa_memory_return)
{
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
uint8_t *ptr;
size_t i;
void *recv_buf = SERVICE_RECV_BUFFER();
@@ -121,12 +121,12 @@
exception_setup(NULL, exception_handler_yield_data_abort);
- spci_vm_id_t sender =
+ ffa_vm_id_t sender =
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
ptr = (uint8_t *)composite->constituents[0].address;
@@ -137,12 +137,11 @@
/* Give the memory back and notify the sender. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, send_buf, hf_vm_get_id(), sender,
+ FFA_MEM_DONATE_32, send_buf, hf_vm_get_id(), sender,
composite->constituents, composite->constituent_count, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/*
* Try and access the memory which will cause a fault unless the memory
@@ -156,27 +155,27 @@
/**
* Attempt to modify above the upper bound of a memory region sent to us.
*/
-TEST_SERVICE(spci_check_upper_bound)
+TEST_SERVICE(ffa_check_upper_bound)
{
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
uint8_t *ptr;
uint8_t index;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
exception_setup(NULL, exception_handler_yield_data_abort);
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- memory_region = (struct spci_memory_region *)recv_buf;
- composite = spci_memory_region_get_composite(memory_region, 0);
+ memory_region = (struct ffa_memory_region *)recv_buf;
+ composite = ffa_memory_region_get_composite(memory_region, 0);
/* Choose which constituent we want to test. */
index = *(uint8_t *)composite->constituents[0].address;
ptr = (uint8_t *)composite->constituents[index].address;
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/*
* Check that we can't access out of bounds after the region sent to us.
@@ -190,27 +189,27 @@
/**
* Attempt to modify below the lower bound of a memory region sent to us.
*/
-TEST_SERVICE(spci_check_lower_bound)
+TEST_SERVICE(ffa_check_lower_bound)
{
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
uint8_t *ptr;
uint8_t index;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
exception_setup(NULL, exception_handler_yield_data_abort);
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- memory_region = (struct spci_memory_region *)recv_buf;
- composite = spci_memory_region_get_composite(memory_region, 0);
+ memory_region = (struct ffa_memory_region *)recv_buf;
+ composite = ffa_memory_region_get_composite(memory_region, 0);
/* Choose which constituent we want to test. */
index = *(uint8_t *)composite->constituents[0].address;
ptr = (uint8_t *)composite->constituents[index].address;
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/*
* Check that we can't access out of bounds before the region sent to
@@ -224,19 +223,19 @@
/**
* Attempt to donate memory and then modify.
*/
-TEST_SERVICE(spci_donate_secondary_and_fault)
+TEST_SERVICE(ffa_donate_secondary_and_fault)
{
uint8_t *ptr;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender =
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender =
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
ASSERT_EQ(sender, HF_PRIMARY_VM_ID);
exception_setup(NULL, exception_handler_yield_data_abort);
@@ -245,12 +244,11 @@
/* Donate memory to next VM. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, send_buf, hf_vm_get_id(), SERVICE_VM2,
+ FFA_MEM_DONATE_32, send_buf, hf_vm_get_id(), SERVICE_VM2,
composite->constituents, composite->constituent_count, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Ensure that we are unable to modify memory any more. */
ptr[0] = 'c';
@@ -261,114 +259,113 @@
/**
* Attempt to donate memory twice from VM.
*/
-TEST_SERVICE(spci_donate_twice)
+TEST_SERVICE(ffa_donate_twice)
{
uint32_t msg_size;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender =
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender =
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
- struct spci_memory_region_constituent constituent =
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region_constituent constituent =
composite->constituents[0];
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Yield to allow attempt to re donate from primary. */
- spci_yield();
+ ffa_yield();
/* Give the memory back and notify the sender. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, send_buf, hf_vm_get_id(), sender,
- &constituent, 1, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_MEM_DONATE_32, send_buf, hf_vm_get_id(), sender,
+ &constituent, 1, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_X);
/* Attempt to donate the memory to another VM. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
send_buf, hf_vm_get_id(), SERVICE_VM2, &constituent, 1, 0, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size), SPCI_DENIED);
+ FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size), FFA_DENIED);
- spci_yield();
+ ffa_yield();
}
/**
* Continually receive memory, check if we have access and ensure it is not
* changed by a third party.
*/
-TEST_SERVICE(spci_memory_receive)
+TEST_SERVICE(ffa_memory_receive)
{
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
for (;;) {
- struct spci_value ret = spci_msg_wait();
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
+ struct ffa_value ret = ffa_msg_wait();
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
uint8_t *ptr;
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- memory_region = (struct spci_memory_region *)recv_buf;
- composite = spci_memory_region_get_composite(memory_region, 0);
+ memory_region = (struct ffa_memory_region *)recv_buf;
+ composite = ffa_memory_region_get_composite(memory_region, 0);
ptr = (uint8_t *)composite->constituents[0].address;
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
ptr[0] = 'd';
- spci_yield();
+ ffa_yield();
/* Ensure memory has not changed. */
EXPECT_EQ(ptr[0], 'd');
- spci_yield();
+ ffa_yield();
}
}
/**
* Receive memory and attempt to donate from primary VM.
*/
-TEST_SERVICE(spci_donate_invalid_source)
+TEST_SERVICE(ffa_donate_invalid_source)
{
uint32_t msg_size;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender =
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender =
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
/* Give the memory back and notify the sender. */
send_memory_and_retrieve_request(
- SPCI_MEM_DONATE_32, send_buf, hf_vm_get_id(), sender,
+ FFA_MEM_DONATE_32, send_buf, hf_vm_get_id(), sender,
composite->constituents, composite->constituent_count, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_X);
+ FFA_DATA_ACCESS_NOT_SPECIFIED, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_INSTRUCTION_ACCESS_X);
/* Fail to donate the memory from the primary to VM2. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
send_buf, HF_PRIMARY_VM_ID, SERVICE_VM2,
composite->constituents, composite->constituent_count, 0, 0,
- SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
- spci_yield();
+ FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_FFA_ERROR(ffa_mem_donate(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
+ ffa_yield();
}
-TEST_SERVICE(spci_memory_lend_relinquish)
+TEST_SERVICE(ffa_memory_lend_relinquish)
{
exception_setup(NULL, exception_handler_yield_data_abort);
@@ -379,19 +376,19 @@
uint32_t count;
uint32_t count2;
size_t i;
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender = retrieve_memory_from_message(
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender = retrieve_memory_from_message(
recv_buf, send_buf, ret, &handle);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
- struct spci_memory_region_constituent *constituents =
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region_constituent *constituents =
composite->constituents;
/* ASSERT_TRUE isn't enough for clang-analyze. */
@@ -402,7 +399,7 @@
ptr2 = (uint8_t *)constituents[1].address;
count2 = constituents[1].page_count;
/* Relevant information read, mailbox can be cleared. */
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Check that one has access to the shared region. */
for (i = 0; i < PAGE_SIZE * count; ++i) {
@@ -413,10 +410,10 @@
}
/* Give the memory back and notify the sender. */
- spci_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
- EXPECT_EQ(spci_mem_relinquish().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), sender, 0, 0).func,
- SPCI_SUCCESS_32);
+ ffa_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
+ EXPECT_EQ(ffa_mem_relinquish().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), sender, 0, 0).func,
+ FFA_SUCCESS_32);
/*
* Try and access the memory which will cause a fault unless the
@@ -429,22 +426,22 @@
/**
* Ensure that we can't relinquish donated memory.
*/
-TEST_SERVICE(spci_memory_donate_relinquish)
+TEST_SERVICE(ffa_memory_donate_relinquish)
{
for (;;) {
size_t i;
- spci_memory_handle_t handle;
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
+ ffa_memory_handle_t handle;
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
uint8_t *ptr;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
retrieve_memory_from_message(recv_buf, send_buf, ret, &handle);
- memory_region = (struct spci_memory_region *)recv_buf;
- composite = spci_memory_region_get_composite(memory_region, 0);
+ memory_region = (struct ffa_memory_region *)recv_buf;
+ composite = ffa_memory_region_get_composite(memory_region, 0);
ptr = (uint8_t *)composite->constituents[0].address;
@@ -457,15 +454,14 @@
* Attempt to relinquish the memory, which should fail because
* it was donated not lent.
*/
- spci_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_SPCI_ERROR(spci_mem_relinquish(),
- SPCI_INVALID_PARAMETERS);
+ ffa_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_FFA_ERROR(ffa_mem_relinquish(), FFA_INVALID_PARAMETERS);
/* Ensure we still have access to the memory. */
ptr[0] = 123;
- spci_yield();
+ ffa_yield();
}
}
@@ -473,109 +469,108 @@
* Receive memory that has been shared, try to relinquish it with the clear flag
* set (and expect to fail), and then relinquish without any flags.
*/
-TEST_SERVICE(spci_memory_share_relinquish_clear)
+TEST_SERVICE(ffa_memory_share_relinquish_clear)
{
exception_setup(NULL, exception_handler_yield_data_abort);
/* Loop, receiving memory and relinquishing it. */
for (;;) {
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender = retrieve_memory_from_message(
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender = retrieve_memory_from_message(
recv_buf, send_buf, ret, &handle);
/*
* Mailbox can be cleared, we don't actually care what the
* memory region is.
*/
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Trying to relinquish the memory and clear it should fail. */
- spci_mem_relinquish_init(send_buf, handle,
- SPCI_MEMORY_REGION_FLAG_CLEAR,
- hf_vm_get_id());
- EXPECT_SPCI_ERROR(spci_mem_relinquish(),
- SPCI_INVALID_PARAMETERS);
+ ffa_mem_relinquish_init(send_buf, handle,
+ FFA_MEMORY_REGION_FLAG_CLEAR,
+ hf_vm_get_id());
+ EXPECT_FFA_ERROR(ffa_mem_relinquish(), FFA_INVALID_PARAMETERS);
/* Give the memory back and notify the sender. */
- spci_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
- EXPECT_EQ(spci_mem_relinquish().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), sender, 0, 0).func,
- SPCI_SUCCESS_32);
+ ffa_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
+ EXPECT_EQ(ffa_mem_relinquish().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), sender, 0, 0).func,
+ FFA_SUCCESS_32);
}
}
/**
* Receive memory and attempt to donate from primary VM.
*/
-TEST_SERVICE(spci_lend_invalid_source)
+TEST_SERVICE(ffa_lend_invalid_source)
{
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
uint32_t msg_size;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender =
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender =
retrieve_memory_from_message(recv_buf, send_buf, ret, &handle);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
/* Give the memory back and notify the sender. */
- spci_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
- EXPECT_EQ(spci_mem_relinquish().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), sender, 0, 0).func,
- SPCI_SUCCESS_32);
+ ffa_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
+ EXPECT_EQ(ffa_mem_relinquish().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), sender, 0, 0).func,
+ FFA_SUCCESS_32);
/* Ensure we cannot lend from the primary to another secondary. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
send_buf, HF_PRIMARY_VM_ID, SERVICE_VM2,
composite->constituents, composite->constituent_count, 0, 0,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_X,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_X,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_lend(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
/* Ensure we cannot share from the primary to another secondary. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
send_buf, HF_PRIMARY_VM_ID, SERVICE_VM2,
composite->constituents, composite->constituent_count, 0, 0,
- SPCI_DATA_ACCESS_RW, SPCI_INSTRUCTION_ACCESS_X,
- SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ FFA_DATA_ACCESS_RW, FFA_INSTRUCTION_ACCESS_X,
+ FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ EXPECT_FFA_ERROR(ffa_mem_share(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
- spci_yield();
+ ffa_yield();
}
/**
* Attempt to execute an instruction from the lent memory.
*/
-TEST_SERVICE(spci_memory_lend_relinquish_X)
+TEST_SERVICE(ffa_memory_lend_relinquish_X)
{
exception_setup(NULL, exception_handler_yield_instruction_abort);
for (;;) {
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender = retrieve_memory_from_message(
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender = retrieve_memory_from_message(
recv_buf, send_buf, ret, &handle);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
- struct spci_memory_region_constituent *constituents;
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region_constituent *constituents;
uint64_t *ptr;
/* ASSERT_TRUE isn't enough for clang-analyze. */
@@ -584,7 +579,7 @@
constituents = composite->constituents;
ptr = (uint64_t *)constituents[0].address;
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/*
* Verify that the instruction in memory is the encoded RET
@@ -595,56 +590,56 @@
__asm__ volatile("blr %0" ::"r"(ptr));
/* Release the memory again. */
- spci_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
- EXPECT_EQ(spci_mem_relinquish().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), sender, 0, 0).func,
- SPCI_SUCCESS_32);
+ ffa_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
+ EXPECT_EQ(ffa_mem_relinquish().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), sender, 0, 0).func,
+ FFA_SUCCESS_32);
}
}
/**
* Attempt to retrieve a shared page but expect to fail.
*/
-TEST_SERVICE(spci_memory_share_fail)
+TEST_SERVICE(ffa_memory_share_fail)
{
for (;;) {
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender = retrieve_memory_from_message_expect_fail(
- recv_buf, send_buf, ret, SPCI_DENIED);
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender = retrieve_memory_from_message_expect_fail(
+ recv_buf, send_buf, ret, FFA_DENIED);
/* Return control to primary. */
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), sender, 0, 0).func,
- SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), sender, 0, 0).func,
+ FFA_SUCCESS_32);
}
}
/**
* Attempt to read and write to a shared page.
*/
-TEST_SERVICE(spci_memory_lend_relinquish_RW)
+TEST_SERVICE(ffa_memory_lend_relinquish_RW)
{
exception_setup(NULL, exception_handler_yield_data_abort);
for (;;) {
- spci_memory_handle_t handle;
+ ffa_memory_handle_t handle;
uint8_t *ptr;
size_t i;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_value ret = spci_msg_wait();
- spci_vm_id_t sender = retrieve_memory_from_message(
+ struct ffa_value ret = ffa_msg_wait();
+ ffa_vm_id_t sender = retrieve_memory_from_message(
recv_buf, send_buf, ret, &handle);
- struct spci_memory_region *memory_region =
- (struct spci_memory_region *)recv_buf;
- struct spci_composite_memory_region *composite =
- spci_memory_region_get_composite(memory_region, 0);
- struct spci_memory_region_constituent constituent_copy =
+ struct ffa_memory_region *memory_region =
+ (struct ffa_memory_region *)recv_buf;
+ struct ffa_composite_memory_region *composite =
+ ffa_memory_region_get_composite(memory_region, 0);
+ struct ffa_memory_region_constituent constituent_copy =
composite->constituents[0];
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
ptr = (uint8_t *)constituent_copy.address;
@@ -654,7 +649,7 @@
}
/* Return control to primary, to verify shared access. */
- spci_yield();
+ ffa_yield();
/* Attempt to modify the memory. */
for (i = 0; i < PAGE_SIZE; ++i) {
@@ -662,32 +657,32 @@
}
/* Give the memory back and notify the sender. */
- spci_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
- EXPECT_EQ(spci_mem_relinquish().func, SPCI_SUCCESS_32);
- EXPECT_EQ(spci_msg_send(hf_vm_get_id(), sender, 0, 0).func,
- SPCI_SUCCESS_32);
+ ffa_mem_relinquish_init(send_buf, handle, 0, hf_vm_get_id());
+ EXPECT_EQ(ffa_mem_relinquish().func, FFA_SUCCESS_32);
+ EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), sender, 0, 0).func,
+ FFA_SUCCESS_32);
}
}
-TEST_SERVICE(spci_memory_lend_twice)
+TEST_SERVICE(ffa_memory_lend_twice)
{
- struct spci_value ret = spci_msg_wait();
+ struct ffa_value ret = ffa_msg_wait();
uint8_t *ptr;
uint32_t msg_size;
size_t i;
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- struct spci_memory_region *memory_region;
- struct spci_composite_memory_region *composite;
- struct spci_memory_region_constituent constituent_copy;
+ struct ffa_memory_region *memory_region;
+ struct ffa_composite_memory_region *composite;
+ struct ffa_memory_region_constituent constituent_copy;
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL);
- memory_region = (struct spci_memory_region *)recv_buf;
- composite = spci_memory_region_get_composite(memory_region, 0);
+ memory_region = (struct ffa_memory_region *)recv_buf;
+ composite = ffa_memory_region_get_composite(memory_region, 0);
constituent_copy = composite->constituents[0];
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
ptr = (uint8_t *)constituent_copy.address;
@@ -705,24 +700,24 @@
constituent_copy.address = (uint64_t)ptr + i;
/* Fail to lend or share the memory from the primary. */
- msg_size = spci_memory_region_init(
+ msg_size = ffa_memory_region_init(
send_buf, HF_PRIMARY_VM_ID, SERVICE_VM2,
- &constituent_copy, 1, 0, 0, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_X, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
- msg_size = spci_memory_region_init(
+ &constituent_copy, 1, 0, 0, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_X, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_lend(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
+ msg_size = ffa_memory_region_init(
send_buf, HF_PRIMARY_VM_ID, SERVICE_VM2,
- &constituent_copy, 1, 0, 0, SPCI_DATA_ACCESS_RW,
- SPCI_INSTRUCTION_ACCESS_X, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK,
- SPCI_MEMORY_OUTER_SHAREABLE);
- EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size),
- SPCI_INVALID_PARAMETERS);
+ &constituent_copy, 1, 0, 0, FFA_DATA_ACCESS_RW,
+ FFA_INSTRUCTION_ACCESS_X, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK,
+ FFA_MEMORY_OUTER_SHAREABLE);
+ EXPECT_FFA_ERROR(ffa_mem_share(msg_size, msg_size),
+ FFA_INVALID_PARAMETERS);
}
/* Return control to primary. */
- spci_yield();
+ ffa_yield();
}
diff --git a/test/vmapi/primary_with_secondaries/services/perfmon.c b/test/vmapi/primary_with_secondaries/services/perfmon.c
index 1e19ffb..ced0ea9 100644
--- a/test/vmapi/primary_with_secondaries/services/perfmon.c
+++ b/test/vmapi/primary_with_secondaries/services/perfmon.c
@@ -31,5 +31,5 @@
write_msr(PMINTENSET_EL1, 0xf);
EXPECT_EQ(exception_handler_get_num(), 3);
- spci_yield();
+ ffa_yield();
}
diff --git a/test/vmapi/primary_with_secondaries/services/receive_block.c b/test/vmapi/primary_with_secondaries/services/receive_block.c
index 49ea5f2..348e9b0 100644
--- a/test/vmapi/primary_with_secondaries/services/receive_block.c
+++ b/test/vmapi/primary_with_secondaries/services/receive_block.c
@@ -18,13 +18,13 @@
#include "hf/arch/vm/interrupts.h"
#include "hf/dlog.h"
-#include "hf/spci.h"
+#include "hf/ffa.h"
#include "vmapi/hf/call.h"
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/*
* Secondary VM that enables an interrupt, disables interrupts globally, and
@@ -47,12 +47,12 @@
hf_interrupt_enable(EXTERNAL_INTERRUPT_ID_A, true);
for (i = 0; i < 10; ++i) {
- struct spci_value res = spci_msg_wait();
- EXPECT_SPCI_ERROR(res, SPCI_INTERRUPTED);
+ struct ffa_value res = ffa_msg_wait();
+ EXPECT_FFA_ERROR(res, FFA_INTERRUPTED);
}
- memcpy_s(SERVICE_SEND_BUFFER(), SPCI_MSG_PAYLOAD_MAX, message,
+ memcpy_s(SERVICE_SEND_BUFFER(), FFA_MSG_PAYLOAD_MAX, message,
sizeof(message));
- spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, sizeof(message), 0);
+ ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, sizeof(message), 0);
}
diff --git a/test/vmapi/primary_with_secondaries/services/relay.c b/test/vmapi/primary_with_secondaries/services/relay.c
index 7917251..2ab8534 100644
--- a/test/vmapi/primary_with_secondaries/services/relay.c
+++ b/test/vmapi/primary_with_secondaries/services/relay.c
@@ -30,31 +30,31 @@
* message so multiple IDs can be places at the start of the message.
*/
for (;;) {
- spci_vm_id_t *chain;
- spci_vm_id_t next_vm_id;
+ ffa_vm_id_t *chain;
+ ffa_vm_id_t next_vm_id;
void *next_message;
uint32_t next_message_size;
/* Receive the message to relay. */
- struct spci_value ret = spci_msg_wait();
- ASSERT_EQ(ret.func, SPCI_MSG_SEND_32);
+ struct ffa_value ret = ffa_msg_wait();
+ ASSERT_EQ(ret.func, FFA_MSG_SEND_32);
/* Prepare to relay the message. */
void *recv_buf = SERVICE_RECV_BUFFER();
void *send_buf = SERVICE_SEND_BUFFER();
- ASSERT_GE(spci_msg_send_size(ret), sizeof(spci_vm_id_t));
+ ASSERT_GE(ffa_msg_send_size(ret), sizeof(ffa_vm_id_t));
- chain = (spci_vm_id_t *)recv_buf;
+ chain = (ffa_vm_id_t *)recv_buf;
next_vm_id = le16toh(*chain);
next_message = chain + 1;
next_message_size =
- spci_msg_send_size(ret) - sizeof(spci_vm_id_t);
+ ffa_msg_send_size(ret) - sizeof(ffa_vm_id_t);
/* Send the message to the next stage. */
- memcpy_s(send_buf, SPCI_MSG_PAYLOAD_MAX, next_message,
+ memcpy_s(send_buf, FFA_MSG_PAYLOAD_MAX, next_message,
next_message_size);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
- spci_msg_send(hf_vm_get_id(), next_vm_id, next_message_size, 0);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+ ffa_msg_send(hf_vm_get_id(), next_vm_id, next_message_size, 0);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/smp.c b/test/vmapi/primary_with_secondaries/services/smp.c
index 9030fb5..79d91fc 100644
--- a/test/vmapi/primary_with_secondaries/services/smp.c
+++ b/test/vmapi/primary_with_secondaries/services/smp.c
@@ -23,7 +23,7 @@
#include "hf/std.h"
#include "vmapi/hf/call.h"
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
#include "../psci.h"
#include "primary_with_secondary.h"
@@ -40,10 +40,10 @@
/** Send a message back to the primary. */
void send_message(const char *message, uint32_t size)
{
- memcpy_s(SERVICE_SEND_BUFFER(), SPCI_MSG_PAYLOAD_MAX, message, size);
+ memcpy_s(SERVICE_SEND_BUFFER(), FFA_MSG_PAYLOAD_MAX, message, size);
- ASSERT_EQ(spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, size, 0).func,
- SPCI_SUCCESS_32);
+ ASSERT_EQ(ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, size, 0).func,
+ FFA_SUCCESS_32);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/services/unmapped.c b/test/vmapi/primary_with_secondaries/services/unmapped.c
index 30d9f07..ec85310 100644
--- a/test/vmapi/primary_with_secondaries/services/unmapped.c
+++ b/test/vmapi/primary_with_secondaries/services/unmapped.c
@@ -40,17 +40,17 @@
{
void *send_buf = SERVICE_SEND_BUFFER();
/* Give some memory to the primary VM so that it's unmapped. */
- struct spci_memory_region_constituent constituents[] = {
+ struct ffa_memory_region_constituent constituents[] = {
{.address = (uint64_t)(&pages[PAGE_SIZE]), .page_count = 1},
};
- uint32_t msg_size = spci_memory_region_init(
+ uint32_t msg_size = ffa_memory_region_init(
send_buf, hf_vm_get_id(), HF_PRIMARY_VM_ID, constituents,
- ARRAY_SIZE(constituents), 0, 0, SPCI_DATA_ACCESS_NOT_SPECIFIED,
- SPCI_INSTRUCTION_ACCESS_NOT_SPECIFIED, SPCI_MEMORY_NORMAL_MEM,
- SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
+ ARRAY_SIZE(constituents), 0, 0, FFA_DATA_ACCESS_NOT_SPECIFIED,
+ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, FFA_MEMORY_NORMAL_MEM,
+ FFA_MEMORY_CACHE_WRITE_BACK, FFA_MEMORY_OUTER_SHAREABLE);
exception_setup(NULL, exception_handler_yield_data_abort);
- EXPECT_EQ(spci_mem_donate(msg_size, msg_size).func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_mem_donate(msg_size, msg_size).func, FFA_SUCCESS_32);
*(volatile uint64_t *)(&pages[PAGE_SIZE - 6]);
FAIL("Exception not generated by invalid access.");
diff --git a/test/vmapi/primary_with_secondaries/services/wfi.c b/test/vmapi/primary_with_secondaries/services/wfi.c
index 6d61194..4b9f6bc 100644
--- a/test/vmapi/primary_with_secondaries/services/wfi.c
+++ b/test/vmapi/primary_with_secondaries/services/wfi.c
@@ -48,8 +48,8 @@
interrupt_wait();
}
- memcpy_s(SERVICE_SEND_BUFFER(), SPCI_MSG_PAYLOAD_MAX, message,
+ memcpy_s(SERVICE_SEND_BUFFER(), FFA_MSG_PAYLOAD_MAX, message,
sizeof(message));
- spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, sizeof(message), 0);
+ ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID, sizeof(message), 0);
}
diff --git a/test/vmapi/primary_with_secondaries/smp.c b/test/vmapi/primary_with_secondaries/smp.c
index d76b5f0..685d556 100644
--- a/test/vmapi/primary_with_secondaries/smp.c
+++ b/test/vmapi/primary_with_secondaries/smp.c
@@ -22,11 +22,11 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
TEAR_DOWN(smp)
{
- EXPECT_SPCI_ERROR(spci_rx_release(), SPCI_DENIED);
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
}
/**
@@ -37,40 +37,40 @@
{
const char expected_response_0[] = "vCPU 0";
const char expected_response_1[] = "vCPU 1";
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM3, "smp", mb.send);
/* Let the first vCPU start the second vCPU. */
- run_res = spci_run(SERVICE_VM3, 0);
- EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAKE_UP);
- EXPECT_EQ(spci_vm_id(run_res), SERVICE_VM3);
- EXPECT_EQ(spci_vcpu_index(run_res), 1);
+ run_res = ffa_run(SERVICE_VM3, 0);
+ EXPECT_EQ(run_res.func, HF_FFA_RUN_WAKE_UP);
+ EXPECT_EQ(ffa_vm_id(run_res), SERVICE_VM3);
+ EXPECT_EQ(ffa_vcpu_index(run_res), 1);
/* Run the second vCPU and wait for a message. */
dlog("Run second vCPU for message\n");
- run_res = spci_run(SERVICE_VM3, 1);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_1));
+ run_res = ffa_run(SERVICE_VM3, 1);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response_1));
EXPECT_EQ(memcmp(mb.recv, expected_response_1,
sizeof(expected_response_1)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Run the first vCPU and wait for a different message. */
dlog("Run first vCPU for message\n");
- run_res = spci_run(SERVICE_VM3, 0);
- EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
- EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_0));
+ run_res = ffa_run(SERVICE_VM3, 0);
+ EXPECT_EQ(run_res.func, FFA_MSG_SEND_32);
+ EXPECT_EQ(ffa_msg_send_size(run_res), sizeof(expected_response_0));
EXPECT_EQ(memcmp(mb.recv, expected_response_0,
sizeof(expected_response_0)),
0);
- EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+ EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
/* Run the second vCPU again, and expect it to turn itself off. */
dlog("Run second vCPU for poweroff.\n");
- run_res = spci_run(SERVICE_VM3, 1);
- EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = ffa_run(SERVICE_VM3, 1);
+ EXPECT_EQ(run_res.func, HF_FFA_RUN_WAIT_FOR_INTERRUPT);
+ EXPECT_EQ(run_res.arg2, FFA_SLEEP_INDEFINITE);
}
diff --git a/test/vmapi/primary_with_secondaries/spci.c b/test/vmapi/primary_with_secondaries/spci.c
deleted file mode 100644
index 6ffc85f..0000000
--- a/test/vmapi/primary_with_secondaries/spci.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2019 The Hafnium Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "hf/spci.h"
-
-#include <stdint.h>
-
-#include "hf/std.h"
-
-#include "vmapi/hf/call.h"
-
-#include "primary_with_secondary.h"
-#include "test/hftest.h"
-#include "test/vmapi/spci.h"
-
-/**
- * Send a message to a secondary VM which checks the validity of the received
- * header.
- */
-TEST(spci, msg_send)
-{
- const char message[] = "spci_msg_send";
- struct spci_value run_res;
- struct mailbox_buffers mb = set_up_mailbox();
-
- SERVICE_SELECT(SERVICE_VM1, "spci_check", mb.send);
-
- /* Set the payload, init the message header and send the message. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
- EXPECT_EQ(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, sizeof(message), 0)
- .func,
- SPCI_SUCCESS_32);
-
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
-}
-
-/**
- * Send a message to a secondary VM spoofing the source VM id.
- */
-TEST(spci, msg_send_spoof)
-{
- const char message[] = "spci_msg_send";
- struct mailbox_buffers mb = set_up_mailbox();
-
- SERVICE_SELECT(SERVICE_VM1, "spci_check", mb.send);
-
- /* Set the payload, init the message header and send the message. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
- EXPECT_SPCI_ERROR(
- spci_msg_send(SERVICE_VM2, SERVICE_VM1, sizeof(message), 0),
- SPCI_INVALID_PARAMETERS);
-}
-
-/**
- * Send a message to a secondary VM with incorrect destination id.
- */
-TEST(spci, spci_invalid_destination_id)
-{
- const char message[] = "fail to send";
- struct mailbox_buffers mb = set_up_mailbox();
-
- SERVICE_SELECT(SERVICE_VM1, "spci_check", mb.send);
- /* Set the payload, init the message header and send the message. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
- EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, -1, sizeof(message), 0),
- SPCI_INVALID_PARAMETERS);
-}
-
-/**
- * Ensure that the length parameter is respected when sending messages.
- */
-TEST(spci, spci_incorrect_length)
-{
- const char message[] = "this should be truncated";
- struct spci_value run_res;
- struct mailbox_buffers mb = set_up_mailbox();
-
- SERVICE_SELECT(SERVICE_VM1, "spci_length", mb.send);
-
- /* Send the message and compare if truncated. */
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
- /* Hard code incorrect length. */
- EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 16, 0).func,
- SPCI_SUCCESS_32);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
-}
-
-/**
- * Attempt to send a message larger than what is supported.
- */
-TEST(spci, spci_large_message)
-{
- const char message[] = "fail to send";
- struct mailbox_buffers mb = set_up_mailbox();
-
- memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
- /* Send a message that is larger than the mailbox supports (4KB). */
- EXPECT_SPCI_ERROR(
- spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, 4 * 1024 + 1, 0),
- SPCI_INVALID_PARAMETERS);
-}
-
-/**
- * Verify secondary VM non blocking recv.
- */
-TEST(spci, spci_recv_non_blocking)
-{
- struct mailbox_buffers mb = set_up_mailbox();
- struct spci_value run_res;
-
- /* Check is performed in secondary VM. */
- SERVICE_SELECT(SERVICE_VM1, "spci_recv_non_blocking", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.func, SPCI_YIELD_32);
-}
diff --git a/test/vmapi/primary_with_secondaries/sysregs.c b/test/vmapi/primary_with_secondaries/sysregs.c
index 42f0636..fa7a30c 100644
--- a/test/vmapi/primary_with_secondaries/sysregs.c
+++ b/test/vmapi/primary_with_secondaries/sysregs.c
@@ -20,7 +20,7 @@
#include "primary_with_secondary.h"
#include "test/vmapi/exception_handler.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
SET_UP(sysregs)
{
diff --git a/test/vmapi/primary_with_secondaries/unmapped.c b/test/vmapi/primary_with_secondaries/unmapped.c
index 64fa9a0..42c69a9 100644
--- a/test/vmapi/primary_with_secondaries/unmapped.c
+++ b/test/vmapi/primary_with_secondaries/unmapped.c
@@ -19,19 +19,19 @@
#include "primary_with_secondary.h"
#include "test/hftest.h"
#include "test/vmapi/exception_handler.h"
-#include "test/vmapi/spci.h"
+#include "test/vmapi/ffa.h"
/**
* Accessing unmapped memory traps the VM.
*/
TEST(unmapped, data_unmapped)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "data_unmapped", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -41,12 +41,12 @@
*/
TEST(unmapped, straddling_data_unmapped)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "straddling_data_unmapped", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}
@@ -56,12 +56,12 @@
*/
TEST(unmapped, instruction_unmapped)
{
- struct spci_value run_res;
+ struct ffa_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM1, "instruction_unmapped", mb.send);
- run_res = spci_run(SERVICE_VM1, 0);
+ run_res = ffa_run(SERVICE_VM1, 0);
EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
1);
}