All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-02-26 14:03 ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2021-02-26 14:03 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Arnd Bergmann, Ard Biesheuvel, Mark Rutland, Marc Zyngier,
	David Brazdil, Kees Cook, linux-arm-kernel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
I sometimes see an assertion

 ld.lld: error: Entry trampoline text too big

This happens when any reference to the trampoline is discarded at link
time. Marking the section as KEEP() avoids the assertion, but I have
not figured out whether this is the correct solution for the underlying
problem.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm64/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 926cdb597a45..c5ee9d5842db 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -96,7 +96,7 @@ jiffies = jiffies_64;
 #define TRAMP_TEXT					\
 	. = ALIGN(PAGE_SIZE);				\
 	__entry_tramp_text_start = .;			\
-	*(.entry.tramp.text)				\
+	KEEP(*(.entry.tramp.text))			\
 	. = ALIGN(PAGE_SIZE);				\
 	__entry_tramp_text_end = .;
 #else
-- 
2.29.2


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-02-26 14:03 ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2021-02-26 14:03 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Mark Rutland, Kees Cook, Arnd Bergmann, Marc Zyngier,
	linux-kernel, David Brazdil, Ard Biesheuvel, linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
I sometimes see an assertion

 ld.lld: error: Entry trampoline text too big

This happens when any reference to the trampoline is discarded at link
time. Marking the section as KEEP() avoids the assertion, but I have
not figured out whether this is the correct solution for the underlying
problem.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm64/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 926cdb597a45..c5ee9d5842db 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -96,7 +96,7 @@ jiffies = jiffies_64;
 #define TRAMP_TEXT					\
 	. = ALIGN(PAGE_SIZE);				\
 	__entry_tramp_text_start = .;			\
-	*(.entry.tramp.text)				\
+	KEEP(*(.entry.tramp.text))			\
 	. = ALIGN(PAGE_SIZE);				\
 	__entry_tramp_text_end = .;
 #else
-- 
2.29.2


_______________________________________________
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-02-26 14:03 ` Arnd Bergmann
@ 2021-02-26 20:59   ` Kees Cook
  -1 siblings, 0 replies; 18+ messages in thread
From: Kees Cook @ 2021-02-26 20:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Catalin Marinas, Will Deacon, Arnd Bergmann, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, linux-arm-kernel,
	linux-kernel, Fangrui Song

On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> I sometimes see an assertion
> 
>  ld.lld: error: Entry trampoline text too big

Heh, "too big" seems a weird report for having it discarded. :)

Any idea on this Fangrui?

( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )

> 
> This happens when any reference to the trampoline is discarded at link
> time. Marking the section as KEEP() avoids the assertion, but I have
> not figured out whether this is the correct solution for the underlying
> problem.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

As a work-around, it seems fine to me.

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/arm64/kernel/vmlinux.lds.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
> index 926cdb597a45..c5ee9d5842db 100644
> --- a/arch/arm64/kernel/vmlinux.lds.S
> +++ b/arch/arm64/kernel/vmlinux.lds.S
> @@ -96,7 +96,7 @@ jiffies = jiffies_64;
>  #define TRAMP_TEXT					\
>  	. = ALIGN(PAGE_SIZE);				\
>  	__entry_tramp_text_start = .;			\
> -	*(.entry.tramp.text)				\
> +	KEEP(*(.entry.tramp.text))			\
>  	. = ALIGN(PAGE_SIZE);				\
>  	__entry_tramp_text_end = .;
>  #else
> -- 
> 2.29.2
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-02-26 20:59   ` Kees Cook
  0 siblings, 0 replies; 18+ messages in thread
From: Kees Cook @ 2021-02-26 20:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mark Rutland, Fangrui Song, Arnd Bergmann, Catalin Marinas,
	linux-kernel, Marc Zyngier, David Brazdil, Will Deacon,
	Ard Biesheuvel, linux-arm-kernel

On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> I sometimes see an assertion
> 
>  ld.lld: error: Entry trampoline text too big

Heh, "too big" seems a weird report for having it discarded. :)

Any idea on this Fangrui?

( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )

> 
> This happens when any reference to the trampoline is discarded at link
> time. Marking the section as KEEP() avoids the assertion, but I have
> not figured out whether this is the correct solution for the underlying
> problem.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

As a work-around, it seems fine to me.

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/arm64/kernel/vmlinux.lds.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
> index 926cdb597a45..c5ee9d5842db 100644
> --- a/arch/arm64/kernel/vmlinux.lds.S
> +++ b/arch/arm64/kernel/vmlinux.lds.S
> @@ -96,7 +96,7 @@ jiffies = jiffies_64;
>  #define TRAMP_TEXT					\
>  	. = ALIGN(PAGE_SIZE);				\
>  	__entry_tramp_text_start = .;			\
> -	*(.entry.tramp.text)				\
> +	KEEP(*(.entry.tramp.text))			\
>  	. = ALIGN(PAGE_SIZE);				\
>  	__entry_tramp_text_end = .;
>  #else
> -- 
> 2.29.2
> 

-- 
Kees Cook

_______________________________________________
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-02-26 20:59   ` Kees Cook
@ 2021-02-27  4:32     ` Fangrui Song
  -1 siblings, 0 replies; 18+ messages in thread
From: Fangrui Song @ 2021-02-27  4:32 UTC (permalink / raw)
  To: Kees Cook
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Arnd Bergmann,
	Ard Biesheuvel, Mark Rutland, Marc Zyngier, David Brazdil,
	linux-arm-kernel, linux-kernel


On 2021-02-26, Kees Cook wrote:
>On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
>> I sometimes see an assertion
>>
>>  ld.lld: error: Entry trampoline text too big
>
>Heh, "too big" seems a weird report for having it discarded. :)
>
>Any idea on this Fangrui?
>
>( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )

This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds

   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
    "Entry trampoline text too big")

In our case (aarch64-linux-gnu-ld or LLD, --gc-sections), all the input sections with this name
are discarded, so the output section is either absent (GNU ld) or empty (LLD).

KEEP  makes the sections GC roots, and it is appropriate to use here.


However, I worry that many other KEEP keywords in vmlinux.lds are unnecessary:
https://lore.kernel.org/linux-arm-kernel/20210226211323.arkvjnr4hifxapqu@google.com/

git log -S KEEP -- include/asm-generic/vmlinux.lds.h => there is quite a
bit unjustified usage. Sure, adding KEEP (GC root) is easy and
works around problems, but it not good for CONFIG_LD_DEAD_CODE_DATA_ELIMINATION.

Reviewed-by: Fangrui Song <maskray@google.com>

>

>>
>> This happens when any reference to the trampoline is discarded at link
>> time. Marking the section as KEEP() avoids the assertion, but I have
>> not figured out whether this is the correct solution for the underlying
>> problem.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
>As a work-around, it seems fine to me.
>
>Reviewed-by: Kees Cook <keescook@chromium.org>
>
>-Kees
>
>> ---
>>  arch/arm64/kernel/vmlinux.lds.S | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
>> index 926cdb597a45..c5ee9d5842db 100644
>> --- a/arch/arm64/kernel/vmlinux.lds.S
>> +++ b/arch/arm64/kernel/vmlinux.lds.S
>> @@ -96,7 +96,7 @@ jiffies = jiffies_64;
>>  #define TRAMP_TEXT					\
>>  	. = ALIGN(PAGE_SIZE);				\
>>  	__entry_tramp_text_start = .;			\
>> -	*(.entry.tramp.text)				\
>> +	KEEP(*(.entry.tramp.text))			\
>>  	. = ALIGN(PAGE_SIZE);				\
>>  	__entry_tramp_text_end = .;
>>  #else
>> --
>> 2.29.2
>>
>
>-- 
>Kees Cook

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-02-27  4:32     ` Fangrui Song
  0 siblings, 0 replies; 18+ messages in thread
From: Fangrui Song @ 2021-02-27  4:32 UTC (permalink / raw)
  To: Kees Cook
  Cc: Mark Rutland, Arnd Bergmann, Arnd Bergmann, Catalin Marinas,
	linux-kernel, Marc Zyngier, David Brazdil, Will Deacon,
	Ard Biesheuvel, linux-arm-kernel


On 2021-02-26, Kees Cook wrote:
>On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
>> I sometimes see an assertion
>>
>>  ld.lld: error: Entry trampoline text too big
>
>Heh, "too big" seems a weird report for having it discarded. :)
>
>Any idea on this Fangrui?
>
>( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )

This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds

   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
    "Entry trampoline text too big")

In our case (aarch64-linux-gnu-ld or LLD, --gc-sections), all the input sections with this name
are discarded, so the output section is either absent (GNU ld) or empty (LLD).

KEEP  makes the sections GC roots, and it is appropriate to use here.


However, I worry that many other KEEP keywords in vmlinux.lds are unnecessary:
https://lore.kernel.org/linux-arm-kernel/20210226211323.arkvjnr4hifxapqu@google.com/

git log -S KEEP -- include/asm-generic/vmlinux.lds.h => there is quite a
bit unjustified usage. Sure, adding KEEP (GC root) is easy and
works around problems, but it not good for CONFIG_LD_DEAD_CODE_DATA_ELIMINATION.

Reviewed-by: Fangrui Song <maskray@google.com>

>

>>
>> This happens when any reference to the trampoline is discarded at link
>> time. Marking the section as KEEP() avoids the assertion, but I have
>> not figured out whether this is the correct solution for the underlying
>> problem.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
>As a work-around, it seems fine to me.
>
>Reviewed-by: Kees Cook <keescook@chromium.org>
>
>-Kees
>
>> ---
>>  arch/arm64/kernel/vmlinux.lds.S | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
>> index 926cdb597a45..c5ee9d5842db 100644
>> --- a/arch/arm64/kernel/vmlinux.lds.S
>> +++ b/arch/arm64/kernel/vmlinux.lds.S
>> @@ -96,7 +96,7 @@ jiffies = jiffies_64;
>>  #define TRAMP_TEXT					\
>>  	. = ALIGN(PAGE_SIZE);				\
>>  	__entry_tramp_text_start = .;			\
>> -	*(.entry.tramp.text)				\
>> +	KEEP(*(.entry.tramp.text))			\
>>  	. = ALIGN(PAGE_SIZE);				\
>>  	__entry_tramp_text_end = .;
>>  #else
>> --
>> 2.29.2
>>
>
>-- 
>Kees Cook

_______________________________________________
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-02-27  4:32     ` Fangrui Song
@ 2021-03-16 10:45       ` Catalin Marinas
  -1 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-03-16 10:45 UTC (permalink / raw)
  To: Fangrui Song
  Cc: Kees Cook, Arnd Bergmann, Will Deacon, Arnd Bergmann,
	Ard Biesheuvel, Mark Rutland, Marc Zyngier, David Brazdil,
	linux-arm-kernel, linux-kernel

On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> On 2021-02-26, Kees Cook wrote:
> > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@arndb.de>
> > > 
> > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > I sometimes see an assertion
> > > 
> > >  ld.lld: error: Entry trampoline text too big
> > 
> > Heh, "too big" seems a weird report for having it discarded. :)
> > 
> > Any idea on this Fangrui?
> > 
> > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> 
> This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> 
>   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
>    "Entry trampoline text too big")

Can we not change the ASSERT to be <= PAGE_SIZE instead?

-- 
Catalin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-03-16 10:45       ` Catalin Marinas
  0 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-03-16 10:45 UTC (permalink / raw)
  To: Fangrui Song
  Cc: Kees Cook, Arnd Bergmann, Will Deacon, Arnd Bergmann,
	Ard Biesheuvel, Mark Rutland, Marc Zyngier, David Brazdil,
	linux-arm-kernel, linux-kernel

On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> On 2021-02-26, Kees Cook wrote:
> > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@arndb.de>
> > > 
> > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > I sometimes see an assertion
> > > 
> > >  ld.lld: error: Entry trampoline text too big
> > 
> > Heh, "too big" seems a weird report for having it discarded. :)
> > 
> > Any idea on this Fangrui?
> > 
> > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> 
> This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> 
>   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
>    "Entry trampoline text too big")

Can we not change the ASSERT to be <= PAGE_SIZE instead?

-- 
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-03-16 10:45       ` Catalin Marinas
@ 2021-03-16 16:27         ` Catalin Marinas
  -1 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-03-16 16:27 UTC (permalink / raw)
  To: Fangrui Song
  Cc: Kees Cook, Arnd Bergmann, Will Deacon, Arnd Bergmann,
	Ard Biesheuvel, Mark Rutland, Marc Zyngier, David Brazdil,
	linux-arm-kernel, linux-kernel

On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > On 2021-02-26, Kees Cook wrote:
> > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > 
> > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > I sometimes see an assertion
> > > > 
> > > >  ld.lld: error: Entry trampoline text too big
> > > 
> > > Heh, "too big" seems a weird report for having it discarded. :)
> > > 
> > > Any idea on this Fangrui?
> > > 
> > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > 
> > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > 
> >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> >    "Entry trampoline text too big")
> 
> Can we not change the ASSERT to be <= PAGE_SIZE instead?

Ah, that won't work as I suspect we still need the trampoline section.

Arnd, do you know why this section disappears? I did a simple test with
defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
still around.

-- 
Catalin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-03-16 16:27         ` Catalin Marinas
  0 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-03-16 16:27 UTC (permalink / raw)
  To: Fangrui Song
  Cc: Kees Cook, Arnd Bergmann, Will Deacon, Arnd Bergmann,
	Ard Biesheuvel, Mark Rutland, Marc Zyngier, David Brazdil,
	linux-arm-kernel, linux-kernel

On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > On 2021-02-26, Kees Cook wrote:
> > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > 
> > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > I sometimes see an assertion
> > > > 
> > > >  ld.lld: error: Entry trampoline text too big
> > > 
> > > Heh, "too big" seems a weird report for having it discarded. :)
> > > 
> > > Any idea on this Fangrui?
> > > 
> > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > 
> > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > 
> >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> >    "Entry trampoline text too big")
> 
> Can we not change the ASSERT to be <= PAGE_SIZE instead?

Ah, that won't work as I suspect we still need the trampoline section.

Arnd, do you know why this section disappears? I did a simple test with
defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
still around.

-- 
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-03-16 16:27         ` Catalin Marinas
@ 2021-03-16 16:39           ` Arnd Bergmann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2021-03-16 16:39 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Fangrui Song, Kees Cook, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > On 2021-02-26, Kees Cook wrote:
> > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > >
> > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > I sometimes see an assertion
> > > > >
> > > > >  ld.lld: error: Entry trampoline text too big
> > > >
> > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > >
> > > > Any idea on this Fangrui?
> > > >
> > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > >
> > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > >
> > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > >    "Entry trampoline text too big")
> >
> > Can we not change the ASSERT to be <= PAGE_SIZE instead?
>
> Ah, that won't work as I suspect we still need the trampoline section.
>
> Arnd, do you know why this section disappears? I did a simple test with
> defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> still around.

If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
is disabled, which dropped the only reference into this section.
If that doesn't make sense, I can try digging through the old build logs to
reproduce the problem.

    Arnd

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-03-16 16:39           ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2021-03-16 16:39 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Fangrui Song, Kees Cook, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > On 2021-02-26, Kees Cook wrote:
> > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > >
> > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > I sometimes see an assertion
> > > > >
> > > > >  ld.lld: error: Entry trampoline text too big
> > > >
> > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > >
> > > > Any idea on this Fangrui?
> > > >
> > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > >
> > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > >
> > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > >    "Entry trampoline text too big")
> >
> > Can we not change the ASSERT to be <= PAGE_SIZE instead?
>
> Ah, that won't work as I suspect we still need the trampoline section.
>
> Arnd, do you know why this section disappears? I did a simple test with
> defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> still around.

If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
is disabled, which dropped the only reference into this section.
If that doesn't make sense, I can try digging through the old build logs to
reproduce the problem.

    Arnd

_______________________________________________
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-03-16 16:39           ` Arnd Bergmann
@ 2021-03-16 19:09             ` Catalin Marinas
  -1 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-03-16 19:09 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Fangrui Song, Kees Cook, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote:
> On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > > On 2021-02-26, Kees Cook wrote:
> > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > > >
> > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > > I sometimes see an assertion
> > > > > >
> > > > > >  ld.lld: error: Entry trampoline text too big
> > > > >
> > > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > > >
> > > > > Any idea on this Fangrui?
> > > > >
> > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > > >
> > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > > >
> > > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > > >    "Entry trampoline text too big")
> > >
> > > Can we not change the ASSERT to be <= PAGE_SIZE instead?
> >
> > Ah, that won't work as I suspect we still need the trampoline section.
> >
> > Arnd, do you know why this section disappears? I did a simple test with
> > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> > still around.
> 
> If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
> is disabled, which dropped the only reference into this section.
> If that doesn't make sense, I can try digging through the old build logs to
> reproduce the problem.

I suspected this as well but still worked for me when disabling it.

Anyway, I don't think identifying the exact option is necessary. With
CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only
__entry_tramp_text_start/end are referenced.

In this case we happened to detect this issue because of the ASSERT in
vmlinux.lds.S but I wonder what else the linker drops with this dead
code elimination that we may not notice (it seems to remove about 500KB
from the resulting image in my test).

I'll push these two patches to -next for wider coverage before deciding
on mainline (though the option may not get much testing as it's hidden
behind EXPERT and default n).

-- 
Catalin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-03-16 19:09             ` Catalin Marinas
  0 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-03-16 19:09 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Fangrui Song, Kees Cook, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote:
> On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > > On 2021-02-26, Kees Cook wrote:
> > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > > >
> > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > > I sometimes see an assertion
> > > > > >
> > > > > >  ld.lld: error: Entry trampoline text too big
> > > > >
> > > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > > >
> > > > > Any idea on this Fangrui?
> > > > >
> > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > > >
> > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > > >
> > > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > > >    "Entry trampoline text too big")
> > >
> > > Can we not change the ASSERT to be <= PAGE_SIZE instead?
> >
> > Ah, that won't work as I suspect we still need the trampoline section.
> >
> > Arnd, do you know why this section disappears? I did a simple test with
> > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> > still around.
> 
> If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
> is disabled, which dropped the only reference into this section.
> If that doesn't make sense, I can try digging through the old build logs to
> reproduce the problem.

I suspected this as well but still worked for me when disabling it.

Anyway, I don't think identifying the exact option is necessary. With
CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only
__entry_tramp_text_start/end are referenced.

In this case we happened to detect this issue because of the ASSERT in
vmlinux.lds.S but I wonder what else the linker drops with this dead
code elimination that we may not notice (it seems to remove about 500KB
from the resulting image in my test).

I'll push these two patches to -next for wider coverage before deciding
on mainline (though the option may not get much testing as it's hidden
behind EXPERT and default n).

-- 
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-03-16 19:09             ` Catalin Marinas
@ 2021-06-02 19:32               ` Kees Cook
  -1 siblings, 0 replies; 18+ messages in thread
From: Kees Cook @ 2021-06-02 19:32 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Arnd Bergmann, Fangrui Song, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote:
> On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote:
> > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > > > On 2021-02-26, Kees Cook wrote:
> > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > > > >
> > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > > > I sometimes see an assertion
> > > > > > >
> > > > > > >  ld.lld: error: Entry trampoline text too big
> > > > > >
> > > > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > > > >
> > > > > > Any idea on this Fangrui?
> > > > > >
> > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > > > >
> > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > > > >
> > > > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > > > >    "Entry trampoline text too big")
> > > >
> > > > Can we not change the ASSERT to be <= PAGE_SIZE instead?
> > >
> > > Ah, that won't work as I suspect we still need the trampoline section.
> > >
> > > Arnd, do you know why this section disappears? I did a simple test with
> > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> > > still around.
> > 
> > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
> > is disabled, which dropped the only reference into this section.
> > If that doesn't make sense, I can try digging through the old build logs to
> > reproduce the problem.
> 
> I suspected this as well but still worked for me when disabling it.
> 
> Anyway, I don't think identifying the exact option is necessary. With
> CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only
> __entry_tramp_text_start/end are referenced.
> 
> In this case we happened to detect this issue because of the ASSERT in
> vmlinux.lds.S but I wonder what else the linker drops with this dead
> code elimination that we may not notice (it seems to remove about 500KB
> from the resulting image in my test).
> 
> I'll push these two patches to -next for wider coverage before deciding
> on mainline (though the option may not get much testing as it's hidden
> behind EXPERT and default n).

I don't see this in -next? Catalin, do you want me to pick it up as part
of my collecting various linker fixes?

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-06-02 19:32               ` Kees Cook
  0 siblings, 0 replies; 18+ messages in thread
From: Kees Cook @ 2021-06-02 19:32 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Arnd Bergmann, Fangrui Song, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote:
> On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote:
> > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > > > On 2021-02-26, Kees Cook wrote:
> > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > > > >
> > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > > > I sometimes see an assertion
> > > > > > >
> > > > > > >  ld.lld: error: Entry trampoline text too big
> > > > > >
> > > > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > > > >
> > > > > > Any idea on this Fangrui?
> > > > > >
> > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > > > >
> > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > > > >
> > > > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > > > >    "Entry trampoline text too big")
> > > >
> > > > Can we not change the ASSERT to be <= PAGE_SIZE instead?
> > >
> > > Ah, that won't work as I suspect we still need the trampoline section.
> > >
> > > Arnd, do you know why this section disappears? I did a simple test with
> > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> > > still around.
> > 
> > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
> > is disabled, which dropped the only reference into this section.
> > If that doesn't make sense, I can try digging through the old build logs to
> > reproduce the problem.
> 
> I suspected this as well but still worked for me when disabling it.
> 
> Anyway, I don't think identifying the exact option is necessary. With
> CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only
> __entry_tramp_text_start/end are referenced.
> 
> In this case we happened to detect this issue because of the ASSERT in
> vmlinux.lds.S but I wonder what else the linker drops with this dead
> code elimination that we may not notice (it seems to remove about 500KB
> from the resulting image in my test).
> 
> I'll push these two patches to -next for wider coverage before deciding
> on mainline (though the option may not get much testing as it's hidden
> behind EXPERT and default n).

I don't see this in -next? Catalin, do you want me to pick it up as part
of my collecting various linker fixes?

-Kees

-- 
Kees Cook

_______________________________________________
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] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
  2021-06-02 19:32               ` Kees Cook
@ 2021-06-03 12:07                 ` Catalin Marinas
  -1 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-06-03 12:07 UTC (permalink / raw)
  To: Kees Cook
  Cc: Arnd Bergmann, Fangrui Song, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Wed, Jun 02, 2021 at 12:32:40PM -0700, Kees Cook wrote:
> On Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote:
> > On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote:
> > > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > > > > On 2021-02-26, Kees Cook wrote:
> > > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > > > > >
> > > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > > > > I sometimes see an assertion
> > > > > > > >
> > > > > > > >  ld.lld: error: Entry trampoline text too big
> > > > > > >
> > > > > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > > > > >
> > > > > > > Any idea on this Fangrui?
> > > > > > >
> > > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > > > > >
> > > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > > > > >
> > > > > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > > > > >    "Entry trampoline text too big")
> > > > >
> > > > > Can we not change the ASSERT to be <= PAGE_SIZE instead?
> > > >
> > > > Ah, that won't work as I suspect we still need the trampoline section.
> > > >
> > > > Arnd, do you know why this section disappears? I did a simple test with
> > > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> > > > still around.
> > > 
> > > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
> > > is disabled, which dropped the only reference into this section.
> > > If that doesn't make sense, I can try digging through the old build logs to
> > > reproduce the problem.
> > 
> > I suspected this as well but still worked for me when disabling it.
> > 
> > Anyway, I don't think identifying the exact option is necessary. With
> > CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only
> > __entry_tramp_text_start/end are referenced.
> > 
> > In this case we happened to detect this issue because of the ASSERT in
> > vmlinux.lds.S but I wonder what else the linker drops with this dead
> > code elimination that we may not notice (it seems to remove about 500KB
> > from the resulting image in my test).
> > 
> > I'll push these two patches to -next for wider coverage before deciding
> > on mainline (though the option may not get much testing as it's hidden
> > behind EXPERT and default n).
> 
> I don't see this in -next? Catalin, do you want me to pick it up as part
> of my collecting various linker fixes?

IIRC this patch only makes sense if we also enable
HAVE_LD_DEAD_CODE_DATA_ELIMINATION on arm64. Last time I looked at
Arnd's RFC it still had some issues:

https://lore.kernel.org/r/20210319122506.GA6832@arm.com

So I decided against queuing that for now (and this patch on top was not
necessary).

-- 
Catalin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section
@ 2021-06-03 12:07                 ` Catalin Marinas
  0 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2021-06-03 12:07 UTC (permalink / raw)
  To: Kees Cook
  Cc: Arnd Bergmann, Fangrui Song, Will Deacon, Ard Biesheuvel,
	Mark Rutland, Marc Zyngier, David Brazdil, Linux ARM,
	linux-kernel

On Wed, Jun 02, 2021 at 12:32:40PM -0700, Kees Cook wrote:
> On Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote:
> > On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote:
> > > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote:
> > > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote:
> > > > > > On 2021-02-26, Kees Cook wrote:
> > > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
> > > > > > > > From: Arnd Bergmann <arnd@arndb.de>
> > > > > > > >
> > > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
> > > > > > > > I sometimes see an assertion
> > > > > > > >
> > > > > > > >  ld.lld: error: Entry trampoline text too big
> > > > > > >
> > > > > > > Heh, "too big" seems a weird report for having it discarded. :)
> > > > > > >
> > > > > > > Any idea on this Fangrui?
> > > > > > >
> > > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )
> > > > > >
> > > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds
> > > > > >
> > > > > >   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
> > > > > >    "Entry trampoline text too big")
> > > > >
> > > > > Can we not change the ASSERT to be <= PAGE_SIZE instead?
> > > >
> > > > Ah, that won't work as I suspect we still need the trampoline section.
> > > >
> > > > Arnd, do you know why this section disappears? I did a simple test with
> > > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is
> > > > still around.
> > > 
> > > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE
> > > is disabled, which dropped the only reference into this section.
> > > If that doesn't make sense, I can try digging through the old build logs to
> > > reproduce the problem.
> > 
> > I suspected this as well but still worked for me when disabling it.
> > 
> > Anyway, I don't think identifying the exact option is necessary. With
> > CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only
> > __entry_tramp_text_start/end are referenced.
> > 
> > In this case we happened to detect this issue because of the ASSERT in
> > vmlinux.lds.S but I wonder what else the linker drops with this dead
> > code elimination that we may not notice (it seems to remove about 500KB
> > from the resulting image in my test).
> > 
> > I'll push these two patches to -next for wider coverage before deciding
> > on mainline (though the option may not get much testing as it's hidden
> > behind EXPERT and default n).
> 
> I don't see this in -next? Catalin, do you want me to pick it up as part
> of my collecting various linker fixes?

IIRC this patch only makes sense if we also enable
HAVE_LD_DEAD_CODE_DATA_ELIMINATION on arm64. Last time I looked at
Arnd's RFC it still had some issues:

https://lore.kernel.org/r/20210319122506.GA6832@arm.com

So I decided against queuing that for now (and this patch on top was not
necessary).

-- 
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] 18+ messages in thread

end of thread, other threads:[~2021-06-03 12:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 14:03 [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section Arnd Bergmann
2021-02-26 14:03 ` Arnd Bergmann
2021-02-26 20:59 ` Kees Cook
2021-02-26 20:59   ` Kees Cook
2021-02-27  4:32   ` Fangrui Song
2021-02-27  4:32     ` Fangrui Song
2021-03-16 10:45     ` Catalin Marinas
2021-03-16 10:45       ` Catalin Marinas
2021-03-16 16:27       ` Catalin Marinas
2021-03-16 16:27         ` Catalin Marinas
2021-03-16 16:39         ` Arnd Bergmann
2021-03-16 16:39           ` Arnd Bergmann
2021-03-16 19:09           ` Catalin Marinas
2021-03-16 19:09             ` Catalin Marinas
2021-06-02 19:32             ` Kees Cook
2021-06-02 19:32               ` Kees Cook
2021-06-03 12:07               ` Catalin Marinas
2021-06-03 12:07                 ` 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.