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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EE55C11F66 for ; Tue, 29 Jun 2021 08:59:53 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AABA761CC1 for ; Tue, 29 Jun 2021 08:59:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AABA761CC1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9BA6682FE8; Tue, 29 Jun 2021 10:59:50 +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="a5nRqaDy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7D8F783121; Tue, 29 Jun 2021 10:59:49 +0200 (CEST) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 BBC6E82EC5 for ; Tue, 29 Jun 2021 10:59:46 +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-wr1-x434.google.com with SMTP id l8so16081279wry.13 for ; Tue, 29 Jun 2021 01:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J5UBF4h+1P5LrRFmic9mfPQhE2en7YjrwJsmCXVuYvY=; b=a5nRqaDyEOgOb1ikO1BYDGrSAB36FhACpeIWVjfOqp6N7AoEI6IoiAs/Fj/GWw/6R8 Gd8iKQf5NTv72klHTwyk8QzabZjiTL0YUkeCrldbp8PZvi3LuL4Biv25rMUq6OQf/y9A psB0AbAI6o7cWFWRaENhwphpy1kc3SAgD6KauooDFVreeh6+K4Oby24YmUiJDjeG4zgY pzVdfpo1Rj4DXN+vBHn/MvbpqKOWVByynfnDdVgh4b0HGp5sh+hIjyHhncpyxAZhd+ix 0V+sWN7dasmpIyrs9VKE2QuF2a34Ejk/3uwhRX5VOq/BL0vuLvgCO/fPxkLLVMNaj76k VakA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J5UBF4h+1P5LrRFmic9mfPQhE2en7YjrwJsmCXVuYvY=; b=HLqwF9oHmsnS39/5RNN5wOk+WJ6qGzB76T09ELuRKH4kCdU6AjXa5VsIRXDMPUYU2O BRwcEh5mkVlLOOJ8E1op4nmJdIh1aB6hvpJ484xmDqL/E+/a+aOhtYU59HJtowlgxhAr y9vN0audM0hZf7+PRKvRz48SmOyE/Ad4WmLsMMLHbel8D5mlT7GeiFdsQBpRbnvM5OPx dHdAeyxu5jvHlljr72ORyMtTj3stidmeUlZRLJVtf+sKVAojbWx/nPO50v3/Q3U44Cgw iNzedjSrfLJ1LrpTxBFboHkXgnxKuxOZ3+z5zKCpJ3VE/0Uy44oy0sK/lJzmWWCLsPrg Fxvg== X-Gm-Message-State: AOAM53309Lny5+Ew64UiLRgooR3uP4FVZjkYvp41Hp53qVp7bKmsMOaC VoX4PVZsPL1MA10r49Kg4jfHEw== X-Google-Smtp-Source: ABdhPJyNII96snRV04LwWBjIESjgHEcG1JURQEZu0W6vNR1JEp8V8juXTd2chyrzDtSPrNeN6F6Hiw== X-Received: by 2002:adf:e7c1:: with SMTP id e1mr10112791wrn.198.1624957186344; Tue, 29 Jun 2021 01:59:46 -0700 (PDT) Received: from iliass-mbp (athedsl-356348.home.otenet.gr. [85.72.247.154]) by smtp.gmail.com with ESMTPSA id b187sm2246648wmh.32.2021.06.29.01.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 01:59:46 -0700 (PDT) Date: Tue, 29 Jun 2021 11:59:42 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Alexander Graf , AKASHI Takahiro , Sughosh Ganu Subject: Re: [PATCH 1/1] efi_loader: fix set_capsule_result() Message-ID: References: <20210629074021.63612-1-xypron.glpk@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210629074021.63612-1-xypron.glpk@gmx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Tue, Jun 29, 2021 at 09:40:21AM +0200, Heinrich Schuchardt wrote: > The log category must be LOG_CATEGORY LOGC_EFI. > > efi_set_variable() should be called with EFI_CALL(). Use > efi_set_variable_int() instead. > > A log text "Updating ..." if SetVariable() fails does not make sense for a > variable that is not required to be preexisting. > > Flag EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED must be reset in > variable OsIndications. > > Signed-off-by: Heinrich Schuchardt > --- > lib/efi_loader/efi_capsule.c | 38 +++++++++++++++++++++++++++++------- > 1 file changed, 31 insertions(+), 7 deletions(-) > > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > index 60309d4a07..f7c0c5725f 100644 > --- a/lib/efi_loader/efi_capsule.c > +++ b/lib/efi_loader/efi_capsule.c > @@ -6,6 +6,8 @@ > * Author: AKASHI Takahiro > */ > > +#define LOG_CATEGORY LOGC_EFI > + > #include > #include > #include > @@ -84,6 +86,8 @@ void set_capsule_result(int index, struct efi_capsule_header *capsule, > struct efi_capsule_result_variable_header result; > struct efi_time time; > efi_status_t ret; > + efi_uintn_t size; > + u64 os_indications; > > efi_create_indexed_name(variable_name16, sizeof(variable_name16), > "Capsule", index); > @@ -95,13 +99,33 @@ void set_capsule_result(int index, struct efi_capsule_header *capsule, > else > memset(&result.capsule_processed, 0, sizeof(time)); > result.capsule_status = return_status; > - ret = efi_set_variable(variable_name16, &efi_guid_capsule_report, > - EFI_VARIABLE_NON_VOLATILE | > - EFI_VARIABLE_BOOTSERVICE_ACCESS | > - EFI_VARIABLE_RUNTIME_ACCESS, > - sizeof(result), &result); > - if (ret) > - log_err("EFI: creating %ls failed\n", variable_name16); > + ret = efi_set_variable_int(variable_name16, &efi_guid_capsule_report, > + EFI_VARIABLE_NON_VOLATILE | > + EFI_VARIABLE_BOOTSERVICE_ACCESS | > + EFI_VARIABLE_RUNTIME_ACCESS, > + sizeof(result), &result, false); > + if (ret != EFI_SUCCESS) > + log_err("Setting %ls failed\n", variable_name16); > + > + if (return_status != EFI_SUCCESS) > + return; > + The spec for capsule updates delivered on mass storage devices says: "This bit will be cleared from OsIndications by system firmware in all cases during processing following reboot." So shouldn't we clear the EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED bit even if the update failed? > + size = sizeof(os_indications); > + ret = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid, > + NULL, &size, &os_indications, NULL); > + if (ret != EFI_SUCCESS) > + os_indications = 0; > + else > + os_indications &= > + ~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; > + ret = efi_set_variable_int(L"OsIndications", &efi_global_variable_guid, > + EFI_VARIABLE_NON_VOLATILE | > + EFI_VARIABLE_BOOTSERVICE_ACCESS | > + EFI_VARIABLE_RUNTIME_ACCESS, > + sizeof(os_indications), &os_indications, > + false); > + if (ret != EFI_SUCCESS) > + log_err("Setting %ls failed\n", L"OsIndications"); > } > > #ifdef CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT > -- > 2.30.2 >