mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Brian Gerst <brgerst@gmail.com>,
	Andrew Lutomirski <luto@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Dan Williams <dan.j.williams@intel.com>
Subject: [PATCH] x86/entry/64: Simplify ENCODE_FRAME_POINTER
Date: Tue, 20 Feb 2018 20:42:14 -0600	[thread overview]
Message-ID: <20180221024214.lhl5jfgw33c4vz3m@treble> (raw)
In-Reply-To: <CA+55aFx=moDaKj3Ogc_Fvm0vKQ1DP=yA9UE3axmpECyv3Khi1Q@mail.gmail.com>

On Tue, Feb 20, 2018 at 02:25:03PM -0800, Linus Torvalds wrote:
> On Tue, Feb 20, 2018 at 1:01 PM, Dominik Brodowski
> <linux@dominikbrodowski.net> wrote:
> > +ENTRY(interrupt_entry)
> > +       UNWIND_HINT_FUNC
> > +
> > +       PUSH_AND_CLEAR_REGS save_ret=1
> > +       ENCODE_FRAME_POINTER 8
> > +
> > +       ret
> > +END(interrupt_entry)
> 
> There's nothing wrong with this patch, but it does expose what a nasty
> hack our "ENCODE_FRAME_POINTER" thing is.
> 
> It generates (when there is an offset, like this):
> 
>         leaq \ptregs_offset(%rsp), %rbp
>         orq     $0x1, %rbp
> 
> and I would _really_ hope that the stack pointer is always aligned on
> interrupt entry, so I don't see why it's not just
> 
>         leaq 1+\ptregs_offset(%rsp), %rbp
> 
> instead.
> 
> I dunno. Let's ask Josh what the reason for the separate "or" was.
> 
> But this is an independent issue of this patch, really.

Indeed, how about this?

----

From: Josh Poimboeuf <jpoimboe@redhat.com>
Subject: [PATCH] x86/entry/64: Simplify ENCODE_FRAME_POINTER

On 64-bit, the stack pointer is always aligned on interrupt, so instead
of setting the LSB of the pt_regs address, we can just add 1 to it.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/entry/calling.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
index dce7092ab24a..400cea8bbf4b 100644
--- a/arch/x86/entry/calling.h
+++ b/arch/x86/entry/calling.h
@@ -172,12 +172,7 @@ For 32-bit we have the following conventions - kernel is built with
  */
 .macro ENCODE_FRAME_POINTER ptregs_offset=0
 #ifdef CONFIG_FRAME_POINTER
-	.if \ptregs_offset
-		leaq \ptregs_offset(%rsp), %rbp
-	.else
-		mov %rsp, %rbp
-	.endif
-	orq	$0x1, %rbp
+	leaq 1+\ptregs_offset(%rsp), %rbp
 #endif
 .endm
 
-- 
2.14.3

  reply	other threads:[~2018-02-21  2:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 21:01 [RFC PATCH v3 0/6] x86/entry/64: interrupt entry size reduction Dominik Brodowski
2018-02-20 21:01 ` [RFC PATCH v3 1/6] x86/entry/64: move PUSH_AND_CLEAR_REGS from interrupt macro to helper function Dominik Brodowski
2018-02-20 22:25   ` Linus Torvalds
2018-02-21  2:42     ` Josh Poimboeuf [this message]
2018-02-21 10:50       ` [tip:x86/pti] x86/entry/64: Simplify ENCODE_FRAME_POINTER tip-bot for Josh Poimboeuf
2018-02-21 17:03       ` tip-bot for Josh Poimboeuf
2018-02-21 10:45   ` [tip:x86/pti] x86/entry/64: Move PUSH_AND_CLEAR_REGS from interrupt macro to helper function tip-bot for Dominik Brodowski
2018-02-21 16:58   ` tip-bot for Dominik Brodowski
2018-02-20 21:01 ` [RFC PATCH v3 2/6] x86/entry/64: move ENTER_IRQ_STACK from interrupt macro to interrupt_entry Dominik Brodowski
2018-02-21 10:46   ` [tip:x86/pti] x86/entry/64: Move " tip-bot for Dominik Brodowski
2018-02-21 16:59   ` tip-bot for Dominik Brodowski
2018-02-20 21:01 ` [RFC PATCH v3 3/6] x86/entry/64: move switch_to_thread_stack " Dominik Brodowski
2018-02-21 10:46   ` [tip:x86/pti] x86/entry/64: Move the switch_to_thread_stack() call to interrupt_entry() tip-bot for Dominik Brodowski
2018-02-21 16:59   ` tip-bot for Dominik Brodowski
2018-02-20 21:01 ` [RFC PATCH v3 4/6] x86/entry/64: remove interrupt macro Dominik Brodowski
2018-02-21 10:47   ` [tip:x86/pti] x86/entry/64: Remove 'interrupt' macro tip-bot for Dominik Brodowski
2018-02-21 17:00   ` tip-bot for Dominik Brodowski
2018-02-20 21:01 ` [RFC PATCH v3 5/6] x86/entry/64: move ASM_CLAC to interrupt_entry Dominik Brodowski
2018-02-21 10:47   ` [tip:x86/pti] x86/entry/64: Move ASM_CLAC to interrupt_entry() tip-bot for Dominik Brodowski
2018-02-21 17:00   ` tip-bot for Dominik Brodowski
2018-02-20 21:01 ` [RFC PATCH v3 6/6] x86/entry/64: open-code switch_to_thread_stack Dominik Brodowski
2018-02-21 10:48   ` [tip:x86/pti] x86/entry/64: Open-code switch_to_thread_stack() tip-bot for Dominik Brodowski
2018-02-21 17:01   ` tip-bot for Dominik Brodowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180221024214.lhl5jfgw33c4vz3m@treble \
    --to=jpoimboe@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=brgerst@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®