.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Kexec bzImage loader |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014 Red Hat Inc. |
---|
5 | 6 | * Authors: |
---|
6 | 7 | * Vivek Goyal <vgoyal@redhat.com> |
---|
7 | | - * |
---|
8 | | - * This source code is licensed under the GNU General Public License, |
---|
9 | | - * Version 2. See the file COPYING for more details. |
---|
10 | 8 | */ |
---|
11 | 9 | |
---|
12 | 10 | #define pr_fmt(fmt) "kexec-bzImage64: " fmt |
---|
.. | .. |
---|
143 | 141 | struct setup_data *sd = (void *)params + efi_setup_data_offset; |
---|
144 | 142 | struct efi_setup_data *esd = (void *)sd + sizeof(struct setup_data); |
---|
145 | 143 | |
---|
146 | | - esd->fw_vendor = efi.fw_vendor; |
---|
147 | | - esd->runtime = efi.runtime; |
---|
148 | | - esd->tables = efi.config_table; |
---|
| 144 | + esd->fw_vendor = efi_fw_vendor; |
---|
| 145 | + esd->tables = efi_config_table; |
---|
149 | 146 | esd->smbios = efi.smbios; |
---|
150 | 147 | |
---|
151 | 148 | sd->type = SETUP_EFI; |
---|
.. | .. |
---|
173 | 170 | if (!current_ei->efi_memmap_size) |
---|
174 | 171 | return 0; |
---|
175 | 172 | |
---|
176 | | - /* |
---|
177 | | - * If 1:1 mapping is not enabled, second kernel can not setup EFI |
---|
178 | | - * and use EFI run time services. User space will have to pass |
---|
179 | | - * acpi_rsdp=<addr> on kernel command line to make second kernel boot |
---|
180 | | - * without efi. |
---|
181 | | - */ |
---|
182 | | - if (efi_enabled(EFI_OLD_MEMMAP)) |
---|
183 | | - return 0; |
---|
184 | | - |
---|
| 173 | + params->secure_boot = boot_params.secure_boot; |
---|
185 | 174 | ei->efi_loader_signature = current_ei->efi_loader_signature; |
---|
186 | 175 | ei->efi_systab = current_ei->efi_systab; |
---|
187 | 176 | ei->efi_systab_hi = current_ei->efi_systab_hi; |
---|
.. | .. |
---|
216 | 205 | /* Fill in memsize later */ |
---|
217 | 206 | params->screen_info.ext_mem_k = 0; |
---|
218 | 207 | params->alt_mem_k = 0; |
---|
| 208 | + |
---|
| 209 | + /* Always fill in RSDP: it is either 0 or a valid value */ |
---|
| 210 | + params->acpi_rsdp_addr = boot_params.acpi_rsdp_addr; |
---|
219 | 211 | |
---|
220 | 212 | /* Default APM info */ |
---|
221 | 213 | memset(¶ms->apm_bios_info, 0, sizeof(params->apm_bios_info)); |
---|
.. | .. |
---|
255 | 247 | setup_efi_state(params, params_load_addr, efi_map_offset, efi_map_sz, |
---|
256 | 248 | efi_setup_data_offset); |
---|
257 | 249 | #endif |
---|
258 | | - |
---|
259 | 250 | /* Setup EDD info */ |
---|
260 | 251 | memcpy(params->eddbuf, boot_params.eddbuf, |
---|
261 | 252 | EDDMAXNR * sizeof(struct edd_info)); |
---|
.. | .. |
---|
315 | 306 | */ |
---|
316 | 307 | if (efi_enabled(EFI_RUNTIME_SERVICES) && !efi_enabled(EFI_64BIT)) { |
---|
317 | 308 | pr_debug("EFI is 32 bit. Can't load kernel above 4G.\n"); |
---|
| 309 | + return ret; |
---|
| 310 | + } |
---|
| 311 | + |
---|
| 312 | + if (!(header->xloadflags & XLF_5LEVEL) && pgtable_l5_enabled()) { |
---|
| 313 | + pr_err("bzImage cannot handle 5-level paging mode.\n"); |
---|
318 | 314 | return ret; |
---|
319 | 315 | } |
---|
320 | 316 | |
---|
.. | .. |
---|
413 | 409 | efi_map_offset = params_cmdline_sz; |
---|
414 | 410 | efi_setup_data_offset = efi_map_offset + ALIGN(efi_map_sz, 16); |
---|
415 | 411 | |
---|
416 | | - /* Copy setup header onto bootparams. Documentation/x86/boot.txt */ |
---|
| 412 | + /* Copy setup header onto bootparams. Documentation/x86/boot.rst */ |
---|
417 | 413 | setup_header_size = 0x0202 + kernel[0x0201] - setup_hdr_offset; |
---|
418 | 414 | |
---|
419 | 415 | /* Is there a limit on setup header size? */ |
---|
.. | .. |
---|
436 | 432 | kbuf.memsz = PAGE_ALIGN(header->init_size); |
---|
437 | 433 | kbuf.buf_align = header->kernel_alignment; |
---|
438 | 434 | kbuf.buf_min = MIN_KERNEL_LOAD_ADDR; |
---|
| 435 | + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; |
---|
439 | 436 | ret = kexec_add_buffer(&kbuf); |
---|
440 | 437 | if (ret) |
---|
441 | 438 | goto out_free_params; |
---|
.. | .. |
---|
450 | 447 | kbuf.bufsz = kbuf.memsz = initrd_len; |
---|
451 | 448 | kbuf.buf_align = PAGE_SIZE; |
---|
452 | 449 | kbuf.buf_min = MIN_INITRD_LOAD_ADDR; |
---|
| 450 | + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; |
---|
453 | 451 | ret = kexec_add_buffer(&kbuf); |
---|
454 | 452 | if (ret) |
---|
455 | 453 | goto out_free_params; |
---|
.. | .. |
---|
533 | 531 | #ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG |
---|
534 | 532 | static int bzImage64_verify_sig(const char *kernel, unsigned long kernel_len) |
---|
535 | 533 | { |
---|
536 | | - return verify_pefile_signature(kernel, kernel_len, |
---|
537 | | - VERIFY_USE_SECONDARY_KEYRING, |
---|
538 | | - VERIFYING_KEXEC_PE_SIGNATURE); |
---|
| 534 | + int ret; |
---|
| 535 | + |
---|
| 536 | + ret = verify_pefile_signature(kernel, kernel_len, |
---|
| 537 | + VERIFY_USE_SECONDARY_KEYRING, |
---|
| 538 | + VERIFYING_KEXEC_PE_SIGNATURE); |
---|
| 539 | + if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) { |
---|
| 540 | + ret = verify_pefile_signature(kernel, kernel_len, |
---|
| 541 | + VERIFY_USE_PLATFORM_KEYRING, |
---|
| 542 | + VERIFYING_KEXEC_PE_SIGNATURE); |
---|
| 543 | + } |
---|
| 544 | + return ret; |
---|
539 | 545 | } |
---|
540 | 546 | #endif |
---|
541 | 547 | |
---|