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: 168766 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8908021ilk; Tue, 9 Jul 2019 11:45:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXJgNfGR0C8/lRNPYD15OgDdkK45b+HPyMmUNpts+96gR9yRKdNbP/Z4WS++ZfVpVsVYCJ X-Received: by 2002:a17:90a:d3d4:: with SMTP id d20mr1814340pjw.28.1562697926899; Tue, 09 Jul 2019 11:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562697926; cv=none; d=google.com; s=arc-20160816; b=ztrYqbDOuO5GZLidS5/1nod38/ChXcgxstcvHrquHdiu/08hwlaJsznOBuNvUdiIv1 f0Sx0WpVOwIfTmol8CuyaWZuN5j8lEyxtSLpYKl5UbpseN4q0B7wSN/8czfK612vUFRY r8P35kfm3uH87dXOgJHVK5cttheUU9CP0CvXo1siUfCV+Zeb7ihyk9WVSePUfa7qQa4H OHraueVnuO9pEBzp00XYeOm5OkGrd+st9+DA8n/EsJrYgpVNeze1+GY5QapSPyqWvGYZ Qo0fHg4XqtomKlp47s6vJBle+2RfP4mmonXr1EWYy1Ji9OmMitwFLcWps8lKvMqFtMJb 8lcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=v3oh8BdlhD1mkfWRC8qyY4zdTguQnDD1yEIY+sqex0U=; b=IZC3W4y/WIrnZFOtT6jx6dR35xq79SLPU1eS03lEzv+KIIfeFnmr4nuYuaTjtVRmHR 0JaMFXhf4RKV9rRnhwZVbi2sQ5iJfKp2+FvgISCeb8cQHZa94F0x4+3JJ5Us145l3o8d OKDKYqFI5Ms5bgNDdS3vSgowUhgdXz3Nsxcps/QyzBF2+wjW8RnYcWtWdyupapByHP0c RKXJxwBbzu5n3E73kJoAU55zC6tGZT+brMWGm6VJOzbONg1HK35CZ6IvVQIa/SHzAAeH +1s022b9HsW3u1A1cAjhYzvZWATZqb7B25Htc2I6ebJBu2HYEqsMTeKz4PAK7NE9dlr8 HaKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si22865248plk.342.2019.07.09.11.45.26; Tue, 09 Jul 2019 11:45:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729263AbfGISpZ (ORCPT + 30 others); Tue, 9 Jul 2019 14:45:25 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:51369 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbfGISpY (ORCPT ); Tue, 9 Jul 2019 14:45:24 -0400 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 Cc: Linus Walleij , linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com 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-Spam-Flag: NO 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== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.20.0 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__ */