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 A79FCC433F5 for ; Thu, 3 Feb 2022 01:24:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C0AD838FE; Thu, 3 Feb 2022 02:24:53 +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="l9bgB5M5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EFFE283909; Thu, 3 Feb 2022 02:24:51 +0100 (CET) Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 98FC7838F5 for ; Thu, 3 Feb 2022 02:24:48 +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-pg1-x535.google.com with SMTP id z131so943961pgz.12 for ; Wed, 02 Feb 2022 17:24:48 -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:in-reply-to; bh=jcIzLBaq9i2/pTxmMrX1Z90FCfqKP3Voq+2Ef892SwY=; b=l9bgB5M50jLi4/17tVslR2rs1Mycb4ENRHSPjuzS9bvybdEVq27GAdOc3OaqDi1m0C sMq72zyBgOT19YyFU27Q9aZUg7qc+q1B24MWMU6KNx6L/3w4/KXwKCMXhx53d1+bag73 ahZ0b2II78Zt9SNKrcHVzPHuuzeuROBPbku0THbWtMCVNH1ZmxEr0DBdou5Uw7AdTg5L ykAHHJNcmvQbmgcgPpLZ7bU460muAHk/JDiZ7XAbpf/hMWycHeZNj3jdodSfBUJDXCQx 255CoPf0x0mYTp7ER7fICmqN7cxjdvkZpc6QOuxKuFMrm/hRZK+KtmsewftKkVdNvWGt mNIw== 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 :in-reply-to; bh=jcIzLBaq9i2/pTxmMrX1Z90FCfqKP3Voq+2Ef892SwY=; b=ZuqBA6dbuzXcJRSYUyDGceOLTc/+dX8YBpIG91mVh4MJUP/HZAmJ0GdZqAJnHnI5WW ake9h3MOGqtaSwwaloquJkfOh45mO/CtIaHvHd/8+D2h8NMviwsHkx65I31Xh2YrzT9T Mqj3s/aMoCX2gErpV1fahN3Fb1e4ydg7DZHbtxlt2+ZHfow3epdHnFdJkQr8K66jxSKX NODEMahoLvQk4j0zH5HUfkLa1Y87FGKX9QRkrVVSaWBBIhV2HQhpLjpUuSpe8bVMiM0i g8OsWwQ7rLFYEhDRxkY5iWYEy5JqMxdXcsWOVm7bKolBVuwtYYt0REoiM0RjpjWo7rvu XMyA== X-Gm-Message-State: AOAM533yy7nN4Q3p+tr3VECxD6f+bbJZlXadvvtbQn/oTFry4mSE3Qnf BU+2a2VhYMXhFphJYIWTHbaXTg== X-Google-Smtp-Source: ABdhPJwN+easEiTTcOaENWMeqo/eE24HhnnqLKzQdgeGl+GB3RwVNnkEN6nUHMV5nhiV8oy4UdFgGg== X-Received: by 2002:aa7:928f:: with SMTP id j15mr32378660pfa.58.1643851486706; Wed, 02 Feb 2022 17:24:46 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:90e6:b652:873e:8ca0]) by smtp.gmail.com with ESMTPSA id d32sm36232604pgb.46.2022.02.02.17.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 17:24:46 -0800 (PST) Date: Thu, 3 Feb 2022 10:24:40 +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: [PATCH v2 2/2] efi_loader: Reset system after CapsuleUpdate on disk Message-ID: <20220203012440.GA46235@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: <164381006265.420956.16575397258903175632.stgit@localhost> <164381008301.420956.13884226784193349269.stgit@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <164381008301.420956.13884226784193349269.stgit@localhost> 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.5 at phobos.denx.de X-Virus-Status: Clean On Wed, Feb 02, 2022 at 10:54:43PM +0900, Masami Hiramatsu wrote: > Add a config option to reset system soon after processing capsule update > on disk. We no longer have a new config option :) > This is required in UEFI specification 2.9 Section 8.5.5 > "Delivery of Capsules via file on Mass Storage device" as; > > In all cases that a capsule is identified for processing the system is > restarted after capsule processing is completed. > > This also reports the result of each capsule update so that the user can > notice that the capsule update has been succeeded or not from console log. > > Signed-off-by: Masami Hiramatsu > --- > Changes in v3: > - Log succeeded capsule update in info level. > - Use sysreset if possible. > - Use do_reset() and hang() instead of panic(). > Changes in v2: > - Remove kconfig option to disable this feature. > - Use panic() instead of do_reset() so that if the reset fails, > the machine halt. > - Log the result of each capsule update always. > --- > lib/efi_loader/efi_capsule.c | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > index 1ec7ea29ff..ade9155042 100644 > --- a/lib/efi_loader/efi_capsule.c > +++ b/lib/efi_loader/efi_capsule.c > @@ -14,9 +14,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > #include > > #include > @@ -1120,8 +1122,11 @@ efi_status_t efi_launch_capsules(void) > if (ret == EFI_SUCCESS) { > ret = efi_capsule_update_firmware(capsule); > if (ret != EFI_SUCCESS) > - log_err("Applying capsule %ls failed\n", > + log_err("Applying capsule %ls failed.\n", > files[i]); > + else > + log_info("Applying capsule %ls succeeded.\n", > + files[i]); > > /* create CapsuleXXXX */ > set_capsule_result(index, capsule, ret); > @@ -1142,6 +1147,19 @@ efi_status_t efi_launch_capsules(void) > free(files[i]); > free(files); > > - return ret; > + /* > + * UEFI spec requires to reset system after complete processing capsule > + * update on the storage. > + */ > + puts("Reboot after firmware update"); > + if (CONFIG_IS_ENABLED(SYSRESET)) { > + reset_cpu(); > + } else { > + do_reset(NULL, 0, 0, NULL); > + hang(); > + } > + /* not reach here */ Despite the code that I proposed, I have a few concerns: 1) warm or cold reset Now that we are updating firmware, we may have to initiate a cold reset in some cases. (That's why I used 'sysreset(WARM)' to raise a question.) >From the viewpoint of UEFI specification, * A type of reset can be determined per capsule by calling QueryCapsuleCapabilities API. (The spec said, "Returns if the capsule can be supported via UpdateCapsule()" and Capsule-on-disk might be out of scope?) * There exists ResetSystem API and it takes a *reset type* as a parameter. 2) ResetSystem at boot time So we may want to internally make use of efi_reset_system() following capsule-on-disk processing. The current implementation, however, does not utilize SYSRESET drivers, but call do_reset(). This should be changed (as I suggested above?). -Takahiro Akashi > + > + return 0; > } > #endif /* CONFIG_EFI_CAPSULE_ON_DISK */ >