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.

Merge tag 'x86_seves_fixes_for_v5.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 SEV-ES fixes from Borislav Petkov:
"Three fixes to SEV-ES to correct setting up the new early pagetable on
5-level paging machines, to always map boot_params and the kernel
cmdline, and disable stack protector for ../compressed/head{32,64}.c.
(Arvind Sankar)"

* tag 'x86_seves_fixes_for_v5.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/boot/64: Explicitly map boot_params and command line
x86/head/64: Disable stack protection for head$(BITS).o
x86/boot/64: Initialize 5-level paging variables earlier

+40 -16
+3
arch/x86/boot/compressed/head_64.S
··· 544 544 pushq %rsi 545 545 call set_sev_encryption_mask 546 546 call load_stage2_idt 547 + 548 + /* Pass boot_params to initialize_identity_maps() */ 549 + movq (%rsp), %rdi 547 550 call initialize_identity_maps 548 551 popq %rsi 549 552
+19 -8
arch/x86/boot/compressed/ident_map_64.c
··· 33 33 #define __PAGE_OFFSET __PAGE_OFFSET_BASE 34 34 #include "../../mm/ident_map.c" 35 35 36 - #ifdef CONFIG_X86_5LEVEL 37 - unsigned int __pgtable_l5_enabled; 38 - unsigned int pgdir_shift = 39; 39 - unsigned int ptrs_per_p4d = 1; 40 - #endif 36 + #define _SETUP 37 + #include <asm/setup.h> /* For COMMAND_LINE_SIZE */ 38 + #undef _SETUP 39 + 40 + extern unsigned long get_cmd_line_ptr(void); 41 41 42 42 /* Used by PAGE_KERN* macros: */ 43 43 pteval_t __default_kernel_pte_mask __read_mostly = ~0; ··· 107 107 } 108 108 109 109 /* Locates and clears a region for a new top level page table. */ 110 - void initialize_identity_maps(void) 110 + void initialize_identity_maps(void *rmode) 111 111 { 112 + unsigned long cmdline; 113 + 112 114 /* Exclude the encryption mask from __PHYSICAL_MASK */ 113 115 physical_mask &= ~sme_me_mask; 114 116 ··· 151 149 } 152 150 153 151 /* 154 - * New page-table is set up - map the kernel image and load it 155 - * into cr3. 152 + * New page-table is set up - map the kernel image, boot_params and the 153 + * command line. The uncompressed kernel requires boot_params and the 154 + * command line to be mapped in the identity mapping. Map them 155 + * explicitly here in case the compressed kernel does not touch them, 156 + * or does not touch all the pages covering them. 156 157 */ 157 158 add_identity_map((unsigned long)_head, (unsigned long)_end); 159 + boot_params = rmode; 160 + add_identity_map((unsigned long)boot_params, (unsigned long)(boot_params + 1)); 161 + cmdline = get_cmd_line_ptr(); 162 + add_identity_map(cmdline, cmdline + COMMAND_LINE_SIZE); 163 + 164 + /* Load the new page-table. */ 158 165 write_cr3(top_level_pgt); 159 166 } 160 167
-8
arch/x86/boot/compressed/kaslr.c
··· 840 840 return; 841 841 } 842 842 843 - #ifdef CONFIG_X86_5LEVEL 844 - if (__read_cr4() & X86_CR4_LA57) { 845 - __pgtable_l5_enabled = 1; 846 - pgdir_shift = 48; 847 - ptrs_per_p4d = 512; 848 - } 849 - #endif 850 - 851 843 boot_params->hdr.loadflags |= KASLR_FLAG; 852 844 853 845 if (IS_ENABLED(CONFIG_X86_32))
+16
arch/x86/boot/compressed/pgtable_64.c
··· 8 8 #define BIOS_START_MIN 0x20000U /* 128K, less than this is insane */ 9 9 #define BIOS_START_MAX 0x9f000U /* 640K, absolute maximum */ 10 10 11 + #ifdef CONFIG_X86_5LEVEL 12 + /* __pgtable_l5_enabled needs to be in .data to avoid being cleared along with .bss */ 13 + unsigned int __section(.data) __pgtable_l5_enabled; 14 + unsigned int __section(.data) pgdir_shift = 39; 15 + unsigned int __section(.data) ptrs_per_p4d = 1; 16 + #endif 17 + 11 18 struct paging_config { 12 19 unsigned long trampoline_start; 13 20 unsigned long l5_required; ··· 205 198 206 199 /* Restore trampoline memory */ 207 200 memcpy(trampoline_32bit, trampoline_save, TRAMPOLINE_32BIT_SIZE); 201 + 202 + /* Initialize variables for 5-level paging */ 203 + #ifdef CONFIG_X86_5LEVEL 204 + if (__read_cr4() & X86_CR4_LA57) { 205 + __pgtable_l5_enabled = 1; 206 + pgdir_shift = 48; 207 + ptrs_per_p4d = 512; 208 + } 209 + #endif 208 210 }
+2
arch/x86/kernel/Makefile
··· 47 47 # non-deterministic coverage. 48 48 KCOV_INSTRUMENT := n 49 49 50 + CFLAGS_head$(BITS).o += -fno-stack-protector 51 + 50 52 CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace 51 53 52 54 obj-y := process_$(BITS).o signal.o