On Sun, Jul 21, 2024 at 8:33 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > Aside from testing I agree with Andrii regarding rbp usage, > it seems like it should be possible to do the following in prologue: > > movabs $0x...,%rsp > add %gs:0x...,%rsp > push %rbp > > and there would be no need to modify translation for instructions > accessing r10, plus debugger stack unrolling logic should still work?. > Or am I mistaken? It's not that simple. Above sequence violates -mno-red-zone. The part of the fix may look like: movabs .., rax add %gs.., rax mov rbp, qword ptr [rax - ...] mov rax, rsp mox rax, rbp sub rsp, ... it's probably correct from mno-red-zone pov and end result is maybe correct for stack unwind, but if irq happens in the middle it won't crash, but unwind will not work. The main reason to use r9 is to have valid unwind at any point of the prog.