From: Jean-Philippe Brucker Date: Thu, 8 Oct 2015 09:08:18 +0000 (+0100) Subject: Protect against overlapping with the 32-bit kernel X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5933e49b6f45fa18dd1e32d14372bb60837ff954;p=people%2Fjulieng%2Fboot-wrapper-aarch64.git Protect against overlapping with the 32-bit kernel This patch adds a guard in the linker script to abort the build when the bootloader code overflows the 12k limit. Indeed, 32-bit Linux with LPAE enabled puts its initial page tables between 0x80003000 and 0x80007fff. Signed-off-by: Jean-Philippe Brucker Signed-off-by: Mark Rutland --- diff --git a/Makefile.am b/Makefile.am index 0e2b92a..5cc7d0b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,9 +71,11 @@ endif if KERNEL_32 MBOX_OFFSET := 0x7ff8 KERNEL_OFFSET := 0x8000 +TEXT_LIMIT := 0x80003000 else MBOX_OFFSET := 0xfff8 KERNEL_OFFSET := 0x80000 +TEXT_LIMIT := 0x80080000 endif LD_SCRIPT := model.lds.S @@ -123,7 +125,7 @@ $(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM) $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $< model.lds: $(LD_SCRIPT) Makefile - $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -P -C -o $@ $< + $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $< fdt.dtb: $(KERNEL_DTB) Makefile gen-cpu-nodes.sh ( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) $(CPUS_NODE) };" ) | $(DTC) -O dtb -o $@ - diff --git a/model.lds.S b/model.lds.S index c906d0c..f1902e1 100644 --- a/model.lds.S +++ b/model.lds.S @@ -49,10 +49,13 @@ SECTIONS *(.text* .data* .rodata* .bss* COMMON) *(.vectors) *(.stack) + PROVIDE(etext = .); } .mbox (PHYS_OFFSET + MBOX_OFFSET): { mbox = .; QUAD(0x0) } + + ASSERT(etext <= TEXT_LIMIT, ".text overflow!") }