From patchwork Fri Feb 27 05:46:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 5897901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0D647BF440 for ; Fri, 27 Feb 2015 05:49:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 239462021B for ; Fri, 27 Feb 2015 05:49:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23F2C20218 for ; Fri, 27 Feb 2015 05:48:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YRDlC-00088q-G7; Fri, 27 Feb 2015 05:46:50 +0000 Received: from mail-yk0-x22b.google.com ([2607:f8b0:4002:c07::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YRDl7-000803-LQ for linux-arm-kernel@lists.infradead.org; Fri, 27 Feb 2015 05:46:46 +0000 Received: by ykr200 with SMTP id 200so6292906ykr.12 for ; Thu, 26 Feb 2015 21:46:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=rnre6NGZdZ5R/bdhncbPakqxedgXEFXiYHgvZe6LtwY=; b=VjwNXP/FYY+Q1LelTy/meo7WrPr7DG0IZP6ii8+gFs0Z9Qbs3w0WVfG9AORcXJitcS sfoH7xfW+ikh4xaBmUvV01raOa8ywah8LvlTomxql/nrwYU1SfdnIOv/AmixnxR1LMlk Tzh508ixFmYpjYW5KtfjhV1+bBmt6xPY7u838dFs6mVgokF5EiFYs1Mov1wbF0PRO040 94a+C8s3EXw4/CTmya/1jxOwQLdMXMtHUxOUVu6NAubnZ0e+XmfrnGuoimPBs0bBTZ6X OSlbFXJi3wPkDqCooR/MdcYUO3eF1/1oaMv30bda8lAM3Gd4U5qimggruVghsjDN/Tzz PUNQ== X-Received: by 10.236.14.101 with SMTP id c65mr11605720yhc.159.1425015982401; Thu, 26 Feb 2015 21:46:22 -0800 (PST) Received: from evgadesktop.attlocal.net (108-232-152-155.lightspeed.tukrga.sbcglobal.net. [108.232.152.155]) by mx.google.com with ESMTPSA id v6sm2411188yhg.47.2015.02.26.21.46.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Feb 2015 21:46:21 -0800 (PST) From: Pranith Kumar To: Catalin Marinas , Will Deacon , Steve Capper , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org (open list) Subject: [RFC PATCH] ARM64: cmpxchg.h: Clear the exclusive access bit on fail Date: Fri, 27 Feb 2015 00:46:55 -0500 Message-Id: <1425016026-19766-1-git-send-email-bobby.prani@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150226_214645_759665_0514116D X-CRM114-Status: UNSURE ( 9.10 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.8 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In cmpxchg(), we do a load exclusive on an address and upon a comparison fail, we skip the store exclusive instruction. This can result in the exclusive bit still set. If there was a store exclusive after this to the same address, that will see the exclusive bit set. This should not happen. We need to clear the exclusive bit in these cases. Signed-off-by: Pranith Kumar --- arch/arm64/include/asm/cmpxchg.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h index cb95930..ed2cf90 100644 --- a/arch/arm64/include/asm/cmpxchg.h +++ b/arch/arm64/include/asm/cmpxchg.h @@ -94,7 +94,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, " cmp %w1, %w3\n" " b.ne 1f\n" " stxrb %w0, %w4, %2\n" - "1:\n" + "1: clrex\n" : "=&r" (res), "=&r" (oldval), "+Q" (*(u8 *)ptr) : "Ir" (old), "r" (new) : "cc"); @@ -109,7 +109,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, " cmp %w1, %w3\n" " b.ne 1f\n" " stxrh %w0, %w4, %2\n" - "1:\n" + "1: clrex\n" : "=&r" (res), "=&r" (oldval), "+Q" (*(u16 *)ptr) : "Ir" (old), "r" (new) : "cc"); @@ -124,7 +124,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, " cmp %w1, %w3\n" " b.ne 1f\n" " stxr %w0, %w4, %2\n" - "1:\n" + "1: clrex\n" : "=&r" (res), "=&r" (oldval), "+Q" (*(u32 *)ptr) : "Ir" (old), "r" (new) : "cc"); @@ -139,7 +139,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, " cmp %1, %3\n" " b.ne 1f\n" " stxr %w0, %4, %2\n" - "1:\n" + "1: clrex\n" : "=&r" (res), "=&r" (oldval), "+Q" (*(u64 *)ptr) : "Ir" (old), "r" (new) : "cc"); @@ -173,7 +173,7 @@ static inline int __cmpxchg_double(volatile void *ptr1, volatile void *ptr2, " mov %w0, #0\n" " cbnz %1, 1f\n" " stxp %w0, %5, %6, %2\n" - "1:\n" + "1: clrex\n" : "=&r"(loop), "=&r"(lost), "+Q" (*(u64 *)ptr1) : "r" (old1), "r"(old2), "r"(new1), "r"(new2)); } while (loop);