llvm-project
153e71e6 - [Hexagon] Add probe-stack=inline-asm support for stack clash protection (#190568)

Commit
21 days ago
[Hexagon] Add probe-stack=inline-asm support for stack clash protection (#190568) Large stack allocations can skip over guard pages, causing stack clash vulnerabilities. The probe-stack=inline-asm function attribute tells LLVM to emit inline probing code that touches each page during stack allocation, ensuring guard pages are hit. `framelimit` provides hardware bounds checking, but only on the allocframe instruction itself. SP decrements via A2_addi -- used for frames >= 16k bytes and all no-FP prologues bypass it. Software probing closes that gap. When the attribute is present and the frame size exceeds the probe size, the prologue now emits a PS_probed_stackalloc pseudo that inlineStackProbe() expands into a compare-and-branch loop: r29 = add(r29, #-ProbeSize) memw(r29+#0) = #0 p0 = cmp.gtu(r29, r28) if (p0) jump LoopMBB r29 = r28 Both the frame-pointer and no-frame-pointer prologue paths are handled. The stack-probe-size attribute is respected for custom probe sizes.
Author
Parents
Loading