* [PATCH v3] MIPS: Workaround clang inline compat branch issue
@ 2023-02-28 19:34 Jiaxun Yang
2023-02-28 19:42 ` Nick Desaulniers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jiaxun Yang @ 2023-02-28 19:34 UTC (permalink / raw)
To: linux-mips; +Cc: tsbogend, nathan, llvm, Jiaxun Yang
Clang is unable to handle the situation that a chunk of inline
assembly ends with a compat branch instruction and then compiler
generates another control transfer instruction immediately after
this compat branch. The later instruction will end up in forbidden
slot and cause exception.
Workaround by add a option to control the use of compact branch.
Currently it's selected by CC_IS_CLANG and hopefully we can change
it to a version check in future if clang manages to fix it.
Fix boot on boston board.
Link: https://github.com/llvm/llvm-project/issues/61045
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Acked-by: Nathan Chancellor <nathan@kernel.org>
---
v2: Add Link tag to LLVM bug
v3: Docuement issue link in Kconfig as well
---
arch/mips/Kconfig | 4 ++++
arch/mips/include/asm/asm.h | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 37072e15b263..c8b878aa690f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -3206,6 +3206,10 @@ config CC_HAS_MNO_BRANCH_LIKELY
def_bool y
depends on $(cc-option,-mno-branch-likely)
+# https://github.com/llvm/llvm-project/issues/61045
+config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
+ def_bool y if CC_IS_CLANG
+
menu "Power management options"
config ARCH_HIBERNATION_POSSIBLE
diff --git a/arch/mips/include/asm/asm.h b/arch/mips/include/asm/asm.h
index 336ac9b65235..2e99450f4228 100644
--- a/arch/mips/include/asm/asm.h
+++ b/arch/mips/include/asm/asm.h
@@ -336,7 +336,7 @@ symbol = value
*/
#ifdef CONFIG_WAR_R10000_LLSC
# define SC_BEQZ beqzl
-#elif MIPS_ISA_REV >= 6
+#elif !defined(CONFIG_CC_HAS_BROKEN_INLINE_COMPAT_BRANCH) && MIPS_ISA_REV >= 6
# define SC_BEQZ beqzc
#else
# define SC_BEQZ beqz
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] MIPS: Workaround clang inline compat branch issue
2023-02-28 19:34 [PATCH v3] MIPS: Workaround clang inline compat branch issue Jiaxun Yang
@ 2023-02-28 19:42 ` Nick Desaulniers
2023-02-28 22:15 ` Thomas Bogendoerfer
2023-03-01 9:02 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2023-02-28 19:42 UTC (permalink / raw)
To: Jiaxun Yang; +Cc: linux-mips, tsbogend, nathan, llvm
On Tue, Feb 28, 2023 at 11:35 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>
> Clang is unable to handle the situation that a chunk of inline
> assembly ends with a compat branch instruction and then compiler
> generates another control transfer instruction immediately after
> this compat branch. The later instruction will end up in forbidden
> slot and cause exception.
>
> Workaround by add a option to control the use of compact branch.
> Currently it's selected by CC_IS_CLANG and hopefully we can change
> it to a version check in future if clang manages to fix it.
>
> Fix boot on boston board.
>
> Link: https://github.com/llvm/llvm-project/issues/61045
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Acked-by: Nathan Chancellor <nathan@kernel.org>
Thanks for the patch!
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> v2: Add Link tag to LLVM bug
> v3: Docuement issue link in Kconfig as well
> ---
> arch/mips/Kconfig | 4 ++++
> arch/mips/include/asm/asm.h | 2 +-
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 37072e15b263..c8b878aa690f 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -3206,6 +3206,10 @@ config CC_HAS_MNO_BRANCH_LIKELY
> def_bool y
> depends on $(cc-option,-mno-branch-likely)
>
> +# https://github.com/llvm/llvm-project/issues/61045
> +config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
> + def_bool y if CC_IS_CLANG
> +
> menu "Power management options"
>
> config ARCH_HIBERNATION_POSSIBLE
> diff --git a/arch/mips/include/asm/asm.h b/arch/mips/include/asm/asm.h
> index 336ac9b65235..2e99450f4228 100644
> --- a/arch/mips/include/asm/asm.h
> +++ b/arch/mips/include/asm/asm.h
> @@ -336,7 +336,7 @@ symbol = value
> */
> #ifdef CONFIG_WAR_R10000_LLSC
> # define SC_BEQZ beqzl
> -#elif MIPS_ISA_REV >= 6
> +#elif !defined(CONFIG_CC_HAS_BROKEN_INLINE_COMPAT_BRANCH) && MIPS_ISA_REV >= 6
> # define SC_BEQZ beqzc
> #else
> # define SC_BEQZ beqz
> --
> 2.37.1 (Apple Git-137.1)
>
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] MIPS: Workaround clang inline compat branch issue
2023-02-28 19:34 [PATCH v3] MIPS: Workaround clang inline compat branch issue Jiaxun Yang
2023-02-28 19:42 ` Nick Desaulniers
@ 2023-02-28 22:15 ` Thomas Bogendoerfer
2023-03-01 9:02 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2023-02-28 22:15 UTC (permalink / raw)
To: Jiaxun Yang; +Cc: linux-mips, nathan, llvm
On Tue, Feb 28, 2023 at 07:34:59PM +0000, Jiaxun Yang wrote:
> Clang is unable to handle the situation that a chunk of inline
> assembly ends with a compat branch instruction and then compiler
> generates another control transfer instruction immediately after
> this compat branch. The later instruction will end up in forbidden
> slot and cause exception.
>
> Workaround by add a option to control the use of compact branch.
> Currently it's selected by CC_IS_CLANG and hopefully we can change
> it to a version check in future if clang manages to fix it.
>
> Fix boot on boston board.
>
> Link: https://github.com/llvm/llvm-project/issues/61045
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Acked-by: Nathan Chancellor <nathan@kernel.org>
> ---
> v2: Add Link tag to LLVM bug
> v3: Docuement issue link in Kconfig as well
> ---
> arch/mips/Kconfig | 4 ++++
> arch/mips/include/asm/asm.h | 2 +-
> 2 files changed, 5 insertions(+), 1 deletion(-)
applied to mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] MIPS: Workaround clang inline compat branch issue
2023-02-28 19:34 [PATCH v3] MIPS: Workaround clang inline compat branch issue Jiaxun Yang
2023-02-28 19:42 ` Nick Desaulniers
2023-02-28 22:15 ` Thomas Bogendoerfer
@ 2023-03-01 9:02 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-03-01 9:02 UTC (permalink / raw)
To: Jiaxun Yang, linux-mips; +Cc: tsbogend, nathan, llvm
On 28/2/23 20:34, Jiaxun Yang wrote:
> Clang is unable to handle the situation that a chunk of inline
> assembly ends with a compat branch instruction and then compiler
> generates another control transfer instruction immediately after
> this compat branch. The later instruction will end up in forbidden
> slot and cause exception.
>
> Workaround by add a option to control the use of compact branch.
> Currently it's selected by CC_IS_CLANG and hopefully we can change
> it to a version check in future if clang manages to fix it.
>
> Fix boot on boston board.
>
> Link: https://github.com/llvm/llvm-project/issues/61045
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Acked-by: Nathan Chancellor <nathan@kernel.org>
> ---
> v2: Add Link tag to LLVM bug
> v3: Docuement issue link in Kconfig as well
> ---
> arch/mips/Kconfig | 4 ++++
> arch/mips/include/asm/asm.h | 2 +-
> 2 files changed, 5 insertions(+), 1 deletion(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-01 9:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28 19:34 [PATCH v3] MIPS: Workaround clang inline compat branch issue Jiaxun Yang
2023-02-28 19:42 ` Nick Desaulniers
2023-02-28 22:15 ` Thomas Bogendoerfer
2023-03-01 9:02 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).