From patchwork Tue Jul 9 18:44:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11037375 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 E3557138D for ; Tue, 9 Jul 2019 18:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDD6F28871 for ; Tue, 9 Jul 2019 18:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBC3228874; Tue, 9 Jul 2019 18:45:27 +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 59B8B28871 for ; Tue, 9 Jul 2019 18:45:27 +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=bb0c8tbU64FLCLFWAaJDd+D2sUTaE6XzdgWzDbx60gE=; b=Du1Gldsqv1f6QQ aWNPYAex68N6yY6a7RxMBTACAMdZroF83+brUg6LkYcYOrJOpRBDMa1V7Pi/GQy3XdO8++GDbcdSO Nit710tLCD1WN/j/KyMcn/OWdCClqNniZTxDab73O1Y623AFK5QF+1zMDsPmNtu2QSXIhKqHheD09 745nOQhqyzvJqMeU8Q3r+kCZC5t8nxt857IkkdZVJLCxby52bJ6+kvFIUEuxTnldpHWkdgGt0vHCi 7OnuXEpXWmwcxJ/yOVyvCmj3jzYzj6c9TStZ0m+XXSn9uBFQlCuMhp2UwPtvyzibDIN9Ul6XoDD+1 8KCBK7KdAwC8dUOnzZyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hkv7G-0006ah-C2; Tue, 09 Jul 2019 18:45:26 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkv7B-0006Vu-EZ for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2019 18:45:23 +0000 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mt7Pt-1idzjz2DuL-00tTez; Tue, 09 Jul 2019 20:45:10 +0200 From: Arnd Bergmann To: Russell King Subject: [PATCH] [v2] ARM: mtd-xip: work around clang/llvm bug Date: Tue, 9 Jul 2019 20:44:57 +0200 Message-Id: <20190709184509.2967503-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:nUy/ge+wQYWTJFpTzajM48Zt0XR341x3ye6BHYNlezP3zD2R+Fl 9o2NckE1O/IEMT9a7C+mPH6dOzZoanf6JBnCRem3dzLHQdHaEH0N3O5xdEcipjjfHjOj2N0 O7du1CzjrDYrslT9HuNZjZwGI495tjDa33+cZu5GaujvauGiFl5jc6/ophvmYrq0SQrZNbO qZkUbiefWFywNY3tMYg5A== X-UI-Out-Filterresults: notjunk:1;V03:K0:gXOCuUaHk4U=:Bjom7hSzoUeYR7ZcaDToJH 4hzyP0frf+d8a0d3kDrqFN9l57bKYZ67+WdHuGmFw7N9H00MKb1CGwSSYQLA5GBsCZYnSaydr VIwvJpqEAm9L2F45SMuqdYvsmgOhCmzaUL+EvxzWwYa2fViA8NDeHEEJyig6PMv9nKBANOJBo cM36r3OY1tra8vryoR8O+jYtIwNDSK9OMXIysfgbX/m+eoMqE+uTuHMbqIH6aTDB9ZOoYeU3d XcBt2/UYEsH6P25b/I8PcoakPqJJHxsayXhuhUMABppUPtVAOO6+npJtAVoq2zcTDDRuLovwR P9CbUH0wZKP7tGDCxkIxLiGoW0bf7f8Z9zUoDA6UDg15JVUp6Ib8reA07Kpm21YTtK4dYCj5d TODaXMOTPnMB04IvykU86zxyDeJuKDc+nsff37sv9ANTB5lBlBEnqVAmy3cIAazdsfcqLs5xZ k+QxitwDSj4xSkc+bJcR65wuk4IQ1nIWsjnNv1qgS3hccMrwUOvOKoQHZq+EvzJAL+zY/fMj4 faaXseke75b5Boo7KG6/3ikiDhL/2UF22hEKb0K2GG3Ls6g4nnK/I/ESEB5QECfhDenHiKX1b blkFztg6R+hg+0a7SFEV+kKX+7iRdA5gyNrQDtZuGqiRrd7ylCbBDzliYt5qkXPe1WdX0HD+v HjoTH26jlsGx07wMjFunU9DgZh6dv4PGolGG4HK6K3oOJ2o0PaE0VxITdhxWSc00/zsmE0EPk 79gGnYlxlR/AYisnh60ip+o2+o5EPNtB3q6W8A== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190709_114521_788168_A3F5AEBD X-CRM114-Status: GOOD ( 10.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Linus Walleij , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.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 llvm gets confused by inline asm with .rep directives, which can lead to miscalculating the number of instructions inside it, and in turn lead to an overflow for relative address calculation: /tmp/cfi_cmdset_0002-539a47.s: Assembler messages: /tmp/cfi_cmdset_0002-539a47.s:11288: Error: bad immediate value for offset (4100) /tmp/cfi_cmdset_0002-539a47.s:11289: Error: bad immediate value for offset (4100) This might be fixed in future clang versions, but is not hard to work around by just replacing the .rep with a series of eight unrolled nop instructions. As Russell points out, the original code uses an undocumented assembler directive, as .rep is normally spelled .rept, though the shorter form is common on arch/x86 as well. Link: https://bugs.llvm.org/show_bug.cgi?id=42539 Link: https://godbolt.org/z/DSM2Jy Acked-by: Nick Desaulniers Reviewed-by: Linus Walleij Signed-off-by: Arnd Bergmann --- v2: mention .rep/.rept add missing "Link:" keyword. --- arch/arm/include/asm/mtd-xip.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/mtd-xip.h b/arch/arm/include/asm/mtd-xip.h index dfcef0152e3d..5ad0325604e4 100644 --- a/arch/arm/include/asm/mtd-xip.h +++ b/arch/arm/include/asm/mtd-xip.h @@ -15,6 +15,8 @@ #include /* fill instruction prefetch */ -#define xip_iprefetch() do { asm volatile (".rep 8; nop; .endr"); } while (0) +#define xip_iprefetch() do { \ + asm volatile ("nop; nop; nop; nop; nop; nop; nop; nop;"); \ +} while (0) \ #endif /* __ARM_MTD_XIP_H__ */