From patchwork Tue Jan 25 11:31:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 536483 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp3625234imr; Tue, 25 Jan 2022 03:31:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxfwZbpvJFvV06DT/72FPwz8RjM+coFfXiTj7UtciLQNVfKvpODeXID9Vl2Tp9RJt4nCOo X-Received: by 2002:a17:906:1f04:: with SMTP id w4mr15373992ejj.603.1643110302627; Tue, 25 Jan 2022 03:31:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643110302; cv=none; d=google.com; s=arc-20160816; b=AIjtCE9zPlC115i/1UR58hDPnm1nNTiD2Aoq3jKpRs0Lu1bpECfBFFlATSFR7vyeLy r2vdusDYX0WDHYQ/FFurBdqRl12jV1l9c8Bg6Ow5zAQUWlj/XfUuxjlOIZQpCWXjgg9v b2j9/YN6CwEVCdzQvZDGxaY7uB8km0+38Bz4dF/nAdt7SLNBIm7R7jsnP93Ubh4MI5gr 98Ffx++qDgv3+z426/8JJuMGuHt5bsJ9jM9ANi06ArSlPo5m6tzG20alu2wNPQuGsBch 2cjrbaNsVJgpPaD5FwtKmLP2XKl9PAG6Wi59UtyJ3KAQRUxJiBY55DvVS2o0BxtFlZam kHkw== 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=QIVzpy0MsSfbcWtcTdJi4HK1q2u6/2sWGEDxNe2d3Jo=; b=z0JlWUftgbab+hS2ZXdDnSDDifVr73w3f9i4PojlyiO1YipSZpcxer97SnA6Qi5niC zBxZo8jiZCzAXyxFsUhPDRWHetAjaakWEykZJhzc3PdjBfZo0S8+22LqomxVoEX1joId DWegFG4wOzbQzyrgmLT4PFd4k2jdcZC80/BxLQyeQQGTbT0u+j/NUsJaJwu4vIlVB0Vx fzFXxwp6N2/ZkMlbrdktlalETQo1cLENkyciFH4AoeWOtOg3jQ52IZMN9PqHPVT+0giv pqVPHbwC1umCQx0P/EhFW1pjouBs5s6ELN/32QQZVSZjYtk8omldv41gVCRhnSRCP4H1 u2bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NW5L8ejD; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id j5si9149721ejo.649.2022.01.25.03.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 03:31:42 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NW5L8ejD; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 D8E728354B; Tue, 25 Jan 2022 12:31:41 +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="NW5L8ejD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5745F8354B; Tue, 25 Jan 2022 12:31:40 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 BCBFB837B1 for ; Tue, 25 Jan 2022 12:31:35 +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=masami.hiramatsu@linaro.org Received: by mail-pl1-x62e.google.com with SMTP id x11so13198111plg.6 for ; Tue, 25 Jan 2022 03:31:35 -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=QIVzpy0MsSfbcWtcTdJi4HK1q2u6/2sWGEDxNe2d3Jo=; b=NW5L8ejD7PpGsLP8mQ0kUAbIqslvLk+brOcwFq4x9CJxpwypVI09Uo21O4/N58V+yN 8dbhxewhGGhg4MG6ItcubETB4WwwczYt1dB/PZaDKmamCVrMt35TPHYffWWtUOEvEL6h XubKImwDW4Sbs3iF0BwhW4Vln1g+98iMiT+Q/9LlRpKMMe/WF2rQZbWdfoHZesGnyiDC emxEJ5fOSi3J5q7ooUpN/iCRBV6UrOA4qRcNnpsrUfvq+1bzZZ8Y7zPUw4dIqp89/10z DX0YA9/AoIkGVBB/q3G1xXz1HI7af4F/c4JzTI1qIeV2QRPDYRALQtsIPmDk7++HBNjW dhkw== 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=QIVzpy0MsSfbcWtcTdJi4HK1q2u6/2sWGEDxNe2d3Jo=; b=XS6nr6Jhjth/GEAPFY7vvfCLhE4pq1qNiepdsiAHke0qcQBK/4NGaySRMp5kU4Xkrz y8moRkNaRTVtWzVWvT8OiIVQEOvBbdtSnKDhJiKRLFSbyaXeHA+xD5bNFhv82JUYi0Mr yLTb1koNYlZgcCM/rdWxU6LCKDtkfdAudefcjynXkZZi8v0BWhjQKWWMWqPz9/t+3zZS kddSJ4b8IPOq/0M+Wb7SeRBJx25bCKD6n4uvXKnMGM1zZOp4TatGPD4X6eYsmn7KGKaq 1mKjIpqzb1KWw78GQy07+rIQEGLLNicqT/pNRbMa/eUIrsMrtGW7yiBaG+YxgB/xdlkf QKjg== X-Gm-Message-State: AOAM533azl4DT529YyBy5rMxb2SyoTaryM9tiBAxA4KXVN1Rd6kuP0Pq Iz1tze/kcN3HO6wBqh+RO2Lydb65MsNbvg== X-Received: by 2002:a17:902:aa8b:b0:148:ee33:70fe with SMTP id d11-20020a170902aa8b00b00148ee3370femr18277343plr.38.1643110293972; Tue, 25 Jan 2022 03:31:33 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id n22sm18596296pfu.193.2022.01.25.03.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 03:31:33 -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 1/2] EFI: Support CAPSULE_FLAGS_INITIATE_RESET for capsule update Date: Tue, 25 Jan 2022 20:31:29 +0900 Message-Id: <164311028928.175897.11020560607087529330.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164311027891.175897.14232281505893559986.stgit@localhost> References: <164311027891.175897.14232281505893559986.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 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); + } + return ret; } #else