From patchwork Wed Feb 22 10:40:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 655685 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp621376wrb; Wed, 22 Feb 2023 02:39:52 -0800 (PST) X-Google-Smtp-Source: AK7set+F2jw2gamd4w4H3ZG9gWnU3tW2i5zt47L8fl8Y3Qs8JExZHlxTjwO71MAwO7LjvQoaOQ/L X-Received: by 2002:a9d:6c9:0:b0:68d:72c8:10a9 with SMTP id 67-20020a9d06c9000000b0068d72c810a9mr3060464otx.9.1677062392017; Wed, 22 Feb 2023 02:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677062391; cv=none; d=google.com; s=arc-20160816; b=pzGEmwDbB0FuT6gYRdPJsmWdKhQPTv2UDbUuVHHRnof1Jk2+Q3zbXnqNs0nIAkyHTw zvWpxonJAzcUhddXTTRsC2TiCbD8WZ/Io9YaWTdcB1lD7Y0chOEh1SQF1ywzkmZ2Yyli KiGvsL8FQvlhpgPP46KZdeqUY4VU8fFcnjGKxgbjuGdCrIxMSiZhfEdy+If5n2lB5liG XLXeIUTqVbE63QAzL/f7ICsiWR1Oqevv3pdx3NN38zDwY/Z4Kseo4WeLnmMgN4hvGusd QKMsvXBS+AOwuof9rCrnh597o2VMuLk5aRDShG3y7I6jNCCkwVnD/XDneo2dEact7j7x qKpA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=7F/xYo75zDgMVvX20AIT64XcI5lt+sOU5sOkoZasTe0=; b=JfQlZdKOO1NnMbNhfFX80W9yCPrEOyDc9PvT0tr3Sviyk4oTt8YWFzqRhUjnT8AzWh cZl1xM+hhMwM1UejNPK9OhI5XrDN4m79+gbAv9iYNzuDUKn3o6eGpKqEusdNLmrY4fSf TUj97MyR9pAIZosXosKitDd3NqpCCBu2tjsD7dzxxb4N+im6cTNwSpwtXGCfLOmBG5NG BuaIhn46wl83HwojSjWr4dD8VR5I8VTdPwwBvxmn2JyzG/FCJnOqwrue+4o4iMDRvyWX 24Ik18bR2h7poRyiiwTexV206upsnSWAn07zeQ08QhMYbHyzQQDo2jj1go0FQMvl/AaX ZcPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rUkP7utC; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id q20-20020a9d6554000000b0068bd5de3604si2996361otl.29.2023.02.22.02.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 02:39:51 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rUkP7utC; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 7888885A9F; Wed, 22 Feb 2023 11:39:38 +0100 (CET) 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="rUkP7utC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0327D85A85; Wed, 22 Feb 2023 11:39:22 +0100 (CET) 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 8A14985A86 for ; Wed, 22 Feb 2023 11:39:12 +0100 (CET) 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-pj1-x102b.google.com with SMTP id z20-20020a17090a8b9400b002372d7f823eso4268914pjn.4 for ; Wed, 22 Feb 2023 02:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=7F/xYo75zDgMVvX20AIT64XcI5lt+sOU5sOkoZasTe0=; b=rUkP7utC0zpL8d8Poit9fvphd3HVBDbJKPphs00V4gOP/BvUmSuAV9OXSldaPBxQIw 10jZ1vmRFiL7Del+tlmiXP4qErdcul4QBqGeyvql+w+dMj78JGGWI3EBFjHSOke2Yodm pPKpMUkpsrYAQ/pD591Bs2bWvyihBmj9HpCNJ36g+E3i0wPcNbAgw1P/nGxAveNH9++Q trFcFc6sfpCrWH6dvOtJ8xK0gfbJsp2currZ0FX/3bYaOPR/J03Vx1ZTyHG3tv90lrS8 e9nmkmRpUgcq2auMAJwL1yrqx9qYMtxqH5G3PHb9KPP8IVk2f/ULQ1qvBKreCYD04ANm 4DaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=7F/xYo75zDgMVvX20AIT64XcI5lt+sOU5sOkoZasTe0=; b=KlE2j0kcSekNkevavVt19s5C3eRuORwkv/8l5/Na1Mm9ox8zw2uOuScps24tvMtjMN KiGCNpHtpcGGXxuKzi3g3iTQlcP8EitjlUH5/VbPBubhyi2DKHQ1dECobsgceZK+kVOn WilZ2fj6pxiHN95nhIX2XiHEUyKjbNXioGiXRPVSUofU2BcJWR1FYE1djXGHoiN/8Crv 86gZYNDuRNfK/IBR2TPaFn4AknL+CsBZ8PP7gSchlXIOpHuYFBSm42hkIFzCKFFvTGdQ wvBJaic1mIiGbr0UvranO+N5VEDUJXCWJSFMG+O+TlHqe4WySg/IAfszeeReZ61WFtbj z7Lg== X-Gm-Message-State: AO0yUKWB2G+QSszly3EMCldnjO0rMuwQqk+RIc1P5l2DMIlS7W1PLrUW qTT2AP0wXntqGNYC5Id/U0R/Wdcn3cRr+j614Oc= X-Received: by 2002:a17:902:ec86:b0:19a:a9dd:ed3f with SMTP id x6-20020a170902ec8600b0019aa9dded3fmr9007664plg.49.1677062350606; Wed, 22 Feb 2023 02:39:10 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id ja17-20020a170902efd100b0019acd3151d0sm6201029plb.114.2023.02.22.02.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 02:39:10 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Masahisa Kojima Subject: [PATCH RFC 2/3] efi_loader: versioning support in GetImageInfo Date: Wed, 22 Feb 2023 19:40:35 +0900 Message-Id: <20230222104036.14262-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230222104036.14262-1-masahisa.kojima@linaro.org> References: <20230222104036.14262-1-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.6 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, lowest supported version, last attempt version and last attempt status in FMP->GetImageInfo(). Now FMP->GetImageInfo() and ESRT have the meaningful version number. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_firmware.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 72343e2616..1d63804717 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -173,13 +173,38 @@ static efi_status_t efi_fill_image_desc_array( *package_version_name = NULL; /* not supported */ for (i = 0; i < num_image_type_guids; i++) { + u16 varname[13]; /* u"FmpStateXXXX" */ + efi_status_t ret; + efi_uintn_t size; + struct fmp_state var_state = { 0 }; + 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 */ + efi_create_indexed_name(varname, sizeof(varname), "FmpState", + fw_array[i].image_index); + size = sizeof(var_state); + ret = efi_get_variable_int(varname, &efi_guid_fmp_state, NULL, + &size, &var_state, NULL); + if (ret == EFI_SUCCESS) { + image_info[i].version = var_state.fw_version; + image_info[i].lowest_supported_image_version = + var_state.lowest_supported_version; + image_info[i].last_attempt_version = + var_state.last_attempt_version; + image_info[i].last_attempt_status = + var_state.last_attempt_status; + } else { + image_info[i].version = 0; + 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].version_name = NULL; /* not supported */ image_info[i].size = 0; image_info[i].attributes_supported = @@ -193,9 +218,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; }