diff mbox series

[v5,1/8] arch: enable relative relocations for arm64, power, x86, s390 and x86

Message ID 20171225205440.14575-2-ard.biesheuvel@linaro.org
State Superseded
Headers show
Series add support for relative references in special sections | expand

Commit Message

Ard Biesheuvel Dec. 25, 2017, 8:54 p.m. UTC
Before updating certain subsystems to use place relative 32-bit
relocations in special sections, to save space  and reduce the
number of absolute relocations that need to be processed at runtime
by relocatable kernels, introduce the Kconfig symbol and define it
for some architectures that should be able to support and benefit
from it.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 arch/Kconfig                    | 10 ++++++++++
 arch/arm64/Kconfig              |  1 +
 arch/arm64/kernel/vmlinux.lds.S |  2 +-
 arch/powerpc/Kconfig            |  1 +
 arch/s390/Kconfig               |  1 +
 arch/x86/Kconfig                |  1 +
 6 files changed, 15 insertions(+), 1 deletion(-)

-- 
2.11.0

Comments

Sam Ravnborg Dec. 25, 2017, 9:05 p.m. UTC | #1
Hi Ard.

On Mon, Dec 25, 2017 at 08:54:33PM +0000, Ard Biesheuvel wrote:
> Before updating certain subsystems to use place relative 32-bit

> relocations in special sections, to save space  and reduce the

> number of absolute relocations that need to be processed at runtime

> by relocatable kernels, introduce the Kconfig symbol and define it

> for some architectures that should be able to support and benefit

> from it.

> 

> Cc: Catalin Marinas <catalin.marinas@arm.com>

> Cc: Will Deacon <will.deacon@arm.com>

> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> Cc: Paul Mackerras <paulus@samba.org>

> Cc: Michael Ellerman <mpe@ellerman.id.au>

> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>

> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>

> Cc: Thomas Gleixner <tglx@linutronix.de>

> Cc: Ingo Molnar <mingo@redhat.com>

> Cc: "H. Peter Anvin" <hpa@zytor.com>

> Cc: x86@kernel.org

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  arch/Kconfig                    | 10 ++++++++++

>  arch/arm64/Kconfig              |  1 +


>  arch/arm64/kernel/vmlinux.lds.S |  2 +-

The change to arch/arm64/kernel/vmlinux.lds.S is
not justified in the changelog.
Did you add it by mistake?

	Sam
Ard Biesheuvel Dec. 25, 2017, 9:09 p.m. UTC | #2
On 25 December 2017 at 21:05, Sam Ravnborg <sam@ravnborg.org> wrote:
> Hi Ard.

>

> On Mon, Dec 25, 2017 at 08:54:33PM +0000, Ard Biesheuvel wrote:

>> Before updating certain subsystems to use place relative 32-bit

>> relocations in special sections, to save space  and reduce the

>> number of absolute relocations that need to be processed at runtime

>> by relocatable kernels, introduce the Kconfig symbol and define it

>> for some architectures that should be able to support and benefit

>> from it.

>>

>> Cc: Catalin Marinas <catalin.marinas@arm.com>

>> Cc: Will Deacon <will.deacon@arm.com>

>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>

>> Cc: Paul Mackerras <paulus@samba.org>

>> Cc: Michael Ellerman <mpe@ellerman.id.au>

>> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>

>> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>

>> Cc: Thomas Gleixner <tglx@linutronix.de>

>> Cc: Ingo Molnar <mingo@redhat.com>

>> Cc: "H. Peter Anvin" <hpa@zytor.com>

>> Cc: x86@kernel.org

>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>> ---

>>  arch/Kconfig                    | 10 ++++++++++

>>  arch/arm64/Kconfig              |  1 +

>

>>  arch/arm64/kernel/vmlinux.lds.S |  2 +-

> The change to arch/arm64/kernel/vmlinux.lds.S is

> not justified in the changelog.

> Did you add it by mistake?

>


No. The PREL32 support adds a __ADDRESSABLE() macro that emits code
into .discard.text, and on arm64, the EFI object sections get a .init
prefix so we need to discard .init.discard.* explicitly as well.

I will add this as a note.

Thanks,
Ard.
diff mbox series

Patch

diff --git a/arch/Kconfig b/arch/Kconfig
index 400b9e1b2f27..dbc036a7bd1b 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -959,4 +959,14 @@  config REFCOUNT_FULL
 	  against various use-after-free conditions that can be used in
 	  security flaw exploits.
 
+config HAVE_ARCH_PREL32_RELOCATIONS
+	bool
+	help
+	  May be selected by an architecture if it supports place-relative
+	  32-bit relocations, both in the toolchain and in the module loader,
+	  in which case relative references can be used in special sections
+	  for PCI fixup, initcalls etc which are only half the size on 64 bit
+	  architectures, and don't require runtime relocation on relocatable
+	  kernels.
+
 source "kernel/gcov/Kconfig"
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index c9a7e9e1414f..66c7b9ab2a3d 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -89,6 +89,7 @@  config ARM64
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 7da3e5c366a0..49ae5b43fe2b 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -156,7 +156,7 @@  SECTIONS
 		CON_INITCALL
 		SECURITY_INITCALL
 		INIT_RAM_FS
-		*(.init.rodata.* .init.bss)	/* from the EFI stub */
+		*(.init.rodata.* .init.bss .init.discard.*)	/* EFI stub */
 	}
 	.exit.data : {
 		ARM_EXIT_KEEP(EXIT_DATA)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c51e6ce42e7a..e172478e2ae7 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -177,6 +177,7 @@  config PPC
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select ARCH_HAS_STRICT_KERNEL_RWX	if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 829c67986db7..ed29d1ebecd9 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -129,6 +129,7 @@  config S390
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL
 	select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_SOFT_DIRTY
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d4fc98c50378..9f2bb853aedb 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -115,6 +115,7 @@  config X86
 	select HAVE_ARCH_MMAP_RND_BITS		if MMU
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if MMU && COMPAT
 	select HAVE_ARCH_COMPAT_MMAP_BASES	if MMU && COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE