Skip to contentSkip to conversation

arm64: Allow user selection of ARM64_MODULE_PLTS

PATCH In review Florian Fainelli 3 participants 4 messages Jun 17, 2019 – Jun 26, 2019 arm64

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 arm64: Allow user selection of ARM64_MODULE_PLTS

Make ARM64_MODULE_PLTS a selectable Kconfig symbol, since some people might have very big modules spilling out of the dedicated module area into vmalloc. Help text is copied from the ARM 32-bit counterpart and modified to a mention of KASLR and specific ARM errata workaround(s).

---
Changes in v3:
- take out the part about "The modules will use slightly more memory, but after rounding up to page size, the actual memory footprint is usually the same.
- take out the "If unusure say Y", since we would really prefer this to be off by default for maximum performance

Changes in v2:

- added Ard's paragraph about KASLR
- added a paragraph about specific workarounds also requiring ARM64_MODULE_PLTS

 arch/arm64/Kconfig | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +19 -1
index 697ea0510729..9206feaeff07 100644
@@ -1418,8 +1418,26 @@ config ARM64_SVE
 	  KVM in the same kernel image.
 
 config ARM64_MODULE_PLTS
-	bool
+	bool "Use PLTs to allow module memory to spill over into vmalloc area"
 	select HAVE_MOD_ARCH_SPECIFIC
+	help
+	  Allocate PLTs when loading modules so that jumps and calls whose
+	  targets are too far away for their relative offsets to be encoded
+	  in the instructions themselves can be bounced via veneers in the
+	  module's PLT. This allows modules to be allocated in the generic
+	  vmalloc area after the dedicated module memory area has been
+	  exhausted.
+
+	  When running with address space randomization (KASLR), the module
+	  region itself may be too far away for ordinary relative jumps and
+	  calls, and so in that case, module PLTs are required and cannot be
+	  disabled.
+
+	  Specific errata workaround(s) might also force module PLTs to be
+	  enabled (ARM64_ERRATUM_843419).
+
+	  Disabling this is usually safe for small single-platform
+	  configurations.
 
 config ARM64_PSEUDO_NMI
 	bool "Support for NMI-like interrupts"
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#1 lore raw
Quoted 41 lines · Florian Fainelli

Make ARM64_MODULE_PLTS a selectable Kconfig symbol, since some people might have very big modules spilling out of the dedicated module area into vmalloc. Help text is copied from the ARM 32-bit counterpart and modified to a mention of KASLR and specific ARM errata workaround(s).

---
Changes in v3:
- take out the part about "The modules will use slightly more memory, but after rounding up to page size, the actual memory footprint is usually the same.
- take out the "If unusure say Y", since we would really prefer this to be off by default for maximum performance

Changes in v2:

- added Ard's paragraph about KASLR
- added a paragraph about specific workarounds also requiring ARM64_MODULE_PLTS

 arch/arm64/Kconfig | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +9 -1
index 697ea0510729..9206feaeff07 100644
@@ -1418,8 +1418,26 @@ config ARM64_SVE
 	  KVM in the same kernel image.
 
 config ARM64_MODULE_PLTS
-	bool
+	bool "Use PLTs to allow module memory to spill over into vmalloc area"
 	select HAVE_MOD_ARCH_SPECIFIC
+	help
+	  Allocate PLTs when loading modules so that jumps and calls whose
+	  targets are too far away for their relative offsets to be encoded
+	  in the instructions themselves can be bounced via veneers in the
+	  module's PLT. This allows modules to be allocated in the generic
+	  vmalloc area after the dedicated module memory area has been
+	  exhausted.
+

arch/arm64/Kconfig config ARM64_SVE · line 1440

Quoted 10 lines
arch/arm64/Kconfig +10 -0
+	  When running with address space randomization (KASLR), the module
+	  region itself may be too far away for ordinary relative jumps and
+	  calls, and so in that case, module PLTs are required and cannot be
+	  disabled.
+
+	  Specific errata workaround(s) might also force module PLTs to be
+	  enabled (ARM64_ERRATUM_843419).
+
+	  Disabling this is usually safe for small single-platform
+	  configurations.

I think I'd still drop this last sentence, because labelling a kernel "usually safe" without this option is a bit OTT. We'll just reject large modules, nothing unsafe about that.

Assuming Catalin can do that when he applies, so:

Will

maintainer
#2 lore raw
In reply to Florian Fainelli

arch/arm64/Kconfig config ARM64_SVE · line 1422

Quoted 11 lines · Florian Fainelli
arch/arm64/Kconfig +1 -1
index 697ea0510729..9206feaeff07 100644
@@ -1418,8 +1418,26 @@ config ARM64_SVE
 	  KVM in the same kernel image.
 
 config ARM64_MODULE_PLTS
-	bool
+	bool "Use PLTs to allow module memory to spill over into vmalloc area"
 	select HAVE_MOD_ARCH_SPECIFIC

This needs a depends on MODULES now (it failed to build in one of my tests where modules were disabled but this option was left enabled).

I'll add a patch on top.

Signature · 1 line
Catalin
#3 lore raw
Quoted 16 lines · Catalin Marinas

arch/arm64/Kconfig config ARM64_SVE · line 1422

Quoted 11 lines · Florian Fainelli
arch/arm64/Kconfig +1 -1
index 697ea0510729..9206feaeff07 100644
@@ -1418,8 +1418,26 @@ config ARM64_SVE
 	  KVM in the same kernel image.
 
 config ARM64_MODULE_PLTS
-	bool
+	bool "Use PLTs to allow module memory to spill over into vmalloc area"
 	select HAVE_MOD_ARCH_SPECIFIC

This needs a depends on MODULES now (it failed to build in one of my tests where modules were disabled but this option was left enabled).

Quoted 1 line

I'll add a patch on top.

Ah, sorry about that, thanks, I see both in linux-next now.

Signature · 1 line
Florian