Received: from eggs.gnu.org ([2001:4830:134:3::10]:48028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5cj1-0002TM-W2 for qemu-devel@nongnu.org; Wed, 25 May 2016 13:36:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5cix-00036K-TC for qemu-devel@nongnu.org; Wed, 25 May 2016 13:36:06 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:34391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5cix-00036E-Op for qemu-devel@nongnu.org; Wed, 25 May 2016 13:36:03 -0400 Received: by mail-qk0-x244.google.com with SMTP id i7so6568384qkd.1 for ; Wed, 25 May 2016 10:36:03 -0700 (PDT) Sender: Richard Henderson References: <20160524171856.1000-1-bobby.prani@gmail.com> <20160524171856.1000-3-bobby.prani@gmail.com> From: Richard Henderson Message-ID: <8a9b6d4e-278a-08b5-d1fb-d66e28e8e3ac@twiddle.net> Date: Wed, 25 May 2016 10:35:59 -0700 MIME-Version: 1.0 In-Reply-To: <20160524171856.1000-3-bobby.prani@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 2/3] tcg: Add support for fence generation in x86 backend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pranith Kumar , Peter Maydell , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Sergey Fedorov , "open list:i386 target" On 05/24/2016 10:18 AM, Pranith Kumar wrote: > Signed-off-by: Pranith Kumar > --- > tcg/i386/tcg-target.h | 1 + > tcg/i386/tcg-target.inc.c | 9 +++++++++ > tcg/tcg-opc.h | 2 +- > tcg/tcg.c | 1 + > 4 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h > index 92be341..93ea42e 100644 > --- a/tcg/i386/tcg-target.h > +++ b/tcg/i386/tcg-target.h > @@ -100,6 +100,7 @@ extern bool have_bmi1; > #define TCG_TARGET_HAS_muls2_i32 1 > #define TCG_TARGET_HAS_muluh_i32 0 > #define TCG_TARGET_HAS_mulsh_i32 0 > +#define TCG_TARGET_HAS_fence 1 This has to be defined for all hosts. The default implementation should be a function call into tcg-runtime.c that calls smp_mb(). > @@ -347,6 +347,7 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, > #define OPC_SHRX (0xf7 | P_EXT38 | P_SIMDF2) > #define OPC_TESTL (0x85) > #define OPC_XCHG_ax_r32 (0x90) > +#define OPC_MFENCE (0xAE | P_EXT) > > #define OPC_GRP3_Ev (0xf7) > #define OPC_GRP5 (0xff) > @@ -686,6 +687,14 @@ static inline void tcg_out_pushi(TCGContext *s, tcg_target_long val) > } > } > > +static inline void tcg_out_fence(TCGContext *s) > +{ > + /* TODO: Figure out an appropriate place for the encoding */ > + tcg_out8(s, 0x0F); > + tcg_out8(s, 0xAE); > + tcg_out8(s, 0xF0); > +} Why define OPC_MFENCE if you're not going to use it? Of course, it's not exactly a complete and useful definition, so maybe just delete OPC_MFENCE. Also, for 32-bit you need to check for sse2 before outputting this. See also the existing cpuid checks in tcg_target_init and the fallback smp_mb definition for pre-gcc-4.4. r~