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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 A087BC11F66 for ; Tue, 29 Jun 2021 07:43:56 +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 A604A61DAC for ; Tue, 29 Jun 2021 07:43:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A604A61DAC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de 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 DE1B083111; Tue, 29 Jun 2021 09:43:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="b52Ydrqu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9EF1983117; Tue, 29 Jun 2021 09:43:52 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 90E3782FC5 for ; Tue, 29 Jun 2021 09:43:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1624952626; bh=oAduik7zUNvROsAFzUIQeEd17RCqQs9sMfaQzkdI+Ds=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=b52Ydrqui5i+3LaKqrpDAYVAbNjxOEymjET372d8ZB70oLvjuh0FkIzORpGCGfh9d gbB3tAgIAyR+EnRcXCodCifkrFrmBapR84fHARtnsoLKQAHRIMV4H38tOkBXsNUslz FRG+j3tvCqF5xQ3PQVMCoK0zXUQ1GG/ZMCd7loQs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([88.152.144.157]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MTRMs-1loBjB3L92-00TjTg; Tue, 29 Jun 2021 09:43:45 +0200 Subject: Re: [PATCH] efi_loader: Allow capsule update on-disk without checking OsIndications To: Ilias Apalodimas Cc: masami.hiramatsu@linaro.org, takahiro.akashi@linaro.org, pbrobinson@redhat.com, richard@hughsie.com, Alexander Graf , u-boot@lists.denx.de References: <20210629045552.22372-1-ilias.apalodimas@linaro.org> From: Heinrich Schuchardt Message-ID: Date: Tue, 29 Jun 2021 09:43:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210629045552.22372-1-ilias.apalodimas@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:6x/bJpqHM/kDHR2fsnf+++ZHuDA6AzbCTtj4jhMFo+NOyPfynG3 z4b2ikyp7pPUO19bVTsVhXD8lcc5mA7HUlKpf9iYYGNgfmZEvh92uCGAeWKwdqc7B2FrkaV gQZEF1dUMfJmV1I3esCRGBaCZYooTNYtUiHDYhJnJV9DdwMwJ2gZCl503kXX46GohdpSNrT SS/vfjq85JiCvgkUTy4mA== X-UI-Out-Filterresults: notjunk:1;V03:K0:XlLoyYe9H5k=:iqGgtYxChSFK7HuKjnDvSS Js1t8oF95D1dYW98dF2l0yP8wXvUlMLe3LQTaeaYzXjoRKmLYq8++x7hCuxlgYHdeWMWxYTMV 0vusNJw0PylGsFcqafjucCgue6nBWuYPjp/xQI/eICqZsRzqJnN26aJozRj8cuROvYTzlZRjj 3amZuoGcLKM6lCBqeGayfNCpem+F0axYB/L0IXTNfXJHCup99wnpG8CfzFfNSsf/QagrsEf3V kC/7vE/LAbS3UYRJ2X/OCJ9GcCr+eq4xtoRMB7bFuz1I5ECxurv42qLslVarBMY4N/MP0Wj/H RBkasu/xlAUlqCzLheMQ9YWYFkf1zuB2DEV3Av4m5KwpS+JheQH3nktye/vhZw49mRJc2XshO WQ0exHCdGY7cmhNo+jJlo4Kkt+cWTRQM2eWwOoGV3bLVQ1uXRnBaw+FIurfIAs+9xYrYvGYKl Abw2pSTnfG57Iwo15bmkzCjkeBDbTk8K6ap66agM1C2XIf47CGYhWp7S2mlrEDBtYZq5EZtJl 3hEfutzYnc4FMidgs/V/62uHc4852Bbfn2vFRd29Ffgr+Xc4qDHCs3jrCeD8yx7nVcCyMyO3W c+aA9kpt23/l/PrgfXtaGk+Ez+hT5WsLo6SBN9jb3Y6oPuk9uK4CXQJ/U0Am6D+LVYchvWfu2 zoyqlZUZB2jdWbOuYQQpmmjkmD133NRaEFq08ezCAoiLrQhG6jptqi4P5nJED2HCHnEr6NjJz fSC7Wp1RHu5GblJCizhl1//GQwfs13hgrjke2AYgBJQlGuKy9SblcxfV0oi930kHXL3Ke7TRM JX3x/GAOqlD52mHaVAuslwtYorXSxLGFpmfwFBgPFcIniwCQzVEa9Aq4Z5lGck4S+BJU5Yb2B ogoWaH7IcicHkziJfZVFwwfFJvU/XWN0Nj4QD8Bh+ek8lwSIdWoGKzRypJBl9SjV15d/Lx1l1 yG21z8UG7mpu+/KAmCrZpB1F9PgYFaYzyoJW0Ihz2LzA1I63oYLgEXabxG3NQ8tvh+LH4GEbE zUBke0SSut9+DEsoT+lNizhqb1zml5ES782RnNYK97qkNLIzJbDzsoiZc0e5w99DBY59kkcN8 yrqWX/qiDoVKgS/9Ki/MZVNMmfC9+wW722E 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 6/29/21 6:55 AM, Ilias Apalodimas wrote: > From: apalos > > Although U-Boot supports capsule update on-disk, it's lack of support fo= r > SetVariable at runtime prevents applications like fwupd from using it. > > In order to perform the capsule update on-disk the spec says that the OS > must copy the capsule to the \EFI\UpdateCapsule directory and set a bit = in > the OsIndications variable. The firmware then checks for the > EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED bit in OsIndications > variable, which is set by submitter to trigger processing of the capsule > on next reboot. > > Let's add a config option which ignores the bit checking in OsIndication= s > and just rely on the capsule being present. Since U-Boot deletes the > capsule while processing it, we won't end up running it multiple times. > > Note that this is allowed for all capsules. In the future once, > authenticated capsules is fully supported, we can limit the functionalit= y > to those only. > > Signed-off-by: apalos > --- > lib/efi_loader/Kconfig | 9 +++++++++ > lib/efi_loader/efi_capsule.c | 36 ++++++++++++++++++++++++++++-------- > 2 files changed, 37 insertions(+), 8 deletions(-) > > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig > index 684adfb62379..5a3820e76122 100644 > --- a/lib/efi_loader/Kconfig > +++ b/lib/efi_loader/Kconfig > @@ -137,6 +137,15 @@ config EFI_CAPSULE_ON_DISK > under a specific directory on UEFI system partition instead of > via UpdateCapsule API. > > +config EFI_IGNORE_OSINDICATIONS > + bool "Ignore OsIndications for CapsuleUpdate on-disk" > + depends on EFI_CAPSULE_ON_DISK > + default n > + help > + There are boards were we can't support SetVariable at runtime. > + Select this option if you want to use capsule-on-disk feature, > + without setting the OsIndications bit. > + > config EFI_CAPSULE_ON_DISK_EARLY > bool "Initiate capsule-on-disk at U-Boot boottime" > depends on EFI_CAPSULE_ON_DISK > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > index d7136035d8f9..50bed32bfb3b 100644 > --- a/lib/efi_loader/efi_capsule.c > +++ b/lib/efi_loader/efi_capsule.c > @@ -948,6 +948,33 @@ efi_status_t __weak efi_load_capsule_drivers(void) > return ret; > } > > +/** > + * check_run_capsules - Check whether capsule update should run > + * > + * The spec says OsIndications must be set in order to run the capsule = update > + * on-disk. Since U-Boot doesn't support runtime SetVariable, allow ca= psules to > + * run explicitly if CONFIG_EFI_IGNORE_OSINDICATIONS is selected > + */ > +static bool check_run_capsules(void) > +{ > + u64 os_indications; > + efi_uintn_t size; > + efi_status_t ret; > + > + if (IS_ENABLED(CONFIG_EFI_IGNORE_OSINDICATIONS)) > + return true; > + > + size =3D sizeof(os_indications); > + ret =3D efi_get_variable_int(L"OsIndications", &efi_global_variable_gu= id, > + NULL, &size, &os_indications, NULL); > + if (ret =3D=3D EFI_SUCCESS && > + (os_indications > + & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED)) The bit EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED must be cleared in OsIndications after successfully applying the capsule. See related patch [PATCH 1/1] efi_loader: fix set_capsule_result() https://lists.denx.de/pipermail/u-boot/2021-June/453111.html Reviewed-by: Heinrich Schuchardt > + return true; > + > + return false; > +} > + > /** > * efi_launch_capsule - launch capsules > * > @@ -958,20 +985,13 @@ efi_status_t __weak efi_load_capsule_drivers(void) > */ > efi_status_t efi_launch_capsules(void) > { > - u64 os_indications; > - efi_uintn_t size; > struct efi_capsule_header *capsule =3D NULL; > u16 **files; > unsigned int nfiles, index, i; > u16 variable_name16[12]; > efi_status_t ret; > > - size =3D sizeof(os_indications); > - ret =3D efi_get_variable_int(L"OsIndications", &efi_global_variable_gu= id, > - NULL, &size, &os_indications, NULL); > - if (ret !=3D EFI_SUCCESS || > - !(os_indications > - & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED)) > + if (!check_run_capsules()) > return EFI_SUCCESS; > > index =3D get_last_capsule(); >