From patchwork Thu Mar 7 09:14:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10842453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37BE914DE for ; Thu, 7 Mar 2019 09:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 220A92DE2E for ; Thu, 7 Mar 2019 09:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 137682E7B8; Thu, 7 Mar 2019 09:15:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5A3012DE2E for ; Thu, 7 Mar 2019 09:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M8+QAxRNultmOD07PxEaAApHwSQVCq9qo/ofeSRa9bg=; b=MOXypURFUTqiNR Cul9NH3lGCpXrCGmXffOTGoKfWZDYa9peMhWvUISt9nbTiYFpoDkDA2IDz0nEoIxRg8URkglc8/5v afE/XN9kZAxbVEMoacNA0YH6Pn1w2v1UmIwRJXeLQ9c/fkeFediQBT/fzWOLsEqn7GgAh+hBLQopn F0dOLygF3VHv5NuigHRFuV4EH08+tf847jyiZa1QK/yqaxIEArDLWPljBG5mxibvljU8CxBxmQevg WT9A+tUSQcoNUhmzYPOSGP61vDPzsoHvw+/lmfsDDvV1cVxbpwlBqSMqbyL8D7GJsi5c2+YTFqY0n TEjWAp/oICS0EuyL/4HA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1p85-0003Vv-VX; Thu, 07 Mar 2019 09:15:53 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1p81-0003Up-K2 for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2019 09:15:51 +0000 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MavF5-1gVWVq1TCt-00cUMs; Thu, 07 Mar 2019 10:15:33 +0100 From: Arnd Bergmann To: Russell King , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart Subject: [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable Date: Thu, 7 Mar 2019 10:14:49 +0100 Message-Id: <20190307091514.2489338-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190307091514.2489338-1-arnd@arndb.de> References: <20190307091514.2489338-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:d8KGsnS5I5jJ69letBdYqJMsef6CKlINAH4fRowUoENhI3Wj5Oz XQzXp+l7Zv0gYInCjyd3uARXmT6Dz0ERe80AM40RF0ipFK4jBAF+/1bOH+W/X9myqZpdQ3t ovCX5yOkGgDRJJXGWQPdIFbRGyzhBmeHqo4vm0J8gnT8G9QvNHxUlwgrQOtlqkJBtVijf+G nQisNIXf/OnQwkH/rnp4Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:zcJO1LULneg=:37AzrR9WoMpjoMCrxyWa08 zJKL7raTOs/Vaht+hOTaY87qL5QvUbW9tib1GjK8WfUAo76qh5rrvvS6/yDoqF8JBNIeXUUgv MBmIyq2oNNJN8oBI7iy7ExGk+PLZy+NDs7BQFMbkKMJp/lTulMXKMfhOhuzkjiuiRCI6kAFHF SGUZQyeAkzf/Ql2sif15cIsEBSRDo9rX1CiS3G9fsPLgpymnBkMrNkrBeT45OTH8eD04sVLmT LNFfYhveQ+9mSpptIn+knDxhK7MDzdmBX7bOV4mOzazZOoOZthl3YWz2MU/SodJdLxpkl716I Fo/fPIFQWWYRu8Qn/NJfi7qHG8c7ecavvyqtiErHv5bz/y5Mkmy/WILVFlf2y4ljFwXCD2cFV 2QX3ZZlG8MZLcnGzahakZildLgjRlfWpRTj6V00nN7p7f6dxZEd0NHffpZ8DUAkUHncuUblWT 92YtibFG6rX3hiDUpiNln0cllH9z3Q4ydka5d3jSPSgfNyJZyAnEHXzT/jNWhTmxaU4gtxt19 wOj5NWEnb0/q5NdVpA7LYh7M67v9bZdGrbAqli8bEvoqhSIeuVyzd6DOmRp9U7QHn+Url8jIL 47asrP6AHLijJor9S59D/l+5nRlmMa7ngCCtb0flx4p8SSjzj6hj7QPRkvH3WjqM62efDNkzY 5bspvKYd3rE7Z0Q6ZyyzHoEs37bXqZbQ2bdSzIr74RwwYwO7PuCyUQXspmqwFxv3tnVko9Cfn dqFQgE0nNcLniH3o3yaRXtVqcwz9Ehlsk84RpA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190307_011549_968828_9882567C X-CRM114-Status: GOOD ( 13.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mikael Pettersson , Mikael Pettersson , Arnd Bergmann , Nick Desaulniers , linux-kernel@vger.kernel.org, Dave Martin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Passing registers containing zero as both the address (NULL pointer) and data into cmpxchg_futex_value_locked() leads clang to assign the same register for both inputs on ARM, which triggers a warning explaining that this instruction has unpredictable behavior on ARMv5. /tmp/futex-7e740e.s: Assembler messages: /tmp/futex-7e740e.s:12713: Warning: source register same as write-back base This patch was suggested by Mikael Pettersson back in 2011 (!) with gcc-4.4, as Mikael wrote: "One way of fixing this is to make uaddr an input/output register, since "that prevents it from overlapping any other input or output." but then withdrawn as the warning was determined to be harmless, and it apparently never showed up again with later gcc versions. Now the same problem is back when compiling with clang, and we are trying to get clang to build the kernel without warnings, as gcc normally does. Cc: Mikael Pettersson Cc: Mikael Pettersson Cc: Dave Martin Link: https://lore.kernel.org/linux-arm-kernel/20009.45690.158286.161591@pilspetsen.it.uu.se/ Signed-off-by: Arnd Bergmann Reviewed-by: Nick Desaulniers --- arch/arm/include/asm/futex.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h index 0a46676b4245..79790912974e 100644 --- a/arch/arm/include/asm/futex.h +++ b/arch/arm/include/asm/futex.h @@ -110,13 +110,13 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, preempt_disable(); __ua_flags = uaccess_save_and_enable(); __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n" - "1: " TUSER(ldr) " %1, [%4]\n" - " teq %1, %2\n" + "1: " TUSER(ldr) " %1, [%2]\n" + " teq %1, %3\n" " it eq @ explicit IT needed for the 2b label\n" - "2: " TUSER(streq) " %3, [%4]\n" + "2: " TUSER(streq) " %4, [%2]\n" __futex_atomic_ex_table("%5") - : "+r" (ret), "=&r" (val) - : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT) + : "+&r" (ret), "=&r" (val), "+&r" (uaddr) + : "r" (oldval), "r" (newval), "Ir" (-EFAULT) : "cc", "memory"); uaccess_restore(__ua_flags);