[rtems commit] bsps/aarch64: Add missing MMU map recursion check

Joel Sherrill joel at rtems.org
Mon Nov 1 13:34:57 UTC 2021


Module:    rtems
Branch:    master
Commit:    55a93ae3b427a37ad77cd72d0f02f5bd1bf6be25
Changeset: http://git.rtems.org/rtems/commit/?id=55a93ae3b427a37ad77cd72d0f02f5bd1bf6be25

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Mon Oct 25 09:50:12 2021 -0500

bsps/aarch64: Add missing MMU map recursion check

Certain input parameters for MMU mapping operations could cause an
infinite recursion if block end boundaries didn't align to 4k. This
ensures that recursion descent does not exceed 2 levels and instead
rounds up to the nearest 4k block if necessary.

---

 bsps/aarch64/include/bsp/aarch64-mmu.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/bsps/aarch64/include/bsp/aarch64-mmu.h b/bsps/aarch64/include/bsp/aarch64-mmu.h
index 4f42d5b..9926eb9 100644
--- a/bsps/aarch64/include/bsp/aarch64-mmu.h
+++ b/bsps/aarch64/include/bsp/aarch64-mmu.h
@@ -246,6 +246,15 @@ BSP_START_TEXT_SECTION static inline rtems_status_code aarch64_mmu_map_block(
       } else {
         /* block starts on a boundary, but is short */
         chunk_size = size;
+
+	/* it isn't possible to go beyond page table level 2 */
+	if ( page_flag ) {
+          /* no sub-table, apply block properties */
+          page_table[index] = addr | flags | page_flag;
+          size -= chunk_size;
+          addr += chunk_size;
+          continue;
+	}
       }
     } else {
       uintptr_t block_top = RTEMS_ALIGN_UP( addr, granularity );



More information about the vc mailing list