Commit 9f0bd5c
SCB_DisableDCache: always clean/invalidate stack locals after D-Cache disable (#288)
## Summary
Always perform the cache clean/invalidate sequence for the
stack-resident local
variables in `SCB_DisableDCache()`, independent of the optimization
level.
## Motivation / Problem
The current implementation only does this when `__OPTIMIZE__` is not
defined.
However, even with optimization enabled (e.g. `-Og`), compilers may
still spill
locals to the stack depending on register pressure and code generation.
If D-Cache is disabled while relevant locals still reside in cacheable
stack
memory, stale values may later be read from RAM. This can lead to data
inconsistency and, in some cases, endless loops.
## Change
Remove the `!defined(__OPTIMIZE__)` guard so the local-variable cache
maintenance is always executed.
Related to #286
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 4097ab7 commit 9f0bd5c
1 file changed
Lines changed: 17 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
| |||
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
219 | | - | |
220 | | - | |
221 | | - | |
| 221 | + | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
0 commit comments