[Skiboot] [PATCH 3/3] phys map: Add tests for holes in MMIO region and order

Michael Neuling mikey at neuling.org
Fri May 12 15:49:39 AEST 2017


This adds a couple of tests to ensure that there are no holes in the
map for MMIO mappings and the map is sorted by start address.

Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 hw/test/phys-map-test.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/hw/test/phys-map-test.c b/hw/test/phys-map-test.c
index 55ebff1f48..33810745f9 100644
--- a/hw/test/phys-map-test.c
+++ b/hw/test/phys-map-test.c
@@ -89,13 +89,14 @@ static void check_map_call(void)
 	struct proc_chip c;
 	uint64_t start, size, end;
 	const struct phys_map_entry *e;
-	struct map_call_entry *tbl, *t;
+	struct map_call_entry *tbl, *t, *tnext;
 	int tbl_size = 0;
 	bool passed;
 
 	for (e = phys_map->table; !phys_map_entry_null(e); e++)
 		tbl_size++;
 
+	tbl_size++; /* allow for null entry at end */
 	tbl_size *= sizeof(struct map_call_entry);
 	tbl = malloc(tbl_size);
 	assert(tbl != NULL);
@@ -143,6 +144,31 @@ static void check_map_call(void)
 		t->end = end;
 	}
 
+	for (t = tbl; !map_call_entry_null(t + 1); t++) {
+		tnext = t + 1;
+		/* Make sure the table is sorted */
+		if (t->start > tnext->start) {
+			printf("Phys map test FAILED: Entry not sorted\n");
+			printf("First:  addr:%016lx size:%016lx\n",
+			       t->start, t->end - t->start);
+			printf("Second:  addr:%016lx size:%016lx\n",
+			       tnext->start, tnext->end - tnext->start);
+			assert(0);
+		}
+
+		/* Look for holes in the table in MMIO region */
+		/* We assume over 1PB is MMIO. */
+		if ((t->end != tnext->start) &&
+		    (t->start > 0x0004000000000000)) {
+			printf("Phys map test FAILED: Hole in map\n");
+			printf("First:  addr:%016lx size:%016lx\n",
+			       t->start, t->end - t->start);
+			printf("Second:  addr:%016lx size:%016lx\n",
+			       tnext->start, tnext->end - tnext->start);
+			assert(0);
+		}
+	}
+
 	free(tbl);
 }
 
-- 
2.11.0



More information about the Skiboot mailing list