refactor: check return values

Add CHECK statements on return values during mmu initialization. it is
possible that memory allocation fails if the heap is too small, which
will only be caught via indirect faults.
This patch also fixes the function definition for the fake
arch_mm_stack_init that returned void, but should return a bool, and
changes the fake layout so that start address in the layout is not 0,
which is the same as NULL and causes test failures.

Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
Change-Id: I6ef0b6e31f9b5bfd683b18d43c21019970685dd9
diff --git a/src/arch/fake/mm.c b/src/arch/fake/mm.c
index 8c7d169..ce6f755 100644
--- a/src/arch/fake/mm.c
+++ b/src/arch/fake/mm.c
@@ -167,11 +167,12 @@
 	return attrs >> PTE_ATTR_MODE_SHIFT;
 }
 
-void arch_stack_mm_init(struct mm_stage1_locked stage1_locked,
+bool arch_stack_mm_init(struct mm_stage1_locked stage1_locked,
 			struct mpool *ppool)
 {
 	(void)stage1_locked;
 	(void)ppool;
+	return true;
 }
 
 bool arch_mm_init(paddr_t table)
diff --git a/src/layout_fake.c b/src/layout_fake.c
index eab3492..0b5e1be 100644
--- a/src/layout_fake.c
+++ b/src/layout_fake.c
@@ -10,7 +10,7 @@
 
 paddr_t layout_text_begin(void)
 {
-	return pa_init(0);
+	return pa_init(1);
 }
 
 paddr_t layout_text_end(void)
diff --git a/src/mm.c b/src/mm.c
index 8180be9..b7e748d 100644
--- a/src/mm.c
+++ b/src/mm.c
@@ -1130,17 +1130,18 @@
 	plat_console_mm_init(stage1_locked, ppool);
 
 	/* Map each section. */
-	mm_identity_map(stage1_locked, layout_text_begin(), layout_text_end(),
-			MM_MODE_X, ppool);
+	CHECK(mm_identity_map(stage1_locked, layout_text_begin(),
+			      layout_text_end(), MM_MODE_X, ppool) != NULL);
 
-	mm_identity_map(stage1_locked, layout_rodata_begin(),
-			layout_rodata_end(), MM_MODE_R, ppool);
+	CHECK(mm_identity_map(stage1_locked, layout_rodata_begin(),
+			      layout_rodata_end(), MM_MODE_R, ppool) != NULL);
 
-	mm_identity_map(stage1_locked, layout_data_begin(), layout_data_end(),
-			MM_MODE_R | MM_MODE_W, ppool);
+	CHECK(mm_identity_map(stage1_locked, layout_data_begin(),
+			      layout_data_end(), MM_MODE_R | MM_MODE_W,
+			      ppool) != NULL);
 
 	/* Arch-specific stack mapping. */
-	arch_stack_mm_init(stage1_locked, ppool);
+	CHECK(arch_stack_mm_init(stage1_locked, ppool));
 
 	return true;
 }