From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26488C433EF for ; Thu, 25 Nov 2021 00:16:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A07C837B7; Thu, 25 Nov 2021 01:14:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZtDvHWH9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5FFBF801E7; Thu, 25 Nov 2021 01:13:15 +0100 (CET) Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EABD682F89 for ; Thu, 25 Nov 2021 01:13:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ot1-x32f.google.com with SMTP id h19-20020a9d3e53000000b0056547b797b2so6838946otg.4 for ; Wed, 24 Nov 2021 16:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eRlmrCuuSJzVOJEwE8EzLYPht59l+uNspDcJ/H91rn4=; b=ZtDvHWH9lR8qIrdrufw4l0C657GoewYN8Maqik+9DTowxAZaXqCRcDSsrmGGEYbou6 8ykq+Ls3HLw60mAgK25fbOXBy4XR+TdzGFGzv1k1NpHtEy/jR9yeJr03nXR1xKNwrBp9 V5BWP96Plse/RJMxsI1m6g+Jgqwn2mhceYP0g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eRlmrCuuSJzVOJEwE8EzLYPht59l+uNspDcJ/H91rn4=; b=DfPiWHhpna5mcrMA+nlh4fOaZCAMwB1FmIo2xxYSvdFR2CWp3+3G3DSK0HYZaIDLCR MB2JDSJgm8DO+1RtXyqJtx+W6GjvE8xYsVLYV1yz9BYXPcsIcBk9zs1KxiPBXZ2LTZUI VHpsgsGkWZlSqERDhLYftXOG/3hb+Duy1mBjkHgp4Jo3V1eGISMjKnrOKHkhMFjv2Qtv iQ1shNsMNudcWFP6FmxAdF01d0mGuGiCQn/dblhQY++zC8An2RgOg/hUe1apzalxooZp tWnLUIJktIE1uGar7ttM9bvW2r8oz2d1L+17VclU5o2EMQ5hGnjooCgO3XcCKX5O4acY QiTA== X-Gm-Message-State: AOAM531mq2sSrUCdyNrXOkUDZ2w2kFewh/rpHegxRlap5CZupCNVaLx7 hmCz8IzeaXfbi2pahz8bpagZoLnJEHCY/aexYRTXvw== X-Google-Smtp-Source: ABdhPJwuJavQAGtauwhP8uBOe7c9nI39shcATvwnwYdivOko/dZEVimcB2XdB7XAJr0ekUfFdD6pi0OdVYNHCX+GyJ0= X-Received: by 2002:a9d:58f:: with SMTP id 15mr14475320otd.11.1637799189118; Wed, 24 Nov 2021 16:13:09 -0800 (PST) MIME-Version: 1.0 References: <20211117175215.24262-1-philippe.reynes@softathome.com> <20211117175215.24262-6-philippe.reynes@softathome.com> In-Reply-To: <20211117175215.24262-6-philippe.reynes@softathome.com> From: Simon Glass Date: Wed, 24 Nov 2021 17:12:56 -0700 Message-ID: Subject: Re: [RFC PATCH v3 5/8] cmd: bootm: add a stage pre-load To: Philippe Reynes Cc: mr.nuke.me@gmail.com, joel.peshkin@broadcom.com, u-boot@lists.denx.de Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Philippe, On Wed, 17 Nov 2021 at 10:52, Philippe Reynes wrote: > > This commit adds a stage pre-load to the command Add a stage... > bootm. Right now, this stage may be used to read > a header and check the signature of the full > image. > > Signed-off-by: Philippe Reynes > --- > boot/bootm.c | 33 +++++++++++++++++++++++++++++++++ > cmd/Kconfig | 10 ++++++++++ > cmd/bootm.c | 2 +- > include/image.h | 1 + > 4 files changed, 45 insertions(+), 1 deletion(-) > Reviewed-by: Simon Glass > diff --git a/boot/bootm.c b/boot/bootm.c > index 4482f84b40..4803c577cc 100644 > --- a/boot/bootm.c > +++ b/boot/bootm.c > @@ -87,6 +87,33 @@ static int bootm_start(struct cmd_tbl *cmdtp, int flag, int argc, > return 0; > } > > +static ulong bootm_data_addr(int argc, char *const argv[]) > +{ > + ulong addr; > + > + if (argc > 0) > + addr = simple_strtoul(argv[0], NULL, 16); > + else > + addr = image_load_addr; > + > + return addr; > +} > + > +static int bootm_pre_load(struct cmd_tbl *cmdtp, int flag, int argc, > + char *const argv[]) > +{ > + ulong data_addr = bootm_data_addr(argc, argv); > + int ret = 0; > + > + if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD)) > + ret = image_pre_load(data_addr); > + > + if (ret) > + ret = CMD_RET_FAILURE; > + > + return ret; > +} > + > static int bootm_find_os(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > { > @@ -677,6 +704,9 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, > if (states & BOOTM_STATE_START) > ret = bootm_start(cmdtp, flag, argc, argv); > > + if (!ret && (states & BOOTM_STATE_PRE_LOAD)) > + ret = bootm_pre_load(cmdtp, flag, argc, argv); > + > if (!ret && (states & BOOTM_STATE_FINDOS)) > ret = bootm_find_os(cmdtp, flag, argc, argv); > > @@ -866,6 +896,9 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc, > &fit_uname_config, > &fit_uname_kernel); > > + if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD)) > + img_addr += image_load_offset; > + > bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC); > > /* check image type, for FIT images get FIT kernel node */ > diff --git a/cmd/Kconfig b/cmd/Kconfig > index 5b30b13e43..cad2cda0bf 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -194,6 +194,16 @@ config CMD_BOOTM > help > Boot an application image from the memory. > > +config CMD_BOOTM_PRE_LOAD > + bool "enable pre-load on bootm" > + depends on CMD_BOOTM > + depends on IMAGE_PRE_LOAD > + default n > + help > + Enable support of stage pre-load for the bootm command. > + This stage allow to check of modifty the image provided > + to the bootm command. modify > + > config BOOTM_EFI > bool "Support booting UEFI FIT images" > depends on CMD_BOOTEFI && CMD_BOOTM && FIT > diff --git a/cmd/bootm.c b/cmd/bootm.c > index 92468d09a1..acfb8eedde 100644 > --- a/cmd/bootm.c > +++ b/cmd/bootm.c > @@ -126,7 +126,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) > } > > return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START | > - BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER | > + BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER | > BOOTM_STATE_LOADOS | > #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH > BOOTM_STATE_RAMDISK | > diff --git a/include/image.h b/include/image.h > index 5f83e4c747..42fb01ab07 100644 > --- a/include/image.h > +++ b/include/image.h > @@ -351,6 +351,7 @@ typedef struct bootm_headers { > #define BOOTM_STATE_OS_PREP (0x00000100) > #define BOOTM_STATE_OS_FAKE_GO (0x00000200) /* 'Almost' run the OS */ > #define BOOTM_STATE_OS_GO (0x00000400) > +#define BOOTM_STATE_PRE_LOAD (0x00000800) Drop () > int state; > > #if defined(CONFIG_LMB) && !defined(USE_HOSTCC) > -- > 2.17.1 > Regards, Simon