From nobody Fri Oct 27 03:18:59 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SGnv73y88z4xfDN; Fri, 27 Oct 2023 03:18:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SGnv73RCQz4YrY; Fri, 27 Oct 2023 03:18:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698376739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NUoKwPjVcS8DUEYLps2WKJDdX9TwuMmvW/cnFmo1FYg=; b=tzdnXnlj9qBo/bJ6YcptaWVKT24cgFnGFsyx8E2/LSxhNQcWiengE5fE4zqqgDbv5kNYAt zSO6MrObft5he+vMbgLjGUmcsQYcDe4nZKORACJUVxyBDYjYBnADzy06kx3dqj8qcsERBd so5PwTmrvF1APGPQYjHqyAmVKRbt7SDisN2E1UtD9FnoXBJoZaC1hComE60QSKCcFyNLJJ YziOWbVeSWisIuatu29V84mH6w0yRvUuvs6ffuiX4dW18UYiewnsmDYagm1LKKwwhLsucX BZ+Hz22RW0uguyx7cApl94MUwvdl+FG6IM/YYDY3Zi3WpcXclxMPbyVrJKejQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698376739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NUoKwPjVcS8DUEYLps2WKJDdX9TwuMmvW/cnFmo1FYg=; b=E/N6iD0ClUX0kis7sBHK3jFzt0RUgMM75ppMZiw0w8K6rnb91sRshjA8T2Hmbf/xOfJDnK 3dy4DIfpM8xpXVYHX7GQYNJgx2gyesBFOIA1Pf8v35mUzN8coQ45x8+8FTbhKCPj5kLmRI V2aWvMXs35c+WqLp/YzPYMGPrQmFByFhT4XR5YRhcdrieEQb6tNKTrT2FKfoZog5eMML1a CLg1V/JAd3bm8XNk/MqK4Tq+GB99TfCwOrODQ7yaJB2xBzlIAV42DLpX0ZsB4/STSSSQOv bJ7t6v3aZ95US37dDmnGTalKY8JdUajUT/1NJtS1RqGr7kz/ZFSCxHCURcJ6Fw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698376739; a=rsa-sha256; cv=none; b=Yl/DYkHeuIQSoNUGLw2OMh8o3cu1TLp23ct2x0yNi4oPyqkMOCnGIo/QRGHAw5syO4Dwhg A+Qi71LZOiIi0WV5FEOLv7osZWjTTvRRODliPMYfu/xSto5NQw5WVLuKYOzr35NHss7ILJ lxqm5F/tcT33nEZ8/wz2I9w+bL7Ud7OLBKGqZ6LA3vs9ReoBcYjdkBcrBhq9Xwtug9es5q ZHcUTSUO6WY70WGAL3Ma25q2DGctIr2k2trX5b1KTGN9FBSWruHkcJKkvAwxkP6AXqbJbQ XLwRGS+rZugiFC+2t7xF3+Xek0o5OAJJVDgV+ElSG3gQj1cRoXt5Rj6UNed9Gw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SGnv72TWwzxS6; Fri, 27 Oct 2023 03:18:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39R3IxiO056805; Fri, 27 Oct 2023 03:18:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39R3Ixli056802; Fri, 27 Oct 2023 03:18:59 GMT (envelope-from git) Date: Fri, 27 Oct 2023 03:18:59 GMT Message-Id: <202310270318.39R3Ixli056802@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 34632ed1a495 - main - arm: Introduce MK_KERNEL_BIN to control generation of kernel.bin List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 34632ed1a49512f52968736abca66c0420bb576a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=34632ed1a49512f52968736abca66c0420bb576a commit 34632ed1a49512f52968736abca66c0420bb576a Author: Warner Losh AuthorDate: 2023-10-27 03:10:36 +0000 Commit: Warner Losh CommitDate: 2023-10-27 03:10:36 +0000 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 --- sys/conf/Makefile.arm | 5 ----- sys/conf/Makefile.arm64 | 6 ------ sys/conf/kern.opts.mk | 19 ++++++++++++------- sys/conf/kern.post.mk | 9 +++++++++ tools/build/options/WITH_KERNEL_BIN | 8 ++++++++ 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm index af6ce7136636..d3047406e31c 100644 --- a/sys/conf/Makefile.arm +++ b/sys/conf/Makefile.arm @@ -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" diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64 index 77c36fa6ce6c..435326cadd9d 100644 --- a/sys/conf/Makefile.arm64 +++ b/sys/conf/Makefile.arm64 @@ -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 diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index cc6f8a1d8755..d9d96a133250 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -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 diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index bea29507a736..5258cea9441c 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -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" diff --git a/tools/build/options/WITH_KERNEL_BIN b/tools/build/options/WITH_KERNEL_BIN new file mode 100644 index 000000000000..b5e008dbd6f0 --- /dev/null +++ b/tools/build/options/WITH_KERNEL_BIN @@ -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.