From patchwork Wed Feb 2 13:54:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 539327 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1582638imr; Wed, 2 Feb 2022 05:55:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzl7nk/NkZVrJbuexb/yEnUNXf16HZ7d0vknAl7iWBi8gM/7EC7XxRudX0q4Qj0gYjhrDJw X-Received: by 2002:a17:906:6a28:: with SMTP id qw40mr25360112ejc.550.1643810117051; Wed, 02 Feb 2022 05:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643810117; cv=none; d=google.com; s=arc-20160816; b=QjbP3JAnJbk0J+y01ttICDEb5w06dDwq7g95e2KkAK3f5nE5RHQtcUFeAC4UsDZlKH f/cP0o/BMvUztJLB1pK3m0Aiq7UWeH2WKL9GQpvL/gdLyUtEmZu4tpp0xtYICQOFnKYz /QVQYQTLH6nhRyTlItvaxoIBVqc00zqnxdSEZ18g6Rb8aXp6jAbxPHvpZ2YTp16ipZki 0P0cm2BMb9sY1DGaFo5GSPmqTgQN7NF4BdnhP3cMQShpR41jACnTeamic/7e7Eh0NmrY nwAXes+dUDDg+GY0axBfMNYzK8bai74WaKigOFYosf45jVPsSRMJmdNhJt0rwQ4EYEpF uK6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=oGE5JX9wD2IHETOmokvSfqHExlYTgw6LiDnI/ldGsj4=; b=sfRa2TjgyxQnPJzhy3YHoB7rYR3CkjXPcO6/wxQXJMhkiyyWFdAfYSjSxVaCSdrUu6 hcoQEVGp9kafZfpm5U2bs6WAaOw9EhHDNQGCaL/c7MrTsWuWkQAMwdUALZGCi7cYtSaw DisfBRpqSleedHvG72EdQfi/eO8aTRczIj4jdhfg9xln4cXmEjTnkKivLjSuuyvH6zAe AhXd67uiEogYBk8HGd6kJQOdldfdYzBDFT8mvlw8185wQkL7aqmJTnx49Ww8+pmE1fy8 PsSA+PXmuRSHZ+gK3SylBXOLCKYDzqgktEhGSI2K3NWWF/EEnvKIONUhufWW2N10EZfn jMLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kyW7aXvZ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z67si11532734ede.475.2022.02.02.05.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 05:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kyW7aXvZ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 21B05838F5; Wed, 2 Feb 2022 14:55:05 +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="kyW7aXvZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 553F7838CC; Wed, 2 Feb 2022 14:55:02 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 5BA0783902 for ; Wed, 2 Feb 2022 14:54:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pg1-x52e.google.com with SMTP id e16so18373930pgn.4 for ; Wed, 02 Feb 2022 05:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=oGE5JX9wD2IHETOmokvSfqHExlYTgw6LiDnI/ldGsj4=; b=kyW7aXvZKVrNAu13SQ/d91B1g8+3DIiw5LysXEBUPwUeRDPn/sfjGfRPRFuhLFGG6d OePiOnSqHCEapuq93vdIvtQTE/JH1dIMuKyXlwYKOtTdffCxILJJxjrZ6mn45ZW/HXPh ogk1oDj7A97fsKTnGgodqgCGtnL48u3YMRZE0tGs72He+dkkkRPrywxjZVFygm+enjL/ 0uLboyO7IczISgoNuVSu4s1GOeBQoXw3KpqyqtxQCCqW9DMv9Sw7aRoXqaXivRzt9g2a FIJmMed8ujgeXksWs26pWVLMLF/9+9IBpl2mgg8rqBRB9AAUpsSW1pFV/nIOtO4w+zqs TGFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=oGE5JX9wD2IHETOmokvSfqHExlYTgw6LiDnI/ldGsj4=; b=nAooXEOrc0ZmM1rK7yoW/gvQUw6d1R4imxjTNCnVlIwD8H1qopzKabtC3tMWhQZLG2 c5I5E04Vq14L7jXY+KwNO3JI63X9yQ8ojAFM6hffMzlodIyxnoOdaagKqKihVEwIKHOr POFBs8LA3C8Zz7/jaGDoiiK2atZwFA/mCbzrrR3cjtDOEABvcDDVUicSauz8JUjnaCJi 7MOXRVR9hYFTnzj3poMdI/pFgOGlwO5BjNIguffeCFW5HCfKB1itQnjYwR5viMurTL8x YaCNroxOiMcnZwCRwmkn2Bd0As/h3m1H3GDcMZp9rvlXHn8gpkT9ffGeB9hjhj3x5eFY JA9A== X-Gm-Message-State: AOAM533Z5bFnM7wpIE11qgaCtZUs68ZkIN/j+XdGMGRZCRNa7K6zXQob PRDqsd0CWb0fu8W4ilf/7HIDRd4+9ZeQbg== X-Received: by 2002:aa7:96c1:: with SMTP id h1mr29858910pfq.17.1643810087621; Wed, 02 Feb 2022 05:54:47 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id k3sm27534255pfu.180.2022.02.02.05.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 05:54:47 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v2 2/2] efi_loader: Reset system after CapsuleUpdate on disk Date: Wed, 2 Feb 2022 22:54:43 +0900 Message-Id: <164381008301.420956.13884226784193349269.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164381006265.420956.16575397258903175632.stgit@localhost> References: <164381006265.420956.16575397258903175632.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 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 Add a config option to reset system soon after processing capsule update on disk. 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 */ + + return 0; } #endif /* CONFIG_EFI_CAPSULE_ON_DISK */