From patchwork Wed Jan 17 19:16:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 862523 X-Patchwork-Delegate: agraf@suse.de 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 3zMH89695nz9t4P for ; Thu, 18 Jan 2018 06:24:09 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 715B4C21DCA; Wed, 17 Jan 2018 19:21:22 +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_H3, RCVD_IN_MSPIKE_WL 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 2D8DAC21ED9; Wed, 17 Jan 2018 19:16:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8251CC21EBC; Wed, 17 Jan 2018 19:16:33 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lists.denx.de (Postfix) with ESMTPS id D669EC21E39 for ; Wed, 17 Jan 2018 19:16:26 +0000 (UTC) Received: from workstation4.fritz.box ([95.222.46.37]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MLfH9-1eb47G0mHb-000r46; Wed, 17 Jan 2018 20:16:25 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 17 Jan 2018 20:16:12 +0100 Message-Id: <20180117191612.17108-19-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180117191612.17108-1-xypron.glpk@gmx.de> References: <20180117191612.17108-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:EJCvkmW8iJevNjBJ7TNoIGxfP5xqTDohvtGMLpVdyokNV8NUubP FE5zEReAA84CgKlylXlx6aO/LC6RmvzxNnbkrrQQ+dEPg2gEDZs/VZkhD2s0NJbRqWGOKeJ 9Z+1i+2hWKmdSVTexUh9j5nRp91JhpQSnEYZQ5+vgrxCMhohnpV/O2HNc6B2Y4FOpOZ4cyB zHarMzqMxI34+uHt9ir/Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:uvmMKs9ZHgI=:6KoOguHb5JwiAu2fx1LH8J tLSN7216zakjADcAohzdrhT7BMpXkaVkN9pybV+CmVLCs1QI2cCI8PeCWz6iQbRd/ui9LZ1gg BKBtkQVNRJihb1UloMKbwvdzIKtQ0QyKajHp8UZolcThn+b/hCSmLuM2TgiY8cGDw0HH2Rrej hyV9Quvv4j5boVBzQUft8uibjjDkIZL4hg7HDitWpVcSA+RSCuEjVO9OBf2tBmjZ7RHfVt4nb 8zQl5opz94lUC8IxJTkvWW7oVxNvYLnwEcqmYZuc+/KLbFoWPQWNOxHdcVrdUchJgZv3O/Wbj 6utbws2Zmp3SxFWyoBs6J7XmLmyaMFY509RUsvKcrPfiSTmCzqOtzCtMKZijRnRqhuzpmNsEi 8/cxZM8yqgARZETRM5Upv+bPOvJy4LeVjS0mB6KdR8qp71RBbnInm1SJbpH2Nz9PmsEkd2o+M ilamQjhO3pj3oqDsvPFdEfXwMwKizYXhfxi3ATSbQ8D7d7T9nRd9VnBpGTmjE0NMa2x17fmqg h3EVH8pPQjfC/jkRpGpB2s0DIT/cJPh3kZU8c5RVT3/rkIyO8n4o4Gxxfn8pZmmYDYzCFCx5a BebX8htwiqO5cRzf+SBRiltBnTm7yvrcwQjdL1+OwzNtZWeRQnI+ppxajGYRWDn/T7pQyNxU0 5hbg9baGRU/m8LHMrfcINY8x0OY+6ElQC7BdQDf6L1eVcE/gWlxOrXkwgqFR+fNgFDU1+HRY7 8YK7ztJ+lXJicwXgplKUcfJbGbCpjxBwox3rJu8HAdXLj+x0V+bEu4ZuHQ/r8fs59uR+OLDOZ GDPI8q3MZKgzFclpmJeIyYKlsBhEA== Cc: Heinrich Schuchardt , Tom Rini , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 18/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 --- v2 new patch --- include/efi_api.h | 6 +++--- lib/efi_loader/efi_boottime.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 0bc244444d..4252d11398 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -247,11 +247,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 4b3b63e39a..2c5499e0c8 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1645,12 +1645,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 @@ -1662,16 +1666,24 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t 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]); + if (!efi_events[i].notify_function) + continue; + EFI_CALL_VOID(efi_events[i].notify_function( + &efi_events[i], efi_events[i].notify_context)); } - /* 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(); @@ -1681,6 +1693,20 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t 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();