EFI fixes for v6.6 take 2:

- fix boot regression on SEV-SNP (and TDX) caused by a fix in the
   preceding batch
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQQm/3uucuRGn1Dmh0wbglWLn0tXAUCZQ1ddAAKCRAwbglWLn0t
 XOIQAP4nS3RWd2On40iOMpyfmKo8BmuM1smJC5r6xQTc55eORwEA3ezhbKZruxMp
 bU2qR0yH/aGEtyOX0lDN0NIntplQdgI=
 =ldKV
 -----END PGP SIGNATURE-----

Merge tag 'efi-fixes-for-v6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fix from Ard Biesheuvel:
 "Follow-up fix for the unaccepted memory fix merged last week as part
  of the first EFI fixes batch.

  The unaccepted memory table needs to be accessible very early, even in
  cases (such as crashkernels) where the direct map does not cover all
  of DRAM, and so it is added to memblock explicitly, and subsequently
  memblock_reserve()'d as before"

* tag 'efi-fixes-for-v6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
  efi/unaccepted: Make sure unaccepted table is mapped
This commit is contained in:
Linus Torvalds 2023-09-22 09:25:26 -07:00
commit dc912ba91b

View File

@ -623,6 +623,34 @@ static __init int match_config_table(const efi_guid_t *guid,
return 0;
}
/**
* reserve_unaccepted - Map and reserve unaccepted configuration table
* @unaccepted: Pointer to unaccepted memory table
*
* memblock_add() makes sure that the table is mapped in direct mapping. During
* normal boot it happens automatically because the table is allocated from
* usable memory. But during crashkernel boot only memory specifically reserved
* for crash scenario is mapped. memblock_add() forces the table to be mapped
* in crashkernel case.
*
* Align the range to the nearest page borders. Ranges smaller than page size
* are not going to be mapped.
*
* memblock_reserve() makes sure that future allocations will not touch the
* table.
*/
static __init void reserve_unaccepted(struct efi_unaccepted_memory *unaccepted)
{
phys_addr_t start, size;
start = PAGE_ALIGN_DOWN(efi.unaccepted);
size = PAGE_ALIGN(sizeof(*unaccepted) + unaccepted->size);
memblock_add(start, size);
memblock_reserve(start, size);
}
int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
int count,
const efi_config_table_type_t *arch_tables)
@ -751,11 +779,9 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
unaccepted = early_memremap(efi.unaccepted, sizeof(*unaccepted));
if (unaccepted) {
unsigned long size;
if (unaccepted->version == 1) {
size = sizeof(*unaccepted) + unaccepted->size;
memblock_reserve(efi.unaccepted, size);
reserve_unaccepted(unaccepted);
} else {
efi.unaccepted = EFI_INVALID_TABLE_ADDR;
}