Skip to content

Commit

Permalink
arch: aarch32: fix z_mapped_start location for non-XIP operation
Browse files Browse the repository at this point in the history
Move the z_mapped_start marker for non-XIP builds to the base RAM address.
This has already been the marker's location when building for XIP.

Prior to this change, z_mapped_start was located at the start of the
text section for non-XIP builds. However, at least for the Cortex-A
family of CPUs, the first section located at the RAM base address
isn't the text section, but the single 4k page containing the exception
vectors which are copied to either address 0 or the HIVECS address upon
early boot.

This resulted in this first 4k page at the bottom of RAM to be considered
available for memory mappings via the MMU at run-time, followed by all
the permanently mapped stuff, with available mappable memory only
continuing behind z_mapped_end. A call at run-time requesting memory to
be mapped via the MMU therefore always assigned the single 4k page
containing the vectors data first, before continuing mapping physical
memory behind z_mapped_end. For any map call requesting more than 4k,
this resulted in a contiguous virtual memory address range mapped to
non-contiguous physical memory. This behaviour has already been
documented in #51024.

This behaviour would also cause further problems in case of support
for the Cortex-A's VBAR register, which has been proposed before, but
eventually wasn't merged. Letting VBAR point to the RAM base where
the 4k vectors page is located within the Zephyr image instead of
copying the vectors to either 0 or the HIVECS address means that this
page may under no circumstance be re-assigned for use as regular RAM
mapped via the MMU.

Signed-off-by: Immo Birnbaum <[email protected]>
  • Loading branch information
ibirnbaum authored and fabiobaltieri committed Aug 9, 2023
1 parent 36997de commit 9e9e60b
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions include/zephyr/arch/arm/aarch32/cortex_a_r/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ SECTIONS
{
. = ALIGN(_region_min_align);
__text_region_start = .;
#ifndef CONFIG_XIP
z_mapped_start = .;
#endif

#include <zephyr/linker/kobject-text.ld>

Expand Down Expand Up @@ -252,9 +249,7 @@ SECTIONS
*/
. = ALIGN(_region_min_align);
_image_ram_start = .;
#ifdef CONFIG_XIP
z_mapped_start = .;
#endif

/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
Expand Down

0 comments on commit 9e9e60b

Please sign in to comment.