diff options
author | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2015-09-23 03:19:56 +0000 |
---|---|---|
committer | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2015-09-23 03:19:56 +0000 |
commit | 99c8123ca7fc33c14a0c8cc9a2ae60bfd9252407 (patch) | |
tree | e0947db86cceca4f68256d1443139762c0867d23 /sys/arch | |
parent | 3673fec0f06faa393553e0c3f36ceb81c478abad (diff) |
efiboot used 3MB memory below the region for the kernel, but UEFI
firmware on some machines allocates larger area whose upper part
overlaps the kernel region. Let the efiboot use lower area for its
heap. Also change its size from 3MB to 1MB and limit it by
HEAP_LIMIT.
The problem is reported by Toby Slight and Brian Conway.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/stand/efiboot/Makefile.common | 5 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/efiboot.c | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/sys/arch/amd64/stand/efiboot/Makefile.common b/sys/arch/amd64/stand/efiboot/Makefile.common index 6f70551eaff..b2a8d2cf2fb 100644 --- a/sys/arch/amd64/stand/efiboot/Makefile.common +++ b/sys/arch/amd64/stand/efiboot/Makefile.common @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.common,v 1.1 2015/09/02 01:52:25 yasuoka Exp $ +# $OpenBSD: Makefile.common,v 1.2 2015/09/23 03:19:55 yasuoka Exp $ S= ${.CURDIR}/../../../../.. SADIR= ${.CURDIR}/../.. @@ -7,6 +7,8 @@ EFIDIR= ${.CURDIR}/../../efi OBJCOPY?= objcopy OBJDUMP?= objdump +EFI_HEAP_LIMIT= 0xc00000 + LDFLAGS+= -nostdlib -T${.CURDIR}/../${LDSCRIPT} -Bsymbolic -shared COPTS+= -DEFIBOOT -DNEEDS_HEAP_H -DLINKADDR=${LINKADDR} -I${.CURDIR}/.. @@ -65,6 +67,7 @@ ${PROG}: ${PROG.so} .include <bsd.prog.mk> CFLAGS+= -Wno-pointer-sign CPPFLAGS+= -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD +CPPFLAGS+= -DHEAP_LIMIT=${EFI_HEAP_LIMIT} ${PROG.so}: ${OBJS} ${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LDADD} diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c b/sys/arch/amd64/stand/efiboot/efiboot.c index cdb7a284963..e9921605704 100644 --- a/sys/arch/amd64/stand/efiboot/efiboot.c +++ b/sys/arch/amd64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.3 2015/09/03 09:22:40 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.4 2015/09/23 03:19:55 yasuoka Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -42,7 +42,7 @@ EFI_RUNTIME_SERVICES *RS; EFI_HANDLE IH, efi_bootdp = NULL; EFI_PHYSICAL_ADDRESS heap; EFI_LOADED_IMAGE *loadedImage; -UINTN heapsiz = 3 * 1024 * 1024; +UINTN heapsiz = 1 * 1024 * 1024; UINTN mmap_key; static EFI_GUID imgdp_guid = { 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf }}; @@ -199,7 +199,7 @@ efi_heap_init(void) { EFI_STATUS status; - heap = 0x1000000; /* Below kernel base address */ + heap = HEAP_LIMIT; status = EFI_CALL(BS->AllocatePages, AllocateMaxAddress, EfiLoaderData, EFI_SIZE_TO_PAGES(heapsiz), &heap); if (status != EFI_SUCCESS) |