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 7A880C77B73 for ; Mon, 22 May 2023 21:29:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4920847CE; Mon, 22 May 2023 23:29:17 +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="SPxA5gmo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8318D85283; Mon, 22 May 2023 23:29:16 +0200 (CEST) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 1EAD88476E for ; Mon, 22 May 2023 23:29:14 +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-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f607059b4eso9162785e9.0 for ; Mon, 22 May 2023 14:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684790953; x=1687382953; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xbUGNT8fz3H1RksiUp8M3IXnjNU91dvYLxPcYCds65M=; b=SPxA5gmoLggNHTgi7wuZQzWcVHUgOeRqWEakvJQbRvLdpRSFxl/zWIhdt7+Mpn6vJ6 HNuNHlyEFbaDq8HSLw7q13KHrz+T9KtEtc9KYlmOtVubVtDWMVjynqlqPKM0QCUSZuBE yKgto33c9932bwUuh+A7dPnbvmLQvDxpc/Uk9c3IjGaJMeypbAzu2Us5VPMSGNOxjuWI wObb5RojBTtb3rmxnAosp4YxjjYa1nharl0+/r4ZCSh26yHw7Hn1RwJ8SXik3UdFMZcq H47zGCcXZno55SZL+oOVjfiv4VONnL+ywsnIg11zrqRQFkEryBgCcStDqsOQFZx+v/NY iMeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684790953; x=1687382953; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xbUGNT8fz3H1RksiUp8M3IXnjNU91dvYLxPcYCds65M=; b=XCmUUkCNX40yoXKoUjrO53XI5yb83P/YY/N6O1XHbZkzqeus63zG1F6jGherutidmA 6NJTfo39X7ds4VSuho8FIQc/6/ptcH2Kk5RWfIdaFritSsIBlB1E8W6TudebYNn3yJfh aZnZ83HZ4XE/kfWbFCNAGK1Tx2GCxGqJlpzkf18f+QwtTfSZHE+ipfCHtxFWGHwRuBlm 1fhiWxRSU+oyP+NVsyF5YAdl8lZP3BrCrSsxmXt9OIJwd9cPiv/8SaXLZEJl9pYM30eY IC1iN+i+SkL862FgBrYV8BJ55zgQgFNI8EEv/2A36JIS7CHL+6nzpHj/Ux7xEapQez/v KU4w== X-Gm-Message-State: AC+VfDxfduqFNK+7pl4ulL30YnBxt8pkovL1dUM000q8nu41VGWnR3KP es1eWX1TuCHsvMrUYEq+XANIzQ== X-Google-Smtp-Source: ACHHUZ4Af878yiNBizvJsc5jVaUzUEIOgd/zKxP1d6Q6tAfwYr09ADW0rejLhAk7vBYQiGBiQy9B4g== X-Received: by 2002:a05:600c:22c6:b0:3f1:74bd:bc22 with SMTP id 6-20020a05600c22c600b003f174bdbc22mr7683512wmg.6.1684790953536; Mon, 22 May 2023 14:29:13 -0700 (PDT) Received: from hera (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id u15-20020a05600c00cf00b003f4268f51f5sm9696327wmm.0.2023.05.22.14.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 14:29:13 -0700 (PDT) Date: Tue, 23 May 2023 00:29:11 +0300 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Simon Glass , Takahiro Akashi Subject: Re: [PATCH v6 3/8] efi_loader: versioning support in GetImageInfo Message-ID: References: <20230519103214.1239656-1-masahisa.kojima@linaro.org> <20230519103214.1239656-4-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230519103214.1239656-4-masahisa.kojima@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.8 at phobos.denx.de X-Virus-Status: Clean On Fri, May 19, 2023 at 07:32:09PM +0900, Masahisa Kojima wrote: > 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 > --- > 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 fc085e3c08..64ceefa212 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; > } > -- > 2.17.1 > Reviewed-by: Ilias Apalodimas