-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arch: arm: mpu: Use temporary MPU mapping while reprogramming NXP MPU
Race conditions exist when remapping the NXP MPU. When writing the start, end, or attribute registers of a MPU descriptor, the hardware will automatically clear the region's valid bit. If that region gets accessed before the code is able to set the valid bit, the core will fault. Issue #20595 revealled this problem with the code in region_init() when the compiler options are set to no optimizations. The code generated by the compiler put local variables on the stack and then read those stack based variables when writing the MPU descriptor registers. If that region mapped the stack a memory fault would occur. Higher compiler optimizations would store these local variables in CPU registers which avoided the memory access when programming the MPU descriptor. Because the NXP MPU uses a logic OR operation of the MPU descriptors, the fix uses the last descriptor in the MPU hardware to remap all of dynamic memory for access instead of the first of the dynamic memory descriptors as was occuring before. This allows reprogramming of the primary discriptor blocks without having a memory fault. After all the dynamic memory blocks are mapped, the unused blocks will have their valid bits cleared including this temporary one, if it wasn't alread changed during the mapping of the current set. Fixes #20595 Signed-off-by: David Leach <david.leach@nxp.com>
- Loading branch information
Showing
2 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters