diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-05-22 15:40:49 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-05-22 15:40:49 +0000 |
commit | 99e095aae4b7134fa58f00fbc6bbb58862b8e938 (patch) | |
tree | 82bd2e97f4b51940d0c2889e61d7ec418a6637c8 | |
parent | aea4812887c029ac0d89199497663740c997cde9 (diff) |
Allow loading of bigger ucode. This implementation uses the UEFI memory
allocation service to allocate a block of memory below 16MB such that there
is no risk of overwriting it when the bootloader moves the kernel in place.
It removes the 128k limit that was previously there.
Based on an earlier diff by patrick@
ok mlarkin@
-rw-r--r-- | sys/arch/amd64/stand/efiboot/exec_i386.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/arch/amd64/stand/efiboot/exec_i386.c b/sys/arch/amd64/stand/efiboot/exec_i386.c index e4b39d6cd0c..b1d9915938a 100644 --- a/sys/arch/amd64/stand/efiboot/exec_i386.c +++ b/sys/arch/amd64/stand/efiboot/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.2 2019/05/22 15:40:48 kettenis Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -46,8 +46,13 @@ #include "softraid_amd64.h" #endif +#include <efi.h> +#include <efiapi.h> +#include "eficall.h" #include "efiboot.h" +extern EFI_BOOT_SERVICES *BS; + typedef void (*startfuncp)(int, int, int, int, int, int, int, int) __attribute__ ((noreturn)); @@ -165,6 +170,7 @@ run_loadfile(uint64_t *marks, int howto) void ucode_load(void) { + EFI_PHYSICAL_ADDRESS addr; uint32_t model, family, stepping; uint32_t dummy, signature; uint32_t vendor[4]; @@ -200,12 +206,13 @@ ucode_load(void) return; buflen = sb.st_size; - if (buflen > 128*1024) { - printf("ucode too large\n"); + addr = 16 * 1024 * 1024; + if (EFI_CALL(BS->AllocatePages, AllocateMaxAddress, EfiLoaderData, + EFI_SIZE_TO_PAGES(buflen), &addr) != EFI_SUCCESS) { + printf("cannot allocate memory for ucode\n"); return; } - - buf = (char *)(1*1024*1024); + buf = (char *)((paddr_t)addr); if (read(fd, buf, buflen) != buflen) { close(fd); |