From f7679d437d5f27a3168f017db8d42bc561ac0c59 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Mon, 15 Apr 2024 12:42:13 -0500 Subject: [PATCH] refactor(smccc): move pmf to vendor el3 calls Move pmf support to vendor-specific EL3 Monitor Service Calls. Remove pmf call count as it's not supported in vendor-specific el3 as per SMCCC Documentation 1.5: https://developer.arm.com/documentation/den0028/latest Add a deprecation notice to inform PMF is moved from arm-sip range to vendor-specific EL3 range. PMF support from arm-sip range will be removed and will not available after TF-A 2.12 release. Change-Id: Ie1e14aa601d4fc3db352cd5621d842017a18e9ec Signed-off-by: Govindraj Raja --- docs/components/arm-sip-service.rst | 7 ------- docs/components/ven-el3-service.rst | 15 +++++++++++++-- include/lib/pmf/pmf.h | 25 ++++++++++++++++++------- include/plat/arm/common/arm_sip_svc.h | 1 + include/services/ven_el3_svc.h | 3 +++ lib/pmf/pmf_smc.c | 8 +++++--- plat/arm/common/arm_sip_svc.c | 7 +++++-- services/el3/ven_el3_svc.c | 20 ++++++++++++++++++++ 8 files changed, 65 insertions(+), 21 deletions(-) diff --git a/docs/components/arm-sip-service.rst b/docs/components/arm-sip-service.rst index 9bbedb0b7..4445fb18d 100644 --- a/docs/components/arm-sip-service.rst +++ b/docs/components/arm-sip-service.rst @@ -15,18 +15,11 @@ services: The Arm SiP implementation offers the following services: -- Performance Measurement Framework (PMF) - Execution State Switching service Source definitions for Arm SiP service are located in the ``arm_sip_svc.h`` header file. -Performance Measurement Framework (PMF) ---------------------------------------- - -The :ref:`Performance Measurement Framework ` -allows callers to retrieve timestamps captured at various paths in TF-A -execution. Execution State Switching service --------------------------------- diff --git a/docs/components/ven-el3-service.rst b/docs/components/ven-el3-service.rst index fc9f13cbf..fdafa58cd 100644 --- a/docs/components/ven-el3-service.rst +++ b/docs/components/ven-el3-service.rst @@ -24,15 +24,26 @@ Vendor-specific EL3 monitor services are as follows: +-----------------------------------+-----------------------+---------------------------------------------+ | SMC Function Identifier | Service Type | FID's Usage | +===================================+=======================+=============================================+ -| 0x87000010 - 0x8700001F (SMC32) | DebugFS Interface | | 0 - 11 are in use | -+-----------------------------------+ | | 12 - 15 are reserved for future expansion | +| 0x87000010 - 0x8700001F (SMC32) | DebugFS Interface | | 0 - 11 are in use. | ++-----------------------------------+ | | 12 - 15 are reserved for future expansion.| | 0xC7000010 - 0xC700001F (SMC64) | | | +-----------------------------------+-----------------------+---------------------------------------------+ +| 0x87000020 - 0x8700002F (SMC32) | Performance | | 0 is in use. | ++-----------------------------------+ Measurement Framework | | 1 - 15 are reserved for future expansion. | +| 0xC7000020 - 0xC700002F (SMC64) | (PMF) | | ++-----------------------------------+-----------------------+---------------------------------------------+ Source definitions for vendor-specific EL3 Monitor Service Calls are located in the ``ven_el3_svc.h`` header file. +Performance Measurement Framework (PMF) +--------------------------------------- + +The :ref:`Performance Measurement Framework ` +allows callers to retrieve timestamps captured at various paths in TF-A +execution. + DebugFS interface ----------------- diff --git a/include/lib/pmf/pmf.h b/include/lib/pmf/pmf.h index 9d901e202..89eeb2200 100644 --- a/include/lib/pmf/pmf.h +++ b/include/lib/pmf/pmf.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -36,19 +36,30 @@ #define PMF_NO_CACHE_MAINT U(0) /* - * Defines for PMF SMC function ids. + * Defines for PMF SMC function ids used with arm-sip + * range, this is now deprecated and will be removed. */ -#define PMF_SMC_GET_TIMESTAMP_32 U(0x82000010) -#define PMF_SMC_GET_TIMESTAMP_64 U(0xC2000010) +#define PMF_SMC_GET_TIMESTAMP_32_DEP U(0x82000010) +#define PMF_SMC_GET_TIMESTAMP_64_DEP U(0xC2000010) + +#define PMF_FID_VALUE_DEPRECATED U(0x10) +#define is_pmf_fid_deprecated(_fid) \ + (((_fid) & FUNCID_NUM_MASK) == PMF_FID_VALUE_DEPRECATED) + +/* + * Defines for PMF SMC function ids used with Vendor-Specific + * EL3 range. + */ +#define PMF_SMC_GET_TIMESTAMP_32 U(0x87000020) +#define PMF_SMC_GET_TIMESTAMP_64 U(0xC7000020) #define PMF_NUM_SMC_CALLS 2 /* * The macros below are used to identify * PMF calls from the SMC function ID. */ -#define PMF_FID_MASK U(0xffe0) -#define PMF_FID_VALUE U(0) -#define is_pmf_fid(_fid) (((_fid) & PMF_FID_MASK) == PMF_FID_VALUE) +#define PMF_FID_VALUE U(0x20) +#define is_pmf_fid(_fid) (((_fid) & FUNCID_NUM_MASK) == PMF_FID_VALUE) /* Following are the supported PMF service IDs */ #define PMF_PSCI_STAT_SVC_ID 0 diff --git a/include/plat/arm/common/arm_sip_svc.h b/include/plat/arm/common/arm_sip_svc.h index b3e41a757..bca224d5e 100644 --- a/include/plat/arm/common/arm_sip_svc.h +++ b/include/plat/arm/common/arm_sip_svc.h @@ -16,6 +16,7 @@ /* U(0x8200ff02) is reserved */ #define ARM_SIP_SVC_VERSION U(0x8200ff03) +/* Deprecated FID's Range and will be removed */ /* PMF_SMC_GET_TIMESTAMP_32 0x82000010 */ /* PMF_SMC_GET_TIMESTAMP_64 0xC2000010 */ diff --git a/include/services/ven_el3_svc.h b/include/services/ven_el3_svc.h index 5974a2b51..e030b68cc 100644 --- a/include/services/ven_el3_svc.h +++ b/include/services/ven_el3_svc.h @@ -26,4 +26,7 @@ /* DEBUGFS_SMC_32 0x87000010U */ /* DEBUGFS_SMC_64 0xC7000010U */ +/* PMF_SMC_GET_TIMESTAMP_32 0x87000020U */ +/* PMF_SMC_GET_TIMESTAMP_64 0xC7000020U */ + #endif /* VEN_EL3_SVC_H */ diff --git a/lib/pmf/pmf_smc.c b/lib/pmf/pmf_smc.c index f3dd11276..3c7c29884 100644 --- a/lib/pmf/pmf_smc.c +++ b/lib/pmf/pmf_smc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -36,7 +36,8 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid, x2 = (uint32_t)x2; x3 = (uint32_t)x3; - if (smc_fid == PMF_SMC_GET_TIMESTAMP_32) { + if (smc_fid == PMF_SMC_GET_TIMESTAMP_32 || + smc_fid == PMF_SMC_GET_TIMESTAMP_32_DEP) { /* * Return error code and the captured * time-stamp to the caller. @@ -49,7 +50,8 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid, (uint32_t)(ts_value >> 32)); } } else { - if (smc_fid == PMF_SMC_GET_TIMESTAMP_64) { + if (smc_fid == PMF_SMC_GET_TIMESTAMP_64 || + smc_fid == PMF_SMC_GET_TIMESTAMP_64_DEP) { /* * Return error code and the captured * time-stamp to the caller. diff --git a/plat/arm/common/arm_sip_svc.c b/plat/arm/common/arm_sip_svc.c index 02a7a03f2..18e9381ae 100644 --- a/plat/arm/common/arm_sip_svc.c +++ b/plat/arm/common/arm_sip_svc.c @@ -22,9 +22,11 @@ DEFINE_SVC_UUID2(arm_sip_svc_uid, static int arm_sip_setup(void) { +#if ENABLE_PMF if (pmf_setup() != 0) { return 1; } +#endif /* ENABLE_PMF */ #if USE_DEBUGFS @@ -60,12 +62,13 @@ static uintptr_t arm_sip_handler(unsigned int smc_fid, int call_count = 0; #if ENABLE_PMF - /* * Dispatch PMF calls to PMF SMC handler and return its return * value */ - if (is_pmf_fid(smc_fid)) { + if (is_pmf_fid_deprecated(smc_fid)) { + NOTICE("PMF Interface usage from arm-sip range is deprecated. \ + Please migrate smc call to Vendor-specific el3 range.\n"); return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle, flags); } diff --git a/services/el3/ven_el3_svc.c b/services/el3/ven_el3_svc.c index de003ae46..32a3dc273 100644 --- a/services/el3/ven_el3_svc.c +++ b/services/el3/ven_el3_svc.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -25,6 +26,12 @@ static int ven_el3_svc_setup(void) } #endif /* USE_DEBUGFS */ +#if ENABLE_PMF + if (pmf_setup() != 0) { + return 1; + } +#endif /* ENABLE_PMF */ + return 0; } @@ -51,6 +58,19 @@ static uintptr_t ven_el3_svc_handler(unsigned int smc_fid, } #endif /* USE_DEBUGFS */ +#if ENABLE_PMF + + /* + * Dispatch PMF calls to PMF SMC handler and return its return + * value + */ + if (is_pmf_fid(smc_fid)) { + return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie, + handle, flags); + } + +#endif /* ENABLE_PMF */ + switch (smc_fid) { case VEN_EL3_SVC_UID: /* Return UID to the caller */