refactor(mm): replace max level with root level
The name `mm_max_level()` is misleading, since it is not actually the
maximum value that the level can be (since the root level is the "max"
level plus 1).
The use of `mm_max_level()` in `mm.c` was also inconsistent: sometimes
they call `mm_max_level() + 1` to calculate the root level, sometimes
they just pass `mm_max_level()` to recursive subcalls to process the
next level down. This made it hard to know when a plus or minus one was
needed and so ended up introducing off-by-one errors. Now, you always
start at `mm_root_level()` and pass `root_level - 1` to recursive
subcalls.
Also add explanatory comments explaining the level-related arithmetic.
Change-Id: I7b701d6d2c908db03c2853a008565126890e7959
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/src/vm_test.cc b/src/vm_test.cc
index 08dd3ca..97f5b74 100644
--- a/src/vm_test.cc
+++ b/src/vm_test.cc
@@ -39,7 +39,7 @@
using struct_vm_locked = struct vm_locked;
constexpr size_t TEST_HEAP_SIZE = PAGE_SIZE * 64;
-const mm_level_t TOP_LEVEL = arch_mm_stage2_max_level();
+const mm_level_t TOP_LEVEL = arch_mm_stage2_root_level() - 1;
class vm : public ::testing::Test
{