From patchwork Sat Jul 6 19:46:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1128526 X-Patchwork-Delegate: xypron.glpk@gmx.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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="bCDN12At"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45h2QR0Wdlz9sN4 for ; Sun, 7 Jul 2019 05:51:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9343FC21C3F; Sat, 6 Jul 2019 19:47:52 +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, T_DKIM_INVALID 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 7D287C21DB3; Sat, 6 Jul 2019 19:47:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5D7F6C21C3F; Sat, 6 Jul 2019 19:47:05 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id C29C4C21C6A for ; Sat, 6 Jul 2019 19:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1562442423; bh=R98f2X2Z22MPMEFlCrBzwGqZyH4RJ5JNJTIFwQHDPVc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=bCDN12At2LT87GXu9tCIJxYkngqIgIfVD6Ey08Iyh+1HhO0KIWftHDnp+Uj0DAXUK SbAEvJLFPtmLEwd7Mdo5ttLM7xFxx2VVmOL5TebsGAAiPUTXdTps7hY7yv0hJJisor UB76rUkHlPACRq1LYzVWkYHO5vHAr6HaPBKDXY+M= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([84.118.159.3]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MMXVC-1hs4e902P8-008NkF; Sat, 06 Jul 2019 21:47:03 +0200 From: Heinrich Schuchardt To: Alexander Graf , AKASHI Takahiro Date: Sat, 6 Jul 2019 21:46:26 +0200 Message-Id: <20190706194634.3349-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190706194634.3349-1-xypron.glpk@gmx.de> References: <20190706194634.3349-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:GxTkFJTCiioDxN5hRlDJH9sC/PnEB1HmEbWm/II+ZwAqJYvyEcu AgLKm9oJK40o5SMyqRwrUcryoItlkHt51O6GFzjF3V8lf4t9Sr3qOfw8cZ3K5TjqE9Rz6CT goxDnEeEo6uLKiyThiaZclNotQOSeh/RNdYpN93hXJ4M8xC32uM7prn45zCN7GvLbRTk3rZ yZlhPtIu9BQpm8QuIJpkw== X-UI-Out-Filterresults: notjunk:1; V03:K0:mQ5tC6quQ1g=:gghSRBH5MikkAiOT4zDsk9 yfpNYlQaB29l7ERwLVLPs7OaMBwEumuWlNTzZUbpo7QNp3E0WLwEcxTMYNGcAHxUIz2J1zqXO zf4A8v8Hdupfa29NA9jmcF0j3kq3mUK5SWR+wHpKkkxOv+tt3BbaoT+oysOsaaG4ygNU5KmBE DiSGz9kR+uMY/kG+rev6eWk1cCFxtjumIGBQBT3Bt8fHOP8HF/8g2A6ZPbJd0sao8dIAdsmGx ix43f4sZoypMgb9Imw603M+cov1BykuGjKO3nRSVVnYOwTEZKEoQVQ/AG/11lMqCvURU75d63 DsjhBsGFZHXfUjZ/B1JlLFIooWKVW9nxSgbwK3Q3AvUrA8uQIuwljcg66RRqfPAXnqZxIt2h7 e0CAjFAhXhq855xsTNCq4g+q2TVwIxoNcvnt6HnhpgXS4OrYBmAAIuo0qCW0uMDDPpqTlihtl HorliHywAVd+CmBCPDx6pqkFDT1lqIc5OnFSwwRJVJeWhx2K1bAa4mmPcYJucylIefMC83Zwk VUQJGMsr8zia4PCUwZ4gEcmAaxJD14QJVxH9bPuMOWp2Lz5YGf5tKiIOsd/DtcKcyEAAm2g5F aXHo9K0rKqMMHzYPKeyDTU0IWU8HYmyV9JjaLBM/B8KuoS7Mbqu5XSsXNGP0VioGI9h+Wlx55 OurLbc5PF2EEDojV2R9VlBRQ+2F3rwR0Yjb+Ye+70N9so8M9ahh9zj/QEyIDotCHD+7rvrVoc 7kHLO5nugCET5gdNLdV5OjxCmpJE21twsNaLnGlc2ci0ocXlk6h77i8a2NkmWNeLIU5/BTC8e QElHSxUL+XtHfDJtIMMBmyXTC5vyNjI+3DdV9rySyki1SioS7OKcb+XhQBxu/93kI/CtHwnqt ERYDH7/+7dflP8A1K/u+SdDQ5mq1Zq6nzoUtKspfqKaOgSroPf2ArjT99FkOtlb/Lt9HFBoPb /jDCXGiE8NffxnINAgc2DQlTVbFzMAMfcTAvwUtEw2UeCNhSJBZMOqKFC71iue3lnjOnuo+Kh gSDj3n6F/NPBZ12Nmi8oK3StgMfplr6NUQULMSKDpCdtL2NEEtUQO8jjhYyhexSOrDsbuZVKt LiDuIiBchYuF40= Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 05/13] efi_loader: let the variable driver patch out the runtime 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Our variable services are only provided at boottime. Therefore when leaving boottime the variable function are replaced by dummy functions returning EFI_UNSUPPORTED. Move this patching of the runtime table to the variable services implementation. Executed it in ExitBootServices(). Signed-off-by: Heinrich Schuchardt --- v3 rebase patch v2 Do not use an event but a direct call at ExitBootServices(). So we do the patching after processing all events. --- include/efi_loader.h | 2 ++ lib/efi_loader/efi_boottime.c | 3 ++- lib/efi_loader/efi_runtime.c | 9 ------- lib/efi_loader/efi_variable.c | 44 +++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/include/efi_loader.h b/include/efi_loader.h index d30c4e8ef3..8d75dde569 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -327,6 +327,8 @@ extern struct list_head efi_register_notify_events; efi_status_t efi_init_obj_list(void); /* Initialize variable services */ efi_status_t efi_init_variables(void); +/* Notify ExitBootServices() is called */ +void efi_variables_boot_exit_notify(void); /* Called by bootefi to initialize root node */ efi_status_t efi_root_node_register(void); /* Called by bootefi to initialize runtime */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index bf2df80c83..ba4c1e5765 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1968,7 +1968,8 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, /* Make sure that notification functions are not called anymore */ efi_tpl = TPL_HIGH_LEVEL; - /* TODO: Should persist EFI variables here */ + /* Notify variable services */ + efi_variables_boot_exit_notify(); board_quiesce_devices(); diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 702136ae0e..bc2a23afbb 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -408,15 +408,6 @@ static const struct efi_runtime_detach_list_struct efi_runtime_detach_list[] = { }, { .ptr = &efi_runtime_services.set_time, .patchto = &efi_set_time, - }, { - .ptr = &efi_runtime_services.get_variable, - .patchto = &efi_device_error, - }, { - .ptr = &efi_runtime_services.get_next_variable_name, - .patchto = &efi_device_error, - }, { - .ptr = &efi_runtime_services.set_variable, - .patchto = &efi_device_error, } }; diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 6210425f5e..bc8ed678c9 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -548,6 +548,50 @@ efi_status_t __efi_runtime EFIAPI efi_query_variable_info( return EFI_UNSUPPORTED; } +/** + * efi_get_variable_runtime() - runtime implementation of GetVariable() + */ +static efi_status_t __efi_runtime EFIAPI +efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *vendor, + u32 *attributes, efi_uintn_t *data_size, void *data) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_get_next_variable_name_runtime() - runtime implementation of + * GetNextVariable() + */ +static efi_status_t __efi_runtime EFIAPI +efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size, + u16 *variable_name, const efi_guid_t *vendor) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_set_variable_runtime() - runtime implementation of SetVariable() + */ +static efi_status_t __efi_runtime EFIAPI +efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor, + u32 attributes, efi_uintn_t data_size, + const void *data) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_variables_boot_exit_notify() - notify ExitBootServices() is called + */ +void efi_variables_boot_exit_notify(void) +{ + efi_runtime_services.get_variable = efi_get_variable_runtime; + efi_runtime_services.get_next_variable_name = + efi_get_next_variable_name_runtime; + efi_runtime_services.set_variable = efi_set_variable_runtime; + efi_update_table_header_crc32(&efi_runtime_services.hdr); +} + /** * efi_init_variables() - initialize variable services *