Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5453970pxu; Thu, 22 Oct 2020 02:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt1pb//J4ql0opKmxdbCS7sG1Kvnn0U5S9hsOCXlKtvOuCRnL5wd14HfAmvVQXYvsyKCSK X-Received: by 2002:a17:906:2c45:: with SMTP id f5mr1400189ejh.112.1603359948860; Thu, 22 Oct 2020 02:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603359948; cv=none; d=google.com; s=arc-20160816; b=I/1ENlCDkHc4NWuKPXZTgSVBTc2G/l/pgXV68u2Chw/RGm4Ez+WFT/O3D5AwZDC4m0 sTWvWepnPiOvyvswkY4fnyLgtFmOmbfBWVKIYq2S/XXt+hBgssOLrFAP2EOzCcwUM/9V 3t7f4mLgWcttKddiKqUqg9pigaz84L1+5GqChvUAjIUv9rQFBXcVjyYzW/E3GOTGacUc /h/ewrB71qIbDlm8V7mX9Gjhm2b0103de1PV/UYUeHmGBhXJNENffJQNWeZ4M5hyK/fT tQql1Q4b361ZlbqEHp89QvabE+iTZg3rDCZ6odKc15l9DxSE+RFcuO9UREIHAJyFJCPm HYsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=WPvCeDNwqqG5Ya9SHA+Xrunp0AQAkiDt/efKMlLWwws=; b=L/ec6L8RuEHG3t03DNN2Q9xQf8MoGDS37TRVgIcssircc8Pv8FB0NBOCqfxTj8MJHs Aa65YINlmZnepP5nMUWQN3mTbI8C+NTC67mHR8Vvlf5XNWdFr3hfD0C+EPFbwJoLoesE cZ/KcTvFWbmxT9FX8WMJkaES0yGYSKq2+pHo2uklHop6IczdKtIjsHp9m7vQOYMElL4d 5G9XwvQV/sQKR98lGL2PSG6p/fqh+eWWeaX4py913Nr+JoEaSm9imQcAZnlD9oBW3d9l HXm0CNIurLQc63zIjIon1ks6vk+tZYgUlvnT9pgBqboRHV1eIxcYH2uJqgU3zFdV6y2y Oeyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si458699ejt.9.2020.10.22.02.45.26; Thu, 22 Oct 2020 02:45:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895907AbgJVJ3Y (ORCPT + 99 others); Thu, 22 Oct 2020 05:29:24 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:58300 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508740AbgJVJ3X (ORCPT ); Thu, 22 Oct 2020 05:29:23 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4CH2B64pPTz9tx11; Thu, 22 Oct 2020 11:29:18 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id LVNi8__7y1oz; Thu, 22 Oct 2020 11:29:18 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4CH2B63ydhzB09bQ; Thu, 22 Oct 2020 11:29:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B63638B769; Thu, 22 Oct 2020 11:29:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id TPw1l00OW4rb; Thu, 22 Oct 2020 11:29:19 +0200 (CEST) Received: from po17688vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 601B28B807; Thu, 22 Oct 2020 11:29:19 +0200 (CEST) Received: by po17688vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 179756680D; Thu, 22 Oct 2020 09:29:19 +0000 (UTC) Message-Id: <25e6fca46fda3e2a4298448edbf654f64756eee7.1603358942.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH v3 1/3] powerpc/uaccess: Don't use "m<>" constraint with GCC 4.9 To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 22 Oct 2020 09:29:19 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC 4.9 sometimes fails to build with "m<>" constraint in inline assembly. CC lib/iov_iter.o In file included from ./arch/powerpc/include/asm/cmpxchg.h:6:0, from ./arch/powerpc/include/asm/atomic.h:11, from ./include/linux/atomic.h:7, from ./include/linux/crypto.h:15, from ./include/crypto/hash.h:11, from lib/iov_iter.c:2: lib/iov_iter.c: In function 'iovec_from_user.part.30': ./arch/powerpc/include/asm/uaccess.h:287:2: error: 'asm' operand has impossible constraints __asm__ __volatile__( \ ^ ./include/linux/compiler.h:78:42: note: in definition of macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ ./arch/powerpc/include/asm/uaccess.h:583:34: note: in expansion of macro 'unsafe_op_wrap' #define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e) ^ ./arch/powerpc/include/asm/uaccess.h:329:10: note: in expansion of macro '__get_user_asm' case 4: __get_user_asm(x, (u32 __user *)ptr, retval, "lwz"); break; \ ^ ./arch/powerpc/include/asm/uaccess.h:363:3: note: in expansion of macro '__get_user_size_allowed' __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \ ^ ./arch/powerpc/include/asm/uaccess.h:100:2: note: in expansion of macro '__get_user_nocheck' __get_user_nocheck((x), (ptr), sizeof(*(ptr)), false) ^ ./arch/powerpc/include/asm/uaccess.h:583:49: note: in expansion of macro '__get_user_allowed' #define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e) ^ lib/iov_iter.c:1663:3: note: in expansion of macro 'unsafe_get_user' unsafe_get_user(len, &uiov[i].iov_len, uaccess_end); ^ make[1]: *** [scripts/Makefile.build:283: lib/iov_iter.o] Error 1 Define a UPD_CONSTR macro that is "<>" by default and only "" with GCC prior to GCC 5. Fixes: fcf1f26895a4 ("powerpc/uaccess: Add pre-update addressing to __put_user_asm_goto()") Fixes: 2f279eeb68b8 ("powerpc/uaccess: Add pre-update addressing to __get_user_asm() and __put_user_asm()") Signed-off-by: Christophe Leroy Acked-by: Segher Boessenkool --- v2: Moved UPD_CONSTR to asm-const.h to avoid circular inclusion issues with patch 3. --- arch/powerpc/include/asm/asm-const.h | 13 +++++++++++++ arch/powerpc/include/asm/uaccess.h | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/asm-const.h b/arch/powerpc/include/asm/asm-const.h index 082c1538c562..0ce2368bd20f 100644 --- a/arch/powerpc/include/asm/asm-const.h +++ b/arch/powerpc/include/asm/asm-const.h @@ -11,4 +11,17 @@ # define __ASM_CONST(x) x##UL # define ASM_CONST(x) __ASM_CONST(x) #endif + +/* + * Inline assembly memory constraint + * + * GCC 4.9 doesn't properly handle pre update memory constraint "m<>" + * + */ +#if defined(GCC_VERSION) && GCC_VERSION < 50000 +#define UPD_CONSTR "" +#else +#define UPD_CONSTR "<>" +#endif + #endif /* _ASM_POWERPC_ASM_CONST_H */ diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index 604d705f1bb8..8f27ea48fadb 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -223,7 +223,7 @@ do { \ "1: " op "%U1%X1 %0,%1 # put_user\n" \ EX_TABLE(1b, %l2) \ : \ - : "r" (x), "m<>" (*addr) \ + : "r" (x), "m"UPD_CONSTR (*addr) \ : \ : label) @@ -294,7 +294,7 @@ extern long __get_user_bad(void); ".previous\n" \ EX_TABLE(1b, 3b) \ : "=r" (err), "=r" (x) \ - : "m<>" (*addr), "i" (-EFAULT), "0" (err)) + : "m"UPD_CONSTR (*addr), "i" (-EFAULT), "0" (err)) #ifdef __powerpc64__ #define __get_user_asm2(x, addr, err) \ -- 2.25.0