Thread (26 messages) 26 messages, 10 authors, 2021-03-19

Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION

From: Arnd Bergmann <arnd@kernel.org>
Date: 2021-03-19 14:02:29
Also in: lkml

On Fri, Mar 19, 2021 at 1:25 PM Catalin Marinas [off-list ref] wrote:
On Thu, Mar 18, 2021 at 09:41:54AM +0100, Arnd Bergmann wrote:
quoted
On Wed, Mar 17, 2021 at 5:18 PM Catalin Marinas [off-list ref] wrote:
quoted
On Wed, Mar 17, 2021 at 02:37:57PM +0000, Catalin Marinas wrote:
quoted
On Thu, Feb 25, 2021 at 12:20:56PM +0100, Arnd Bergmann wrote:
quoted
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index bad2b9eaab22..926cdb597a45 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -217,7 +217,7 @@ SECTIONS
            INIT_CALLS
            CON_INITCALL
            INIT_RAM_FS
-           *(.init.altinstructions .init.bss .init.bss.*)  /* from the EFI stub */
+           *(.init.altinstructions .init.data.* .init.bss .init.bss.*)     /* from the EFI stub */
INIT_DATA already covers .init.data and .init.data.*, so I don't think
we need this change.
Ah, INIT_DATA only covers init.data.* (so no dot in front). The above
is needed for the EFI stub.
I wonder if that is just a typo in INIT_DATA. Nico introduced it as part of
266ff2a8f51f ("kbuild: Fix asm-generic/vmlinux.lds.h for
LD_DEAD_CODE_DATA_ELIMINATION"), so perhaps that should have
been .init.data.* instead.
I think it was the other Nicholas ;) (with an 'h'). The vmlinux.lds.h
change indeed looks like a typo (it's been around since 4.18).
Right, my mistake.
quoted hunk ↗ jump to hunk
quoted
It looks like pointer authentication gone wrong, which ended up
with dereferencing the broken pointer in x22, and it explains why
it only happens with -cpu max. Presumably this also only happens
on secondary CPUs, so maybe the bit that initializes PAC on
secondary CPUs got discarded?
I seems that the whole alternative instructions section is gone, so any
run-time code patching that the kernel does won't work. The kernel boots
with the diff below but I'm not convinced we don't miss anything else.
In some cases you get a linker warning about gc sections but not in this
case. Maybe we need some more asserts to ensure that certain sections
are not empty.
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 11909782ee3e..036cc59033d3 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -203,7 +203,7 @@ SECTIONS
        . = ALIGN(4);
        .altinstructions : {
                __alt_instructions = .;
-               *(.altinstructions)
+               KEEP(*(.altinstructions))
                __alt_instructions_end = .;
        }
Do we need a KEEP(.init.altinstructions) as well?
I would guess so. Whatever causes the .altinstructions to get dropped
presumably also leads to the same happening to .init.altinstructions.

Ideally each use of altinstructions would cause a reference to a
particular symbol so that one gets kept, while any .altinstructions
for unused functions get discarded.

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help