From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com
 [209.85.212.176]) by dpdk.org (Postfix) with ESMTP id C3A02C4C0
 for <dev@dpdk.org>; Mon, 29 Jun 2015 12:20:29 +0200 (CEST)
Received: by wicnd19 with SMTP id nd19so66873616wic.1
 for <dev@dpdk.org>; Mon, 29 Jun 2015 03:20:29 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:organization
 :user-agent:in-reply-to:references:mime-version
 :content-transfer-encoding:content-type;
 bh=SeDgsTa2H0u8Kg92eNXyN1qM3Ubqo56Q6gQpzoO4ghs=;
 b=gXyl3ISYUtknWVuzpddaYS40leqmnFYuudkVgIRZ8gK4cFQ4C6oINx0vPGpn6WKV3+
 zbs/TMrR6Od4LvTnwaRFMB/iAuLCjfilmZ28T9higTTjy1i/eBDIhBVrpm6IC+jVSKuD
 RzFNRlTi5pnt0V4DbF+dMx+0Uzh4VqbofV1/exbfHe0mLXwCGHHbLYDyBNufPoqvSpJv
 7w4YuY2hf61l+8uqhZedRzilMm5+1c8B9TgVSoWQjeJTkIyXLRz6mjX7asSnyUmIb+oJ
 jklR64FwMtd7ludBiL+fodtD76k2qaJ2la78twbisf8piaUzQ+J7ZE9PXkVYXvjttjpv
 nHRg==
X-Gm-Message-State: ALoCoQk1qqG+v19BhsDjw+Qbj4dBVRC39TBYO3mE/OeHLG8bWqJx3SAYmFy9iZR9nyPB0ffbiosl
X-Received: by 10.194.52.37 with SMTP id q5mr29591979wjo.122.1435573229607;
 Mon, 29 Jun 2015 03:20:29 -0700 (PDT)
Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136])
 by mx.google.com with ESMTPSA id q2sm63231549wjz.15.2015.06.29.03.20.28
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 29 Jun 2015 03:20:28 -0700 (PDT)
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: Roman Dementiev <roman.dementiev@intel.com>,
 Matthew Hall <mhall@mhcomputing.net>
Date: Mon, 29 Jun 2015 12:19:20 +0200
Message-ID: <2576181.dRfjlrHRWI@xps13>
Organization: 6WIND
User-Agent: KMail/4.14.8 (Linux/4.0.4-2-ARCH; KDE/4.14.8; x86_64; ; )
In-Reply-To: <386858255.20150629121137@intel.com>
References: <1A87AD2E-38CD-4C61-A9FD-C52608FF9DAC@mhcomputing.net>
 <39879033.dIVnPGkh8l@xps13> <386858255.20150629121137@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] RTM instruction compile failure for XABORT when AVX
	is active
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Jun 2015 10:20:30 -0000

2015-06-29 12:11, Roman Dementiev:
> >> On Jun 28, 2015, at 10:16 AM, Matthew Hall <mhall@mhcomputing.net> wrote:
> >> > I am getting a strange error compiling some RTM instructions when
> >> > I upgraded my VM environment from VirtualBox 4 to VirtualBox 5 and
> >> > AVX instructions from the host CPU became available. However when
> >> > I am reading the opcode description for XABORT it supposedly allows
> >> > an immediate operand for the argument so I can't understand why this
> >> > code would not compile. Any advice?
> >> > 
> >> >  CC test_hash_scaling.o
> >> > In file included from /vagrant/external/dpdk/app/test/test_hash_scaling.c:37:
> >> > In file included from /vagrant/external/dpdk/build/include/rte_spinlock.h:42:
> >> > /vagrant/external/dpdk/build/include/rte_rtm.h:56:15: error: invalid operand for inline asm constraint 'i'
> >> >        asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory");

There is no such bug with my compiler:
	clang version 3.6.1 (tags/RELEASE_361/final)
	Target: x86_64-unknown-linux-gnu

Matthew, which version are you using?

> It  looks  like  a  compiler  bug for me. In the meantime Clang should
> have native TSX intrinsics (but    most   compilers   fail   to   implement
> them correctly  on  a first attempt allowing instruction reordering). Could
> you try this workaround:
> 
> diff --git a/lib/librte_eal/common/include/arch/x86/rte_rtm.h b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
> index d935641..ee73dd4 100644
> --- a/lib/librte_eal/common/include/arch/x86/rte_rtm.h
> +++ b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
> @@ -50,10 +50,14 @@ void rte_xend(void)
>          asm volatile(".byte 0x0f,0x01,0xd5" ::: "memory");
>  }
> 
> +#include <immintrin.h>
> +
>  static __attribute__((__always_inline__)) inline
>  void rte_xabort(const unsigned int status)
>  {
> -       asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory");
> +       asm volatile(::: "memory");
> +       _xabort(status);
> +       asm volatile(::: "memory");
>  }
> 
>  static __attribute__((__always_inline__)) inline