Only allow identity memory mapping
The code has the assumption that virtual addresses are mapped to the
same physical address but the mm function would allow this assumption to
be broken. Only offering identity mapping function avoids this problem
by enforcing assumption.
Non-identity mapping can still be added later if there proves to be a
need for it.
Change-Id: Ie3db41e1582c72d880275acdb48cabefe05b3ba0
diff --git a/src/fdt_handler.c b/src/fdt_handler.c
index fa2f9b6..47637ca 100644
--- a/src/fdt_handler.c
+++ b/src/fdt_handler.c
@@ -167,8 +167,8 @@
bool ret = false;
/* Map the fdt header in. */
- if (!mm_map((vaddr_t)fdt, (vaddr_t)fdt + fdt_header_size(),
- (paddr_t)fdt, MM_MODE_R)) {
+ if (!mm_identity_map((vaddr_t)fdt, (vaddr_t)fdt + fdt_header_size(),
+ MM_MODE_R)) {
dlog("Unable to map FDT header.\n");
goto err_unmap_fdt_header;
}
@@ -179,8 +179,8 @@
}
/* Map the rest of the fdt in. */
- if (!mm_map((vaddr_t)fdt, (vaddr_t)fdt + fdt_total_size(fdt),
- (paddr_t)fdt, MM_MODE_R)) {
+ if (!mm_identity_map((vaddr_t)fdt, (vaddr_t)fdt + fdt_total_size(fdt),
+ MM_MODE_R)) {
dlog("Unable to map full FDT.\n");
goto err_unmap_fdt_header;
}
@@ -216,8 +216,8 @@
bool ret = false;
/* Map the fdt header in. */
- if (!mm_map((vaddr_t)fdt, (vaddr_t)fdt + fdt_header_size(),
- (paddr_t)fdt, MM_MODE_R)) {
+ if (!mm_identity_map((vaddr_t)fdt, (vaddr_t)fdt + fdt_header_size(),
+ MM_MODE_R)) {
dlog("Unable to map FDT header.\n");
return false;
}
@@ -228,9 +228,9 @@
}
/* Map the fdt (+ a page) in r/w mode in preparation for updating it. */
- if (!mm_map((vaddr_t)fdt,
- (vaddr_t)fdt + fdt_total_size(fdt) + PAGE_SIZE,
- (paddr_t)fdt, MM_MODE_R | MM_MODE_W)) {
+ if (!mm_identity_map((vaddr_t)fdt,
+ (vaddr_t)fdt + fdt_total_size(fdt) + PAGE_SIZE,
+ MM_MODE_R | MM_MODE_W)) {
dlog("Unable to map FDT in r/w mode.\n");
goto err_unmap_fdt_header;
}