From: Nick Desaulniers <ndesaulniers@google.com> To: mpe@ellerman.id.au Cc: christophe.leroy@c-s.fr, segher@kernel.crashing.org, arnd@arndb.de, Nick Desaulniers <ndesaulniers@google.com>, Nathan Chancellor <natechancellor@gmail.com>, kbuild test robot <lkp@intel.com>, Benjamin Herrenschmidt <benh@kernel.crashing.org>, Paul Mackerras <paulus@samba.org>, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] powerpc: workaround clang codegen bug in dcbz Date: Mon, 29 Jul 2019 13:25:41 -0700 [thread overview] Message-ID: <20190729202542.205309-1-ndesaulniers@google.com> (raw) Commit 6c5875843b87 ("powerpc: slightly improve cache helpers") exposed what looks like a codegen bug in Clang's handling of `%y` output template with `Z` constraint. This is resulting in panics during boot for 32b powerpc builds w/ Clang, as reported by our CI. Add back the original code that worked behind a preprocessor check for __clang__ until we can fix LLVM. Further, it seems that clang allnoconfig builds are unhappy with `Z`, as reported by 0day bot. This is likely because Clang warns about inline asm constraints when the constraint requires inlining to be semantically valid. Link: https://bugs.llvm.org/show_bug.cgi?id=42762 Link: https://github.com/ClangBuiltLinux/linux/issues/593 Link: https://lore.kernel.org/lkml/20190721075846.GA97701@archlinux-threadripper/ Debugged-by: Nathan Chancellor <natechancellor@gmail.com> Reported-by: Nathan Chancellor <natechancellor@gmail.com> Reported-by: kbuild test robot <lkp@intel.com> Suggested-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> --- Alternatively, we could just revert 6c5875843b87. It seems that GCC generates the same code for these functions for out of line versions. But I'm not sure how the inlined code generated would be affected. arch/powerpc/include/asm/cache.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h index b3388d95f451..72983da94dce 100644 --- a/arch/powerpc/include/asm/cache.h +++ b/arch/powerpc/include/asm/cache.h @@ -105,6 +105,30 @@ extern void _set_L3CR(unsigned long); #define _set_L3CR(val) do { } while(0) #endif +/* + * Workaround for https://bugs.llvm.org/show_bug.cgi?id=42762. + */ +#ifdef __clang__ +static inline void dcbz(void *addr) +{ + __asm__ __volatile__ ("dcbz 0, %0" : : "r"(addr) : "memory"); +} + +static inline void dcbi(void *addr) +{ + __asm__ __volatile__ ("dcbi 0, %0" : : "r"(addr) : "memory"); +} + +static inline void dcbf(void *addr) +{ + __asm__ __volatile__ ("dcbf 0, %0" : : "r"(addr) : "memory"); +} + +static inline void dcbst(void *addr) +{ + __asm__ __volatile__ ("dcbst 0, %0" : : "r"(addr) : "memory"); +} +#else static inline void dcbz(void *addr) { __asm__ __volatile__ ("dcbz %y0" : : "Z"(*(u8 *)addr) : "memory"); @@ -124,6 +148,7 @@ static inline void dcbst(void *addr) { __asm__ __volatile__ ("dcbst %y0" : : "Z"(*(u8 *)addr) : "memory"); } +#endif /* __clang__ */ #endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_CACHE_H */ -- 2.22.0.709.g102302147b-goog
WARNING: multiple messages have this Message-ID (diff)
From: Nick Desaulniers <ndesaulniers@google.com> To: mpe@ellerman.id.au Cc: arnd@arndb.de, Nick Desaulniers <ndesaulniers@google.com>, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Paul Mackerras <paulus@samba.org>, Nathan Chancellor <natechancellor@gmail.com>, linuxppc-dev@lists.ozlabs.org, kbuild test robot <lkp@intel.com> Subject: [PATCH] powerpc: workaround clang codegen bug in dcbz Date: Mon, 29 Jul 2019 13:25:41 -0700 [thread overview] Message-ID: <20190729202542.205309-1-ndesaulniers@google.com> (raw) Commit 6c5875843b87 ("powerpc: slightly improve cache helpers") exposed what looks like a codegen bug in Clang's handling of `%y` output template with `Z` constraint. This is resulting in panics during boot for 32b powerpc builds w/ Clang, as reported by our CI. Add back the original code that worked behind a preprocessor check for __clang__ until we can fix LLVM. Further, it seems that clang allnoconfig builds are unhappy with `Z`, as reported by 0day bot. This is likely because Clang warns about inline asm constraints when the constraint requires inlining to be semantically valid. Link: https://bugs.llvm.org/show_bug.cgi?id=42762 Link: https://github.com/ClangBuiltLinux/linux/issues/593 Link: https://lore.kernel.org/lkml/20190721075846.GA97701@archlinux-threadripper/ Debugged-by: Nathan Chancellor <natechancellor@gmail.com> Reported-by: Nathan Chancellor <natechancellor@gmail.com> Reported-by: kbuild test robot <lkp@intel.com> Suggested-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> --- Alternatively, we could just revert 6c5875843b87. It seems that GCC generates the same code for these functions for out of line versions. But I'm not sure how the inlined code generated would be affected. arch/powerpc/include/asm/cache.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h index b3388d95f451..72983da94dce 100644 --- a/arch/powerpc/include/asm/cache.h +++ b/arch/powerpc/include/asm/cache.h @@ -105,6 +105,30 @@ extern void _set_L3CR(unsigned long); #define _set_L3CR(val) do { } while(0) #endif +/* + * Workaround for https://bugs.llvm.org/show_bug.cgi?id=42762. + */ +#ifdef __clang__ +static inline void dcbz(void *addr) +{ + __asm__ __volatile__ ("dcbz 0, %0" : : "r"(addr) : "memory"); +} + +static inline void dcbi(void *addr) +{ + __asm__ __volatile__ ("dcbi 0, %0" : : "r"(addr) : "memory"); +} + +static inline void dcbf(void *addr) +{ + __asm__ __volatile__ ("dcbf 0, %0" : : "r"(addr) : "memory"); +} + +static inline void dcbst(void *addr) +{ + __asm__ __volatile__ ("dcbst 0, %0" : : "r"(addr) : "memory"); +} +#else static inline void dcbz(void *addr) { __asm__ __volatile__ ("dcbz %y0" : : "Z"(*(u8 *)addr) : "memory"); @@ -124,6 +148,7 @@ static inline void dcbst(void *addr) { __asm__ __volatile__ ("dcbst %y0" : : "Z"(*(u8 *)addr) : "memory"); } +#endif /* __clang__ */ #endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_CACHE_H */ -- 2.22.0.709.g102302147b-goog
next reply other threads:[~2019-07-29 20:26 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-29 20:25 Nick Desaulniers [this message] 2019-07-29 20:25 ` [PATCH] powerpc: workaround clang codegen bug in dcbz Nick Desaulniers 2019-07-29 20:32 ` Nathan Chancellor 2019-07-29 20:32 ` Nathan Chancellor 2019-07-29 20:45 ` Nick Desaulniers 2019-07-29 20:45 ` Nick Desaulniers 2019-07-29 20:47 ` Nathan Chancellor 2019-07-29 20:47 ` Nathan Chancellor 2019-07-29 20:49 ` Nick Desaulniers 2019-07-29 20:49 ` Nick Desaulniers 2019-07-29 21:52 ` Segher Boessenkool 2019-07-29 21:52 ` Segher Boessenkool 2019-07-30 7:34 ` Arnd Bergmann 2019-07-30 7:34 ` Arnd Bergmann 2019-07-30 11:17 ` Michael Ellerman 2019-07-30 11:17 ` Michael Ellerman 2019-08-09 18:21 ` [PATCH] powerpc: fix inline asm constraints for dcbz Nick Desaulniers 2019-08-09 18:21 ` Nick Desaulniers 2019-08-09 18:28 ` Arnd Bergmann 2019-08-09 18:28 ` Arnd Bergmann 2019-08-09 20:03 ` Christophe Leroy 2019-08-09 20:03 ` Christophe Leroy 2019-08-09 20:12 ` Arnd Bergmann 2019-08-09 20:12 ` Arnd Bergmann 2019-08-09 22:03 ` Nick Desaulniers 2019-08-09 22:03 ` Nick Desaulniers 2019-08-09 22:10 ` Segher Boessenkool 2019-08-09 22:10 ` Segher Boessenkool 2019-08-09 22:00 ` Segher Boessenkool 2019-08-09 22:00 ` Segher Boessenkool 2019-08-09 22:03 ` [PATCH v3] Revert "powerpc: slightly improve cache helpers" Nick Desaulniers 2019-08-09 22:03 ` Nick Desaulniers 2019-08-10 9:09 ` Michael Ellerman 2019-08-10 9:09 ` Michael Ellerman 2019-08-09 21:55 ` [PATCH] powerpc: fix inline asm constraints for dcbz Segher Boessenkool 2019-08-09 21:55 ` Segher Boessenkool 2019-08-09 20:36 ` Nathan Chancellor 2019-08-09 20:36 ` Nathan Chancellor 2019-07-30 13:48 ` [PATCH] powerpc: workaround clang codegen bug in dcbz Segher Boessenkool 2019-07-30 13:48 ` Segher Boessenkool 2019-07-30 14:30 ` Arnd Bergmann 2019-07-30 14:30 ` Arnd Bergmann 2019-07-30 16:16 ` Segher Boessenkool 2019-07-30 16:16 ` Segher Boessenkool 2019-07-30 17:07 ` Segher Boessenkool 2019-07-30 18:24 ` Arnd Bergmann 2019-07-30 18:24 ` Arnd Bergmann 2019-07-30 18:24 ` Arnd Bergmann 2019-07-30 19:35 ` Segher Boessenkool 2019-07-30 19:35 ` Segher Boessenkool 2019-07-30 5:31 ` Christophe Leroy 2019-07-30 5:31 ` Christophe Leroy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190729202542.205309-1-ndesaulniers@google.com \ --to=ndesaulniers@google.com \ --cc=arnd@arndb.de \ --cc=benh@kernel.crashing.org \ --cc=christophe.leroy@c-s.fr \ --cc=clang-built-linux@googlegroups.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=lkp@intel.com \ --cc=mpe@ellerman.id.au \ --cc=natechancellor@gmail.com \ --cc=paulus@samba.org \ --cc=segher@kernel.crashing.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.