From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Hunt, David" Subject: Re: [PATCH] eal: fix bug in x86 cmpset Date: Fri, 10 Feb 2017 10:39:18 +0000 Message-ID: References: <1475184293-18298-1-git-send-email-nikhil.rao@intel.com> <4122748.D2hJ4kS1ho@xps13> <2431986.cxPJYuksjQ@xps13> <1919498.PKpEFfz702@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Thomas Monjalon , Nikhil Rao , bruce.richardson@intel.com, Konstantin Ananyev Return-path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 922883B5 for ; Fri, 10 Feb 2017 11:39:21 +0100 (CET) In-Reply-To: <1919498.PKpEFfz702@xps13> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 9/2/2017 4:53 PM, Thomas Monjalon wrote: > 2016-11-06 22:09, Thomas Monjalon: >> 2016-09-29 18:34, Thomas Monjalon: >>> 2016-09-30 02:54, Nikhil Rao: >>>> The original code used movl instead of xchgl, this caused >>>> rte_atomic64_cmpset to use ebx as the lower dword of the source >>>> to cmpxchg8b instead of the lower dword of function argument "src". >>> Could you please start the explanation with a statement of >>> what is wrong from an user point of view? >>> It could help to understand how severe it is. >> Please, we need a clear explanation of the bug, and an acknowledgement. > Should we close this bug? I took a few minutes to look at this, and the issue can easily be reproduced with a small snippet of code. With the 'mov', the lower dword of the result is incorrect. This is resolved by using 'xchgl'. void main() { uint64_t a = 0xff000000ff; rte_atomic64_cmpset( &a, 0xff000000ff, 0xfa000000fa); printf("0x%lx\n", a); } When using 'mov', the result is 0xfa00000000 When using 'xchgl', the result is 0xfa000000fa, as expected. Rgds, Dave.