[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFxyBrF+2uZYN7dfVJ4MFgfxEQPFWGqBAueRne4LWJP0QA@mail.gmail.com>
Date: Wed, 7 Feb 2018 13:58:20 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Dominik Brodowski <linux@...inikbrodowski.net>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
"the arch/x86 maintainers" <x86@...nel.org>,
Dan Williams <dan.j.williams@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
Andi Kleen <ak@...ux.intel.com>,
Andrew Lutomirski <luto@...nel.org>
Subject: Re: [RFC v2 PATCH 6/7] x86/entry: get rid of ALLOC_PT_GPREGS_ON_STACK
and SAVE_AND_CLEAR_REGS
On Wed, Feb 7, 2018 at 1:29 PM, Dominik Brodowski
<linux@...inikbrodowski.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
Powered by blists - more mailing lists