From patchwork Thu Apr 14 10:54:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 561201 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp896723map; Thu, 14 Apr 2022 03:56:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY16y395B7MU+fuPDHIi4rqvG4n/3Yltwj1urTjOKCcZ53cCoU7ZxjSd2YuZYIH++dbOgE X-Received: by 2002:a17:906:8514:b0:6e8:966f:3004 with SMTP id i20-20020a170906851400b006e8966f3004mr1714366ejx.115.1649933767513; Thu, 14 Apr 2022 03:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649933767; cv=none; d=google.com; s=arc-20160816; b=NFuHj4rs7nHLlH3dqwCCgEGvvj2aVBsFPVEvp1UDDwsTnAdfHsL39WRiDd980vWPbB Dqc77VwsVYk9BsKj3fmi4PNwDLArnL7cHNF/ISLxmOJwf684hdFFNdVb+0WqdGylE42/ C0P3PCRXuzpN0vlce0WotXDDeDzgfAn5kjYM8W9q/i+VC3MJQWYB/u+IjQRpYwNV0asP bFrJqWKuuJA6DG38rclcxMUVc9MIPmap+0r+ryd8bT6CeyfB7W/SIG03YFEUrJzyHPhp 9ehbYeYcZ6KNDxT4SuR17RT4NYfEEJke83sqdeTIunJ+WAEEDqJeNYvB1wlUOJ2o6V2H BtDg== 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=IWk23UUe/3IUlzcKlu0tHkQ+XcO01u73PhnVX+M3oy8=; b=lHs9O5It8pBTR5ZVYrs3E3+njIInoSAXPwthg1Scs7gkzQCIALzlu4xfLdU3xoWHsv nEIuuPHHmEY4zmt/7AcMh3C0lnOgJ+jYzlso5c8SfSh1fk0FIRdo68wgB8y5dnfMrgvT AqjEuuvdzcA5l5HF/O7zfBNzdQXu8cSo+AcYR96OcSLCmHXWjImilkD7zuD8NdTKyQ0g UvjLrpuPb6Pzui5+rmwcWXJYxsNDjUouFJAVpe+dmI08RVvLYQxb5wkuI3Es4nbNt7PM bGmEZkjSFI1CjLeA7EyIQ4tv88KSZqw3gRDVvI50ruFoUpi/C3N0x1TCQJvnaigk9SSh SOkA== 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 27-20020a50875b000000b0041d98bbc698si3457287edv.498.2022.04.14.03.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 03:56:07 -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 591B383E98; Thu, 14 Apr 2022 12:55:44 +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 A0C1983E71; Thu, 14 Apr 2022 12:55:33 +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 BF85783E79 for ; Thu, 14 Apr 2022 12:55:26 +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 DB8441424; Thu, 14 Apr 2022 03:55:25 -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 F3BC73F70D; Thu, 14 Apr 2022 03:55:21 -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 v7 4/8] efi: Define set_dfu_alt_info() for boards with UEFI capsule update enabled Date: Thu, 14 Apr 2022 16:24:44 +0530 Message-Id: <20220414105448.559043-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220414105448.559043-1-sughosh.ganu@linaro.org> References: <20220414105448.559043-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 Reviewed-by: Masami Hiramatsu --- Changes since V6: None 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 46aa7a001a..aff5519e54 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(