From patchwork Fri Nov 10 04:25:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 742842 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp12675wrw; Thu, 9 Nov 2023 20:29:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD3k+ouW985NxlYK4woF1Bei987+rNy3739dRp2su5moA69XjCsBnjg23/6G0PvYKhH+xb X-Received: by 2002:a17:906:dac2:b0:9de:32bb:fa91 with SMTP id xi2-20020a170906dac200b009de32bbfa91mr5755207ejb.74.1699590555309; Thu, 09 Nov 2023 20:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699590555; cv=none; d=google.com; s=arc-20160816; b=m6Jg5bWuCT6lw0Q0iMEf+fpMTiuLc9E7aFKfaBU2EXRdbVaj8HEUux2hUAzVfUAoo/ wGbzTYs7XHVVKmB0g/I0cinrGHsXGS1qPKkv668DpjyIJNAS6pi/ByVLRdt0tN10cbYt aLaAHAdwSO/oIxwUL4rAXV4FwuhE85ixeUkhKvP0V+Z3H2z/Zr8LGQn/9Un+L/5Ebw5R Tmu7+IxxA0nBqQSYMlMmgksB1w7se3QENhh2C16s1mAZuQpRlAQ5LsUhve+iL/0+D3mY cnpHiOc0arITFhL9lPiZyM6jxTyi0t4IfQk0xzk8RAINJRfcdNE/2Jb1G+L3Rz2fRJXg 9p9w== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bKRfTkXsyxHbAbfC2fDvqXQoTddGeOCmf5imGSOro/k=; fh=I7E+BwgHMByijVVN/pPHsLSpz7oP4y4e73noHEekrEE=; b=GTe5Dilk+t5Yku2zJ95Lh51zK7+jt3uM01ZCt4GdQRSt1LTYqsZlA8vVT7mAyAYlZJ Uok+CnYUYQWlHdm+Ts0nsAnNM+FsdqzdjK2SuHgzsvsrvsuGX6LoVkgnl1UbPSq768oF 88obq5pvL7SI0mai9CEwkTAg7z48cuO5wXN6Wpit7Kri0L1AlRUjc8oFCkxr5NcjsdAY 3GhTWRVN2jgOYdObSZ9UPu5qvmX3kv3ZPwnpqbZSYFvhZxoZD2QtT+70RsGQmGb9oS3i YfKhjI7Q74GeVi5QYpiHzLD0WxMX9JhwbgKXbNiiQenvf0SX+i6e+6J22f050BUN86ky M3iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VlRtaEbj; 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 vg18-20020a170907d31200b009d5b7dbf569si4000998ejc.829.2023.11.09.20.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 20:29:15 -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=VlRtaEbj; 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 83741877AF; Fri, 10 Nov 2023 05:27:55 +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="VlRtaEbj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D50C387783; Fri, 10 Nov 2023 05:27:42 +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-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 C281D8778F for ; Fri, 10 Nov 2023 05:27:30 +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=masahisa.kojima@linaro.org Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso1274909a12.3 for ; Thu, 09 Nov 2023 20:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699590448; x=1700195248; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bKRfTkXsyxHbAbfC2fDvqXQoTddGeOCmf5imGSOro/k=; b=VlRtaEbjjIMyWYGunCddfof98AxuBZ5OgC6GNagr1/bbuJGknHhIGYP5NGghWLUGmu 2M4dsP0sGxM9IKDF0vxO4Enj7jjVV4hsbYVzWpICUfMjbqeTBhcS0FbKbm0kgIJ2vg+Y qbhCkF48/vbjhj0QfyEjtbrMgvDTg8RV4MR4Y2TgPm3MOpqt7xe2AWQu0E9Ii/42hfxu wM/OURiFz2AaAi64u7bI9t3qYfrWBiB4cRo/v4m55urCvBIMpkAJOwc6PtL5eh6Y4E9s i3yM2xZ/DQF5+E5EP97TU8saRxb9PUjNIu4BkIrahq2S6Li1TCozKltO1J7Vlnl6GBXi seeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699590448; x=1700195248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bKRfTkXsyxHbAbfC2fDvqXQoTddGeOCmf5imGSOro/k=; b=sj5hbrFNyWnSmzvvwTup0ajQ5u+52fJ7yKWWAnMaQqZG4/a/qUV1g+mMEAPUzeYIhv Bd9xJVriaTlPShfxaocl8LS1uKhEPzd8v2d9k9xV9V0Dix1JbUyCWuxI23Fb5IZx5JvU HqRp1rvmqVp1mhrU8JvYQGAWxyiYfbVrH6rkfR39JjgEWtPnQNAKKsIEWeMi/nBN1yp0 qp6LPXPy3axI1XkNKu9CwArgBSPG07E8yZ4rKNhHTXKvUuX1hqeO7VvTUP3beiBpV3Yv 3IjYHgkhB/WHXE/u0GNmuFUX+Gh5u/tDSdlkuIsCU7sAodwbdpD8H2dyBtC9u2+/oDHk R9Hw== X-Gm-Message-State: AOJu0Yw3UkNLhr7tVW+6DY8fm+gGbs22hTEg0InFyvQc/2/BcmlzJXPO LCWevnL1f9q6r6zCOPdh2NlgoTG3w5rLpwe4FCc= X-Received: by 2002:a05:6a21:3603:b0:185:c32e:cfd8 with SMTP id yg3-20020a056a21360300b00185c32ecfd8mr160317pzb.6.1699590448586; Thu, 09 Nov 2023 20:27:28 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id ij27-20020a170902ab5b00b001c3a8b135ebsm4406508plb.282.2023.11.09.20.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 20:27:27 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Michal Simek , Masahisa Kojima Subject: [PATCH v12 6/9] efi_loader: add return to efibootmgr event group Date: Fri, 10 Nov 2023 13:25:39 +0900 Message-Id: <20231110042542.3797301-7-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231110042542.3797301-1-masahisa.kojima@linaro.org> References: <20231110042542.3797301-1-masahisa.kojima@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean When the image loaded by efibootmgr returns, efibootmgr needs to clean the resources. Adding the event of returning to efibootmgr is useful to simplify the implementation. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- cmd/bootefi.c | 12 ++++++++++++ include/efi_api.h | 3 +++ include/efi_loader.h | 2 ++ lib/efi_loader/efi_boottime.c | 3 +++ 4 files changed, 20 insertions(+) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 20e5c94a33..4d74969ad6 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -356,6 +356,7 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) efi_status_t ret; efi_uintn_t exit_data_size = 0; u16 *exit_data = NULL; + struct efi_event *evt; /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ switch_to_non_secure_mode(); @@ -394,6 +395,17 @@ out: log_err("Failed to remove loadfile2 for initrd\n"); } + /* Notify EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR event group. */ + list_for_each_entry(evt, &efi_events, link) { + if (evt->group && + !guidcmp(evt->group, + &efi_guid_event_group_return_to_efibootmgr)) { + efi_signal_event(evt); + EFI_CALL(systab.boottime->close_event(evt)); + break; + } + } + /* Control is returned to U-Boot, disable EFI watchdog */ efi_set_watchdog(0); diff --git a/include/efi_api.h b/include/efi_api.h index c2d6964467..0e92cb8a7f 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -404,6 +404,9 @@ struct efi_runtime_services { #define EFI_EVENT_GROUP_RESET_SYSTEM \ EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \ 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b) +#define EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR \ + EFI_GUID(0xb4a40fe6, 0x9149, 0x4f29, 0x94, 0x47, \ + 0x49, 0x38, 0x7a, 0x7f, 0xab, 0x87) /* EFI Configuration Table and GUID definitions */ #define NULL_GUID \ diff --git a/include/efi_loader.h b/include/efi_loader.h index e164e6067d..31954e84c3 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -290,6 +290,8 @@ extern const efi_guid_t efi_guid_event_group_memory_map_change; extern const efi_guid_t efi_guid_event_group_ready_to_boot; /* event group ResetSystem() invoked (before ExitBootServices) */ extern const efi_guid_t efi_guid_event_group_reset_system; +/* event group return to efibootmgr */ +extern const efi_guid_t efi_guid_event_group_return_to_efibootmgr; /* GUID of the device tree table */ extern const efi_guid_t efi_guid_fdt; extern const efi_guid_t efi_guid_loaded_image; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index f9b10a9763..3767fa2db4 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -90,6 +90,9 @@ const efi_guid_t efi_guid_event_group_ready_to_boot = /* event group ResetSystem() invoked (before ExitBootServices) */ const efi_guid_t efi_guid_event_group_reset_system = EFI_EVENT_GROUP_RESET_SYSTEM; +/* event group return to efibootmgr */ +const efi_guid_t efi_guid_event_group_return_to_efibootmgr = + EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR; /* GUIDs of the Load File and Load File2 protocols */ const efi_guid_t efi_guid_load_file_protocol = EFI_LOAD_FILE_PROTOCOL_GUID; const efi_guid_t efi_guid_load_file2_protocol = EFI_LOAD_FILE2_PROTOCOL_GUID;