Commit 23d6a81
committed
mchp: Remove undefined behavior in espi msvw handlers
The code in espi_msvw[12]_interrupt relies on undefined behavior today.
__builtin_ctz is specified as returning values in the range [0, 31], but
we are checking for 32.
This behavior may be unexpected compared to the CTZ/CLZ instruction on
ARM, which use the value 32 to indicate that there are no ones in the
provided input.
GCC 11+ optimizes the two loops below into infinite loops, as it can see
that the condition will never be met.
After this change, the disassembly of espi_mswv1_interrupt can be
confirmed to contain an exit behind a branch.
... // r4 is loaded with girq24_result and has bits successively cleared
1a: b90c cbnz r4, 20 <espi_mswv1_interrupt+0x20>
1c: e8bd 81f0 ldmia.w sp!, {r4, r5, r6, r7, r8, pc}
20: fa94 f5a4 rbit r5, r4
...
BUG=EmbeddedController#21
BRANCH=hx20-hx30
TEST=Examined the disassembly for espi_msvw[12]_interrupt; see above
Signed-off-by: Dustin L. Howett <dustin@howett.net>1 parent 38c1b38 commit 23d6a81
1 file changed
+4
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1238 | 1238 | | |
1239 | 1239 | | |
1240 | 1240 | | |
1241 | | - | |
1242 | | - | |
| 1241 | + | |
| 1242 | + | |
1243 | 1243 | | |
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
1247 | | - | |
1248 | 1247 | | |
1249 | 1248 | | |
1250 | 1249 | | |
| |||
1259 | 1258 | | |
1260 | 1259 | | |
1261 | 1260 | | |
1262 | | - | |
1263 | | - | |
| 1261 | + | |
| 1262 | + | |
1264 | 1263 | | |
1265 | 1264 | | |
1266 | 1265 | | |
1267 | 1266 | | |
1268 | | - | |
1269 | 1267 | | |
1270 | 1268 | | |
1271 | 1269 | | |
| |||
0 commit comments