Commit 14fd25c
kernel: keep empty MPU slots from wiping the previous region
arch_thread_regions_set() encodes an unused per-thread region slot as
RBAR=0 / RASR=0. On ARMv7-M the context switch streams the four slots
through MPU_RBAR..MPU_RASR_A3, and an RBAR write with VALID clear does
not change RNR: it updates the region RNR already points at, i.e. the
one the previous slot just programmed. For App and Worker the empty slot
3 therefore lands on region 6 and its RASR=0 disables the task stack
guard. The FreeRTOS port ORed VALID|region into every slot, which is why
v4.36 firmware still faults on the guard while v4.37+ lets an app stack
overflow walk into the kernel heap unnoticed.
Keep VALID|region on empty slots (RASR stays 0, so the region is simply
disabled). ARMv8-M selects the region through RNR and the aliases and is
unaffected.
Observed on qemu_flint: with the App thread running, region 6 read back
as RBAR=0x6 RASR=0 while the thread's saved MPU words held the guard.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>1 parent 185551c commit 14fd25c
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
155 | | - | |
156 | | - | |
| 160 | + | |
157 | 161 | | |
158 | 162 | | |
159 | 163 | | |
| |||
0 commit comments