summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2019-05-22 15:40:48 +0000
committerkettenis <kettenis@openbsd.org>2019-05-22 15:40:48 +0000
commitf537473e237b0a8102269698d3661906e93463f5 (patch)
treef7b7d7812eb69c7ff836a0964e4ed7dd2f735b75
parentPrint the bwfm(4)'s ethernet address on attach. (diff)
downloadwireguard-openbsd-f537473e237b0a8102269698d3661906e93463f5.tar.xz
wireguard-openbsd-f537473e237b0a8102269698d3661906e93463f5.zip
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.c17
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);