* [PATCH] MIPS: Workaround clang inline compat branch issue
@ 2023-02-25 21:45 Jiaxun Yang
2023-02-27 18:19 ` Nick Desaulniers
0 siblings, 1 reply; 2+ messages in thread
From: Jiaxun Yang @ 2023-02-25 21:45 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.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/Kconfig | 3 +++
arch/mips/include/asm/asm.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 37072e15b263..adf2c5a0bdba 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -3206,6 +3206,9 @@ config CC_HAS_MNO_BRANCH_LIKELY
def_bool y
depends on $(cc-option,-mno-branch-likely)
+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] 2+ messages in thread
* Re: [PATCH] MIPS: Workaround clang inline compat branch issue
2023-02-25 21:45 [PATCH] MIPS: Workaround clang inline compat branch issue Jiaxun Yang
@ 2023-02-27 18:19 ` Nick Desaulniers
0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2023-02-27 18:19 UTC (permalink / raw)
To: Jiaxun Yang; +Cc: linux-mips, tsbogend, nathan, llvm
On Sat, Feb 25, 2023 at 1:45 PM 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.
Hi Jiaxun,
Thanks for the patch. Have you filed (or found) a bug in LLVM's issue
tracker with more information?
https://github.com/llvm/llvm-project/issues
Please do so, then send a v2 (or reply with) a Link: tag to the
corresponding llvm issue report.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> arch/mips/Kconfig | 3 +++
> arch/mips/include/asm/asm.h | 2 +-
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 37072e15b263..adf2c5a0bdba 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -3206,6 +3206,9 @@ config CC_HAS_MNO_BRANCH_LIKELY
> def_bool y
> depends on $(cc-option,-mno-branch-likely)
>
> +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] 2+ messages in thread
end of thread, other threads:[~2023-02-27 18:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-25 21:45 [PATCH] MIPS: Workaround clang inline compat branch issue Jiaxun Yang
2023-02-27 18:19 ` Nick Desaulniers
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).