From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.128.44; helo=mail-wm1-f44.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 B830B21161208 for ; Mon, 1 Oct 2018 03:27:00 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id o2-v6so8145727wmh.5 for ; Mon, 01 Oct 2018 03:27:00 -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=ItPG1f1n/J7c/qKM6xvLzkz+BTPZjRXOsvTpA5L9LWI=; b=XjDuqu6PA04Eny1GOVxkTHCDGPXNHaSp64DfsaN8Eap0kRmTHVCfNszZctpdi4l7nZ qiiwnQudY8u4FXPEzcCDXE7+e4EGFMDrVmxsHBKTII4yeINL9QkQomBSDrMZ5KysrFbM CDrtANJih16WqZ6MEv17/OfK7rFuDU/yZYmTLP5jRTNn62cuqB4YNHRn6JcIW6Iw4pnm JEsc9HToEgUHt7+5C/FVN6T9uOHYShnapBzlPzX4rIqp+Xsn561yoJcU4vt1Z8oEjwsH GDqjzYh9uabCVl41H6TGP+8ocSISIQJbc7PLb+IYIDKmS3B7F5MOqUvrapXpI/GZgidh myCA== X-Gm-Message-State: ABuFfojd4BmJWpnK+odz4//n4a7lz5hn25QolXEOhHreBuFtQd6BUpch IUKzs7RGVejqQf2irbfhprIjEQ== X-Google-Smtp-Source: ACcGV62IPiMJAdOSypl8uQvoTFxaWN3HIEWe83Gk9Snq/VUSlUXtB+2Qo12n+HA/jybJzS5behFHyw== X-Received: by 2002:a1c:2142:: with SMTP id h63-v6mr9107255wmh.51.1538389619140; Mon, 01 Oct 2018 03:26:59 -0700 (PDT) Received: from [192.168.2.71] ([80.31.72.241]) by smtp.gmail.com with ESMTPSA id v6-v6sm10553422wro.66.2018.10.01.03.26.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 03:26:58 -0700 (PDT) To: Laszlo Ersek , edk2-devel-01 Cc: Michael D Kinney , Liming Gao References: <20180929222312.32150-1-lersek@redhat.com> <20180929222312.32150-4-lersek@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Mon, 1 Oct 2018 12:26:57 +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-4-lersek@redhat.com> Subject: Re: [PATCH 3/5] MdePkg/BaseSynchronizationLib GCC: fix InternalSyncCompareExchange32() 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:27:01 -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 last one, except for the > InternalSyncCompareExchange16() -> InternalSyncCompareExchange32() and > "cmpxchgw" -> "cmpxchgl" 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 IA32 version of InternalSyncCompareExchange32() correctly marks > CompareValue as input/output, but it marks (*Value) only as input. > > The X64 version of InternalSyncCompareExchange32() 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/Ia32/GccInline.c | 9 ++++----- > MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c | 10 ++++------ > 2 files changed, 8 insertions(+), 11 deletions(-) > > diff --git a/MdePkg/Library/BaseSynchronizationLib/Ia32/GccInline.c b/MdePkg/Library/BaseSynchronizationLib/Ia32/GccInline.c > index bd98a5aebfe7..44188e265af2 100644 > --- a/MdePkg/Library/BaseSynchronizationLib/Ia32/GccInline.c > +++ b/MdePkg/Library/BaseSynchronizationLib/Ia32/GccInline.c > @@ -155,11 +155,10 @@ InternalSyncCompareExchange32 ( > { > __asm__ __volatile__ ( > "lock \n\t" > - "cmpxchgl %1, %2 \n\t" > - : "=a" (CompareValue) // %0 > - : "q" (ExchangeValue), // %1 > - "m" (*Value), // %2 > - "0" (CompareValue) // %3 > + "cmpxchgl %2, %1 \n\t" > + : "+a" (CompareValue), // %0 > + "+m" (*Value) // %1 > + : "q" (ExchangeValue) // %2 > : "memory", > "cc" > ); > diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c > index 4338fb8e65e8..a85cf0265c8b 100644 > --- a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c > +++ b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c > @@ -155,12 +155,10 @@ InternalSyncCompareExchange32 ( > { > __asm__ __volatile__ ( > "lock \n\t" > - "cmpxchgl %3, %1 \n\t" > - : "=a" (CompareValue), // %0 > - "=m" (*Value) // %1 > - : "a" (CompareValue), // %2 > - "r" (ExchangeValue), // %3 > - "m" (*Value) // %4 > + "cmpxchgl %2, %1 \n\t" > + : "+a" (CompareValue), // %0 > + "+m" (*Value) // %1 > + : "r" (ExchangeValue) // %2 > : "memory", > "cc" > ); >