Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/decompressor: Merge trampoline cleanup with switching code

Now that the trampoline setup code and the actual invocation of it are
all done from the C routine, the trampoline cleanup can be merged into
it as well, instead of returning to asm just to call another C function.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/r/20230807162720.545787-16-ardb@kernel.org

authored by

Ard Biesheuvel and committed by
Borislav Petkov (AMD)
03dda951 cb83cece

+8 -24
+4 -10
arch/x86/boot/compressed/head_64.S
··· 430 430 * a trampoline in 32-bit addressable memory if the current number does 431 431 * not match the desired number. 432 432 * 433 - * Pass the boot_params pointer as the first argument. 433 + * Pass the boot_params pointer as the first argument. The second 434 + * argument is the relocated address of the page table to use instead 435 + * of the page table in trampoline memory (if required). 434 436 */ 435 437 movq %r15, %rdi 438 + leaq rva(top_pgtable)(%rbx), %rsi 436 439 call configure_5level_paging 437 - 438 - /* 439 - * cleanup_trampoline() would restore trampoline memory. 440 - * 441 - * RDI is address of the page table to use instead of page table 442 - * in trampoline memory (if required). 443 - */ 444 - leaq rva(top_pgtable)(%rbx), %rdi 445 - call cleanup_trampoline 446 440 447 441 /* Zero EFLAGS */ 448 442 pushq $0
+4 -14
arch/x86/boot/compressed/pgtable_64.c
··· 101 101 return bios_start - TRAMPOLINE_32BIT_SIZE; 102 102 } 103 103 104 - asmlinkage void configure_5level_paging(struct boot_params *bp) 104 + asmlinkage void configure_5level_paging(struct boot_params *bp, void *pgtable) 105 105 { 106 106 void (*toggle_la57)(void *cr3); 107 107 bool l5_required = false; ··· 191 191 } 192 192 193 193 toggle_la57(trampoline_32bit); 194 - } 195 - 196 - void cleanup_trampoline(void *pgtable) 197 - { 198 - void *trampoline_pgtable; 199 - 200 - trampoline_pgtable = trampoline_32bit; 201 194 202 195 /* 203 - * Move the top level page table out of trampoline memory, 204 - * if it's there. 196 + * Move the top level page table out of trampoline memory. 205 197 */ 206 - if ((void *)__native_read_cr3() == trampoline_pgtable) { 207 - memcpy(pgtable, trampoline_pgtable, PAGE_SIZE); 208 - native_write_cr3((unsigned long)pgtable); 209 - } 198 + memcpy(pgtable, trampoline_32bit, PAGE_SIZE); 199 + native_write_cr3((unsigned long)pgtable); 210 200 211 201 /* Restore trampoline memory */ 212 202 memcpy(trampoline_32bit, trampoline_save, TRAMPOLINE_32BIT_SIZE);