* [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
@ 2022-03-09 19:16 ` Nathan Chancellor
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2022-03-09 19:16 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Nick Desaulniers, linux-arm-kernel, linux-kernel, llvm,
Nathan Chancellor, stable, Marc Zyngier, James Morse
When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after
commit 558c303c9734 ("arm64: Mitigate spectre style branch history side
channels"), the following error occurs:
<instantiation>:4:2: error: invalid fixup for movz/movk instruction
mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
^
Marc figured out that moving "#include <linux/init.h>" in
include/linux/arm-smccc.h into a !__ASSEMBLY__ block resolves it. The
full include chain with CONFIG_LTO=y from include/linux/arm-smccc.h:
include/linux/init.h
include/linux/compiler.h
arch/arm64/include/asm/rwonce.h
arch/arm64/include/asm/alternative-macros.h
arch/arm64/include/asm/assembler.h
The asm/alternative-macros.h include in asm/rwonce.h only happens when
CONFIG_LTO is set, which ultimately casues asm/assembler.h to be
included before the definition of ARM_SMCCC_ARCH_WORKAROUND_3. As a
result, the preprocessor does not expand ARM_SMCCC_ARCH_WORKAROUND_3 in
__mitigate_spectre_bhb_fw, which results in the error above.
Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block
in asm/rwonce.h with assembly files, as nothing in that block is useful
to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be
properly expanded with CONFIG_LTO=y builds.
Cc: stable@vger.kernel.org
Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y")
Link: https://lore.kernel.org/r/20220309155716.3988480-1-maz@kernel.org/
Reported-by: Marc Zyngier <maz@kernel.org>
Acked-by: James Morse <james.morse@arm.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
This is based on current mainline; if it should be based on a specific
arm64 branch, please let me know.
As 558c303c9734 is going to stable, I marked this for stable as well to
avoid breaking Android. I used e35123d83ee3 for the fixes tag to make it
clear to the stable team this should only go where that commit is
present. If a different fixes tag should be used, please feel free to
substitute.
arch/arm64/include/asm/rwonce.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
index 1bce62fa908a..56f7b1d4d54b 100644
--- a/arch/arm64/include/asm/rwonce.h
+++ b/arch/arm64/include/asm/rwonce.h
@@ -5,7 +5,7 @@
#ifndef __ASM_RWONCE_H
#define __ASM_RWONCE_H
-#ifdef CONFIG_LTO
+#if defined(CONFIG_LTO) && !defined(__ASSEMBLY__)
#include <linux/compiler_types.h>
#include <asm/alternative-macros.h>
@@ -66,7 +66,7 @@
})
#endif /* !BUILD_VDSO */
-#endif /* CONFIG_LTO */
+#endif /* CONFIG_LTO && !__ASSEMBLY__ */
#include <asm-generic/rwonce.h>
base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
@ 2022-03-09 19:16 ` Nathan Chancellor
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2022-03-09 19:16 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Nick Desaulniers, linux-arm-kernel, linux-kernel, llvm,
Nathan Chancellor, stable, Marc Zyngier, James Morse
When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after
commit 558c303c9734 ("arm64: Mitigate spectre style branch history side
channels"), the following error occurs:
<instantiation>:4:2: error: invalid fixup for movz/movk instruction
mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
^
Marc figured out that moving "#include <linux/init.h>" in
include/linux/arm-smccc.h into a !__ASSEMBLY__ block resolves it. The
full include chain with CONFIG_LTO=y from include/linux/arm-smccc.h:
include/linux/init.h
include/linux/compiler.h
arch/arm64/include/asm/rwonce.h
arch/arm64/include/asm/alternative-macros.h
arch/arm64/include/asm/assembler.h
The asm/alternative-macros.h include in asm/rwonce.h only happens when
CONFIG_LTO is set, which ultimately casues asm/assembler.h to be
included before the definition of ARM_SMCCC_ARCH_WORKAROUND_3. As a
result, the preprocessor does not expand ARM_SMCCC_ARCH_WORKAROUND_3 in
__mitigate_spectre_bhb_fw, which results in the error above.
Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block
in asm/rwonce.h with assembly files, as nothing in that block is useful
to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be
properly expanded with CONFIG_LTO=y builds.
Cc: stable@vger.kernel.org
Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y")
Link: https://lore.kernel.org/r/20220309155716.3988480-1-maz@kernel.org/
Reported-by: Marc Zyngier <maz@kernel.org>
Acked-by: James Morse <james.morse@arm.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
This is based on current mainline; if it should be based on a specific
arm64 branch, please let me know.
As 558c303c9734 is going to stable, I marked this for stable as well to
avoid breaking Android. I used e35123d83ee3 for the fixes tag to make it
clear to the stable team this should only go where that commit is
present. If a different fixes tag should be used, please feel free to
substitute.
arch/arm64/include/asm/rwonce.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
index 1bce62fa908a..56f7b1d4d54b 100644
--- a/arch/arm64/include/asm/rwonce.h
+++ b/arch/arm64/include/asm/rwonce.h
@@ -5,7 +5,7 @@
#ifndef __ASM_RWONCE_H
#define __ASM_RWONCE_H
-#ifdef CONFIG_LTO
+#if defined(CONFIG_LTO) && !defined(__ASSEMBLY__)
#include <linux/compiler_types.h>
#include <asm/alternative-macros.h>
@@ -66,7 +66,7 @@
})
#endif /* !BUILD_VDSO */
-#endif /* CONFIG_LTO */
+#endif /* CONFIG_LTO && !__ASSEMBLY__ */
#include <asm-generic/rwonce.h>
base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
--
2.35.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
2022-03-09 19:16 ` Nathan Chancellor
@ 2022-03-09 21:53 ` Nick Desaulniers
-1 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2022-03-09 21:53 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
llvm, stable, Marc Zyngier, James Morse
On Wed, Mar 9, 2022 at 11:19 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after
> commit 558c303c9734 ("arm64: Mitigate spectre style branch history side
> channels"), the following error occurs:
>
> <instantiation>:4:2: error: invalid fixup for movz/movk instruction
> mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
> ^
>
> Marc figured out that moving "#include <linux/init.h>" in
> include/linux/arm-smccc.h into a !__ASSEMBLY__ block resolves it. The
> full include chain with CONFIG_LTO=y from include/linux/arm-smccc.h:
>
> include/linux/init.h
> include/linux/compiler.h
> arch/arm64/include/asm/rwonce.h
> arch/arm64/include/asm/alternative-macros.h
> arch/arm64/include/asm/assembler.h
>
> The asm/alternative-macros.h include in asm/rwonce.h only happens when
> CONFIG_LTO is set, which ultimately casues asm/assembler.h to be
> included before the definition of ARM_SMCCC_ARCH_WORKAROUND_3. As a
> result, the preprocessor does not expand ARM_SMCCC_ARCH_WORKAROUND_3 in
> __mitigate_spectre_bhb_fw, which results in the error above.
>
> Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block
> in asm/rwonce.h with assembly files, as nothing in that block is useful
> to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be
> properly expanded with CONFIG_LTO=y builds.
>
> Cc: stable@vger.kernel.org
> Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y")
> Link: https://lore.kernel.org/r/20220309155716.3988480-1-maz@kernel.org/
> Reported-by: Marc Zyngier <maz@kernel.org>
> Acked-by: James Morse <james.morse@arm.com>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks for taking point on all of the BHB fallout.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>
> This is based on current mainline; if it should be based on a specific
> arm64 branch, please let me know.
>
> As 558c303c9734 is going to stable, I marked this for stable as well to
> avoid breaking Android. I used e35123d83ee3 for the fixes tag to make it
> clear to the stable team this should only go where that commit is
> present. If a different fixes tag should be used, please feel free to
> substitute.
>
> arch/arm64/include/asm/rwonce.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
> index 1bce62fa908a..56f7b1d4d54b 100644
> --- a/arch/arm64/include/asm/rwonce.h
> +++ b/arch/arm64/include/asm/rwonce.h
> @@ -5,7 +5,7 @@
> #ifndef __ASM_RWONCE_H
> #define __ASM_RWONCE_H
>
> -#ifdef CONFIG_LTO
> +#if defined(CONFIG_LTO) && !defined(__ASSEMBLY__)
>
> #include <linux/compiler_types.h>
> #include <asm/alternative-macros.h>
> @@ -66,7 +66,7 @@
> })
>
> #endif /* !BUILD_VDSO */
> -#endif /* CONFIG_LTO */
> +#endif /* CONFIG_LTO && !__ASSEMBLY__ */
>
> #include <asm-generic/rwonce.h>
>
>
> base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
> --
> 2.35.1
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
@ 2022-03-09 21:53 ` Nick Desaulniers
0 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2022-03-09 21:53 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
llvm, stable, Marc Zyngier, James Morse
On Wed, Mar 9, 2022 at 11:19 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after
> commit 558c303c9734 ("arm64: Mitigate spectre style branch history side
> channels"), the following error occurs:
>
> <instantiation>:4:2: error: invalid fixup for movz/movk instruction
> mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
> ^
>
> Marc figured out that moving "#include <linux/init.h>" in
> include/linux/arm-smccc.h into a !__ASSEMBLY__ block resolves it. The
> full include chain with CONFIG_LTO=y from include/linux/arm-smccc.h:
>
> include/linux/init.h
> include/linux/compiler.h
> arch/arm64/include/asm/rwonce.h
> arch/arm64/include/asm/alternative-macros.h
> arch/arm64/include/asm/assembler.h
>
> The asm/alternative-macros.h include in asm/rwonce.h only happens when
> CONFIG_LTO is set, which ultimately casues asm/assembler.h to be
> included before the definition of ARM_SMCCC_ARCH_WORKAROUND_3. As a
> result, the preprocessor does not expand ARM_SMCCC_ARCH_WORKAROUND_3 in
> __mitigate_spectre_bhb_fw, which results in the error above.
>
> Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block
> in asm/rwonce.h with assembly files, as nothing in that block is useful
> to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be
> properly expanded with CONFIG_LTO=y builds.
>
> Cc: stable@vger.kernel.org
> Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y")
> Link: https://lore.kernel.org/r/20220309155716.3988480-1-maz@kernel.org/
> Reported-by: Marc Zyngier <maz@kernel.org>
> Acked-by: James Morse <james.morse@arm.com>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks for taking point on all of the BHB fallout.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>
> This is based on current mainline; if it should be based on a specific
> arm64 branch, please let me know.
>
> As 558c303c9734 is going to stable, I marked this for stable as well to
> avoid breaking Android. I used e35123d83ee3 for the fixes tag to make it
> clear to the stable team this should only go where that commit is
> present. If a different fixes tag should be used, please feel free to
> substitute.
>
> arch/arm64/include/asm/rwonce.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
> index 1bce62fa908a..56f7b1d4d54b 100644
> --- a/arch/arm64/include/asm/rwonce.h
> +++ b/arch/arm64/include/asm/rwonce.h
> @@ -5,7 +5,7 @@
> #ifndef __ASM_RWONCE_H
> #define __ASM_RWONCE_H
>
> -#ifdef CONFIG_LTO
> +#if defined(CONFIG_LTO) && !defined(__ASSEMBLY__)
>
> #include <linux/compiler_types.h>
> #include <asm/alternative-macros.h>
> @@ -66,7 +66,7 @@
> })
>
> #endif /* !BUILD_VDSO */
> -#endif /* CONFIG_LTO */
> +#endif /* CONFIG_LTO && !__ASSEMBLY__ */
>
> #include <asm-generic/rwonce.h>
>
>
> base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
> --
> 2.35.1
>
--
Thanks,
~Nick Desaulniers
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
2022-03-09 21:53 ` Nick Desaulniers
@ 2022-03-09 22:31 ` Catalin Marinas
-1 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2022-03-09 22:31 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Nathan Chancellor, Will Deacon, linux-arm-kernel, linux-kernel,
llvm, stable, Marc Zyngier, James Morse
On Wed, Mar 09, 2022 at 01:53:50PM -0800, Nick Desaulniers wrote:
> On Wed, Mar 9, 2022 at 11:19 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block
> > in asm/rwonce.h with assembly files, as nothing in that block is useful
> > to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be
> > properly expanded with CONFIG_LTO=y builds.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y")
> > Link: https://lore.kernel.org/r/20220309155716.3988480-1-maz@kernel.org/
> > Reported-by: Marc Zyngier <maz@kernel.org>
> > Acked-by: James Morse <james.morse@arm.com>
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Thanks for taking point on all of the BHB fallout.
>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Thanks for the review and testing. Unfortunately I've just sent the pull
request to Linus, so didn't include your tags.
--
Catalin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
@ 2022-03-09 22:31 ` Catalin Marinas
0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2022-03-09 22:31 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Nathan Chancellor, Will Deacon, linux-arm-kernel, linux-kernel,
llvm, stable, Marc Zyngier, James Morse
On Wed, Mar 09, 2022 at 01:53:50PM -0800, Nick Desaulniers wrote:
> On Wed, Mar 9, 2022 at 11:19 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > Avoid this problem by just avoiding the CONFIG_LTO=y __READ_ONCE() block
> > in asm/rwonce.h with assembly files, as nothing in that block is useful
> > to assembly files, which allows ARM_SMCCC_ARCH_WORKAROUND_3 to be
> > properly expanded with CONFIG_LTO=y builds.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y")
> > Link: https://lore.kernel.org/r/20220309155716.3988480-1-maz@kernel.org/
> > Reported-by: Marc Zyngier <maz@kernel.org>
> > Acked-by: James Morse <james.morse@arm.com>
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Thanks for taking point on all of the BHB fallout.
>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Thanks for the review and testing. Unfortunately I've just sent the pull
request to Linus, so didn't include your tags.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
2022-03-09 19:16 ` Nathan Chancellor
@ 2022-03-09 22:35 ` Catalin Marinas
-1 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2022-03-09 22:35 UTC (permalink / raw)
To: Nathan Chancellor, Will Deacon
Cc: linux-kernel, llvm, James Morse, Marc Zyngier, stable,
linux-arm-kernel, Nick Desaulniers
On Wed, 9 Mar 2022 12:16:34 -0700, Nathan Chancellor wrote:
> When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after
> commit 558c303c9734 ("arm64: Mitigate spectre style branch history side
> channels"), the following error occurs:
>
> <instantiation>:4:2: error: invalid fixup for movz/movk instruction
> mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
> ^
>
> [...]
Applied to arm64 (for-next/spectre-bhb), thanks!
[1/1] arm64: Do not include __READ_ONCE() block in assembly files
https://git.kernel.org/arm64/c/52c9f93a9c48
--
Catalin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arm64: Do not include __READ_ONCE() block in assembly files
@ 2022-03-09 22:35 ` Catalin Marinas
0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2022-03-09 22:35 UTC (permalink / raw)
To: Nathan Chancellor, Will Deacon
Cc: linux-kernel, llvm, James Morse, Marc Zyngier, stable,
linux-arm-kernel, Nick Desaulniers
On Wed, 9 Mar 2022 12:16:34 -0700, Nathan Chancellor wrote:
> When building arm64 defconfig + CONFIG_LTO_CLANG_{FULL,THIN}=y after
> commit 558c303c9734 ("arm64: Mitigate spectre style branch history side
> channels"), the following error occurs:
>
> <instantiation>:4:2: error: invalid fixup for movz/movk instruction
> mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3
> ^
>
> [...]
Applied to arm64 (for-next/spectre-bhb), thanks!
[1/1] arm64: Do not include __READ_ONCE() block in assembly files
https://git.kernel.org/arm64/c/52c9f93a9c48
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-03-09 22:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 19:16 [PATCH] arm64: Do not include __READ_ONCE() block in assembly files Nathan Chancellor
2022-03-09 19:16 ` Nathan Chancellor
2022-03-09 21:53 ` Nick Desaulniers
2022-03-09 21:53 ` Nick Desaulniers
2022-03-09 22:31 ` Catalin Marinas
2022-03-09 22:31 ` Catalin Marinas
2022-03-09 22:35 ` Catalin Marinas
2022-03-09 22:35 ` Catalin Marinas
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.