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 D0D47C433F5 for ; Tue, 25 Jan 2022 12:49:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2776D8331E; Tue, 25 Jan 2022 13:49:33 +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="v1fBjLy6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0C02883325; Tue, 25 Jan 2022 13:49:32 +0100 (CET) Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 18EA2832CD for ; Tue, 25 Jan 2022 13:49:29 +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-pj1-x102a.google.com with SMTP id d12-20020a17090a628c00b001b4f47e2f51so1969578pjj.3 for ; Tue, 25 Jan 2022 04:49:29 -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=65ZrL9gyBgHUNd+0VTHRcDAghvNiZ1AIrl+CcfGvTCc=; b=v1fBjLy6EaA7jwG3HwL2iGn8tGpIY1rxFhnqBEdSjwHsiFLypkP/SdZ8XXPp6SV9yI JOQt2ef0MFpQMb73PitN5xkKQdXVMkA2x/yGK7Pl6Y4zMQenevFMjPgnwnOuTJGVgP4I YvBFZXyGYBVkUQ8jmXG6SsO4F/W56mt30la3i12Q5wznISXJrSSEFpqE8qzKrUiMNvJN JCbmHZDjtGWY4lrP0EV7bc8Nn5oxYo4YqlWPkKv9BWuUrDOOWAhb5XvdolJuudGfWC6d vmjmrVZokYSvQqVrKbz2HP6aBzaZD8LujADzcip+GmQpdm21nO7YrWNC9McgNJ5tzP2C /BFg== 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=65ZrL9gyBgHUNd+0VTHRcDAghvNiZ1AIrl+CcfGvTCc=; b=5Woe5CKU9yy32qu8j2S6sSJ1cdlnsxPVA9r1b50lT1BNbEvmRef/bqlSwNnLdjZ8Yw c7TJJa7J5itOXHa0UFxmMpKnLcqcGsOREu6cYYx6koIlfEUhUlNjHAE1suy8vzP4pv6q +35tdcT5dTotV8XsfDBnCdPE3qqQT1oPLlWWpRn+NNxHZraNJoAqi+2+f4PuapUo5gpF Ip6Kmjgdjzp5POlMrJWUQmLD/Te5mDWMowHBlM45FXQeYOqTJlBQDEtvfpmbKxOI2Lb4 qOg1u0mCQe7lvefdVm9edRh6ZJO3x0b9SIskiDGXxpylk82hwCeLwebiRrggRh3yqQPw CSnw== X-Gm-Message-State: AOAM533/Q+NPtBNq+wCIGf4H42Ja2Y6moBJ4v7CHV570GKwRGDtEmDaL meXgfVAgiH6uLwAYsNaAoFKecQ== X-Google-Smtp-Source: ABdhPJzfTFskM6G1ZFs/1R//g5XzrkXWd7qOd0umJXLTqt57VQbPNmEj/nGGJvHlE3LsdlClzaMxKw== X-Received: by 2002:a17:902:e5cf:b0:14b:8a7:b26d with SMTP id u15-20020a170902e5cf00b0014b08a7b26dmr18192023plf.80.1643114967279; Tue, 25 Jan 2022 04:49:27 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:c0fe:d8ec:1255:eef8]) by smtp.gmail.com with ESMTPSA id x187sm3649646pgx.10.2022.01.25.04.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 04:49:26 -0800 (PST) Date: Tue, 25 Jan 2022 21:49:21 +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 1/2] EFI: Support CAPSULE_FLAGS_INITIATE_RESET for capsule update Message-ID: <20220125124921.GA56019@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: <164311027891.175897.14232281505893559986.stgit@localhost> <164311028928.175897.11020560607087529330.stgit@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <164311028928.175897.11020560607087529330.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 Hi Masami, Thank you for this enhancement. On Tue, Jan 25, 2022 at 08:31:29PM +0900, Masami Hiramatsu wrote: > Support CAPSULE_FLAGS_INITIATE_RESET for rebooting uboot soon after > updating firmware. Note that the machine will reboot soon after > applying the capsule file which has CAPSULE_FLAGS_INITIATE_RESET > flag. If there are multiple capsules and one has this flag, the > machine may reboot while scanning the capsule files. > You can control when the machine reboot by renaming the capsule > file because the capsule files will be applied alphabetically. > > Signed-off-by: Masami Hiramatsu > --- > lib/efi_loader/efi_capsule.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > index 4463ae00fd..24a2a026a9 100644 > --- a/lib/efi_loader/efi_capsule.c > +++ b/lib/efi_loader/efi_capsule.c > @@ -407,12 +407,20 @@ static efi_status_t efi_capsule_update_firmware( > struct efi_firmware_management_protocol *fmp; > u16 *abort_reason; > efi_status_t ret = EFI_SUCCESS; > + bool reset = false; > > /* sanity check */ > if (capsule_data->header_size < sizeof(*capsule) || > capsule_data->header_size >= capsule_data->capsule_image_size) > return EFI_INVALID_PARAMETER; > > + if (capsule_data->flags & CAPSULE_FLAGS_INITIATE_RESET) { > + /* INITIATE_RESET flag requires PERSIST_ACROSS_RESET flag */ > + if (!(capsule_data->flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET)) > + return EFI_INVALID_PARAMETER; > + reset = true; > + } > + > capsule = (void *)capsule_data + capsule_data->header_size; > capsule_size = capsule_data->capsule_image_size > - capsule_data->header_size; > @@ -498,6 +506,11 @@ static efi_status_t efi_capsule_update_firmware( > out: > efi_free_pool(handles); > > + if (ret == EFI_SUCCESS && reset) { > + log_debug("This capsule has CAPSULE_FLAGS_INITIATE_RESET. Reboot machine.\n"); > + do_reset(NULL, 0, 0, NULL); I don't think this is the right place of calling do_reset(). Whenever you have processed any capsule file, you have to - delete the capsule file, - create/update "CapsuleXXXX" and "CapsuleLast" variables, and - modify ESRT table before initiating a reset. -Takahiro Akashi > + } > + > return ret; > } > #else >