From patchwork Sat Mar 2 23:08:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 10836787 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 E04371390 for ; Sat, 2 Mar 2019 23:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C69902A604 for ; Sat, 2 Mar 2019 23:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9B942A76E; Sat, 2 Mar 2019 23:07:54 +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 C3C032A604 for ; Sat, 2 Mar 2019 23:07:52 +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: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:In-Reply-To:References: List-Owner; bh=x2fW2i+0pNeH1DpK/zpQYYU2biJ9VresyE7iTsPG1yk=; b=FS4gWzdgqifZvN M1iYgvvh0/sA46O7RrHhMtD+r6jZpfutjZo+fIAOk6FCTwOLGOO4qSaKeaelpZmbJgaIALS72XYO7 qgNbWTUUBJWu395c4CZn+IKNgnlTPKVm68Evmx2+YyvpmzgegXsxFUYcIGDcY/1XzeGYS16Yfpj8c 7ExdTGFk22wUo/c69LxtgJ9fA+vjUUQTmnadDsmV+g5yU7JDrXbZw+iF4BNkqh7i2rPLqsuUHuDQW 8JY20ScaPC26Lier+Uf2538lDMrOggMVaTL7j9H1z7H6rZFHPXi0WDRzFFYxME1R1xRCDfeNkHYUl B5t/uhaKqyBSLFrsKoZA==; 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 1h0DjS-0003tw-B5; Sat, 02 Mar 2019 23:07:50 +0000 Received: from mail.kmu-office.ch ([2a02:418:6a02::a2]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0DjN-0003sP-Db for linux-arm-kernel@lists.infradead.org; Sat, 02 Mar 2019 23:07:47 +0000 Received: from zyt.lan (unknown [IPv6:2a02:169:3465:0:5054:ff:fe4f:85bd]) by mail.kmu-office.ch (Postfix) with ESMTPSA id CD0315C0086; Sun, 3 Mar 2019 00:07:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1551568056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=DFt2kZHnj0NjV7f4nRSfqhXB8i9yVn0VsTHIdlAvBNw=; b=wZXidubZ0WNTMII8zWEizaC8kqKKWFG3Y3KvvQFRHhYEg+U2Ft0HY5Rb3XLW806S8mvVf/ O+jsdV4AS2trY/K4mJ1VqGkD0wwXpmYBv+/Gry9D8jU33capxMntlvgGEEMUkNHycc7k7j WpIzwAPymhQKK14ifUr2EC/YQMm0elA= From: Stefan Agner To: linux@armlinux.org.uk Subject: [PATCH 1/2] ARM: add TUSERCOND() macro for conditional postfix Date: Sun, 3 Mar 2019 00:08:18 +0100 Message-Id: <1ed0a317c3e9ae1cdd1b05fad5e1bd13a58a9036.1551567941.git.stefan@agner.ch> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190302_150745_760705_6BA38C2B X-CRM114-Status: GOOD ( 13.60 ) 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: nicolas.pitre@linaro.org, mark.rutland@arm.com, arnd@arndb.de, ard.biesheuvel@linaro.org, will.deacon@arm.com, julien.thierry@arm.com, ndesaulniers@google.com, linux-kernel@vger.kernel.org, Stefan Agner , thierry.reding@gmail.com, natechancellor@gmail.com, 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 Unified assembly syntax requires conditionals to be postfixes. TUSER() currently only takes a single argument which then gets appended t (with translation) on every instruction. This fixes a build error when using LLVM's integrated assembler: In file included from kernel/futex.c:72: ./arch/arm/include/asm/futex.h:116:3: error: invalid instruction, did you mean: strt? "2: " TUSER(streq) " %3, [%4]\n" ^ :5:4: note: instantiated into assembly here 2: streqt r2, [r4] ^~~~~~ Additionally, for GCC ".syntax unified" for inline assembly. When compiling non-Thumb2 GCC always emits a ".syntax divided" at the beginning of the inline assembly which makes the assembler fail. Since GCC 5 there is the -masm-syntax-unified GCC option which make GCC assume unified syntax asm and hence emits ".syntax unified" even in ARM mode. However, the option is broken since GCC version 6 (see GCC PR88648 [1]). Work around by adding ".syntax unified" as part of the inline assembly. [0] https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-masm-syntax-unified [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88648 Signed-off-by: Stefan Agner --- arch/arm/include/asm/domain.h | 6 ++++-- arch/arm/include/asm/futex.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h index 99d9f630d6b6..1888c2d15da5 100644 --- a/arch/arm/include/asm/domain.h +++ b/arch/arm/include/asm/domain.h @@ -133,9 +133,11 @@ static inline void modify_domain(unsigned dom, unsigned type) { } * instructions (inline assembly) */ #ifdef CONFIG_CPU_USE_DOMAINS -#define TUSER(instr) #instr "t" +#define TUSER(instr) TUSERCOND(instr, ) +#define TUSERCOND(instr, cond) #instr "t" #cond #else -#define TUSER(instr) #instr +#define TUSER(instr) TUSERCOND(instr, ) +#define TUSERCOND(instr, cond) #instr #cond #endif #else /* __ASSEMBLY__ */ diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h index 0a46676b4245..83c391b597d4 100644 --- a/arch/arm/include/asm/futex.h +++ b/arch/arm/include/asm/futex.h @@ -110,10 +110,11 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, preempt_disable(); __ua_flags = uaccess_save_and_enable(); __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n" + " .syntax unified\n" "1: " TUSER(ldr) " %1, [%4]\n" " teq %1, %2\n" " it eq @ explicit IT needed for the 2b label\n" - "2: " TUSER(streq) " %3, [%4]\n" + "2: " TUSERCOND(str, eq) " %3, [%4]\n" __futex_atomic_ex_table("%5") : "+r" (ret), "=&r" (val) : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT) From patchwork Sat Mar 2 23:08:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 10836789 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 232B81390 for ; Sat, 2 Mar 2019 23:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BF5D2A604 for ; Sat, 2 Mar 2019 23:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F38A22A76E; Sat, 2 Mar 2019 23:07:59 +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 8B31F2A604 for ; Sat, 2 Mar 2019 23:07:59 +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=gd2J0ONXzruaE6NCrApNqYOC5kG0eXWzoZd5by7+quo=; b=rQcYOyfIH/lqKU QA5EWN5WCj1BS31e93bJL+qMPoT6TVuyFRhcvwktMJjuV+0wJ77UJ/BDl+i87lPDM7rteGgQs80en 6Ita/bm96RYcFNXkaK/JWHWOL2z71c/qbuJ9Je+4TzOQWIbCWo+RW/H81H1/cjBoGMmIi6KKB/l7g 0vM/yLvsHesQ6jvoHZMQ5wWbd3YfxQ1j7CUNPZ5J+A4yVGKRHKFZCOZqEVNvNCieHdVZk76Hi1Lk/ vIeS8duwHe40zL3B1r4rKq6I9RxQMm77/3lLAOHzsxTzzG8A1/xxEar8VSGomJ89YWVXq+8ALLomj 9v7Q1cTOc9mQRC0NXbIQ==; 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 1h0DjX-00040B-Mo; Sat, 02 Mar 2019 23:07:55 +0000 Received: from mail.kmu-office.ch ([2a02:418:6a02::a2]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0DjN-0003sQ-DN for linux-arm-kernel@lists.infradead.org; Sat, 02 Mar 2019 23:07:47 +0000 Received: from zyt.lan (unknown [IPv6:2a02:169:3465:0:5054:ff:fe4f:85bd]) by mail.kmu-office.ch (Postfix) with ESMTPSA id E5CA95C23AE; Sun, 3 Mar 2019 00:07:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1551568057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CXhK/FBjan7/N7CuPcIKHePaIsXcmL2rMJadcisJ42g=; b=FbW1sLSUZGB/5mcjEJfKLD7zYpxDuuVZ4e+4JuvLMitiiIh/1sba4g7fwe3of70c+PsKeN TGR9JaWyZSezbHQR/hivsxJ7ZwAWpGsxFtCPLHlZ1OcqMld7g5YWI/oy9NaRKjmw6F2l2R y+Pb4m7e0Ms9JdrjLh4Hx54OcsYD7wg= From: Stefan Agner To: linux@armlinux.org.uk Subject: [PATCH 2/2] ARM: uaccess: use unified assembler language syntax Date: Sun, 3 Mar 2019 00:08:19 +0100 Message-Id: <9a4f9da0615ec658512dd334d931b5acd947ac5d.1551567941.git.stefan@agner.ch> X-Mailer: git-send-email 2.20.1 In-Reply-To: <1ed0a317c3e9ae1cdd1b05fad5e1bd13a58a9036.1551567941.git.stefan@agner.ch> References: <1ed0a317c3e9ae1cdd1b05fad5e1bd13a58a9036.1551567941.git.stefan@agner.ch> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190302_150745_605643_B51FB7E0 X-CRM114-Status: GOOD ( 12.70 ) 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: nicolas.pitre@linaro.org, mark.rutland@arm.com, arnd@arndb.de, ard.biesheuvel@linaro.org, will.deacon@arm.com, julien.thierry@arm.com, ndesaulniers@google.com, linux-kernel@vger.kernel.org, Stefan Agner , thierry.reding@gmail.com, natechancellor@gmail.com, 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 Convert the conditional infix to a postfix to make sure this inline assembly is unified syntax. Since gcc assumes non-unified syntax when emitting ARM instructions, make sure to define the syntax as unified. This allows to use LLVM's integrated assembler. Additionally, for GCC ".syntax unified" for inline assembly. When compiling non-Thumb2 GCC always emits a ".syntax divided" at the beginning of the inline assembly which makes the assembler fail. Since GCC 5 there is the -masm-syntax-unified GCC option which make GCC assume unified syntax asm and hence emits ".syntax unified" even in ARM mode. However, the option is broken since GCC version 6 (see GCC PR88648 [1]). Work around by adding ".syntax unified" as part of the inline assembly. [0] https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-masm-syntax-unified [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88648 Signed-off-by: Stefan Agner --- I missed this instance in my previous commits and realized only after running some randconfig. arch/arm/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 89a28680934b..18303bcc9990 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -113,10 +113,11 @@ static inline void __user *__uaccess_mask_range_ptr(const void __user *ptr, unsigned long tmp; asm volatile( + " .syntax unified\n" " sub %1, %3, #1\n" " subs %1, %1, %0\n" " addhs %1, %1, #1\n" - " subhss %1, %1, %2\n" + " subshs %1, %1, %2\n" " movlo %0, #0\n" : "+r" (safe_ptr), "=&r" (tmp) : "r" (size), "r" (current_thread_info()->addr_limit)