Figure 7-1, Overlapping memory regions -5, Figure 7-2 – ARM Cortex R4F User Manual

Page 188: Overlay for stack protection -5

Advertising
background image

Memory Protection Unit

ARM DDI 0363E

Copyright © 2009 ARM Limited. All rights reserved.

7-5

ID013010

Non-Confidential, Unrestricted Access

Figure 7-1 Overlapping memory regions

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

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.

Region 2

Region 1

0x4000

0x0000

0x3000

0x3010

Region 1

0x4000

0x0000

Region 2

Advertising
This manual is related to the following products: