Skip to content

Commit a9c406e

Browse files
author
James Morse
committed
arm64: entry: Allow the trampoline text to occupy multiple pages
Adding a second set of vectors to .entry.tramp.text will make it larger than a single 4K page. Allow the trampoline text to occupy up to three pages by adding two more fixmap slots. Previous changes to tramp_valias allowed it to reach beyond a single page. Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: James Morse <[email protected]>
1 parent c47e4d0 commit a9c406e

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

arch/arm64/include/asm/fixmap.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ enum fixed_addresses {
6262
#endif /* CONFIG_ACPI_APEI_GHES */
6363

6464
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
65-
FIX_ENTRY_TRAMP_TEXT,
65+
FIX_ENTRY_TRAMP_TEXT3,
66+
FIX_ENTRY_TRAMP_TEXT2,
67+
FIX_ENTRY_TRAMP_TEXT1,
6668
FIX_ENTRY_TRAMP_DATA,
67-
#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT))
69+
#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1))
6870
#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
6971
__end_of_permanent_fixed_addresses,
7072

arch/arm64/include/asm/sections.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ extern char __mmuoff_data_start[], __mmuoff_data_end[];
2323
extern char __entry_tramp_text_start[], __entry_tramp_text_end[];
2424
extern char __relocate_new_kernel_start[], __relocate_new_kernel_end[];
2525

26+
static inline size_t entry_tramp_text_size(void)
27+
{
28+
return __entry_tramp_text_end - __entry_tramp_text_start;
29+
}
30+
2631
#endif /* __ASM_SECTIONS_H */

arch/arm64/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ alternative_else_nop_endif
642642
.endm
643643

644644
.macro tramp_data_page dst
645-
adr \dst, .entry.tramp.text
645+
adr_l \dst, .entry.tramp.text
646646
sub \dst, \dst, PAGE_SIZE
647647
.endm
648648

arch/arm64/kernel/vmlinux.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1))
341341
<= SZ_4K, "Hibernate exit text too big or misaligned")
342342
#endif
343343
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
344-
ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE,
344+
ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE,
345345
"Entry trampoline text too big")
346346
#endif
347347
#ifdef CONFIG_KVM

arch/arm64/mm/mmu.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ early_param("rodata", parse_rodata);
617617
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
618618
static int __init map_entry_trampoline(void)
619619
{
620+
int i;
621+
620622
pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
621623
phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start);
622624

@@ -625,11 +627,15 @@ static int __init map_entry_trampoline(void)
625627

626628
/* Map only the text into the trampoline page table */
627629
memset(tramp_pg_dir, 0, PGD_SIZE);
628-
__create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE,
629-
prot, __pgd_pgtable_alloc, 0);
630+
__create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS,
631+
entry_tramp_text_size(), prot,
632+
__pgd_pgtable_alloc, NO_BLOCK_MAPPINGS);
630633

631634
/* Map both the text and data into the kernel page table */
632-
__set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot);
635+
for (i = 0; i < DIV_ROUND_UP(entry_tramp_text_size(), PAGE_SIZE); i++)
636+
__set_fixmap(FIX_ENTRY_TRAMP_TEXT1 - i,
637+
pa_start + i * PAGE_SIZE, prot);
638+
633639
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
634640
extern char __entry_tramp_data_start[];
635641

0 commit comments

Comments
 (0)