On Wed, Feb 7, 2018 at 1:29 PM, Dominik Brodowski <li...@dominikbrodowski.net> wrote: >> >> So this removes lines of asm code, but it adds a lot of instructions >> to the end result thanks to the macro, I think. > > Indeed, that is the case (see below). However, if we want to switch to > PUSH instructions and do this in a routine which is call'ed and which > ret'urns, %rsp needs to be moved around even more often than the old > ALLOC_PT_GPREGS_ON_STACK macro did (which you wanted to get rid of, > IIUYC). Or do I miss something?
So I agree that your approach makes for a lot simpler stack setup. I was just hoping that we could play some tricks. For example, right now your PUSH_AND_CLEAR_REGS starts off with pushq %rdi /* pt_regs->di */ pushq %rsi /* pt_regs->si */ pushq %rdx /* pt_regs->dx */ pushq %rcx /* pt_regs->cx */ .... and maybe we could still use this in paranoid_entry and error_entry if we made it something like /* if 'save_ret' is set, we pop the return point into %rsi */ .macro PUSH_AND_CLEAR_REGS save_ret=0 .if \save_ret pushq %%rsi movq 8(%%rsp),%rsi movq %%rdi,8(%%rsp) .else pushq %rdi /* pt_regs->di */ pushq %rsi /* pt_regs->si */ .endif pushq %rdx /* pt_regs->dx */ pushq %rcx /* pt_regs->cx */ .... which would allow error_entry and paranoid_entry to do something like this: PUSH_AND_CLEAR_REGS save_ret=1 pushq %rsi ... do the other common code .. ret (totally untested, I'm just doing a "stream-of-consciousness" thing in the email. See what I'm saying? That said, maybe the pushq sequence is now so small that it doesn't even matter, and duplicating it isn't a big problem. Because your version sure is simpler. Linus