test: add helpers and extend command args to mask interrupts
This patch provides helper utilities and extends the SP_SLEEP command
to support an additional argument that specifies if the SP should run
with its virtual interrupts masked.
This feature would be used in subsequent patch.
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: I4426e71644174c9b34762e184d825d528c65a468
diff --git a/test/vmapi/ffa_secure_partitions/secure_interrupts.c b/test/vmapi/ffa_secure_partitions/secure_interrupts.c
index 7d24a55..ace54a5 100644
--- a/test/vmapi/ffa_secure_partitions/secure_interrupts.c
+++ b/test/vmapi/ffa_secure_partitions/secure_interrupts.c
@@ -112,7 +112,7 @@
enable_trigger_trusted_wdog_timer(own_id, receiver_id, 400);
/* Send request to the SP to sleep. */
- res = sp_sleep_cmd_send(own_id, receiver_id, SP_SLEEP_TIME);
+ res = sp_sleep_cmd_send(own_id, receiver_id, SP_SLEEP_TIME, 0);
/*
* Secure interrupt should trigger during this time, SP will handle the
@@ -213,7 +213,7 @@
enable_trigger_trusted_wdog_timer(own_id, receiver_id, 200);
/* Send request to receiver SP to sleep. */
- res = sp_sleep_cmd_send(own_id, receiver_id, 50);
+ res = sp_sleep_cmd_send(own_id, receiver_id, 50, 0);
/* SP is pre-empted by the non-secure timer interrupt. */
EXPECT_EQ(res.func, FFA_INTERRUPT_32);
@@ -281,7 +281,7 @@
* sleep command. SPMC queues the virtual interrupt and resumes the
* SP.
*/
- res = sp_sleep_cmd_send(own_id, receiver_id, SP_SLEEP_TIME);
+ res = sp_sleep_cmd_send(own_id, receiver_id, SP_SLEEP_TIME, 0);
/* Service3 SP finishes and sends direct response back. */
EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_RESP_32);
@@ -291,7 +291,7 @@
* Allocate cycles to target SP for it to handle the virtual secure
* interrupt.
*/
- res = sp_sleep_cmd_send(own_id, target_id, 10);
+ res = sp_sleep_cmd_send(own_id, target_id, 10, 0);
/*
* Secure interrupt should trigger during this time, SP will handle the
@@ -394,7 +394,7 @@
}
/* Send request to the SP to sleep. */
- res = sp_sleep_cmd_send(own_id, args->receiver_id, SP_SLEEP_TIME);
+ res = sp_sleep_cmd_send(own_id, args->receiver_id, SP_SLEEP_TIME, 0);
EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_RESP_32);
EXPECT_EQ(sp_resp(res), SP_SUCCESS);
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/el0/sp_helpers.c b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/el0/sp_helpers.c
index 0a24a14..b44613a 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/el0/sp_helpers.c
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/el0/sp_helpers.c
@@ -28,6 +28,10 @@
{
}
+void sp_disable_irq(void)
+{
+}
+
struct ffa_value handle_ffa_interrupt(struct ffa_value res)
{
uint32_t intid;
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h
index e16e66b..f7cd578 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/partition_services.h
@@ -375,13 +375,20 @@
#define SP_SLEEP_CMD 0x736c6570U
static inline struct ffa_value sp_sleep_cmd_send(ffa_id_t source, ffa_id_t dest,
- uint32_t sleep_time)
+ uint32_t sleep_time,
+ uint32_t options)
{
return ffa_msg_send_direct_req(source, dest, SP_SLEEP_CMD, sleep_time,
- 0, 0, 0);
+ options, 0, 0);
}
-struct ffa_value sp_sleep_cmd(ffa_id_t source, uint32_t sleep_ms);
+struct ffa_value sp_sleep_cmd(ffa_id_t source, uint32_t sleep_ms,
+ uint32_t options);
+
+static inline uint32_t sp_get_sleep_options(struct ffa_value ret)
+{
+ return (uint32_t)ret.arg5;
+}
/**
* Command to request SP to forward sleep command for the given time in ms.
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/sp_helpers.h b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/sp_helpers.h
index 7fad4ea..786f8b5 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/sp_helpers.h
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/inc/sp_helpers.h
@@ -13,5 +13,6 @@
uint64_t sp_sleep_active_wait(uint32_t ms);
void sp_enable_irq(void);
+void sp_disable_irq(void);
struct ffa_value handle_ffa_interrupt(struct ffa_value res);
struct ffa_value handle_ffa_run(struct ffa_value res);
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c
index 5fcd677..cc9eba0 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/message_loop.c
@@ -79,7 +79,8 @@
res = sp_clear_last_interrupt_cmd(ffa_sender(res));
break;
case SP_SLEEP_CMD:
- res = sp_sleep_cmd(ffa_sender(res), sp_get_sleep_time(res));
+ res = sp_sleep_cmd(ffa_sender(res), sp_get_sleep_time(res),
+ sp_get_sleep_options(res));
break;
case SP_FWD_SLEEP_CMD:
res = sp_fwd_sleep_cmd(ffa_sender(res), sp_get_sleep_time(res),
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c
index 703889b..347b18b 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/secure_interrupts.c
@@ -173,11 +173,22 @@
return true;
}
-struct ffa_value sp_sleep_cmd(ffa_id_t source, uint32_t sleep_ms)
+static inline bool mask_interrupts(uint32_t options)
+{
+ return ((options & 0x1) == 1);
+}
+
+struct ffa_value sp_sleep_cmd(ffa_id_t source, uint32_t sleep_ms,
+ uint32_t options)
{
uint64_t time_lapsed;
ffa_id_t own_id = hf_vm_get_id();
+ if (mask_interrupts(options)) {
+ /* Mask virtual interrupts. */
+ sp_disable_irq();
+ }
+
HFTEST_LOG("Request to sleep %x for %ums", own_id, sleep_ms);
time_lapsed = sp_sleep_active_wait(sleep_ms);
@@ -198,7 +209,7 @@
HFTEST_LOG("VM%x requested %x to sleep for %ums", source, fwd_dest,
sleep_ms);
- ffa_ret = sp_sleep_cmd_send(own_id, fwd_dest, sleep_ms);
+ ffa_ret = sp_sleep_cmd_send(own_id, fwd_dest, sleep_ms, 0);
/*
* The target of the direct request could be pre-empted any number of
diff --git a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/sp_helpers.c b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/sp_helpers.c
index 8d08e68..79e4832 100644
--- a/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/sp_helpers.c
+++ b/test/vmapi/ffa_secure_partitions/services/arch/aarch64/secure/sp_helpers.c
@@ -43,6 +43,11 @@
arch_irq_enable();
}
+void sp_disable_irq(void)
+{
+ arch_irq_disable();
+}
+
struct ffa_value handle_ffa_interrupt(struct ffa_value res)
{
/*
@@ -53,6 +58,10 @@
* the interrupt handler.
*/
ASSERT_EQ(res.arg1, 0);
+
+ /* Unmask all virtual interrupts such that they are handled now. */
+ sp_enable_irq();
+
return ffa_msg_wait();
}