From patchwork Wed May 31 03:35:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 687222 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp1054655wru; Tue, 30 May 2023 20:36:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RreKDTjcIeI/PrM1+4/XzbOQ3f7lguBCZMsBsmWpFsjSDrBeNxi10/GJoPaRxXzj7bTzS X-Received: by 2002:a9d:7446:0:b0:6ac:6fd8:1e4 with SMTP id p6-20020a9d7446000000b006ac6fd801e4mr978217otk.8.1685504200995; Tue, 30 May 2023 20:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685504200; cv=none; d=google.com; s=arc-20160816; b=yLxghY+g54PmolmEXQF/fwX4b7Qzv1r5JiQDq5Q/fxOtH6W6J2qpQJvxu1TOuqE4JZ xjtrcGVizU7UuaWqlsVRFr+7zbwYjYQEub+FkhEzm566oNL5OFFSy/cAyEbCCZ/8o9mU nCt2TQzeYw5htge46Lu+h6aGPqk1cyZTAzqMlNT+3Q8kxYTz2UdfDV9FEm/pGZU4pRVo T4NIEBJdWimSI+LtG5IMzCXWknRmz5tGj+NbWU/IecdWleE9mkGRnAXxGKguO8zYPNrJ n1k6rGeRLDczznxCHFFd4XGf/ywAtFbLdEa4C71H77NxO8DTd2T3slq5H5NbMik+o9VC zkrA== 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:dkim-signature; bh=n0Z04dWPgPckxWdjfSL17/6m3hBT++D2uJu2TYzne6g=; b=nybGMFpjRZpy+IaqY44IGN22czjxKw4W1ICswvljRjNRPefA0GWuYx+s80gvqY19Oq Itk/g3nO4h1s8dYe4uFdzU7BGGPpHO9dH2WNTgiuTBmKCyDyHLV4/5CgwDkmgmIYL3Lh E0R4xf2wIORqx3LUFcqJFPSjJ5vL+aCSyIgB2hmRvTrM7ToPHvhnqgi6ahZnj64jyngX n+sQRREpMzkRVzQGpOsLZT460B/OWPY4JqM1bfaq3/rYXr3gg1uk4PpusciBw+mEocPh 3cyIIVb5qRJPifKbMYJNextbvZO3sFEcwGV+WHs9vgxOm4obifT6jRtUCouNBg/rFRNY //wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PiOFuBpQ; 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=pass (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 f9-20020aa79d89000000b0064f6c2c05besi2856893pfq.108.2023.05.30.20.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 20:36:40 -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; dkim=pass header.i=@linaro.org header.s=google header.b=PiOFuBpQ; 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=pass (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 2898A861C0; Wed, 31 May 2023 05:36:07 +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="PiOFuBpQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C578486093; Wed, 31 May 2023 05:35:59 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (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 2504286093 for ; Wed, 31 May 2023 05: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=masahisa.kojima@linaro.org Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-397f13944f2so3624584b6e.0 for ; Tue, 30 May 2023 20:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685504155; x=1688096155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n0Z04dWPgPckxWdjfSL17/6m3hBT++D2uJu2TYzne6g=; b=PiOFuBpQjGyeBAt9wxuCLoTylMdZL/l6U1DSfzCyckMzPpg8BLPz/PZW1q5jjuNeMk PQKo+xErn81ZaBE+UaW/AOe/mcg/5m7wpMCwT/WMPCkxE3tdvvGSGIhvE6rK+5DaIGUt gOD/XhRMpnu7Ik5vFfE+8SbjHq4LrwWIRlWl42U06lUMD5pqdkXE4/9jNX1QB3yG5z8o wzkoVZY5B/MBklulY56L1Pzkhc4mWW2i8urnVMnj4bE8U49zmhRwaNqIxknf5TaezHh0 q7+nMPLnuO2WMXgocPNCYqMIQLAZD2wC1Q9YTNZI+PfWJPO15gxRHX4lGS5B+vgF6eNL SHNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685504155; x=1688096155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n0Z04dWPgPckxWdjfSL17/6m3hBT++D2uJu2TYzne6g=; b=ciTZWnvZtYm0L8mRvJEzh1sknAB1ZnPU8WaPu5r08g8malSluigLf4uiT+XULJlVd8 2q7C+jebG6xcwl/CnfNhUHnRimY0WwFt1kqFr4dIGBsM0oIX6BLH+99vEOkvc/ufqmGW EOdtMBaFTPzHdT1kzrEzODp9IHpIQpocVdB755WgJ/QK7VKjbsrvG6QWbwTtD/LUSeyU 3qFqy6tEIGaF1IS69YWzNmdrQAGbc0As8hIAucPynbbLn9R+VAU6s+JOa2mTf/GpR0/u JplV5HoHI11D/Ds7sik97t1tkmpKnKJLq02qoAS2Qi8cA7CmlQqR/UlVH6qe02qkSCir 79OA== X-Gm-Message-State: AC+VfDxY9mzYX17pfoYQi+x1G03t86lXcEgAoylJYSrDd5wJ2GN7JXFg IPkOr9mOyj0ze6z/xHVGV59K8HhFTC5Io1w8hOM= X-Received: by 2002:a05:6808:124e:b0:398:139f:fed7 with SMTP id o14-20020a056808124e00b00398139ffed7mr3129847oiv.8.1685504155177; Tue, 30 May 2023 20:35:55 -0700 (PDT) Received: from ubuntu-SVE15129CJS.. ([240d:1a:cf7:5800:b037:3ab0:51c1:7dff]) by smtp.gmail.com with ESMTPSA id b4-20020a170902d30400b001b0395c3ffasm85709plc.180.2023.05.30.20.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 20:35:54 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Masahisa Kojima Subject: [PATCH v7 03/10] efi_loader: versioning support in GetImageInfo Date: Wed, 31 May 2023 12:35:16 +0900 Message-Id: <20230531033523.1581973-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531033523.1581973-1-masahisa.kojima@linaro.org> References: <20230531033523.1581973-1-masahisa.kojima@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.8 at phobos.denx.de X-Virus-Status: Clean Current FMP->GetImageInfo() always return 0 for the firmware version, user can not identify which firmware version is currently running through the EFI interface. This commit reads the "FmpStateXXXX" EFI variable, then fills the firmware version in FMP->GetImageInfo(). Now FMP->GetImageInfo() and ESRT have the meaningful version number. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- No update since v6 Changes in v6: - create function to fill the version information lib/efi_loader/efi_firmware.c | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index a798d380a3..5b71a2fcc9 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -144,6 +144,39 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( return EFI_EXIT(EFI_UNSUPPORTED); } +/** + * efi_firmware_fill_version_info - fill the version information + * @image_info: Image information + * @fw_array: Pointer to size of new image + * + * Fill the version information into image_info strucrure. + * + */ +static +void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_info, + struct efi_fw_image *fw_array) +{ + u16 varname[13]; /* u"FmpStateXXXX" */ + efi_status_t ret; + efi_uintn_t size; + struct fmp_state var_state = { 0 }; + + efi_create_indexed_name(varname, sizeof(varname), "FmpState", + fw_array->image_index); + size = sizeof(var_state); + ret = efi_get_variable_int(varname, &fw_array->image_type_id, + NULL, &size, &var_state, NULL); + if (ret == EFI_SUCCESS) + image_info->version = var_state.fw_version; + else + image_info->version = 0; + + image_info->version_name = NULL; /* not supported */ + image_info->lowest_supported_image_version = 0; + image_info->last_attempt_version = 0; + image_info->last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS; +} + /** * efi_fill_image_desc_array - populate image descriptor array * @image_info_size: Size of @image_info @@ -193,11 +226,10 @@ static efi_status_t efi_fill_image_desc_array( image_info[i].image_index = fw_array[i].image_index; image_info[i].image_type_id = fw_array[i].image_type_id; image_info[i].image_id = fw_array[i].image_index; - image_info[i].image_id_name = fw_array[i].fw_name; - image_info[i].version = 0; /* not supported */ - image_info[i].version_name = NULL; /* not supported */ + efi_firmware_fill_version_info(&image_info[i], &fw_array[i]); + image_info[i].size = 0; image_info[i].attributes_supported = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | @@ -210,9 +242,6 @@ static efi_status_t efi_fill_image_desc_array( image_info[0].attributes_setting |= IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED; - image_info[i].lowest_supported_image_version = 0; - image_info[i].last_attempt_version = 0; - image_info[i].last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS; image_info[i].hardware_instance = 1; image_info[i].dependencies = NULL; }