mirror-linux/arch/x86/boot/compressed
Kirill A. Shutemov f530ee95b7 x86/boot/compressed: Reserve more memory for page tables
The decompressor has a hard limit on the number of page tables it can
allocate. This limit is defined at compile-time and will cause boot
failure if it is reached.

The kernel is very strict and calculates the limit precisely for the
worst-case scenario based on the current configuration. However, it is
easy to forget to adjust the limit when a new use-case arises. The
worst-case scenario is rarely encountered during sanity checks.

In the case of enabling 5-level paging, a use-case was overlooked. The
limit needs to be increased by one to accommodate the additional level.
This oversight went unnoticed until Aaron attempted to run the kernel
via kexec with 5-level paging and unaccepted memory enabled.

Update wost-case calculations to include 5-level paging.

To address this issue, let's allocate some extra space for page tables.
128K should be sufficient for any use-case. The logic can be simplified
by using a single value for all kernel configurations.

[ Also add a warning, should this memory run low - by Dave Hansen. ]

Fixes: 34bbb0009f ("x86/boot/compressed: Enable 5-level paging during decompression stage")
Reported-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230915070221.10266-1-kirill.shutemov@linux.intel.com
2023-09-17 09:48:57 +02:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Makefile x86/efistub: Avoid legacy decompressor when doing EFI boot 2023-08-07 21:07:43 +02:00
acpi.c x86/boot: Add an efi.h header for the decompressor 2022-04-17 21:15:49 +02:00
cmdline.c
cpuflags.c x86/sev-es: Check required CPU features for SEV-ES 2020-09-10 21:49:25 +02:00
early_serial_console.c x86/boot: Put globals that are accessed early into the .data section 2022-04-20 20:10:54 +02:00
efi.c x86/boot: Add an efi.h header for the decompressor 2022-04-17 21:15:49 +02:00
efi.h x86/boot/compressed: Handle unaccepted memory 2023-06-06 17:17:24 +02:00
efi_mixed.S x86/efistub: Avoid legacy decompressor when doing EFI boot 2023-08-07 21:07:43 +02:00
error.c x86/purgatory: Include header for warn() declaration 2023-08-03 16:37:18 +02:00
error.h x86/purgatory: Include header for warn() declaration 2023-08-03 16:37:18 +02:00
head_32.S x86/efistub: Avoid legacy decompressor when doing EFI boot 2023-08-07 21:07:43 +02:00
head_64.S x86/efistub: Avoid legacy decompressor when doing EFI boot 2023-08-07 21:07:43 +02:00
ident_map_64.c x86/boot/compressed: Reserve more memory for page tables 2023-09-17 09:48:57 +02:00
idt_64.c x86/sev: Do not try to parse for the CC blob on non-AMD hardware 2023-08-07 18:05:13 +02:00
idt_handlers_64.S x86/boot/compressed/64: Setup a GHCB-based VC Exception handler 2020-09-07 19:45:25 +02:00
kaslr.c x86/boot/compressed: Handle unaccepted memory 2023-06-06 17:17:24 +02:00
kernel_info.S
mem.c x86/sev: Add SNP-specific unaccepted memory support 2023-06-06 18:31:37 +02:00
mem_encrypt.S x86/boot/compressed: Only build mem_encrypt.S if AMD_MEM_ENCRYPT=y 2022-11-24 08:57:41 +01:00
misc.c x86/decompressor: Factor out kernel decompression and relocation 2023-08-07 20:59:13 +02:00
misc.h x86/decompressor: Assign paging related global variables earlier 2023-08-07 20:42:11 +02:00
mkpiggy.c x86/boot: Remove run-time relocations from head_{32,64}.S 2020-08-14 12:52:35 +02:00
pgtable.h x86/decompressor: Pass pgtable address to trampoline directly 2023-08-07 20:49:26 +02:00
pgtable_64.c x86/decompressor: Merge trampoline cleanup with switching code 2023-08-07 20:51:17 +02:00
sev.c - Handle the case where the beginning virtual address of the address 2023-08-28 15:28:54 -07:00
sev.h x86/sev: Add SNP-specific unaccepted memory support 2023-06-06 18:31:37 +02:00
string.c
tdcall.S x86/boot: Port I/O: Add decompression-time support for TDX 2022-04-07 08:27:52 -07:00
tdx-shared.c x86/tdx: Add unaccepted memory support 2023-06-06 18:25:57 +02:00
tdx.c x86/tdx: Wrap exit reason with hcall_func() 2023-05-23 07:01:45 -07:00
tdx.h x86/tdx: Detect TDX at early kernel decompression time 2022-04-07 08:27:51 -07:00
vmlinux.lds.S cpuidle, tdx: Make TDX code noinstr clean 2023-01-13 11:48:16 +01:00