All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws, rjones@redhat.com
Subject: Re: [Qemu-devel] [PATCH] tcg-i386: Remove abort from GETPC_LDST
Date: Thu, 29 Aug 2013 21:13:18 +0200	[thread overview]
Message-ID: <20130829191318.GI23739@ohm.aurel32.net> (raw)
In-Reply-To: <1377789697-12561-1-git-send-email-rth@twiddle.net>

On Thu, Aug 29, 2013 at 08:21:37AM -0700, Richard Henderson wrote:
> Indeed, remove it entirely and remove the is_tcg_gen_code check
> from GETPC_EXT.
> 
> Fixes https://bugs.launchpad.net/qemu/+bug/1218098 wherein a call
> to a "normal" helper function performed a sequence of tail calls
> all the way into the memory helper functions, leading to a stack
> frame in which the memory helper function appeared to be called
> directly from tcg.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  include/exec/exec-all.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> This is actually conclusive proof that using is_tcg_gen_code, and
> thus any scheme that requires GETPC_LDST, is fundamentally flawed.
> 
> Thankfully, the follow-up patch sets that I've already posted give
> a framework for properly fixing this.  I've already posted a cleanup
> for ARM to fix this.  I have pending but unposted patch sets for
> AArch64 and PowerPC.
> 
> In the meantime, please apply this fix for x86_64 asap.
> 
> 
> r~
> 
> 
> 
> diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
> index b70028a..ffb69a4 100644
> --- a/include/exec/exec-all.h
> +++ b/include/exec/exec-all.h
> @@ -326,9 +326,7 @@ extern uintptr_t tci_tb_ptr;
>     (6) jump to corresponding code of the next of fast path
>   */
>  # if defined(__i386__) || defined(__x86_64__)
> -#  define GETRA() ((uintptr_t)__builtin_return_address(0))
> -/* The return address argument for ldst is passed directly.  */
> -#  define GETPC_LDST()  (abort(), 0)
> +#  define GETPC_EXT()  GETPC()
>  # elif defined (_ARCH_PPC) && !defined (_ARCH_PPC64)
>  #  define GETRA() ((uintptr_t)__builtin_return_address(0))
>  #  define GETPC_LDST() ((uintptr_t) ((*(int32_t *)(GETRA() - 4)) - 1))
> @@ -349,7 +347,7 @@ static inline uintptr_t tcg_getpc_ldst(uintptr_t ra)
>                                     not the start of the next opcode  */
>      return ra;
>  }
> -#elif defined(__aarch64__)
> +# elif defined(__aarch64__)
>  #  define GETRA()       ((uintptr_t)__builtin_return_address(0))
>  #  define GETPC_LDST()  tcg_getpc_ldst(GETRA())
>  static inline uintptr_t tcg_getpc_ldst(uintptr_t ra)
> @@ -367,7 +365,9 @@ static inline uintptr_t tcg_getpc_ldst(uintptr_t ra)
>  #  error "CONFIG_QEMU_LDST_OPTIMIZATION needs GETPC_LDST() implementation!"
>  # endif
>  bool is_tcg_gen_code(uintptr_t pc_ptr);
> -# define GETPC_EXT() (is_tcg_gen_code(GETRA()) ? GETPC_LDST() : GETPC())
> +# ifndef GETPC_EXT
> +#  define GETPC_EXT() (is_tcg_gen_code(GETRA()) ? GETPC_LDST() : GETPC())
> +# endif
>  #else
>  # define GETPC_EXT() GETPC()
>  #endif

Thanks, applied.


-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  parent reply	other threads:[~2013-08-29 19:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-26 21:00 [Qemu-devel] [PULL 0/7] Improve tcg ldst optimization Richard Henderson
2013-08-26 21:00 ` [Qemu-devel] [PULL 1/7] tcg: Tidy generated code for tcg_outN Richard Henderson
2013-08-26 21:00 ` [Qemu-devel] [PULL 2/7] tcg-i386: Add and use tcg_out64 Richard Henderson
2013-08-26 21:00 ` [Qemu-devel] [PULL 3/7] tcg-i386: Try pc-relative lea for constant formation Richard Henderson
2013-08-26 21:00 ` [Qemu-devel] [PULL 4/7] tcg-i386: Tidy qemu_ld/st slow path Richard Henderson
2013-08-26 21:00 ` [Qemu-devel] [PULL 5/7] tcg: Add mmu helpers that take a return address argument Richard Henderson
2013-08-26 22:26   ` Paolo Bonzini
2013-08-26 22:34     ` Richard Henderson
2013-08-27 10:46       ` Aurelien Jarno
2013-08-27 14:53         ` Richard Henderson
2013-08-27 15:43           ` Aurelien Jarno
2013-08-27 15:53             ` Richard Henderson
2013-08-26 23:26   ` Peter Maydell
2013-08-27 10:47     ` Aurelien Jarno
2013-08-26 21:00 ` [Qemu-devel] [PULL 6/7] tcg: Tidy softmmu_template.h Richard Henderson
2013-08-26 21:00 ` [Qemu-devel] [PULL 7/7] tcg-i386: Use new return-argument ld/st helpers Richard Henderson
2013-08-28 22:55   ` Richard W.M. Jones
2013-08-29 15:21     ` [Qemu-devel] [PATCH] tcg-i386: Remove abort from GETPC_LDST Richard Henderson
2013-08-29 15:28       ` Paolo Bonzini
2013-08-29 15:32         ` Richard Henderson
2013-08-29 15:50       ` Richard W.M. Jones
2013-08-29 19:13       ` Aurelien Jarno [this message]
2013-08-27 21:30 ` [Qemu-devel] [PULL 0/7] Improve tcg ldst optimization Aurelien Jarno

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=20130829191318.GI23739@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=rth@twiddle.net \
    /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.