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 1F480C433EF for ; Thu, 31 Mar 2022 19:35:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 627AC83FF8; Thu, 31 Mar 2022 21:35:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dXiKc+Jx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 93CA883C27; Thu, 31 Mar 2022 21:35:38 +0200 (CEST) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (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 0732F83C27 for ; Thu, 31 Mar 2022 21:35:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x42d.google.com with SMTP id a1so1149176wrh.10 for ; Thu, 31 Mar 2022 12:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=n0Z4FY3G8l6gCsBdRXoBIGPdnkWzkS1rKShzamjYDCA=; b=dXiKc+JxUBE1RoI0GmBPl64bDD3wUD6iMtxqMYpzrAAzH3H3Z7enwu336hue2VFjwH fYdueSHyY1PCMHUewXH07tbj4TIYzFmNxMC+q57d87UblGjuWsCjIF8klPXuH4hbjDFw sdO/1m+JyYYfyyJOV6tINt3MVCENLrQcTO7odu+nARDOcryzCJZEFMJxbqXQn0CDUc4e jnyooK9Bu4NZd4Vp/NcfLRzsbf5kdsY1j4DmldBiuUNZYpQH+3PIFmY7ToJ2j92+5QT6 eKAqmrUlp2JQz3DXqiFDbTLDU2skXVaF6lHz3yAmThlxOCvlZ6AKiRuuqH68/wxk/JxS RGCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=n0Z4FY3G8l6gCsBdRXoBIGPdnkWzkS1rKShzamjYDCA=; b=O+AY+P0JcrkfnjQprvlVxNBxpfE3RlXv9YsbUkhOS71kD6qOKYF1WADeNrg8+MLuzz YcKGkbqMd117V3MjbCx3iGYCaJEhtqNDEZudnhDyxzd/dDLwwlDBt1zp/9S8g4sQ8J0v Ho7kbXFvFryYE0T34zZ9AU9TFP5TvR11AZcjGzEZbXYoC3xJTuA+U9Mdrc80GhO2fv9u LO62LCvr2GPegtd3hZVfqYDFVsuigirEU5ebGvbEnJeicEm3zyylsyyTnO3FjU2MPTfX 3YmgbfYR49CQT1LHETYZfgv1eh4GgJV9NmBUd5J1iK/oQYGmrUf2qfX93fMYaMGrR212 QEwA== X-Gm-Message-State: AOAM532nKdjxkbAFe+G+2OvQQOR16Rk1XfUfZVu6J1bMtBGo2Ifk2r0k qE/tCzD5Yd1r3F4UUomfwPsFYw== X-Google-Smtp-Source: ABdhPJzFrcOFEQcOIR+O++tNnSlKHjmt9WSMXw592q5JZ+ezDT5/woKk6Oy9IdokThQeGGz9m2eZ5Q== X-Received: by 2002:a05:6000:1107:b0:205:b8e5:8929 with SMTP id z7-20020a056000110700b00205b8e58929mr5147373wrw.187.1648755328544; Thu, 31 Mar 2022 12:35:28 -0700 (PDT) Received: from hades (athedsl-4461682.home.otenet.gr. [94.71.4.98]) by smtp.gmail.com with ESMTPSA id w7-20020a1cf607000000b00389a5390180sm135684wmc.25.2022.03.31.12.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 12:35:28 -0700 (PDT) Date: Thu, 31 Mar 2022 22:35:24 +0300 From: Ilias Apalodimas To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , AKASHI Takahiro , Ying-Chun Liu , Tuomas Tynkkynen , Heiko Thiery , Frieder Schrempf , Michael Walle , Masami Hiramatsu , Jassi Brar , Michal Simek , Michal Simek Subject: Re: [PATCH v4 4/8] board: Define set_dfu_alt_info() for boards with UEFI capsule update enabled Message-ID: References: <20220331132750.1532722-1-sughosh.ganu@linaro.org> <20220331132750.1532722-5-sughosh.ganu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220331132750.1532722-5-sughosh.ganu@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean Hi Sughosh, Some nots below On Thu, Mar 31, 2022 at 06:57:46PM +0530, Sughosh Ganu wrote: > 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. Currently, these boards define the dfu_alt_info > variable in the board config header, as an environment variable. With > this, 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 > in the board file, and select SET_DFU_ALT_INFO for all platforms which > enable the capsule update feature. With the function defined, the dfu > framework populates the dfu_alt_info variable through the board file, > instead of fetching the variable from the environment, thus making the > update more robust. > > Signed-off-by: Sughosh Ganu > --- > > Changes since V3: > * Do not remove the existing dfu_alt_info definitions made by > platforms in the config files, as discussed with Masami. > * Squash the selection of the SET_DFU_ALT_INFO config symbol for > capsule update feature as part of this patch. > > > .../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 24 +++++++++++++++++ > .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 24 +++++++++++++++++ > board/emulation/common/qemu_dfu.c | 6 ++--- > board/kontron/pitx_imx8m/pitx_imx8m.c | 24 +++++++++++++++++ > board/kontron/sl-mx8mm/sl-mx8mm.c | 24 +++++++++++++++++ > board/kontron/sl28/sl28.c | 25 ++++++++++++++++++ > board/sandbox/sandbox.c | 26 +++++++++++++++++++ > board/socionext/developerbox/developerbox.c | 26 +++++++++++++++++++ > board/xilinx/zynq/board.c | 5 ++-- > board/xilinx/zynqmp/zynqmp.c | 5 ++-- > lib/efi_loader/Kconfig | 2 ++ > 11 files changed, 184 insertions(+), 7 deletions(-) > > diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > index 1c953ba195..41154ca9f3 100644 > --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > @@ -5,10 +5,12 @@ > */ > > #include > +#include > #include > #include > #include > #include > +#include > #include > #include > #include > @@ -24,6 +26,7 @@ > #include > #include > #include > +#include > #include > > DECLARE_GLOBAL_DATA_PTR; > @@ -231,3 +234,24 @@ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc) > } > } > #endif /* CONFIG_SPL_MMC_SUPPORT */ > + > +#if defined(CONFIG_SET_DFU_ALT_INFO) > + > +#define DFU_ALT_BUF_LEN SZ_1K > + > +void set_dfu_alt_info(char *interface, char *devstr) > +{ > + ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); > + > + if (!CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) && > + env_get("dfu_alt_info")) > + return; Just add a helper function with this since we need to repeat it for every board. Something like 'bool needs_runtime_dfu_alt_info() ' > + > + memset(buf, 0, DFU_ALT_BUF_LEN); I'd prefer sizeof(buf) instead of explicitly calling the length. Otherwise LGTM, but I'd prefer if board maintainer had a look as well Thanks /Ilias > + > + snprintf(buf, DFU_ALT_BUF_LEN, > + "mmc 2=flash-bin raw 0 0x1B00 mmcpart 1"); > + > + env_set("dfu_alt_info", buf); > +} > +#endif /* CONFIG_SET_DFU_ALT_INFO */ [...]