diff mbox series

[v3,01/60] arm64: kernel: Disable latent_entropy GCC plugin in early C runtime

Message ID 20230307140522.2311461-2-ardb@kernel.org (mailing list archive)
State New, archived
Headers show
Series arm64: Add support for LPA2 at stage1 and WXN | expand

Commit Message

Ard Biesheuvel March 7, 2023, 2:04 p.m. UTC
Avoid build issues in the early C code related to the latent_entropy GCC
plugin, by incorporating the C flags fragment that disables it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm64/kernel/pi/Makefile | 1 +
 1 file changed, 1 insertion(+)

Comments

Mark Rutland April 28, 2023, 10:37 a.m. UTC | #1
On Tue, Mar 07, 2023 at 03:04:23PM +0100, Ard Biesheuvel wrote:
> Avoid build issues in the early C code related to the latent_entropy GCC
> plugin, by incorporating the C flags fragment that disables it.
> 
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

Just to check, are you seeing issues today? IIUC the plugin only instruments
functions which are explicitly marked with __latent_entropy, and if we're
seeing that happen unexpectedly (or due to that being applying to __meminit /
__init), we might need to do likewise for other noinstr code.

Regardless, for this patch:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

> ---
>  arch/arm64/kernel/pi/Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile
> index 4c0ea3cd4ea406b6..c844a0546d7f0e62 100644
> --- a/arch/arm64/kernel/pi/Makefile
> +++ b/arch/arm64/kernel/pi/Makefile
> @@ -3,6 +3,7 @@
>  
>  KBUILD_CFLAGS	:= $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
>  		   -Os -DDISABLE_BRANCH_PROFILING $(DISABLE_STACKLEAK_PLUGIN) \
> +		   $(DISABLE_LATENT_ENTROPY_PLUGIN) \
>  		   $(call cc-option,-mbranch-protection=none) \
>  		   -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
>  		   -include $(srctree)/include/linux/hidden.h \
> -- 
> 2.39.2
> 
>
Ard Biesheuvel April 28, 2023, 10:54 a.m. UTC | #2
On Fri, 28 Apr 2023 at 11:38, Mark Rutland <mark.rutland@arm.com> wrote:
>
> On Tue, Mar 07, 2023 at 03:04:23PM +0100, Ard Biesheuvel wrote:
> > Avoid build issues in the early C code related to the latent_entropy GCC
> > plugin, by incorporating the C flags fragment that disables it.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> Just to check, are you seeing issues today? IIUC the plugin only instruments
> functions which are explicitly marked with __latent_entropy, and if we're
> seeing that happen unexpectedly (or due to that being applying to __meminit /
> __init), we might need to do likewise for other noinstr code.
>

I don't quite remember, tbh, but it is unlikely that I would have
written or included this patch without having run into some actual
issue.

> Regardless, for this patch:
>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
>

Thanks,
Mark Rutland April 28, 2023, 11:48 a.m. UTC | #3
On Fri, Apr 28, 2023 at 11:54:16AM +0100, Ard Biesheuvel wrote:
> On Fri, 28 Apr 2023 at 11:38, Mark Rutland <mark.rutland@arm.com> wrote:
> >
> > On Tue, Mar 07, 2023 at 03:04:23PM +0100, Ard Biesheuvel wrote:
> > > Avoid build issues in the early C code related to the latent_entropy GCC
> > > plugin, by incorporating the C flags fragment that disables it.
> > >
> > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> >
> > Just to check, are you seeing issues today? IIUC the plugin only instruments
> > functions which are explicitly marked with __latent_entropy, and if we're
> > seeing that happen unexpectedly (or due to that being applying to __meminit /
> > __init), we might need to do likewise for other noinstr code.
> >
> 
> I don't quite remember, tbh, but it is unlikely that I would have
> written or included this patch without having run into some actual
> issue.

Sure.

Looking at the series, from patch 15 onwards you mark portions of the PI code
as __init. As __init currently implies __latent_entropy (which I think is a bit
crazy as of itself...), that's why this'll start to fail.

It would be nice if we could mention that in the commit message, e.g.

| In subsequent patches we'll mark portions of the early C code as __init.
| Unfortunarely, __init implies __latent_entropy, and this would result in the
| early C code being instrumented in an unsafe manner.
|
| Disable the latent entropy plugin for the early C code.

... though my ack stands regardless of whether we add such wording.

Mark.

> > Regardless, for this patch:
> >
> > Acked-by: Mark Rutland <mark.rutland@arm.com>
> >
> 
> Thanks,
diff mbox series

Patch

diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile
index 4c0ea3cd4ea406b6..c844a0546d7f0e62 100644
--- a/arch/arm64/kernel/pi/Makefile
+++ b/arch/arm64/kernel/pi/Makefile
@@ -3,6 +3,7 @@ 
 
 KBUILD_CFLAGS	:= $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
 		   -Os -DDISABLE_BRANCH_PROFILING $(DISABLE_STACKLEAK_PLUGIN) \
+		   $(DISABLE_LATENT_ENTROPY_PLUGIN) \
 		   $(call cc-option,-mbranch-protection=none) \
 		   -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
 		   -include $(srctree)/include/linux/hidden.h \