Skip to content

Commit

Permalink
core: mm: simplify overlap check
Browse files Browse the repository at this point in the history
Overlap region check could be simplified as below:
"(StartA <= EndB) and (StartB <= EndA)"

Signed-off-by: Peng Fan <[email protected]>
Reviewed-by: Joakim Bech <[email protected]>
  • Loading branch information
MrVan authored and jforissier committed Feb 21, 2019
1 parent 69a3d6b commit dfcb422
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/arch/arm/mm/core_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ static void add_phys_mem(struct tee_mmap_region *memory_map, size_t num_elems,
pa = memory_map[n].pa;
size = memory_map[n].size;
if (mem->type == memory_map[n].type &&
((mem->addr >= pa && mem->addr <= (pa + (size - 1))) ||
(pa >= mem->addr && pa <= (mem->addr + (mem->size - 1))))) {
((pa <= (mem->addr + (mem->size - 1))) &&
(mem->addr <= (pa + (size - 1))))) {
DMSG("Physical mem map overlaps 0x%" PRIxPA, mem->addr);
memory_map[n].pa = MIN(pa, mem->addr);
memory_map[n].size = MAX(size, mem->size) +
Expand Down

0 comments on commit dfcb422

Please sign in to comment.