arm: Introduce MK_KERNEL_BIN to control generation of kernel.bin

It's sometimes desirable to generate kernel.bin and install it. While
the mainstream has moved on to UEFI booting on arm, some specialized
gear can't support it. For that gear, we unconditionally generate
kernel.bin. Add a knob so that WITH_KERNEL_BIN or WITHOUT_KERNEL_BIN
control its generation and installation. config files should add
'makeoptions WITH_KERNEL_BIN=t' to enable it. Since its use is
specialized, it is off by default now since the arm world has largely
moved on to UEFI.

It only affects arm and arm64 (since those are the only two that support
it).

Sponsored by:		Netflix
Reviewed by:		mmel
Differential Revision:	https://reviews.freebsd.org/D39013
This commit is contained in:
Warner Losh 2023-10-26 21:10:36 -06:00
parent 4f03a2cae8
commit 34632ed1a4
5 changed files with 29 additions and 18 deletions

View file

@ -69,9 +69,6 @@ SYSTEM_LD= \
# Generate the .bin (no elf headers) kernel as an extra build output.
# We must relink to generate the .bin kernel, because without headers the
# location of everything changes. We also strip the ARM marker symbols.
KERNEL_EXTRA+= ${KERNEL_KO}.bin
KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin
${KERNEL_KO}.bin: ${SYSTEM_DEP} vers.o
@echo "linking ${.TARGET}"
@${SYSTEM_LD_BASECMD} \
@ -100,8 +97,6 @@ genassym.o: bus_if.h device_if.h
%CLEAN
CLEAN+= ${KERNEL_KO}.bin
%RULES
.include "$S/conf/kern.post.mk"

View file

@ -56,11 +56,6 @@ SYSTEM_LD= \
--strip-symbol='$$[adtx]*' \
${.TARGET}
# Generate the .bin (booti images) kernel as an extra build output.
# The targets and rules to generate these appear near the end of the file.
KERNEL_EXTRA+= ${KERNEL_KO}.bin
KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin
.if !empty(DDB_ENABLED) || !empty(DTRACE_ENABLED) || !empty(HWPMC_ENABLED)
CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
.endif
@ -76,7 +71,6 @@ CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
%FILES.m
%CLEAN
CLEAN+= ${KERNEL_KO}.bin
%RULES

View file

@ -56,18 +56,18 @@ __DEFAULT_YES_OPTIONS = \
__DEFAULT_NO_OPTIONS = \
BHYVE_SNAPSHOT \
KERNEL_BIN \
KERNEL_RETPOLINE \
RATELIMIT \
REPRODUCIBLE_BUILD \
VERIEXEC
# Some options are totally broken on some architectures. We disable
# them. If you need to enable them on an experimental basis, you
# must change this code.
# Note: These only apply to the list of modules we build by default
# and sometimes what is in the opt_*.h files by default.
# Kernel config files are unaffected, though some targets can be
# affected by KERNEL_SYMBOLS, FORMAT_EXTENSIONS, CTF and SSP.
# Some options are totally broken on some architectures. We disable them. If you
# need to enable them on an experimental basis, you must change this code.
# Note: These only apply to the list of modules we build by default and
# sometimes what is in the opt_*.h files by default. Kernel config files are
# unaffected, though some targets can be affected by KERNEL_BIN, KERNEL_SYMBOLS,
# FORMAT_EXTENSIONS, CTF and SSP.
# Broken on 32-bit arm, kernel module compile errors
.if ${MACHINE_CPUARCH} == "arm"
@ -84,6 +84,11 @@ BROKEN_OPTIONS+= KERNEL_RETPOLINE
BROKEN_OPTIONS+=EFI
.endif
# We only generate kernel.bin on arm and arm64, otherwise they break the build.
.if ${MACHINE} != "arm" && ${MACHINE} != "arm64"
BROKEN_OPTIONS+=KERNEL_BIN
.endif
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
__DEFAULT_NO_OPTIONS += FDT
.else

View file

@ -466,4 +466,13 @@ embedfs_${MFS_IMAGE:T:R}.o: ${MFS_IMAGE} $S/dev/md/embedfs.S
.endif
.endif
# Generate the .bin (booti images) kernel as an extra build output.
# The targets and rules to generate these appear in Makefile.$MACHINE
# if the platform supports it.
.if ${MK_KERNEL_BIN} != "no"
KERNEL_EXTRA+= ${KERNEL_KO}.bin
KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin
CLEAN+= ${KERNEL_KO}.bin
.endif
.include "kern.mk"

View file

@ -0,0 +1,8 @@
Generate and install kernel.bin from kernel as part of the normal build and
install processes for the kernel. Available only on arm and arm64.
Usually this will be added to the kernel config file with:
makeoptions WITH_KERNEL_BIN=1
though it can also be used on the command line.