From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.221.44; helo=mail-wr1-f44.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 24126211575D3 for ; Mon, 1 Oct 2018 03:28:01 -0700 (PDT) Received: by mail-wr1-f44.google.com with SMTP id n1-v6so3139194wrt.10 for ; Mon, 01 Oct 2018 03:28:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CiWj9GKbwAh6EWyxH4wGRIjVIjHcMcx0dWwPTs6WlkQ=; b=qa+wtID4IlNs30NUFYibsefsI62l15S7K+7YelXtBvRzVxfTYeugO29cayJssmpMGp o/wguy5d1vJ0f8C+WbW4nzhUSlLnQ9rtgc27uPvZ4aWFXsyq45tJnLarrnyjlx9PBmHG LXJyKauGnioLp1y8fnkNio8HyhbJ6vo0SXh+EwaAv59K4OvtzaNX2UN2nKARqYtongWG 0baBtCsv4OZl3eGJEhFrulysBBv4mDo4pTV+tv8YnEeR7elRftqqdxCfgXi+yyJt3TKG SX4c40LKkWvEgsofmuY9Bw6HSoK7HufhdjuelARYIyoQu6yHNVQrlvcEWgVAh3hK8Lqw ukrQ== X-Gm-Message-State: ABuFfohU85HovuSuszm8EDhl/uQgGGsQsKNr5Il3C554eXphSSqM+W/A gGgyulXe25m7azfYwrYGWSswhQ== X-Google-Smtp-Source: ACcGV61jJsWIgHTuXgkAaaKgVohdq/F6YPrDxF0/mFIqly965JDcp3ixeAu0mSvt4Hhf0zFiLcz0GQ== X-Received: by 2002:adf:8385:: with SMTP id 5-v6mr6457891wre.13.1538389680476; Mon, 01 Oct 2018 03:28:00 -0700 (PDT) Received: from [192.168.2.71] ([80.31.72.241]) by smtp.gmail.com with ESMTPSA id k5-v6sm15323128wrc.14.2018.10.01.03.27.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 03:27:59 -0700 (PDT) To: Laszlo Ersek , edk2-devel-01 Cc: Michael D Kinney , Liming Gao References: <20180929222312.32150-1-lersek@redhat.com> <20180929222312.32150-5-lersek@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Mon, 1 Oct 2018 12:27:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180929222312.32150-5-lersek@redhat.com> Subject: Re: [PATCH 4/5] MdePkg/BaseSynchronizationLib GCC: fix X64 InternalSyncCompareExchange64() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2018 10:28:02 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 30/09/2018 00:23, Laszlo Ersek wrote: > (This patch is identical to the X64 half of the last one, except for the > InternalSyncCompareExchange32() -> InternalSyncCompareExchange64() and > "cmpxchgl" -> "cmpxchgq" replacements.) > > The CMPXCHG instruction has the following operands: > - AX (implicit, CompareValue): input and output > - destination operand (*Value): input and output > - source operand (ExchangeValue): input > > The X64 version of InternalSyncCompareExchange64() attempts to mark both > CompareValue and (*Value) as input/output, but it doesn't use the > appropriate constraints for either operand. > > Fix these issues. Furthermore, prefer the short "+" constraint for I/O > operands over the constraint that can be applied > to the input instances of I/O operands. > > Cc: Liming Gao > Cc: Michael D Kinney > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1208 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daudé > --- > MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c > index a85cf0265c8b..edb904c00704 100644 > --- a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c > +++ b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c > @@ -194,12 +194,10 @@ InternalSyncCompareExchange64 ( > { > __asm__ __volatile__ ( > "lock \n\t" > - "cmpxchgq %3, %1 \n\t" > - : "=a" (CompareValue), // %0 > - "=m" (*Value) // %1 > - : "a" (CompareValue), // %2 > - "r" (ExchangeValue), // %3 > - "m" (*Value) // %4 > + "cmpxchgq %2, %1 \n\t" > + : "+a" (CompareValue), // %0 > + "+m" (*Value) // %1 > + : "r" (ExchangeValue) // %2 > : "memory", > "cc" > ); >