Commit 79621f00 authored by Daniel Boulby's avatar Daniel Boulby Committed by Antonio Nino Diaz
Browse files

xlat: Change check in mmap_add and mmap_add_ctx()


Depending on the build flags it is possible that some of the memory
regions mapped in page table setup could have a size of 0. In this
case we simply want to do nothing but still wish to map the other
regions in the array. Therefore we cannot only use size == 0 as
the termination logic for the loop.

Since an attributes field with value 0 means that the region is
device memory, read only, secure and executable. Device memory
can't be executable, so this combination should never be used
and it is safe to use as a terminator value.

Therefore by changing the termination logic to use attributes
instead of size we prevent terminating the loop when we don't
intend to.

Change-Id: I92fc7f689ab08543497be6be4896dace2ed7b66a
Signed-off-by: default avatarDaniel Boulby <daniel.boulby@arm.com>
Showing with 2 additions and 2 deletions
+2 -2
......@@ -176,7 +176,7 @@ void mmap_add(const mmap_region_t *mm)
{
const mmap_region_t *mm_cursor = mm;
while (mm_cursor->size != 0U) {
while (mm_cursor->attr != 0U) {
mmap_add_region(mm_cursor->base_pa, mm_cursor->base_va,
mm_cursor->size, mm_cursor->attr);
mm_cursor++;
......
......@@ -815,7 +815,7 @@ void mmap_add_ctx(xlat_ctx_t *ctx, const mmap_region_t *mm)
{
const mmap_region_t *mm_cursor = mm;
while (mm_cursor->size != 0U) {
while (mm_cursor->attr != 0U) {
mmap_add_region_ctx(ctx, mm_cursor);
mm_cursor++;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment