Skip to contentSkip to conversation

arm64: reduce trampoline data alignment

PATCH Applied Rémi Denis-Courmont 2 participants 2 messages Mar 16, 2020 – Mar 17, 2020 arm64

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 arm64: reduce trampoline data alignment

From: Rémi Denis-Courmont <[email protected]>

The trampoline data, currently consisting of two relocated pointers, must be within a single page. However, there are no needs for it to start a page.

This reduces the alignment to 16 bytes (with SDEI) or 8 bytes (without SDEI), which is sufficient to ensure that the data is entirely within a single page of the fixmap.

---
 arch/arm64/kernel/entry.S | 4 ++--
 arch/arm64/mm/mmu.c       | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)
arch/arm64/kernel/entry.S +2 -2
index af17fcb4aaea..b648f9fe1e33 100644
@@ -858,12 +858,12 @@ SYM_CODE_END(tramp_exit_compat)
 	.popsection				// .entry.tramp.text
 #ifdef CONFIG_RANDOMIZE_BASE
 	.pushsection ".rodata", "a"
-	.align PAGE_SHIFT
 #ifdef CONFIG_ARM_SDE_INTERFACE
+	.align	4	// all .rodata must be in a single fixmap page
 SYM_DATA_START(__sdei_asm_trampoline_next_handler)
 	.quad	__sdei_asm_handler
 SYM_DATA_END(__sdei_asm_trampoline_next_handler)
-#endif
+#endif /* CONFIG_ARM_SDE_INTERFACE */
 SYM_DATA_START(__entry_tramp_data_start)
 	.quad	vectors
 SYM_DATA_END(__entry_tramp_data_start)
arch/arm64/mm/mmu.c +2 -3
index 9b08f7c7e6f0..6a0e75f48e7b 100644
@@ -599,9 +599,8 @@ static int __init map_entry_trampoline(void)
 	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
 		extern char __entry_tramp_data_start[];
 
-		__set_fixmap(FIX_ENTRY_TRAMP_DATA,
-			     __pa_symbol(__entry_tramp_data_start),
-			     PAGE_KERNEL_RO);
+		pa_start = __pa_symbol(__entry_tramp_data_start) & PAGE_MASK;
+		__set_fixmap(FIX_ENTRY_TRAMP_DATA, pa_start, PAGE_KERNEL_RO);
 	}
 
 	return 0;
Signature · 1 line
2.25.1
maintainer Acked-by on v1 3/3
#1 lore raw
Quoted 41 lines · Rémi Denis-Courmont

From: Rémi Denis-Courmont <[email protected]>

The trampoline data, currently consisting of two relocated pointers, must be within a single page. However, there are no needs for it to start a page.

This reduces the alignment to 16 bytes (with SDEI) or 8 bytes (without SDEI), which is sufficient to ensure that the data is entirely within a single page of the fixmap.

---
 arch/arm64/kernel/entry.S | 4 ++--
 arch/arm64/mm/mmu.c       | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)
arch/arm64/kernel/entry.S +2 -2
index af17fcb4aaea..b648f9fe1e33 100644
@@ -858,12 +858,12 @@ SYM_CODE_END(tramp_exit_compat)
 	.popsection				// .entry.tramp.text
 #ifdef CONFIG_RANDOMIZE_BASE
 	.pushsection ".rodata", "a"
-	.align PAGE_SHIFT
 #ifdef CONFIG_ARM_SDE_INTERFACE
+	.align	4	// all .rodata must be in a single fixmap page
 SYM_DATA_START(__sdei_asm_trampoline_next_handler)
 	.quad	__sdei_asm_handler
 SYM_DATA_END(__sdei_asm_trampoline_next_handler)
-#endif
+#endif /* CONFIG_ARM_SDE_INTERFACE */
 SYM_DATA_START(__entry_tramp_data_start)
 	.quad	vectors
 SYM_DATA_END(__entry_tramp_data_start)
arch/arm64/mm/mmu.c +0 -0
index 9b08f7c7e6f0..6a0e75f48e7b 100644
@@ -599,9 +599,8 @@ static int __init map_entry_trampoline(void)
 	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {

arch/arm64/mm/mmu.c static int __init map_entry_trampoline(void) · line 606

Quoted 10 lines
arch/arm64/mm/mmu.c +2 -3
 		extern char __entry_tramp_data_start[];
 
-		__set_fixmap(FIX_ENTRY_TRAMP_DATA,
-			     __pa_symbol(__entry_tramp_data_start),
-			     PAGE_KERNEL_RO);
+		pa_start = __pa_symbol(__entry_tramp_data_start) & PAGE_MASK;
+		__set_fixmap(FIX_ENTRY_TRAMP_DATA, pa_start, PAGE_KERNEL_RO);
 	}
 
 	return 0;

Will