test(memory share): lend device memory region to sp
Add test to check that a device memory region can be successfully
lent to an sp.
This requires some refactoring of the memory sharing test flow so
as to use the correct memory type and cachebility attributes for
the memory being lent. Also limit the words being written to 1
word for device memory so we only write to the data register of the
device.
Also only map device regions from UART2 so that UART0 can be used
by TFTF in the device sharing test.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I9f31769679883f34e0444db75a873765776a85e9
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 1d5cd97..cc17da9 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -111,9 +111,9 @@
}
static const mmap_region_t cactus_mmap[] __attribute__((used)) = {
- /* PLAT_ARM_DEVICE0 area includes UART2 necessary to console */
- MAP_REGION_FLAT(PLAT_ARM_DEVICE0_BASE, PLAT_ARM_DEVICE0_SIZE,
+ MAP_REGION_FLAT(PLAT_CACTUS_DEVICE_BASE, PLAT_CACTUS_DEVICE_SIZE,
MT_DEVICE | MT_RW),
+
/* scratch memory allocated to be used for running SMMU tests */
MAP_REGION_FLAT(PLAT_CACTUS_MEMCPY_BASE, PLAT_CACTUS_MEMCPY_RANGE,
MT_MEMORY | MT_RW),
diff --git a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
index 811c79f..570c648 100644
--- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
+++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
@@ -114,6 +114,8 @@
cactus_mem_send_get_retrv_flags(*args);
uint32_t words_to_write = cactus_mem_send_words_to_write(*args);
bool expect_exception = cactus_mem_send_expect_exception(*args);
+ bool is_normal_memory = cactus_mem_send_is_normal_memory(*args);
+
struct ffa_memory_access receiver = ffa_memory_access_init(
vm_id, FFA_DATA_ACCESS_RW,
@@ -123,7 +125,7 @@
0, NULL);
EXPECT(memory_retrieve(mb, &m, handle, source, &receiver, 1,
- retrv_flags),
+ retrv_flags, is_normal_memory),
true);
composite = ffa_memory_region_get_composite(m, 0);
@@ -337,7 +339,7 @@
}
ffa_ret = cactus_mem_send_cmd(vm_id, receiver_id, mem_func, handle,
- 0, 10, false);
+ 0, 10, false, true);
if (!is_ffa_direct_response(ffa_ret)) {
return cactus_error_resp(vm_id, source, CACTUS_ERROR_FFA_CALL);
diff --git a/spm/cactus/plat/arm/fvp/include/sp_platform_def.h b/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
index bb57ce8..390294f 100644
--- a/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
+++ b/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
@@ -18,8 +18,13 @@
#define PLAT_SP_RX_BASE ULL(0x7300000)
#define PLAT_SP_CORE_COUNT U(8)
-#define PLAT_ARM_DEVICE0_BASE DEVICE0_BASE
-#define PLAT_ARM_DEVICE0_SIZE DEVICE0_SIZE
+/*
+ * Map the device memory starting from UART2
+ * so UART0 can be lent by tftf in the device memory sharing tests.
+ */
+#define PLAT_CACTUS_DEVICE_BASE PL011_UART2_BASE
+#define PLAT_CACTUS_DEVICE_SIZE DEVICE0_SIZE - \
+ (PLAT_CACTUS_DEVICE_BASE - DEVICE0_BASE)
/* Scratch memory used for SMMUv3 driver testing purposes in Cactus SP */
#define PLAT_CACTUS_MEMCPY_BASE ULL(0x7400000)