x86/boot/compressed: Handle unaccepted memory
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tue, 6 Jun 2023 14:26:32 +0000 (17:26 +0300)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 6 Jun 2023 15:17:24 +0000 (17:17 +0200)
commit3fd1239a783522e7158a1f141fabc7b3b5dc84c6
treeeb5d1b2e151a68d34611ae0552cbbe7bd9c88b36
parent745e3ed85f71a6382a239b03d9278a8025f2beae
x86/boot/compressed: Handle unaccepted memory

The firmware will pre-accept the memory used to run the stub. But, the
stub is responsible for accepting the memory into which it decompresses
the main kernel. Accept memory just before decompression starts.

The stub is also responsible for choosing a physical address in which to
place the decompressed kernel image. The KASLR mechanism will randomize
this physical address. Since the accepted memory region is relatively
small, KASLR would be quite ineffective if it only used the pre-accepted
area (EFI_CONVENTIONAL_MEMORY). Ensure that KASLR randomizes among the
entire physical address space by also including EFI_UNACCEPTED_MEMORY.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20230606142637.5171-5-kirill.shutemov@linux.intel.com
arch/x86/boot/compressed/efi.h
arch/x86/boot/compressed/kaslr.c
arch/x86/boot/compressed/mem.c
arch/x86/boot/compressed/misc.c
arch/x86/boot/compressed/misc.h