All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sughosh Ganu <sughosh.ganu@linaro.org>
To: u-boot@lists.denx.de
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	AKASHI Takahiro <takahiro.akashi@linaro.org>,
	Ying-Chun Liu <paul.liu@linaro.org>,
	Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>,
	Heiko Thiery <heiko.thiery@gmail.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Michael Walle <michael@walle.cc>,
	Masami Hiramatsu <masami.hiramatsu@linaro.org>,
	Jassi Brar <jaswinder.singh@linaro.org>,
	Michal Simek <monstr@monstr.eu>,
	Michal Simek <michal.simek@xilinx.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>
Subject: [PATCH v6 4/8] efi: Define set_dfu_alt_info() for boards with UEFI capsule update enabled
Date: Tue, 12 Apr 2022 18:34:43 +0530	[thread overview]
Message-ID: <20220412130447.300574-5-sughosh.ganu@linaro.org> (raw)
In-Reply-To: <20220412130447.300574-1-sughosh.ganu@linaro.org>

Currently, there are a bunch of boards which enable the UEFI capsule
update feature. The actual update of the firmware images is done
through the dfu framework which uses the dfu_alt_info environment
variable for getting information on the update, like device, partition
number/address etc. The dfu framework allows the variable to be set
through the set_dfu_alt_info function defined by the platform, or if
the function is not defined, it gets the variable from the
environment. Using the value set in the environment is not very
robust, since the variable can be modified from the u-boot command
line and this can cause an incorrect update.

To prevent this from happening, define the set_dfu_alt_info function
when the capsule update feature is enabled. A weak function is defined
which sets the dfu_alt_info environment variable by getting the string
for the variable from the platform.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---

Changes since V5:
* Simplify the set_dfu_alt_info function definition to set the
  variable directly from dfu_string, as suggested by Heinrich.

 lib/efi_loader/Kconfig        | 2 ++
 lib/efi_loader/efi_firmware.c | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 559b95a599..d50cd2563d 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -181,6 +181,7 @@ config EFI_CAPSULE_FIRMWARE_FIT
 	depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
 	select UPDATE_FIT
 	select DFU
+	select SET_DFU_ALT_INFO
 	select EFI_CAPSULE_FIRMWARE
 	help
 	  Select this option if you want to enable firmware management protocol
@@ -192,6 +193,7 @@ config EFI_CAPSULE_FIRMWARE_RAW
 	depends on SANDBOX || (!SANDBOX && !EFI_CAPSULE_FIRMWARE_FIT)
 	select DFU_WRITE_ALT
 	select DFU
+	select SET_DFU_ALT_INFO
 	select EFI_CAPSULE_FIRMWARE
 	help
 	  Select this option if you want to enable firmware management protocol
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index e9fc4b9c1e..c2fe660cdd 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -35,6 +35,11 @@ struct fmp_payload_header {
 	u32 lowest_supported_version;
 };
 
+__weak void set_dfu_alt_info(char *interface, char *devstr)
+{
+	env_set("dfu_alt_info", update_info.dfu_string);
+}
+
 /* Place holder; not supported */
 static
 efi_status_t EFIAPI efi_firmware_get_image_unsupported(
-- 
2.25.1


  parent reply	other threads:[~2022-04-12 13:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 13:04 [PATCH v6 0/8] efi: capsule: Capsule Update fixes and enhancements Sughosh Ganu
2022-04-12 13:04 ` [PATCH v6 1/8] capsule: board: Add information needed for capsule updates Sughosh Ganu
2022-04-12 13:04 ` [PATCH v6 2/8] capsule: FMP: Populate the image descriptor array from platform data Sughosh Ganu
2022-04-12 13:04 ` [PATCH v6 3/8] capsule: Put a check for image index before the update Sughosh Ganu
2022-04-12 13:04 ` Sughosh Ganu [this message]
2022-04-12 13:04 ` [PATCH v6 5/8] test: capsule: Modify the capsule tests to use GUID values for sandbox Sughosh Ganu
2022-04-13  6:35   ` AKASHI Takahiro
2022-04-13  8:29     ` Sughosh Ganu
2022-04-12 13:04 ` [PATCH v6 6/8] FMP: Remove GUIDs for FIT and raw images Sughosh Ganu
2022-04-12 13:04 ` [PATCH v6 7/8] mkeficapsule: Remove raw and FIT GUID types Sughosh Ganu
2022-04-13  6:05   ` AKASHI Takahiro
2022-04-13  6:14     ` Sughosh Ganu
2022-04-13  6:23       ` AKASHI Takahiro
2022-04-13  6:30         ` Sughosh Ganu
2022-04-13  6:44           ` AKASHI Takahiro
2022-04-12 13:04 ` [PATCH v6 8/8] doc: uefi: Update the capsule update related documentation Sughosh Ganu
2022-04-13  6:18   ` AKASHI Takahiro
2022-04-13  7:08     ` Sughosh Ganu
2022-04-13  7:33       ` AKASHI Takahiro
2022-04-13  8:11         ` Masami Hiramatsu

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=20220412130447.300574-5-sughosh.ganu@linaro.org \
    --to=sughosh.ganu@linaro.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=heiko.thiery@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jaswinder.singh@linaro.org \
    --cc=masami.hiramatsu@linaro.org \
    --cc=michael@walle.cc \
    --cc=michal.simek@xilinx.com \
    --cc=monstr@monstr.eu \
    --cc=paul.liu@linaro.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=tuomas.tynkkynen@iki.fi \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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.