mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-25 05:47:12 +00:00
aarch64/mmu: Prevent block descriptors at level -1
In the original implementation, level -1 was unused and all levels could have block-like descriptors (level 2 block descriptors are called page descriptors). When support for level -1 page tables was added the constraint on level -1 block descriptors was not honored. This prevents block descriptors from being mapped at level -1 since the hardware will not map them properly.
This commit is contained in:
committed by
Chris Johns
parent
3f644aa874
commit
a9861ceea0
@@ -243,26 +243,29 @@ BSP_START_TEXT_SECTION static inline rtems_status_code aarch64_mmu_map_block(
|
||||
/* check for perfect block match */
|
||||
if ( block_bottom == addr ) {
|
||||
if ( size >= chunk_size ) {
|
||||
/* when page_flag is set the last level must be a page descriptor */
|
||||
if ( page_flag || ( page_table[index] & MMU_DESC_TYPE_TABLE ) != MMU_DESC_TYPE_TABLE ) {
|
||||
/* level -1 can't contain block descriptors, fall through to subtable */
|
||||
if ( level != -1 ) {
|
||||
/* when page_flag is set the last level must be a page descriptor */
|
||||
if ( page_flag || ( page_table[index] & MMU_DESC_TYPE_TABLE ) != MMU_DESC_TYPE_TABLE ) {
|
||||
/* no sub-table, apply block properties */
|
||||
page_table[index] = addr | flags | page_flag;
|
||||
size -= chunk_size;
|
||||
addr += chunk_size;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} 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 {
|
||||
/* 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 );
|
||||
|
||||
Reference in New Issue
Block a user