7.1.2. Overlapping regions

You can program the MPU with two or more overlapping regions. For overlapping regions, a fixed priority scheme determines attributes and permissions for memory access to the overlapping region. Attributes and permissions for region 15 take highest priority, those for region 0 take lowest priority. For example:

Region 2

Is 4KB in size, starting from address 0x3000. Privileged mode has full access, and User mode has read-only access.

Region 1

Is 16KB in size, starting from address 0x0000. Both Privileged and User modes have full access.

When the processor performs a data write to address 0x3010 while in User mode, the address falls into both region 1 and region 2, as Figure 7.1 shows. Because these regions have different permissions, the permissions associated with region 2 are applied. Because User mode is read access only for this region, a permission fault occurs, causing a data abort.

Figure 7.1. Overlapping memory regions

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


Example of using regions that overlap

You can use overlapping regions for stack protection. For example:

  • allocate to region 1 the appropriate size for all stacks

  • allocate to region 2 the minimum region size, 32 bytes, and position it at the end of the stack for the current process

  • set the region 2 access permissions to No Access.

If the current process overflows the stack it uses, a write access to region 2 by the processor causes the MPU to raise a permission fault.

Figure 7.2. Overlay for stack protection

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


Example of using subregions

You can use subregions for stack protection. For example:

  • Allocate to region 1 the appropriate size for all stacks.

  • Set the least-significant subregion disable bit. That is, set the subregion disable field, bits [15:8], of the CP15 MPU Region Size Register to 0x01.

If the current process overflows the stack it uses, a write access by the processor to the disabled subregion causes the MPU to raise a background fault.

Figure 7.3. Overlapping subregion of memory

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


Copyright © 2010-2011 ARM. All rights reserved.ARM DDI 0460C
Non-ConfidentialID021511