refactor(manifest): logic to calculate memory region limit
This patch changes the way the limit of a memory region is recorded such
that it is an inclusive upper limit instead of an exclusive one. This
makes the check_and_record_mem_regions function easier to follow.
Also add unit test to check the case where memory region limits overlap.
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
Change-Id: I04c9569bda4cb27b212bdbc30ff27a1d9d34f549
diff --git a/src/manifest_test.cc b/src/manifest_test.cc
index cc78660..04d97cf 100644
--- a/src/manifest_test.cc
+++ b/src/manifest_test.cc
@@ -29,7 +29,7 @@
using struct_manifest = struct manifest;
-constexpr size_t TEST_HEAP_SIZE = PAGE_SIZE * 32;
+constexpr size_t TEST_HEAP_SIZE = PAGE_SIZE * 64;
template <typename T>
void exec(const char *program, const char *args[], const T &stdin,
@@ -1211,6 +1211,31 @@
MANIFEST_ERROR_MEM_REGION_OVERLAP);
manifest_dealloc();
+ /* clang-format off */
+ dtb = ManifestDtBuilder()
+ .FfaValidManifest()
+ .StartChild("memory-regions")
+ .Compatible({ "arm,ffa-manifest-memory-regions" })
+ .Label("rx")
+ .StartChild("rx")
+ .Description("rx-buffer")
+ .Property("base-address", "<0x7301000>")
+ .Property("pages-count", "<1>")
+ .Property("attributes", "<1>")
+ .EndChild()
+ .Label("tx")
+ .StartChild("tx")
+ .Description("tx-buffer")
+ .Property("base-address", "<0x7300000>")
+ .Property("pages-count", "<2>")
+ .Property("attributes", "<3>")
+ .EndChild()
+ .EndChild()
+ .Build();
+ /* clang-format on */
+ ASSERT_EQ(ffa_manifest_from_vec(&m, dtb),
+ MANIFEST_ERROR_MEM_REGION_OVERLAP);
+
/* Different RXTX buffer sizes */
/* clang-format off */
dtb = ManifestDtBuilder()