[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/5] x86/ELF: don't store function pointer in elf_core_save_regs()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 28 Sep 2020 13:58:40 +0100
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 28 Sep 2020 12:58:52 +0000
  • Ironport-sdr: odH9elqLJTQX+mCXMUfImjkEOOWFRH2Ch5apWAVzhoWkItW20MGkTT7AY1yZv6h1phiVw5TahB GL307L3FAiEZwATYK7MFCvBoHT9lQpBTAivbRKzE+/cz0ylsnoGmwI4QubOvUiPso8TIIb8V6Y auf6KtWvilTH7zdyVB9CXG/f6LwzHwJKydAGlOR2l0KqPs39F0BQgwNryzBKnan7ii/crmpU+F G232in4JUqpHk/7jDllmUf/Y6Q1U3L23CgTyExCN2ja+n0JV/xntN+YrijZ8uOrLJCPWJc/WRk rmQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
>
> --- 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@xxxxxxxxxx>

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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.