From de6b79d8b5e15262b328051095e15ad4c67518eb Mon Sep 17 00:00:00 2001 From: Govindraj Raja <govindraj.raja@arm.com> Date: Fri, 23 Feb 2024 16:50:52 -0600 Subject: [PATCH] feat(smccc): add vendor-specific el3 service Add support for vendor-specific el3 service. SMCCC 1.5 introduces support for vendor-specific EL3 monitor calls. SMCCC Documentation reference: https://developer.arm.com/docs/den0028/latest Change-Id: Id8bc43842eecdb7a8a2ec7f31a631e88fe4fe0b4 Signed-off-by: Govindraj Raja <govindraj.raja@arm.com> --- bl31/bl31.mk | 1 + bl32/sp_min/sp_min.mk | 11 ++-- docs/components/index.rst | 1 + docs/components/ven-el3-service.rst | 29 +++++++++ docs/getting_started/rt-svc-writers-guide.rst | 8 +++ include/services/ven_el3_svc.h | 26 ++++++++ services/el3/ven_el3_svc.c | 59 +++++++++++++++++++ 7 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 docs/components/ven-el3-service.rst create mode 100644 include/services/ven_el3_svc.h create mode 100644 services/el3/ven_el3_svc.c diff --git a/bl31/bl31.mk b/bl31/bl31.mk index cd61d017e..8dde8cb54 100644 --- a/bl31/bl31.mk +++ b/bl31/bl31.mk @@ -45,6 +45,7 @@ BL31_SOURCES += bl31/bl31_main.c \ lib/cpus/aarch64/dsu_helpers.S \ plat/common/aarch64/platform_mp_stack.S \ services/arm_arch_svc/arm_arch_svc_setup.c \ + services/el3/ven_el3_svc.c \ services/std_svc/std_svc_setup.c \ ${PSCI_LIB_SOURCES} \ ${SPMD_SOURCES} \ diff --git a/bl32/sp_min/sp_min.mk b/bl32/sp_min/sp_min.mk index 427e39b3b..8f2cac742 100644 --- a/bl32/sp_min/sp_min.mk +++ b/bl32/sp_min/sp_min.mk @@ -13,12 +13,13 @@ include lib/psci/psci_lib.mk INCLUDES += -Iinclude/bl32/sp_min -BL32_SOURCES += bl32/sp_min/sp_min_main.c \ - bl32/sp_min/aarch32/entrypoint.S \ - common/runtime_svc.c \ - plat/common/aarch32/plat_sp_min_common.c\ +BL32_SOURCES += bl32/sp_min/sp_min_main.c \ + bl32/sp_min/aarch32/entrypoint.S \ + common/runtime_svc.c \ + plat/common/aarch32/plat_sp_min_common.c \ services/arm_arch_svc/arm_arch_svc_setup.c \ - services/std_svc/std_svc_setup.c \ + services/el3/ven_el3_svc.c \ + services/std_svc/std_svc_setup.c \ ${PSCI_LIB_SOURCES} ifeq (${ENABLE_PMF}, 1) diff --git a/docs/components/index.rst b/docs/components/index.rst index 30d80fcdd..36ab6fa1f 100644 --- a/docs/components/index.rst +++ b/docs/components/index.rst @@ -26,3 +26,4 @@ Components realm-management-extension rmm-el3-comms-spec granule-protection-tables-design + ven-el3-service diff --git a/docs/components/ven-el3-service.rst b/docs/components/ven-el3-service.rst new file mode 100644 index 000000000..fe8384553 --- /dev/null +++ b/docs/components/ven-el3-service.rst @@ -0,0 +1,29 @@ +Vendor Specific EL3 Monitor Service Calls +========================================= + +This document enumerates and describes the Vendor Specific EL3 Monitor Service +Calls. + +These are Service Calls defined by the vendor of the EL3 Monitor. +They are accessed via ``SMC`` ("SMC calls") instruction executed from Exception +Levels below EL3. SMC calls for Vendor Specific EL3 Monitor Services: + +- Follow `SMC Calling Convention`_; +- Use SMC function IDs that fall in the vendor-specific EL3 range, which are + ++---------------------------+--------------------------------------------------+ +| SMC Function Identifier | Service Type | ++===========================+==================================================+ +| 0x87000000 - 0x8700FFFF | SMC32: Vendor Specific EL3 Monitor Service Calls | ++---------------------------+--------------------------------------------------+ +| 0xC7000000 - 0xC700FFFF | SMC64: Vendor Specific EL3 Monitor Service Calls | ++---------------------------+--------------------------------------------------+ + +Source definitions for vendor-specific EL3 Monitor Service Calls are located in +the ``ven_el3_svc.h`` header file. + +-------------- + +*Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.* + +.. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest diff --git a/docs/getting_started/rt-svc-writers-guide.rst b/docs/getting_started/rt-svc-writers-guide.rst index 2383ceee0..4d4ec22fe 100644 --- a/docs/getting_started/rt-svc-writers-guide.rst +++ b/docs/getting_started/rt-svc-writers-guide.rst @@ -315,9 +315,17 @@ TODO: Provide details of the additional work required to implement a SPD and the BL31 support for these services. Or a reference to the document that will provide this information.... +Additional References: +---------------------- + +#. :ref:`ARM SiP Services <arm sip services>` +#. :ref:`Vendor Specific EL3 Monitor Service Calls` + -------------- *Copyright (c) 2014-2024, Arm Limited and Contributors. All rights reserved.* .. _SMCCC: https://developer.arm.com/docs/den0028/latest .. _PSCI: https://developer.arm.com/documentation/den0022/latest/ +.. _ARM SiP Services: arm-sip-service.rst +.. _Vendor Specific EL3 Monitor Service Calls: ven-el3-service.rst diff --git a/include/services/ven_el3_svc.h b/include/services/ven_el3_svc.h new file mode 100644 index 000000000..505e4fd9b --- /dev/null +++ b/include/services/ven_el3_svc.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef VEN_EL3_SVC_H +#define VEN_EL3_SVC_H + +/* + * Function Identifier value ranges for Vendor-Specific + * EL3 Monitor Service Calls. + */ +/* VEN_EL3_SMC_32 0x87000000U */ +/* VEN_EL3_SMC_64 0xC7000000U */ + + +/* Function Identifier values of general queries */ +#define VEN_EL3_SVC_UID 0x8700ff01 +/* 0x8700ff02 is reserved */ +#define VEN_EL3_SVC_VERSION 0x8700ff03 + +#define VEN_EL3_SVC_VERSION_MAJOR 1 +#define VEN_EL3_SVC_VERSION_MINOR 0 + +#endif /* VEN_EL3_SVC_H */ diff --git a/services/el3/ven_el3_svc.c b/services/el3/ven_el3_svc.c new file mode 100644 index 000000000..327878ffd --- /dev/null +++ b/services/el3/ven_el3_svc.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <stdint.h> + +#include <common/debug.h> +#include <common/runtime_svc.h> +#include <services/ven_el3_svc.h> +#include <tools_share/uuid.h> + +/* vendor-specific EL3 UUID */ +DEFINE_SVC_UUID2(ven_el3_svc_uid, + 0xb6011dca, 0x57c4, 0x407e, 0x83, 0xf0, + 0xa7, 0xed, 0xda, 0xf0, 0xdf, 0x6c); + +static int ven_el3_svc_setup(void) +{ + return 0; +} + +/* + * This function handles Arm defined vendor-specific EL3 Service Calls. + */ +static uintptr_t ven_el3_svc_handler(unsigned int smc_fid, + u_register_t x1, + u_register_t x2, + u_register_t x3, + u_register_t x4, + void *cookie, + void *handle, + u_register_t flags) +{ + switch (smc_fid) { + case VEN_EL3_SVC_UID: + /* Return UID to the caller */ + SMC_UUID_RET(handle, ven_el3_svc_uid); + break; + case VEN_EL3_SVC_VERSION: + SMC_RET2(handle, VEN_EL3_SVC_VERSION_MAJOR, VEN_EL3_SVC_VERSION_MINOR); + break; + default: + WARN("Unimplemented Vendor specific EL3 Service call: 0x%x\n", smc_fid); + SMC_RET1(handle, SMC_UNK); + break; + } +} + +/* Define a runtime service descriptor for fast SMC calls */ +DECLARE_RT_SVC( + ven_el3_svc, + OEN_VEN_EL3_START, + OEN_VEN_EL3_END, + SMC_TYPE_FAST, + ven_el3_svc_setup, + ven_el3_svc_handler +);