From 58554311679452e8c74ea6e1306bc01791e89ce7 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 26 Oct 2021 14:10:02 +0000 Subject: [PATCH] Allocate fresh memory to put our device tree into, to make sure we have least one page of free space for us to extend into. Fixes booting on VMware Fusion. ok kettenis@ --- sys/arch/arm64/stand/efiboot/efiboot.c | 13 ++++++++++++- sys/arch/armv7/stand/efiboot/efiboot.c | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c index a0de9574cfd..fb3f646faa0 100644 --- a/sys/arch/arm64/stand/efiboot/efiboot.c +++ b/sys/arch/arm64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.35 2021/10/26 10:45:55 patrick Exp $ */ +/* $OpenBSD: efiboot.c,v 1.36 2021/10/26 14:10:02 patrick Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -532,6 +532,7 @@ efi_makebootargs(char *bootargs, int howto) u_char zero[8] = { 0 }; uint64_t uefi_system_table = htobe64((uintptr_t)ST); uint32_t boothowto = htobe32(howto); + EFI_PHYSICAL_ADDRESS addr; void *node; size_t len; int i; @@ -547,6 +548,16 @@ efi_makebootargs(char *bootargs, int howto) if (fdt == NULL || acpi) fdt = efi_acpi(); + if (!fdt_get_size(fdt)) + return NULL; + + len = roundup(fdt_get_size(fdt) + PAGE_SIZE, PAGE_SIZE); + if (BS->AllocatePages(AllocateAnyPages, EfiLoaderData, + EFI_SIZE_TO_PAGES(len), &addr) == EFI_SUCCESS) { + memcpy((void *)addr, fdt, fdt_get_size(fdt)); + fdt = (void *)addr; + } + if (!fdt_init(fdt)) return NULL; diff --git a/sys/arch/armv7/stand/efiboot/efiboot.c b/sys/arch/armv7/stand/efiboot/efiboot.c index 9886d5bb01f..70e6bbbc13d 100644 --- a/sys/arch/armv7/stand/efiboot/efiboot.c +++ b/sys/arch/armv7/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.36 2021/10/26 10:45:55 patrick Exp $ */ +/* $OpenBSD: efiboot.c,v 1.37 2021/10/26 14:10:02 patrick Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -487,6 +487,7 @@ efi_makebootargs(char *bootargs, int howto) u_char zero[8] = { 0 }; uint64_t uefi_system_table = htobe64((uintptr_t)ST); uint32_t boothowto = htobe32(howto); + EFI_PHYSICAL_ADDRESS addr; void *node; size_t len; int i; @@ -499,6 +500,16 @@ efi_makebootargs(char *bootargs, int howto) } } + if (!fdt_get_size(fdt)) + return NULL; + + len = roundup(fdt_get_size(fdt) + PAGE_SIZE, PAGE_SIZE); + if (BS->AllocatePages(AllocateAnyPages, EfiLoaderData, + EFI_SIZE_TO_PAGES(len), &addr) == EFI_SUCCESS) { + memcpy((void *)addr, fdt, fdt_get_size(fdt)); + fdt = (void *)addr; + } + if (!fdt_init(fdt)) return NULL; -- 2.20.1