This is a note to let you know that I've just added the patch titled x86/decompressor: Assign paging related global variables earlier to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: x86-decompressor-assign-paging-related-global-variables-earlier.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 00c6b0978ec182f1a672095930872168b9d5b1e2 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel <ardb@xxxxxxxxxx> Date: Mon, 7 Aug 2023 18:27:05 +0200 Subject: x86/decompressor: Assign paging related global variables earlier From: Ard Biesheuvel <ardb@xxxxxxxxxx> commit 00c6b0978ec182f1a672095930872168b9d5b1e2 upstream. There is no need to defer the assignment of the paging related global variables 'pgdir_shift' and 'ptrs_per_p4d' until after the trampoline is cleaned up, so assign them as soon as it is clear that 5-level paging will be enabled. Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx> Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx> Link: https://lore.kernel.org/r/20230807162720.545787-9-ardb@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/boot/compressed/misc.h | 2 -- arch/x86/boot/compressed/pgtable_64.c | 14 +++++--------- 2 files changed, 5 insertions(+), 11 deletions(-) --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -170,9 +170,7 @@ static inline int count_immovable_mem_re #endif /* ident_map_64.c */ -#ifdef CONFIG_X86_5LEVEL extern unsigned int __pgtable_l5_enabled, pgdir_shift, ptrs_per_p4d; -#endif extern void kernel_add_identity_map(unsigned long start, unsigned long end); /* Used by PAGE_KERN* macros: */ --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -130,6 +130,11 @@ struct paging_config paging_prepare(void native_cpuid_eax(0) >= 7 && (native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)))) { paging_config.l5_required = 1; + + /* Initialize variables for 5-level paging */ + __pgtable_l5_enabled = 1; + pgdir_shift = 48; + ptrs_per_p4d = 512; } paging_config.trampoline_start = find_trampoline_placement(); @@ -206,13 +211,4 @@ void cleanup_trampoline(void *pgtable) /* Restore trampoline memory */ memcpy(trampoline_32bit, trampoline_save, TRAMPOLINE_32BIT_SIZE); - - /* Initialize variables for 5-level paging */ -#ifdef CONFIG_X86_5LEVEL - if (__read_cr4() & X86_CR4_LA57) { - __pgtable_l5_enabled = 1; - pgdir_shift = 48; - ptrs_per_p4d = 512; - } -#endif } Patches currently in stable-queue which might be from ardb@xxxxxxxxxx are queue-6.1/x86-boot-compressed-avoid-touching-ecx-in-startup32_set_idt_entry.patch queue-6.1/x86-boot-compressed-only-build-mem_encrypt.s-if-amd_mem_encrypt-y.patch queue-6.1/efi-capsule-loader-fix-incorrect-allocation-size.patch queue-6.1/x86-decompressor-move-global-symbol-references-to-c-code.patch queue-6.1/x86-boot-compressed-move-startup32_load_idt-into-.text-section.patch queue-6.1/x86-decompressor-only-call-the-trampoline-when-changing-paging-levels.patch queue-6.1/x86-boot-compressed-rename-efi_thunk_64.s-to-efi-mixed.s.patch queue-6.1/x86-decompressor-merge-trampoline-cleanup-with-switching-code.patch queue-6.1/x86-boot-compressed-move-efi32_pe_entry-out-of-head_64.s.patch queue-6.1/efi-verify-that-variable-services-are-supported.patch queue-6.1/x86-decompressor-call-trampoline-directly-from-c-code.patch queue-6.1/x86-boot-compressed-pull-global-variable-reference-into-startup32_load_idt.patch queue-6.1/x86-boot-compressed-simplify-idt-gdt-preserve-restore-in-the-efi-thunk.patch queue-6.1/x86-decompressor-assign-paging-related-global-variables-earlier.patch queue-6.1/x86-boot-compressed-move-32-bit-entrypoint-code-into-.text-section.patch queue-6.1/x86-boot-compressed-move-efi32_pe_entry-into-.text-section.patch queue-6.1/x86-decompressor-avoid-the-need-for-a-stack-in-the-32-bit-trampoline.patch queue-6.1/x86-boot-compressed-move-startup32_check_sev_cbit-out-of-head_64.s.patch queue-6.1/x86-boot-compressed-efi-merge-multiple-definitions-of-image_offset-into-one.patch queue-6.1/x86-boot-compressed-move-startup32_load_idt-out-of-head_64.s.patch queue-6.1/decompress-use-8-byte-alignment.patch queue-6.1/x86-boot-compressed-move-efi32_entry-out-of-head_64.s.patch queue-6.1/efi-libstub-use-efi_loader_code-region-when-moving-the-kernel-in-memory.patch queue-6.1/crypto-arm64-neonbs-fix-out-of-bounds-access-on-short-input.patch queue-6.1/x86-boot-compressed-move-bootargs-parsing-out-of-32-bit-startup-code.patch queue-6.1/efivarfs-request-at-most-512-bytes-for-variable-names.patch queue-6.1/x86-boot-compressed-adhere-to-calling-convention-in-get_sev_encryption_bit.patch queue-6.1/x86-boot-compressed-move-startup32_check_sev_cbit-into-.text.patch queue-6.1/x86-decompressor-store-boot_params-pointer-in-callee-save-register.patch queue-6.1/x86-efistub-branch-straight-to-kernel-entry-point-from-c-code.patch queue-6.1/x86-decompressor-call-trampoline-as-a-normal-function.patch queue-6.1/x86-decompressor-pass-pgtable-address-to-trampoline-directly.patch queue-6.1/x86-decompressor-use-standard-calling-convention-for-trampoline.patch queue-6.1/x86-efi-make-the-deprecated-efi-handover-protocol-optional.patch