From patchwork Fri Jun 14 16:30:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1116136 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="ckV4vA0v"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45QRJM5p17z9sDX for ; Sat, 15 Jun 2019 02:43:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4A700C21F20; Fri, 14 Jun 2019 16:43:40 +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 4D95BC21F9B; Fri, 14 Jun 2019 16:43:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B545EC21F9B; Fri, 14 Jun 2019 16:43:37 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 698E7C21F20 for ; Fri, 14 Jun 2019 16:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1560530617; bh=NDIN/CzN/xwgD54+7ufBbfpVFm8TJIMYFFwkqIpfQlo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=ckV4vA0vhp7YbLsqgEn8iwxVHnbzgJ7l8PdDtEu92v0ZD3V6M3KRP1oN2lwdsJ9OE Q7Iitu7uOvC1maEh2WG6BxhNfAboVtFsoQPmMEcJb0Q+1GtzLWxQ/vV6p9pEI0HKP5 cuy5aIvxXI2aK36JrCDSpYgnPPPMiHxLCIFnFFu8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([84.118.159.3]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MgHHO-1hyK3o3vle-00NgRo; Fri, 14 Jun 2019 18:30:51 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Fri, 14 Jun 2019 18:30:38 +0200 Message-Id: <20190614163038.16029-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:FB08t5kDY7GkeAdPDaw8/7Z5K+JrJoQXvVcjopvO6/KMIzfnEsI L/uLLnf9CiWuzN/3FnVxN/mtIvPLzOj6ciKbkPMOq3eXMbTkIIDBPuIZtAndHKN56OR1qsw oTSx4mrQMoOpTKNlLUSANUNlcoY96aINemyO5GAEmcKfcY7GMlGpqQsNn3Y/ZkTEadWt7LK xjidWyNbrHcqT90tuk/9A== X-UI-Out-Filterresults: notjunk:1; V03:K0:5WkvsB2BPfg=:2B13HE6JEQHYq4ujIeyPbd KXYz/vFizF9y3n33EtZtkGE74Kf+dYXK/q5fduuiFrZzRcVvmE34xvFV/7QSJUmXBNUqQTpoF uZKiNqbYzkHnwHYKog72rNE8Xs0lHrydMrPXoKK8+QTbsVIFzxa6WIkpGO+UL3XCjohwUL6up NkF91cqUd1+NyUViD3upzS471pabL+t40JJxLaCXrg++pCQjcX/GkYew95i3a6DEGNZ3CVzjZ iz3QMGHZc16IKuVA79Fvzi3sv0DKn1Q0CHjAVEOlGqrTgcYRALAaaAY2Iii3NKuLdBeGwCXDe r6QzZhalQ084PLOecYyMMYfYYZbDiiD/cjYf6JHqZgPbAwatMxiwbP6+p1BCJLrF74wrnLDwJ bLl/wMT4YKT34+2ud7nq4KPw0yA+ztUrdwOp6aAQxbqlW3+oRIoomwPFefo7cDedS7WdGeNa4 wUKP4HRuGdKVb/SYunWIkwW3FmUmnEnFzXhrDWy/Dw2YK2ylnOSU9TJ+v5vDy6oGZlIySyqtS 2TjbAyezGBAIj7AjkAayk/5zaNAScqp0UY8wa2A2qN0/sCQhtAZwhEXfWAmQ2CTtOeG5cWzlN i4AcqPziPr82spZLm623k9WISjuSj6VvTDuaNZRJe8l35MoDBwqrFLxwh61O67n2C5VY6saoj RX3H3etQ4tOdyxqXjl7VRkdVZdK4G4qmLppE8ssSFzWPkvQQh1E8UB3blgbhm8SsFVxprreer jMRvim9UZHtddp3dRvT1e88FlQqaSNrFis3++ZEc4iZvGRJ+i09E1RfRz5WGg7G96ZHXlnaPo cw1zA8/tpqEC1T4hzPA2dUQQcWNXzH+jMxFowBlfWWG9AwKTrJ0OW2WqtgqNDVmtJWTVZbW44 wCRC7kaeXg6nZtm4rEITwj8FL24+eR0CHh0ljNhqRSWECfcslIx6gYvwkMyv6SXgzxYvtGg0J WlT/M65IoxPMrwx1jGjOKWLxi5Nai5xKmSMbOVhCDJNsDSfiQaaES Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v4 1/1] efi_loader: add RuntimeServicesSupported variable 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" From: AKASHI Takahiro This variable is defined in UEFI specification 2.8, section 8.1. Its value should be updated whenever we add any usable runtime services function. Currently we only support SetVirtualAddress() for all systems and ResetSystem() for some. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- v4 CONFIG_IS_ENABLED() wants Kconfig variables without CONFIG_ prefix. v3 Ensure that efi_runtime_services_supported is initialized. v2 Currently we only support SetVirtualAddress() for all systems and ResetSystem() for some. --- include/efi_api.h | 15 +++++++++++++++ include/efi_loader.h | 3 +++ lib/efi_loader/efi_runtime.c | 24 ++++++++++++++++++++++++ lib/efi_loader/efi_setup.c | 5 +++++ 4 files changed, 47 insertions(+) -- 2.20.1 diff --git a/include/efi_api.h b/include/efi_api.h index 65584dd2d8..d7d95edd4d 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -213,6 +213,21 @@ struct efi_capsule_header { u32 capsule_image_size; }; +#define EFI_RT_SUPPORTED_GET_TIME 0x0001 +#define EFI_RT_SUPPORTED_SET_TIME 0x0002 +#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004 +#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME 0x0008 +#define EFI_RT_SUPPORTED_GET_VARIABLE 0x0010 +#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME 0x0020 +#define EFI_RT_SUPPORTED_SET_VARIABLE 0x0040 +#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP 0x0080 +#define EFI_RT_SUPPORTED_CONVERT_POINTER 0x0100 +#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT 0x0200 +#define EFI_RT_SUPPORTED_RESET_SYSTEM 0x0400 +#define EFI_RT_SUPPORTED_UPDATE_CAPSULE 0x0800 +#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES 0x1000 +#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO 0x2000 + struct efi_runtime_services { struct efi_table_hdr hdr; efi_status_t (EFIAPI *get_time)(struct efi_time *time, diff --git a/include/efi_loader.h b/include/efi_loader.h index f0e1313f93..b07155cecb 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -573,6 +573,9 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) #define __efi_runtime_data __attribute__ ((section (".data.efi_runtime"))) #define __efi_runtime __attribute__ ((section (".text.efi_runtime"))) +/* Indicate supported runtime services */ +efi_status_t efi_init_runtime_supported(void); + /* Update CRC32 in table header */ void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table); diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 432551d0c8..0c57d0abd7 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -89,6 +89,30 @@ struct elf_rela { * handle a good number of runtime callbacks */ +efi_status_t efi_init_runtime_supported(void) +{ + u16 efi_runtime_services_supported = 0; + + /* + * This value must be synced with efi_runtime_detach_list + * as well as efi_runtime_services. + */ +#if CONFIG_IS_ENABLED(ARCH_BCM283X) || \ + CONFIG_IS_ENABLED(FSL_LAYERSCAPE) || \ + CONFIG_IS_ENABLED(SYSRESET_X86) || \ + CONFIG_IS_ENABLED(PSCI_RESET) + efi_runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM; +#endif + efi_runtime_services_supported |= + EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP; + return EFI_CALL(efi_set_variable(L"RuntimeServicesSupported", + &efi_global_variable_guid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(efi_runtime_services_supported), + &efi_runtime_services_supported)); +} + /** * efi_update_table_header_crc32() - Update crc32 in table header * diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index 8691d686d2..bfb57836fa 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -117,6 +117,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* Indicate supported runtime services */ + ret = efi_init_runtime_supported(); + if (ret != EFI_SUCCESS) + goto out; + /* Initialize system table */ ret = efi_initialize_system_table(); if (ret != EFI_SUCCESS)