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 B6D77C433F5 for ; Fri, 21 Jan 2022 07:09:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA55883434; Fri, 21 Jan 2022 08:09:18 +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="NCL4O9vr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BCC0E83434; Fri, 21 Jan 2022 08:09:16 +0100 (CET) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (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 490158340A for ; Fri, 21 Jan 2022 08:09:11 +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=takahiro.akashi@linaro.org Received: by mail-pf1-x42d.google.com with SMTP id a8so2725261pfa.6 for ; Thu, 20 Jan 2022 23:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Fz9scNCMghG/P2KkZ11x07Zl4bQIp5lJqiMncnxcwmw=; b=NCL4O9vrr6r8LvLnUs2zsWB6FAQkJXiqTTzK6xbgVmr/fp+qw4ed0XD3nF3tAcF+yF Bj9f4dEMuBN/fR9+AmySje3yUIm2/FF9qq3yVnRcLbVLlEyEs7qkXL42Y1NoJtsiMboY iB6A/SUmjD22a1jyP3sEaisejm03//Gs919hCt59FeslXkWhXyV/Kz5LiZ9C7uPor02J trDQ7A015egCgvrQzxewy6jZzS2M/fnWB1O482MGbRV5itamNCEettHdSNGJcgwIWIkM DLDNMcIw3uYxM3S82FjNOrJ2ZBFipF53lpd9hFcAYCOXfRrQSlvLEvdodWX6hm+AMKYG 4AvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=Fz9scNCMghG/P2KkZ11x07Zl4bQIp5lJqiMncnxcwmw=; b=4gCdyzawtyDwS0FJE67H5eycyn3AEgLy7ZFZm4lABxBm7q+nFqqJGeaAAx4FjknvGL G2c4cXc7MxalysUYQUV+VcOLZhxO99hDeEGTgNs/sVAT8DXXBraMoDWS3eZRzJ3SscTo MyUjjYy6WNxODdVypdxwiifx5DOW6csX7XVyNSS4T8J+OxVg9ltT1Mmr9B9HegcoHKeL XvLL0j065L5x6SXG3G+G3HC8oEKHbR2boIXU1I7u6Yd96oFdCKFALHLSPZayYirXZfLn J9FZUZoHSjf+uZRQ3u3No3X4/DMsp/kJ7ZKbosOuPzdkOPAzXm9IbiCmKunPq17VKmZ7 W7rw== X-Gm-Message-State: AOAM5327Z3Nv64YXiCA0oLboPvd2sw8NxihFWDFJu7tPp7GCBJcPCbY5 hwGnG42tpA/lJTePG/TPijFKGg== X-Google-Smtp-Source: ABdhPJxdkkEtVt8cAzaPST0hCzR8UV1W15dtSVUJxqi/9bCcnnGjdeN9jBaZ2AJUHXWfY121jZy6sg== X-Received: by 2002:a63:5007:: with SMTP id e7mr2018775pgb.295.1642748949390; Thu, 20 Jan 2022 23:09:09 -0800 (PST) Received: from laputa (p914133-ipoe.ipoe.ocn.ne.jp. [153.243.15.132]) by smtp.gmail.com with ESMTPSA id y16sm5455387pfl.128.2022.01.20.23.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 23:09:08 -0800 (PST) Date: Fri, 21 Jan 2022 16:08:54 +0900 From: AKASHI Takahiro To: Masami Hiramatsu Cc: u-boot@lists.denx.de, Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: Re: [RFC PATCH 10/14] FWU: Reboot soon after successfully install the new firmware Message-ID: <20220121070854.GA59491@laputa> Mail-Followup-To: AKASHI Takahiro , Masami Hiramatsu , u-boot@lists.denx.de, Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu References: <164269255955.39378.260729958623102750.stgit@localhost> <164269266038.39378.1931983995518536620.stgit@localhost> <20220121014607.GA44335@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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.2 at phobos.denx.de X-Virus-Status: Clean On Fri, Jan 21, 2022 at 03:54:12PM +0900, Masami Hiramatsu wrote: > Hi, > > 2022年1月21日(金) 13:35 Masami Hiramatsu : > > > > Hi Takahiro, > > > > 2022年1月21日(金) 10:46 AKASHI Takahiro : > > > > > > On Fri, Jan 21, 2022 at 12:31:00AM +0900, Masami Hiramatsu wrote: > > > > Reboot to the trial state soon after successfully installing > > > > the new firmware to the next bank and updating the active_index. > > > > This is enabled by CONFIG_FWU_REBOOT_AFTER_UPDATE and is a > > > > recommended option. > > > > > > EFI_CAPSULE_HEADER.Flags may have a flag, CAPSULE_FLAGS_INITIATE_RESET. > > > See Section "8.5.3 Update Capsule" in the UEFI specification. > > > > > > I think that we'd better implement the feature rather than adding > > > CONFIG_FWU_REBOOT_AFTER_UPDATE. > > > > Thanks for pointing it! I agree with you, the flag is more useful. > > According to the UEFI spec 2.9, we need to consider implementing some > related things. > > In 8.5.3 Update Capsule > ---- > A capsule which has the CAPSULE_FLAGS_INITIATE_RESET Flag must have > CAPSULE_FLAGS_PERSIST_ACROSS_RESET set in its header as well. > [...] > If a capsule has the CAPSULE_FLAGS_PERSIST_ACROSS_RESET Flag set in its > header, the firmware will process the capsules after system reset. The > caller must > ensure to reset the system using the required reset value obtained from > QueryCapsuleCapabilities. > ---- > In Table 8-8 Flag Firmware Behavior > ---- > CAPSULE_FLAGS_PERSIST_ACROSS_RESET + > CAPSULE_FLAGS_INITIATE_RESET > > Firmware will attempt to process or launch the capsule > across a reset. The firmware will initiate a reset which is > compatible with the passed-in capsule request and will > not return back to the caller. If the capsule is not > recognized, can expect an error. If the processing requires > a reset which is unsupported by the platform, expect an > error. > ---- > > So, I have 2 questions; > > 1) Should we implement CAPSULE_FLAGS_PERSIST_ACROSS_RESET too? > Since U-Boot only supports capsule update on disk, it seems the capsule already > applied "across a reset". :-) Yeah, I suppose that PERSIST_ACROSS_RESET is most for capsules via UpdateCapsule API. > 2) If there are multiple capsule files and only one file (e.g. aaaa.cap) has > CAPSULE_FLAGS_INITIATE_RESET flag, should U-Boot resets after > applying that capsule, or wait after all capsule files are applied? > (current implementation is the latter one) The order of capsules applied can be controlled by their file names. So IIUC, a reset should be initiated immediately after processing a capsule with INITIATE_RESET. The rest of capsules can be processed even after the reboot. I think that this behavior gives us more flexibility. -Takahiro Akashi > Thank you, > > > > > Regards, > > > > > > > > -Takahiro Akashi > > > > > > > Signed-off-by: Masami Hiramatsu > > > > --- > > > > lib/efi_loader/efi_capsule.c | 10 ++++++++-- > > > > lib/fwu_updates/Kconfig | 9 +++++++++ > > > > 2 files changed, 17 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > > > > index 83c89a0cbb..0928425b5f 100644 > > > > --- a/lib/efi_loader/efi_capsule.c > > > > +++ b/lib/efi_loader/efi_capsule.c > > > > @@ -1355,10 +1355,16 @@ efi_status_t efi_launch_capsules(void) > > > > } else { > > > > log_debug("Successfully updated the active_index\n"); > > > > status = fwu_trial_state_ctr_start(); > > > > - if (status < 0) > > > > + if (status < 0) { > > > > ret = EFI_DEVICE_ERROR; > > > > - else > > > > + } else { > > > > ret = EFI_SUCCESS; > > > > + if (IS_ENABLED(CONFIG_FWU_REBOOT_AFTER_UPDATE)) { > > > > + log_info("New firmware is installed in bank#%d. Reboot from that bank.\n", > > > > + update_index); > > > > + do_reset(NULL, 0, 0, NULL); > > > > + } > > > > + } > > > > } > > > > } else if (capsule_update == true && update_status == false) { > > > > log_err("All capsules were not updated. Not updating FWU metadata\n"); > > > > diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig > > > > index 6de28e0c9c..0940a90747 100644 > > > > --- a/lib/fwu_updates/Kconfig > > > > +++ b/lib/fwu_updates/Kconfig > > > > @@ -29,3 +29,12 @@ config FWU_TRIAL_STATE_CNT > > > > With FWU Multi Bank Update feature enabled, number of times > > > > the platform is allowed to boot in Trial State after an > > > > update. > > > > + > > > > +config FWU_REBOOT_AFTER_UPDATE > > > > + bool "Reboot soon after installing new firmware" > > > > + depends on FWU_MULTI_BANK_UPDATE > > > > + default y > > > > + help > > > > + Reboot the machine soon after installing a new firmware > > > > + and start trial boot. You can disable this option for > > > > + debugging or FWU development, but recommended to enable it. > > > > > > > > > > > > -- > > Masami Hiramatsu > > > > -- > Masami Hiramatsu