Received: from eggs.gnu.org ([2001:4830:134:3::10]:50246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF437-0003om-L3 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 11:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF432-0002Im-QT for qemu-devel@nongnu.org; Thu, 29 Aug 2013 11:22:17 -0400 Received: from mail-qc0-x22a.google.com ([2607:f8b0:400d:c01::22a]:49858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF432-0002Ig-Lt for qemu-devel@nongnu.org; Thu, 29 Aug 2013 11:22:12 -0400 Received: by mail-qc0-f170.google.com with SMTP id i8so301109qcq.15 for ; Thu, 29 Aug 2013 08:22:12 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Thu, 29 Aug 2013 08:21:37 -0700 Message-Id: <1377789697-12561-1-git-send-email-rth@twiddle.net> References: <20130828225553.GA732@redhat.com> Subject: [Qemu-devel] [PATCH] tcg-i386: Remove abort from GETPC_LDST List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: anthony@codemonkey.ws, aurelien@aurel32.net, rjones@redhat.com 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 --- 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 -- 1.8.1.4