@@ -190,6 +190,16 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
}
if (status != EFI_SUCCESS) {
+ if (efi_mirror_found) {
+ status = efi_random_alloc(*reserve_size, min_kimg_align,
+ reserve_addr, 0,
+ efi_mirror_found);
+ if (status == EFI_SUCCESS)
+ goto out;
+
+ efi_err("Failed to relocate kernel to mirrored region\n");
+ }
+
if (!check_image_region((u64)_text, kernel_memsize)) {
efi_err("FIRMWARE BUG: Image BSS overlaps adjacent EFI memory region\n");
} else if (IS_ALIGNED((u64)_text, min_kimg_align)) {
@@ -50,6 +50,7 @@ unsigned long get_entry_num_slots(efi_memory_desc_t *md,
*/
#define MD_NUM_SLOTS(md) ((md)->virt_addr)
+/* random_seed == 0 means alloc mem from the first suitable slot */
efi_status_t efi_random_alloc(unsigned long size,
unsigned long align,
unsigned long *addr,