All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH 3/5] x86/ELF: don't store function pointer in elf_core_save_regs()
Date: Mon, 28 Sep 2020 13:58:40 +0100	[thread overview]
Message-ID: <33b47445-8de4-24f0-69b0-74119f10d7e9@citrix.com> (raw)
In-Reply-To: <8abe7016-1cd7-246e-24ef-92d92ff27ad3@suse.com>

On 28/09/2020 13:06, Jan Beulich wrote:
> This keeps at least gcc 10 from generating a separate function instance
> in common/kexec.o alongside the inlining of the function in its sole
> caller. I also think putting the address of the actual code storing the
> registers is a better indication to consumers than that of an otherwise
> unreferenced function.

Hmm - that's unfortunate.

elf_core_save_regs is certainly a useful name to spot in a backtrace.

> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/include/asm-x86/x86_64/elf.h
> +++ b/xen/include/asm-x86/x86_64/elf.h
> @@ -54,7 +54,7 @@ static inline void elf_core_save_regs(EL
>      asm volatile("movq %%rsi,%0" : "=m"(core_regs->rsi));
>      asm volatile("movq %%rdi,%0" : "=m"(core_regs->rdi));
>      /* orig_rax not filled in for now */
> -    core_regs->rip = (unsigned long)elf_core_save_regs;
> +    asm volatile("call 0f; 0: popq %0" : "=m" (core_regs->rip));

lea 0(%rip) will be faster to execute, and this is 64bit code specifically.

Either way, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

>      core_regs->cs = read_sreg(cs);
>      asm volatile("pushfq; popq %0" :"=m"(core_regs->rflags));
>      asm volatile("movq %%rsp,%0" : "=m"(core_regs->rsp));
>



  reply	other threads:[~2020-09-28 12:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 12:04 [PATCH 0/5] x86: introduce read_sregs() and elf_core_save_regs() adjustments Jan Beulich
2020-09-28 12:05 ` [PATCH 1/5] x86: introduce read_sregs() to allow storing to memory directly Jan Beulich
2020-09-28 12:47   ` Andrew Cooper
2020-09-28 13:29     ` Jan Beulich
2020-09-28 14:49     ` Jan Beulich
2020-09-28 15:11       ` Andrew Cooper
2020-09-28 12:05 ` [PATCH 2/5] x86/ELF: don't open-code read_sreg() Jan Beulich
2020-09-28 12:57   ` Andrew Cooper
2020-09-28 12:06 ` [PATCH 3/5] x86/ELF: don't store function pointer in elf_core_save_regs() Jan Beulich
2020-09-28 12:58   ` Andrew Cooper [this message]
2020-09-28 12:06 ` [PATCH 4/5] x86/ELF: also record FS/GS bases " Jan Beulich
2020-09-28 13:04   ` Andrew Cooper
2020-09-28 13:38     ` Jan Beulich
2020-09-28 12:07 ` [PATCH 5/5] x86/ELF: eliminate pointless local variable from elf_core_save_regs() Jan Beulich
2020-09-28 13:06   ` Andrew Cooper
2020-09-28 15:04 ` [PATCH 6/5] x86/ELF: drop unnecessary volatile from asm()-s in elf_core_save_regs() Jan Beulich
2020-09-28 15:15   ` Andrew Cooper
2020-09-28 15:40     ` Jan Beulich

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=33b47445-8de4-24f0-69b0-74119f10d7e9@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.