From patchwork Tue Apr 12 13:04:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 559988 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3374498map; Tue, 12 Apr 2022 06:06:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmiBlICXXsI3qwgKBb+Ry1cm4vVTXHfJOMB9mxni7edGq20lq+uqzU9xkeQNsaEztA/ZNK X-Received: by 2002:a17:907:6e1c:b0:6e8:8037:a49d with SMTP id sd28-20020a1709076e1c00b006e88037a49dmr11939326ejc.752.1649768781309; Tue, 12 Apr 2022 06:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649768781; cv=none; d=google.com; s=arc-20160816; b=oU7MVv2y0PiEkrZjl0Stlzpc+BKcCo+s1SHtOXCN6wzcRv959QVD0G7DV8eR8S/KQQ W+Z4/1RzM1tHQ+LlPN+LJqvfQlZjKHwUSiONF0hQIuHxsGoofA/BJ0WLWyJls9n+39/P 0ejOjoG6N+FCXcnNp/037rFE0vITWUPMygpsTdOiSBQ1D0LJcGCYyuj6M2CtRcex9IbY Yd9cWic3QRYVZKb/0qdmZ2U6qvwzCyb1EAQTPHyGxCPS+REahcIMGiezyctV8e39R3kK dO0I6c6thiUUQlqQLcBu2ZiqU2k3b5ak8T9OdfnUGC5LJ30swwii5nZyWKILAAWHG5zZ lDyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=rBSLbsBiBCzGuQAnq+jaT2K31EJptKUy5/Xoag9vr3k=; b=uW3BNEt7DvqwWNIMQJ0FKiRCz17baLqe2fp909/MESEJeDpfuyB8f4rc0LBo7JX5AI kKG3kkkoJRApEPyAGW+VlTlVofKQvWA6bYetuwqLTyCj99L5ly0Hw+DKu5JN8DLgoadb DPBzZ50GwNQSqstYB12MNx045lzvp9MA5wC5cJtrVxlYL/yt1Y9HkeTa1RP4pJg8kmMd nOonPkxBMRdI4RcFkOrsa+Lhc/zChzfquneMHpdhRL3hnAe3yUAvZyFIjL3nNIlqvZdb mXAv2WhGJvUjK2RkRH3WYc9Cz45rNkt3B57DSqD74fFJkx836ilresslmtODXqgf1vms CO2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ss9-20020a170907038900b006e6dd21f356si6570182ejb.599.2022.04.12.06.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 06:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A43283DDA; Tue, 12 Apr 2022 15:05:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 6041581DD6; Tue, 12 Apr 2022 15:05:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 7E9C381DD6 for ; Tue, 12 Apr 2022 15:05:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CD64A150C; Tue, 12 Apr 2022 06:05:37 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 176D33F70D; Tue, 12 Apr 2022 06:05:33 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , AKASHI Takahiro , Ying-Chun Liu , Tuomas Tynkkynen , Heiko Thiery , Frieder Schrempf , Michael Walle , Masami Hiramatsu , Jassi Brar , Michal Simek , Michal Simek , Sughosh Ganu 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 Message-Id: <20220412130447.300574-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412130447.300574-1-sughosh.ganu@linaro.org> References: <20220412130447.300574-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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 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 --- 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(