All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denys Dmytriyenko <denis@denix.org>
To: reatmon@ti.com
Cc: Praneeth Bajjuri <praneeth@ti.com>,
	Denys Dmytriyenko <denys@konsulko.com>,
	meta-ti@lists.yoctoproject.org
Subject: Re: [meta-ti][master/kirkstone][PATCH 4/4] kernel-fitimage: Add signing of fitImage entries for 5.10 kernel
Date: Thu, 30 Mar 2023 20:01:42 -0400	[thread overview]
Message-ID: <20230331000142.GZ18050@denix.org> (raw)
In-Reply-To: <20230330212440.19437-5-reatmon@ti.com>

On Thu, Mar 30, 2023 at 04:24:40PM -0500, Ryan Eatmon via lists.yoctoproject.org wrote:
> While we are mirgrating to kernel v6.1 and u-boot 2023.04, we want to
> keep kernel 5.10 and u-boot 2021.01 "working" for anyone looking at
> kirkstone.


>  One of the changes we are looking at changing is the signing of entries 
> in the fitImage.

You might want to rephrase this one :)


> To try and acheive a limited parity with dunfell while we work on the
> migration, this creates a class that implements the logic that was in
> dunfell and applies that class to the 5.10 kernel.

Maybe mention falling back to using SECDEV tooling for now instead of 
uboot-sign class, with the plan to get back and clean it up later?


> Signed-off-by: Ryan Eatmon <reatmon@ti.com>
> ---
>  .../classes/kernel-fitimage-ti-u-boot.bbclass | 214 ++++++++++++++++++
>  .../linux/linux-ti-staging_5.10.bb            |   2 +
>  2 files changed, 216 insertions(+)
>  create mode 100644 meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass
> 
> diff --git a/meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass b/meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass
> new file mode 100644
> index 00000000..503c6d25
> --- /dev/null
> +++ b/meta-ti-bsp/classes/kernel-fitimage-ti-u-boot.bbclass
> @@ -0,0 +1,214 @@
> +
> +inherit ti-secdev
> +
> +# The TI u-boot requires that the kernel image is signed.  To not overload the
> +# entire kernel-fitimage.bbclass from oe-core, we just overwrite one function
> +# and do the signing in there.

I'm wondering how the inherit ordering is handled in this case and whether 
there are any chances of a race - which fitimage_assemble will be used?


> +#
> +# Assemble fitImage
> +#
> +# $1 ... .its filename
> +# $2 ... fitImage name
> +# $3 ... include ramdisk
> +fitimage_assemble() {
> +	kernelcount=1
> +	dtbcount=""
> +	DTBS=""
> +	ramdiskcount=$3
> +	setupcount=""
> +	bootscr_id=""
> +	rm -f $1 arch/${ARCH}/boot/$2
> +
> +	if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
> +		bbfatal "Keys used to sign images and configuration nodes must be different."
> +	fi

<snip>


> +}
> +
> +fitimage_ti_secure() {
> +	if test -n "${TI_SECURE_DEV_PKG}"; then
> +		export TI_SECURE_DEV_PKG=${TI_SECURE_DEV_PKG}
> +		${TI_SECURE_DEV_PKG}/scripts/secure-binary-image.sh $1 $2
> +	else
> +		cp $1 $2
> +	fi
> +}
> +
> diff --git a/meta-ti-bsp/recipes-kernel/linux/linux-ti-staging_5.10.bb b/meta-ti-bsp/recipes-kernel/linux/linux-ti-staging_5.10.bb
> index cc67188a..f3793baf 100644
> --- a/meta-ti-bsp/recipes-kernel/linux/linux-ti-staging_5.10.bb
> +++ b/meta-ti-bsp/recipes-kernel/linux/linux-ti-staging_5.10.bb
> @@ -3,6 +3,8 @@ SUMMARY = "Linux kernel for TI devices"
>  LICENSE = "GPL-2.0-only"
>  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
>  
> +KERNEL_CLASSES += "${@bb.utils.contains('TFA_PLATFORM', 'k3', 'kernel-fitimage-ti-u-boot', '', d)}"

"contains" does a substring search, a bit faster to use "conditional" here:

KERNEL_CLASSES += "${@oe.utils.cconditional('TFA_PLATFORM', 'k3', 'kernel-fitimage-ti-u-boot', '', d)}"

or even a simple Python if-else directly:

KERNEL_CLASSES += "${@ 'kernel-fitimage-ti-u-boot' if d.getVar('TFA_PLATFORM') == 'k3' else ''}"


> +
>  inherit kernel
>  
>  DEFCONFIG_BUILDER = "${S}/ti_config_fragments/defconfig_builder.sh"
> -- 
> 2.17.1


  reply	other threads:[~2023-03-31  0:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 21:24 [meta-ti][master/kirkstone][PATCH 0/4] Sync up from dunfell Ryan Eatmon
2023-03-30 21:24 ` [meta-ti][master/kirkstone][PATCH 1/4] u-boot-ti-staging: Fix u-boot configs to match oe-core fitImage Ryan Eatmon
2023-03-31  0:04   ` Denys Dmytriyenko
2023-03-31 14:15     ` Ryan Eatmon
2023-03-30 21:24 ` [meta-ti][master/kirkstone][PATCH 2/4] trusted-firmware-a: Only sign files for platforms that support it Ryan Eatmon
2023-03-31  0:12   ` Denys Dmytriyenko
     [not found]   ` <1751589DE6D33C0C.27612@lists.yoctoproject.org>
2023-03-31  0:17     ` Denys Dmytriyenko
2023-03-30 21:24 ` [meta-ti][master/kirkstone][PATCH 3/4] optee-os: " Ryan Eatmon
2023-03-30 21:24 ` [meta-ti][master/kirkstone][PATCH 4/4] kernel-fitimage: Add signing of fitImage entries for 5.10 kernel Ryan Eatmon
2023-03-31  0:01   ` Denys Dmytriyenko [this message]
     [not found]   ` <1751580B6CF411F3.12651@lists.yoctoproject.org>
2023-03-31  0:14     ` Denys Dmytriyenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230331000142.GZ18050@denix.org \
    --to=denis@denix.org \
    --cc=denys@konsulko.com \
    --cc=meta-ti@lists.yoctoproject.org \
    --cc=praneeth@ti.com \
    --cc=reatmon@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.