aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Walbran <qwandor@google.com>2020-08-06 14:54:24 +0100
committerAndrew Walbran <qwandor@google.com>2020-08-12 16:44:46 +0000
commitb618a566d764cc11b38bf37ac6caaeca3db050b3 (patch)
tree45be01aa0a30679e81e164085b71b08927538ac2
parentc3847c706b27caf4d8c4aff22497ed0101cc5801 (diff)
downloadhafnium-b618a566d764cc11b38bf37ac6caaeca3db050b3.tar.gz
Ensure more tests release the RX buffer when they are done.
This was done in https://hafnium-review.googlesource.com/c/hafnium/+/8044, but more tests have been added since then without appropriate TEAR_DOWN rules. Bug: 146208457 Change-Id: I73196ddd0989cc0f85338be4552f4af135202e57
-rw-r--r--test/vmapi/arch/aarch64/gicv3/busy_secondary.c6
-rw-r--r--test/vmapi/arch/aarch64/gicv3/gicv3.c6
-rw-r--r--test/vmapi/primary_only/faults.c6
-rw-r--r--test/vmapi/primary_only/primary_only.c5
-rw-r--r--test/vmapi/primary_with_secondaries/boot.c5
-rw-r--r--test/vmapi/primary_with_secondaries/debug_el1.c5
-rw-r--r--test/vmapi/primary_with_secondaries/ffa.c5
-rw-r--r--test/vmapi/primary_with_secondaries/floating_point.c5
-rw-r--r--test/vmapi/primary_with_secondaries/no_services.c5
-rw-r--r--test/vmapi/primary_with_secondaries/perfmon.c5
-rw-r--r--test/vmapi/primary_with_secondaries/unmapped.c5
11 files changed, 58 insertions, 0 deletions
diff --git a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
index 06eeda07f..22b7dd87a 100644
--- a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
@@ -18,6 +18,7 @@
#include "gicv3.h"
#include "msr.h"
#include "test/hftest.h"
+#include "test/vmapi/ffa.h"
/**
* Converts a number of nanoseconds to the equivalent number of timer ticks.
@@ -35,6 +36,11 @@ SET_UP(busy_secondary)
SERVICE_SELECT(SERVICE_VM1, "busy", send_buffer);
}
+TEAR_DOWN(busy_secondary)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
TEST(busy_secondary, virtual_timer)
{
const char message[] = "loop";
diff --git a/test/vmapi/arch/aarch64/gicv3/gicv3.c b/test/vmapi/arch/aarch64/gicv3/gicv3.c
index ef36e6ac1..2b1c822e9 100644
--- a/test/vmapi/arch/aarch64/gicv3/gicv3.c
+++ b/test/vmapi/arch/aarch64/gicv3/gicv3.c
@@ -20,6 +20,7 @@
#include "../msr.h"
#include "test/hftest.h"
+#include "test/vmapi/ffa.h"
alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
@@ -52,6 +53,11 @@ void system_setup()
interrupt_gic_setup();
}
+TEAR_DOWN(system)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/* Check that system registers are configured as we expect on startup. */
TEST(system, system_registers_enabled)
{
diff --git a/test/vmapi/primary_only/faults.c b/test/vmapi/primary_only/faults.c
index 0a6ba89be..75fa4d393 100644
--- a/test/vmapi/primary_only/faults.c
+++ b/test/vmapi/primary_only/faults.c
@@ -16,6 +16,7 @@
#include "vmapi/hf/call.h"
#include "test/hftest.h"
+#include "test/vmapi/ffa.h"
alignas(PAGE_SIZE) static char tx[PAGE_SIZE];
alignas(PAGE_SIZE) static char rx[PAGE_SIZE];
@@ -40,6 +41,11 @@ static void rx_reader(uintptr_t arg)
sl_unlock(&s->lock);
}
+TEAR_DOWN(faults)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/**
* Forces a spurious fault and check that Hafnium recovers from it.
*/
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index 8af5fa4e0..0ba87272f 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -190,6 +190,11 @@ TEST(cpus, stop)
dlog("Second CPU stopped.\n");
}
+TEAR_DOWN(ffa)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/** Ensures that the Hafnium FF-A version is reported as expected. */
TEST(ffa, ffa_version)
{
diff --git a/test/vmapi/primary_with_secondaries/boot.c b/test/vmapi/primary_with_secondaries/boot.c
index 1e2d45a4b..7ecea9c2d 100644
--- a/test/vmapi/primary_with_secondaries/boot.c
+++ b/test/vmapi/primary_with_secondaries/boot.c
@@ -15,6 +15,11 @@
#include "test/vmapi/exception_handler.h"
#include "test/vmapi/ffa.h"
+TEAR_DOWN(boot)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/**
* The VM gets its memory size on boot, and can access it all.
*/
diff --git a/test/vmapi/primary_with_secondaries/debug_el1.c b/test/vmapi/primary_with_secondaries/debug_el1.c
index 5de95263a..4aaef3419 100644
--- a/test/vmapi/primary_with_secondaries/debug_el1.c
+++ b/test/vmapi/primary_with_secondaries/debug_el1.c
@@ -17,6 +17,11 @@
*/
#define CUSTOM_QEMU_BUILD() 0
+TEAR_DOWN(debug_el1)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
TEST(debug_el1, secondary_basic)
{
struct ffa_value run_res;
diff --git a/test/vmapi/primary_with_secondaries/ffa.c b/test/vmapi/primary_with_secondaries/ffa.c
index d13794794..cadb38f60 100644
--- a/test/vmapi/primary_with_secondaries/ffa.c
+++ b/test/vmapi/primary_with_secondaries/ffa.c
@@ -18,6 +18,11 @@
#include "test/hftest.h"
#include "test/vmapi/ffa.h"
+TEAR_DOWN(ffa)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/**
* Send a message to a secondary VM which checks the validity of the received
* header.
diff --git a/test/vmapi/primary_with_secondaries/floating_point.c b/test/vmapi/primary_with_secondaries/floating_point.c
index 9c3bbc06c..e3c5aa23b 100644
--- a/test/vmapi/primary_with_secondaries/floating_point.c
+++ b/test/vmapi/primary_with_secondaries/floating_point.c
@@ -18,6 +18,11 @@
#include "test/hftest.h"
#include "test/vmapi/ffa.h"
+TEAR_DOWN(floating_point)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/**
* Test that floating point registers are saved and restored by
* filling them with one value here and a different value in the
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 7fbc57df0..6b80d01e1 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -99,6 +99,11 @@ TEST(ffa_run, cannot_run_absent_vcpu)
EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
+TEAR_DOWN(ffa_rxtx_map)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/**
* The configured send/receive addresses can't be device memory.
*/
diff --git a/test/vmapi/primary_with_secondaries/perfmon.c b/test/vmapi/primary_with_secondaries/perfmon.c
index 13c4d7142..f8b415ac2 100644
--- a/test/vmapi/primary_with_secondaries/perfmon.c
+++ b/test/vmapi/primary_with_secondaries/perfmon.c
@@ -13,6 +13,11 @@
#include "sysregs.h"
#include "test/vmapi/ffa.h"
+TEAR_DOWN(perfmon)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
TEST(perfmon, secondary_basic)
{
struct ffa_value run_res;
diff --git a/test/vmapi/primary_with_secondaries/unmapped.c b/test/vmapi/primary_with_secondaries/unmapped.c
index 648e8661b..347277484 100644
--- a/test/vmapi/primary_with_secondaries/unmapped.c
+++ b/test/vmapi/primary_with_secondaries/unmapped.c
@@ -13,6 +13,11 @@
#include "test/vmapi/exception_handler.h"
#include "test/vmapi/ffa.h"
+TEAR_DOWN(unmapped)
+{
+ EXPECT_FFA_ERROR(ffa_rx_release(), FFA_DENIED);
+}
+
/**
* Accessing unmapped memory traps the VM.
*/