From patchwork Fri Jan 19 19:24:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 863773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zNWHV0grQz9sP9 for ; Sat, 20 Jan 2018 06:34:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8F471C21F3D; Fri, 19 Jan 2018 19:30:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CF486C21F63; Fri, 19 Jan 2018 19:25:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C3213C21F47; Fri, 19 Jan 2018 19:25:09 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lists.denx.de (Postfix) with ESMTPS id D14A2C21F49 for ; Fri, 19 Jan 2018 19:25:04 +0000 (UTC) Received: from workstation4.fritz.box ([95.222.46.37]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LrvBu-1eoGv32M6o-013hrl; Fri, 19 Jan 2018 20:25:03 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Fri, 19 Jan 2018 20:24:52 +0100 Message-Id: <20180119192454.11172-17-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180119192454.11172-1-xypron.glpk@gmx.de> References: <20180119192454.11172-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:pUKkG1p/0L2sC/XJ+7Lu0LyALQvIpPvdgfyArGlhsBXoUSYUVWx YK+rxXDABWw9DaN0H8Q5h3gJaRy+eaATpeS63q4JatjktYDOQWne1rZ/ULwej626yQ2ZWnl 0GwEzLZoqL/+b6YqovM6Ym8pvwPhgzKExxL2WbP47lNVd4+dRAmTQ1CzJ04rDqZWqRKgfIp lwWG52axlG24BipCDy+gg== X-UI-Out-Filterresults: notjunk:1; V01:K0:om4jLWUi1sk=:HOas6FcdH4r6effKyVG/0t Ro0EBSW+IdEyrDF+XhpWZWbzgyWD5B5J6qL5SAIqP+nvJVvys3I+HxT/heQCvHD6AgJo3Ho6S TmzQB5JuJd5yAIMjewnVsG2GvrpgAYCNOEoVFCyGMV+S7t3Wh6bmJQi8w9xcXgtbrQpOI34HR 6RrDzXv6Uyb+FfmSWWA7qUOJVLRUI3xDIsTUjpK4nj3byl4r0wBKZq7TntGDgSZHWEMZBEzf9 sR+28qO1H5bqukiU8ac5g23gbu40WBP5lWovuVmIlVI7G0RuefsHjoXDlb8UlrQgmiMde+e1q BVFQlYEovr3riVp4Z1QsgBWanFeq9dOGfoN7D12O25RwBItBTVLPQtaMZYehUl/YPrAAYsv4t ZxjjYiCyopqCAtnic9Wrew/zwnueWyQ1EBGDcFvKk/2zIZgiM8ExuwByra/In3fmnMkGcNFD+ GbZ+AcVeQ+E6NuG705ritn6Vy5F4V2tHL/gXYH3Z+Ub3xNmX/jBmIIwGJ76WBucZPGd6vuGNf tsJVxGg3NDlboctKuW0wuZQScW/g+OnwrA+2D2Q17nQ1stgglYrXnahyh8BHdwnqRs4HWO9D+ y4h4Oq8sZZ7CxVmBtN+iWvsifFuHzwUhSKDU1UWrx8TmMfcayBTz5DtnZ1mgzMMvACXhstoSh OWRvaP1ehibU+BR+P4UB0Ap2L0EKRykOO5BKoYGRs4J1ghRknmTKoSHz2albicVYu9hP2S+uq eKHy9qYk+AOfwP/4VbgfqfxO1r+zo/KDESsPcnQ6kU1vExkamUyXBHe5YSQjAjtNqPpdEGnr6 CwnLgld5KDle37kCg39jCY2bQ9bxA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 16/18] efi_loader: fix ExitBootServices X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch lets the implementation of ExitBootServices conform to the UEFI standard. The timer events must be disabled before calling the notification functions of the exit boot services events. The boot services must be disabled in the system table. The handles in the system table should be defined as efi_handle_t. Signed-off-by: Heinrich Schuchardt --- v3 Use efi_signal_event() to signal ExitBootServices event. v2 new patch --- include/efi_api.h | 6 +++--- lib/efi_loader/efi_boottime.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 861897bb57..90e6716b61 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -245,11 +245,11 @@ struct efi_system_table { struct efi_table_hdr hdr; unsigned long fw_vendor; /* physical addr of wchar_t vendor string */ u32 fw_revision; - unsigned long con_in_handle; + efi_handle_t con_in_handle; struct efi_simple_input_interface *con_in; - unsigned long con_out_handle; + efi_handle_t con_out_handle; struct efi_simple_text_output_protocol *con_out; - unsigned long stderr_handle; + efi_handle_t stderr_handle; struct efi_simple_text_output_protocol *std_err; struct efi_runtime_services *runtime; struct efi_boot_services *boottime; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index ebd21b7b05..1e15103b65 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1663,12 +1663,16 @@ static void efi_exit_caches(void) } /* - * Stop boot services. + * Stop all boot services. * * This function implements the ExitBootServices service. * See the Unified Extensible Firmware Interface (UEFI) specification * for details. * + * All timer events are disabled. + * For exit boot services events the notification function is called. + * The boot services are disabled in the system table. + * * @image_handle handle of the loaded image * @map_key key of the memory map * @return status code @@ -1680,16 +1684,22 @@ static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle, EFI_ENTRY("%p, %ld", image_handle, map_key); + /* Make sure that notification functions are not called anymore */ + efi_tpl = TPL_HIGH_LEVEL; + + /* Check if ExitBootServices has already been called */ + if (!systab.boottime) + return EFI_EXIT(EFI_SUCCESS); + /* Notify that ExitBootServices is invoked. */ for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { if (efi_events[i].type != EVT_SIGNAL_EXIT_BOOT_SERVICES) continue; - efi_signal_event(&efi_events[i]); + efi_events[i].is_signaled = true; + efi_signal_event(&efi_events[i], false); } - /* Make sure that notification functions are not called anymore */ - efi_tpl = TPL_HIGH_LEVEL; - /* XXX Should persist EFI variables here */ + /* TODO Should persist EFI variables here */ board_quiesce_devices(); @@ -1699,6 +1709,20 @@ static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle, /* This stops all lingering devices */ bootm_disable_interrupts(); + /* Disable boottime services */ + systab.con_in_handle = NULL; + systab.con_in = NULL; + systab.con_out_handle = NULL; + systab.con_out = NULL; + systab.stderr_handle = NULL; + systab.std_err = NULL; + systab.boottime = NULL; + + /* Recalculate CRC32 */ + systab.hdr.crc32 = 0; + systab.hdr.crc32 = crc32(0, (const unsigned char *)&systab, + sizeof(struct efi_system_table)); + /* Give the payload some time to boot */ efi_set_watchdog(0); WATCHDOG_RESET();