From a10ed08fe00fba7f96e8c95e84ede42735bb5801 Mon Sep 17 00:00:00 2001 From: Brandon Bergren Date: Fri, 1 May 2020 16:56:36 +0000 Subject: [PATCH] [PowerPC] Set fixed boot1.elf load address Due to the way claiming works, we need to ensure on AIM OFW machines that we don't have overlapping ranges on any step of the load. Load boot1.elf at 0x38000 so it will not overlap with anything even if the entire PReP partition gets loaded by OFW. Tested on an iBook G4, a PowerBook G4, a PowerMac G5, and qemu pseries. (qemu pseries is broken without this patch due to the high address used by lld10.) Reviewed by: adalava Sponsored by: Tag1 Consulting, Inc. Differential Revision: https://reviews.freebsd.org/D24623 --- stand/powerpc/boot1.chrp/Makefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/stand/powerpc/boot1.chrp/Makefile b/stand/powerpc/boot1.chrp/Makefile index 8fbc1e59711..e2f1739a4f4 100644 --- a/stand/powerpc/boot1.chrp/Makefile +++ b/stand/powerpc/boot1.chrp/Makefile @@ -10,7 +10,20 @@ FILES= boot1.hfs SRCS= boot1.c ashldi3.c syncicache.c CFLAGS+=-I${LDRSRC} -LDFLAGS=-nostdlib -static -Wl,-N +# Load boot1.elf below kernel. +# +# Due to limitiations in the way we load stuff, we have to avoid reusing +# memory until the kernel MMU code has taken over. +# +# 0x38000 is high enough to not interfere with the trap area, but low +# enough that it doesn't bump into the kernel area starting at 0x100000, +# even if the entire partition gets used as the load size by a buggy OFW. +# +# In theory 0xf0000 would work too under the current 64k size limit for +# boot1.elf defined in the HFS template, but sometimes boot1.elf is written +# directly to the PReP partition. +# +LDFLAGS=-nostdlib -static -Wl,-N -Wl,-Ttext=0x38000 .PATH: ${SYSDIR}/libkern ${SRCTOP}/lib/libc/powerpc/gen ${.CURDIR}