From patchwork Fri Jun 14 05:56:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1115723 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="dR2O7TGS"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45Q93K5shXz9sBr for ; Fri, 14 Jun 2019 16:01:31 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 34349C22306; Fri, 14 Jun 2019 06:01:28 +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 5C662C21E9F; Fri, 14 Jun 2019 06:01:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9B24C21E9F; Fri, 14 Jun 2019 06:01:24 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lists.denx.de (Postfix) with ESMTPS id 8692CC21EC9 for ; Fri, 14 Jun 2019 06:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1560492081; bh=hlRm3kXD5eBB8YkguH4ZB/BPd69iTx3PgH0uASDV6P4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=dR2O7TGSsSLi0snaSwINYAknikJCmGBtCVggNGu58u9voI4wLgM3hL+mj6kvLKKNu t66kfFqPunSp9HZVlO0e+kvKxsUSS0PpVZh9JB+f7+I1dO8Sb9eppACSoIQEdyhNep 8IminmnoUbdT5fEWHn2SmSHo1/35CF7BVINKyKcA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([84.118.159.3]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MRoRF-1i41w53yIr-00SxWF; Fri, 14 Jun 2019 07:56:13 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Fri, 14 Jun 2019 07:56:03 +0200 Message-Id: <20190614055604.4059-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:1T+l7GeBKy5cV8qg82R5k28yBHgZuBf5BheEg5Gm6yOjgalDBXU gBgSjrhfciR8E7a/rYYGR6ScvJyvKJqzthWnw1+OIM5F4+NL3gxg5u+YKXnMwIjbdtXxw6g XW2kOU4s3KmhFNt75KimHykMH0Wukajmcqvm6+PKi54uXWwvtcR8oGY2u85nesrdxD6wqsu 0sbPgqYXe8jY5UTlT6fVQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:DHv0cvdXYlE=:oK6Hk4Rlv0619gYLDUzHDv XQZKn2TTgd0VstsUU6JeEiD/vB3v3qn+H6qBzfvZ0fD2rCSaUlEvdEhDKAmozGvyNUdgPGIdz 0A80Ft3NTrLJe0/QAHqIgl+G4plZ+aCgsA55sWImv+uYp5cXuPBcv+rllHGV13SKbe83104Ph Gb/sxdL5aDPc7E5cpfvc8D4nTJ5OIkBpC8z0prhCBSeermRS6lv0VkiWsiWloaKlzGIxUe2oF ufi8ljbex08lKqBygCsycNxkAUP028r3tUoJuxqBPnYoeZeDZWDWAXhylKC1F/LFLRjf4mhc8 8m2pYOkkGcGs5GWFBGTZWeZAfnanqpEOf7khAaZDz9tgBo3jmDHMG+26EQpSW1FivYlk6m93/ YfdqsUoeJkxajUKRj8hfH7zLwUjRRPkyVw1Lp70VJPJYKGoubeSp2089/oO51+lMYN3uHnOla W3u15xWw9imAlYMnTxWWinEEsaohKraMpf0mSkp0prZynqNPU/xNNDD1S7aOpRR9aOykpy30P mcBxHT4dvFDGhj1Mb7D2SDzD8oxYwEXbVnCBhn9YVphilScwGQLyIc0ly6v01wp6ucRZFdN+0 lhwERPk6ZFcgTSxujjOJbR3rbO1YL3TzmXh3dh2gMcZXOvrtOr8nkS8dHRxQaR/RJl6+crXDp ZAFuAb2ArlQf9rG+czadbXzPcLAfCRFS7yoLzs5s5MgoHuPtubxFuirRhiOtyrlhyOQb3xL/e ASr7wjUmWWGGdbtACz/Bec3SzlHHAcM8fb+QhyXiBndEJLavuSQxYkFBt9sF+ejkYfr2V98St Hc3cuIe4J3iQlqUJN8e69Sr35eIGVHn2mQngKBcHfxVZNOcWkfk0vE8dFUlkRypVWQKrOCC1F 1+Vujg3i2Ei/pSG2GOlM6ecY8eoEn2Q1fL3TQs5HgEdO7XbOPD70VxUpcztwmJDnflUwYu7sb ADBMNFwxSW4UcCpvXfyNBZXPmEXAAfX8= Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 1/1] efi: 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 --- 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..6621b9eeae 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(CONFIG_ARCH_BCM283X) || \ + CONFIG_IS_ENABLED(CONFIG_FSL_LAYERSCAPE) || \ + CONFIG_IS_ENABLED(CONFIG_SYSRESET_X86) || \ + CONFIG_IS_ENABLED(CONFIG_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)