Merge changes from topic "gr/smccc-updates" into integration

* changes:
  refactor(smccc): refactor vendor-el3 build
  refactor(docs): added versioning to smccc services
  feat((smccc): add version FID for PMF
  refactor(smccc): move pmf to vendor el3 calls
  refactor(smccc): move debugfs to vendor el3 calls
  feat(smccc): add vendor-specific el3 service
  feat(smccc): add vendor specific el3 id
This commit is contained in:
Manish V Badarkhe 2024-05-07 10:53:19 +02:00 committed by TrustedFirmware Code Review
commit 15dfbdfcae
15 changed files with 656 additions and 381 deletions

View file

@ -52,13 +52,17 @@ BL31_SOURCES += bl31/bl31_main.c \
${SPMC_SOURCES} \
${SPM_SOURCES}
VENDOR_EL3_SRCS += services/el3/ven_el3_svc.c
ifeq (${ENABLE_PMF}, 1)
BL31_SOURCES += lib/pmf/pmf_main.c
BL31_SOURCES += lib/pmf/pmf_main.c \
${VENDOR_EL3_SRCS}
endif
include lib/debugfs/debugfs.mk
ifeq (${USE_DEBUGFS},1)
BL31_SOURCES += $(DEBUGFS_SRCS)
BL31_SOURCES += ${DEBUGFS_SRCS} \
${VENDOR_EL3_SRCS}
endif
ifeq (${PLATFORM_REPORT_CTX_MEM_USE},1)

View file

@ -13,16 +13,17 @@ 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/std_svc/std_svc_setup.c \
${PSCI_LIB_SOURCES}
ifeq (${ENABLE_PMF}, 1)
BL32_SOURCES += lib/pmf/pmf_main.c
BL32_SOURCES += services/el3/ven_el3_svc.c \
lib/pmf/pmf_main.c
endif
ifneq (${ENABLE_FEAT_AMU},0)

View file

@ -15,19 +15,20 @@ services:
The Arm SiP implementation offers the following services:
- Performance Measurement Framework (PMF)
- Execution State Switching service
- DebugFS interface
Source definitions for Arm SiP service are located in the ``arm_sip_svc.h`` header
file.
Performance Measurement Framework (PMF)
---------------------------------------
+----------------------------+----------------------------+---------------------------------------+
| ARM_SIP_SVC_VERSION_MAJOR | ARM_SIP_SVC_VERSION_MINOR | Changes |
+============================+============================+=======================================+
| 1 | 0 | Move DebugFS and PMF to the new vendor|
| | | specific FID range. The old FID range |
| | | for these services are deprecated |
+----------------------------+----------------------------+---------------------------------------+
The :ref:`Performance Measurement Framework <firmware_design_pmf>`
allows callers to retrieve timestamps captured at various paths in TF-A
execution.
*Table 1: Showing different versions of arm-sip-service and changes done with each version*
Execution State Switching service
---------------------------------
@ -88,348 +89,8 @@ Instead, execution starts at the supplied entry point, with the CPU registers 0
and 1 populated with the supplied *Cookie hi* and *Cookie lo* values,
respectively.
DebugFS interface
-----------------
The optional DebugFS interface is accessed through an SMC SiP service. Refer
to the component documentation for details.
String parameters are passed through a shared buffer using a specific union:
.. code:: c
union debugfs_parms {
struct {
char fname[MAX_PATH_LEN];
} open;
struct mount {
char srv[MAX_PATH_LEN];
char where[MAX_PATH_LEN];
char spec[MAX_PATH_LEN];
} mount;
struct {
char path[MAX_PATH_LEN];
dir_t dir;
} stat;
struct {
char oldpath[MAX_PATH_LEN];
char newpath[MAX_PATH_LEN];
} bind;
};
Format of the dir_t structure as such:
.. code:: c
typedef struct {
char name[NAMELEN];
long length;
unsigned char mode;
unsigned char index;
unsigned char dev;
qid_t qid;
} dir_t;
* Identifiers
======================== =============================================
SMC_OK 0
SMC_UNK -1
DEBUGFS_E_INVALID_PARAMS -2
======================== =============================================
======================== =============================================
MOUNT 0
CREATE 1
OPEN 2
CLOSE 3
READ 4
WRITE 5
SEEK 6
BIND 7
STAT 8
INIT 10
VERSION 11
======================== =============================================
MOUNT
~~~~~
Description
^^^^^^^^^^^
This operation mounts a blob of data pointed to by path stored in `src`, at
filesystem location pointed to by path stored in `where`, using driver pointed
to by path in `spec`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``MOUNT``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if mount operation failed
=============== ==========================================================
OPEN
~~~~
Description
^^^^^^^^^^^
This operation opens the file path pointed to by `fname`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``OPEN``
uint32_t mode
======== ============================================================
mode can be one of:
.. code:: c
enum mode {
O_READ = 1 << 0,
O_WRITE = 1 << 1,
O_RDWR = 1 << 2,
O_BIND = 1 << 3,
O_DIR = 1 << 4,
O_STAT = 1 << 5
};
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if open operation failed
uint32_t w1: file descriptor id on success.
=============== ==========================================================
CLOSE
~~~~~
Description
^^^^^^^^^^^
This operation closes a file described by a file descriptor obtained by a
previous call to OPEN.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``CLOSE``
uint32_t File descriptor id returned by OPEN
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if close operation failed
=============== ==========================================================
READ
~~~~
Description
^^^^^^^^^^^
This operation reads a number of bytes from a file descriptor obtained by
a previous call to OPEN.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``READ``
uint32_t File descriptor id returned by OPEN
uint32_t Number of bytes to read
======== ============================================================
Return values
^^^^^^^^^^^^^
On success, the read data is retrieved from the shared buffer after the
operation.
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if read operation failed
uint32_t w1: number of bytes read on success.
=============== ==========================================================
SEEK
~~~~
Description
^^^^^^^^^^^
Move file pointer for file described by given `file descriptor` of given
`offset` related to `whence`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``SEEK``
uint32_t File descriptor id returned by OPEN
sint32_t offset in the file relative to whence
uint32_t whence
======== ============================================================
whence can be one of:
========= ============================================================
KSEEK_SET 0
KSEEK_CUR 1
KSEEK_END 2
========= ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if seek operation failed
=============== ==========================================================
BIND
~~~~
Description
^^^^^^^^^^^
Create a link from `oldpath` to `newpath`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``BIND``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if bind operation failed
=============== ==========================================================
STAT
~~~~
Description
^^^^^^^^^^^
Perform a stat operation on provided file `name` and returns the directory
entry statistics into `dir`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``STAT``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if stat operation failed
=============== ==========================================================
INIT
~~~~
Description
^^^^^^^^^^^
Initial call to setup the shared exchange buffer. Notice if successful once,
subsequent calls fail after a first initialization. The caller maps the same
page frame in its virtual space and uses this buffer to exchange string
parameters with filesystem primitives.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``INIT``
uint64_t Physical address of the shared buffer.
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ======================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if already initialized,
or internal error occurred.
=============== ======================================================
VERSION
~~~~~~~
Description
^^^^^^^^^^^
Returns the debugfs interface version if implemented in TF-A.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``VERSION``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ======================================================
int32_t w0 == SMC_OK on success
w0 == SMC_UNK if interface is not implemented
uint32_t w1: On success, debugfs interface version, 32 bits
value with major version number in upper 16 bits and
minor version in lower 16 bits.
=============== ======================================================
* CREATE(1) and WRITE (5) command identifiers are unimplemented and
return `SMC_UNK`.
--------------
*Copyright (c) 2017-2020, Arm Limited and Contributors. All rights reserved.*
*Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.*
.. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest

View file

@ -26,3 +26,5 @@ Components
realm-management-extension
rmm-el3-comms-spec
granule-protection-tables-design
ven-el3-service
ven-el3-debugfs

View file

@ -0,0 +1,343 @@
DebugFS interface
=================
The optional DebugFS interface is accessed through a Vendor specific EL3 service. Refer
to the component documentation for details.
String parameters are passed through a shared buffer using a specific union:
.. code:: c
union debugfs_parms {
struct {
char fname[MAX_PATH_LEN];
} open;
struct mount {
char srv[MAX_PATH_LEN];
char where[MAX_PATH_LEN];
char spec[MAX_PATH_LEN];
} mount;
struct {
char path[MAX_PATH_LEN];
dir_t dir;
} stat;
struct {
char oldpath[MAX_PATH_LEN];
char newpath[MAX_PATH_LEN];
} bind;
};
Format of the dir_t structure as such:
.. code:: c
typedef struct {
char name[NAMELEN];
long length;
unsigned char mode;
unsigned char index;
unsigned char dev;
qid_t qid;
} dir_t;
* Identifiers
======================== =============================================
SMC_OK 0
SMC_UNK -1
DEBUGFS_E_INVALID_PARAMS -2
======================== =============================================
======================== =============================================
MOUNT 0
CREATE 1
OPEN 2
CLOSE 3
READ 4
WRITE 5
SEEK 6
BIND 7
STAT 8
INIT 10
VERSION 11
======================== =============================================
MOUNT
~~~~~
Description
^^^^^^^^^^^
This operation mounts a blob of data pointed to by path stored in `src`, at
filesystem location pointed to by path stored in `where`, using driver pointed
to by path in `spec`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``MOUNT``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if mount operation failed
=============== ==========================================================
OPEN
~~~~
Description
^^^^^^^^^^^
This operation opens the file path pointed to by `fname`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``OPEN``
uint32_t mode
======== ============================================================
mode can be one of:
.. code:: c
enum mode {
O_READ = 1 << 0,
O_WRITE = 1 << 1,
O_RDWR = 1 << 2,
O_BIND = 1 << 3,
O_DIR = 1 << 4,
O_STAT = 1 << 5
};
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if open operation failed
uint32_t w1: file descriptor id on success.
=============== ==========================================================
CLOSE
~~~~~
Description
^^^^^^^^^^^
This operation closes a file described by a file descriptor obtained by a
previous call to OPEN.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``CLOSE``
uint32_t File descriptor id returned by OPEN
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if close operation failed
=============== ==========================================================
READ
~~~~
Description
^^^^^^^^^^^
This operation reads a number of bytes from a file descriptor obtained by
a previous call to OPEN.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``READ``
uint32_t File descriptor id returned by OPEN
uint32_t Number of bytes to read
======== ============================================================
Return values
^^^^^^^^^^^^^
On success, the read data is retrieved from the shared buffer after the
operation.
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if read operation failed
uint32_t w1: number of bytes read on success.
=============== ==========================================================
SEEK
~~~~
Description
^^^^^^^^^^^
Move file pointer for file described by given `file descriptor` of given
`offset` related to `whence`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``SEEK``
uint32_t File descriptor id returned by OPEN
sint32_t offset in the file relative to whence
uint32_t whence
======== ============================================================
whence can be one of:
========= ============================================================
KSEEK_SET 0
KSEEK_CUR 1
KSEEK_END 2
========= ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if seek operation failed
=============== ==========================================================
BIND
~~~~
Description
^^^^^^^^^^^
Create a link from `oldpath` to `newpath`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``BIND``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if bind operation failed
=============== ==========================================================
STAT
~~~~
Description
^^^^^^^^^^^
Perform a stat operation on provided file `name` and returns the directory
entry statistics into `dir`.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``STAT``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if stat operation failed
=============== ==========================================================
INIT
~~~~
Description
^^^^^^^^^^^
Initial call to setup the shared exchange buffer. Notice if successful once,
subsequent calls fail after a first initialization. The caller maps the same
page frame in its virtual space and uses this buffer to exchange string
parameters with filesystem primitives.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``INIT``
uint64_t Physical address of the shared buffer.
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ======================================================
int32_t w0 == SMC_OK on success
w0 == DEBUGFS_E_INVALID_PARAMS if already initialized,
or internal error occurred.
=============== ======================================================
VERSION
~~~~~~~
Description
^^^^^^^^^^^
Returns the debugfs interface version if implemented in TF-A.
Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x87000010 / 0xC7000010)
uint32_t ``VERSION``
======== ============================================================
Return values
^^^^^^^^^^^^^
=============== ======================================================
int32_t w0 == SMC_OK on success
w0 == SMC_UNK if interface is not implemented
uint32_t w1: On success, debugfs interface version, 32 bits
value with major version number in upper 16 bits and
minor version in lower 16 bits.
=============== ======================================================
* CREATE(1) and WRITE (5) command identifiers are unimplemented and
return `SMC_UNK`.
--------------
*Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.*

View file

@ -0,0 +1,78 @@
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 |
+---------------------------+--------------------------------------------------+
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.|
| 0xC7000010 - 0xC700001F (SMC64) | | |
+-----------------------------------+-----------------------+---------------------------------------------+
| 0x87000020 - 0x8700002F (SMC32) | Performance | | 0,1 is in use. |
+-----------------------------------+ Measurement Framework | | 2 - 15 are reserved for future expansion. |
| 0xC7000020 - 0xC700002F (SMC64) | (PMF) | |
+-----------------------------------+-----------------------+---------------------------------------------+
| 0x87000030 - 0x8700FFFF (SMC32) | Reserved | | reserved for future expansion |
+-----------------------------------+ | |
| 0xC7000030 - 0xC700FFFF (SMC64) | | |
+-----------------------------------+-----------------------+---------------------------------------------+
Source definitions for vendor-specific EL3 Monitor Service Calls used by TF-A are located in
the ``ven_el3_svc.h`` header file.
+----------------------------+----------------------------+--------------------------------+
| VEN_EL3_SVC_VERSION_MAJOR | VEN_EL3_SVC_VERSION_MINOR | Changes |
+============================+============================+================================+
| 1 | 0 | Added Debugfs and PMF services.|
+----------------------------+----------------------------+--------------------------------+
*Table 1: Showing different versions of Vendor-specific service and changes done with each version*
Each sub service will have its own version, one FID allocated for sub service version.
Some ground rules when one should update top level version.
- VEN_EL3_SVC_VERSION_MAJOR is incremented when any of the sub service version discovery
FID changes or the FID that was allocated for discovery changes. So any breaking subfeature
discovery changes will lead to major version update.
- VEN_EL3_SVC_VERSION_MINOR is incremented when we add a new FID or a new sub service.
For example adding an new monitor service at 0x30, Debugfs starts at 0x10 and PMF
starts at 0x20 next one will start at 0x30, this will need a update to minor version.
Performance Measurement Framework (PMF)
---------------------------------------
The :ref:`Performance Measurement Framework <firmware_design_pmf>`
allows callers to retrieve timestamps captured at various paths in TF-A
execution.
DebugFS interface
-----------------
The optional DebugFS interface is accessed through Vendor specific EL3 service. Refer
to :ref:`DebugFS interface` documentation for further details and usage.
--------------
*Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.*
.. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest

View file

@ -49,8 +49,11 @@ legacy 32-bit software that predates the `SMCCC`_.
Fast 1 CPU Service calls
Fast 2 SiP Service calls
Fast 3 OEM Service calls
Fast 4 Standard Service calls
Fast 5-47 Reserved for future use
Fast 4 Standard Secure Service calls
Fast 5 Standard Hypervisor Service Calls
Fast 6 Vendor Specific Hypervisor Service Calls
Fast 7 Vendor Specific EL3 Monitor Calls
Fast 8-47 Reserved for future use
Fast 48-49 Trusted Application calls
Fast 50-63 Trusted OS calls
@ -312,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-2023, Arm Limited and Contributors. All rights reserved.*
*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

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Arm Limited. All rights reserved.
* Copyright (c) 2019-2024, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -61,12 +61,24 @@ int debugfs_smc_setup(void);
/* Debugfs version returned through SMC interface */
#define DEBUGFS_VERSION (0x000000001U)
/* Function ID for accessing the debugfs interface */
#define DEBUGFS_FID_VALUE (0x30U)
/* Function ID for accessing the debugfs interface from
* Vendor-Specific EL3 Range.
*/
#define DEBUGFS_FID_VALUE (0x10U)
#define is_debugfs_fid(_fid) \
(((_fid) & FUNCID_NUM_MASK) == DEBUGFS_FID_VALUE)
/* Function ID for accessing the debugfs interface from arm sip.
* This is now deprecated FID and will be removed after 2.12 release.
*/
#define DEBUGFS_FID_VALUE_DEPRECATED (0x30U)
#define is_debugfs_fid_deprecated(_fid) \
(((_fid) & FUNCID_NUM_MASK) == DEBUGFS_FID_VALUE_DEPRECATED)
/* Error code for debugfs SMC interface failures */
#define DEBUGFS_E_INVALID_PARAMS (-2)
#define DEBUGFS_E_DENIED (-3)

View file

@ -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,35 @@
#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
#define PMF_SMC_GET_VERSION_32 U(0x87000021)
#define PMF_SMC_GET_VERSION_64 U(0xC7000021)
#define PMF_SMC_VERSION U(0x00000001)
/*
* 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

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -20,7 +20,7 @@
SMCCC_VERSION_MINOR_SHIFT))
#define SMCCC_MAJOR_VERSION U(1)
#define SMCCC_MINOR_VERSION U(4)
#define SMCCC_MINOR_VERSION U(5)
/*******************************************************************************
* Bit definitions inside the function id as per the SMC calling convention
@ -95,6 +95,8 @@
#define OEN_STD_HYP_END U(5)
#define OEN_VEN_HYP_START U(6) /* Vendor Hypervisor Service calls */
#define OEN_VEN_HYP_END U(6)
#define OEN_VEN_EL3_START U(7) /* Vendor Specific EL3 Monitor Calls */
#define OEN_VEN_EL3_END U(7)
#define OEN_TAP_START U(48) /* Trusted Applications */
#define OEN_TAP_END U(49)
#define OEN_TOS_START U(50) /* Trusted OS */

View file

@ -16,12 +16,14 @@
/* 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 */
/* Function ID for requesting state switch of lower EL */
#define ARM_SIP_SVC_EXE_STATE_SWITCH U(0x82000020)
/* Deprecated FID's Range and will be removed */
/* DEBUGFS_SMC_32 0x82000030U */
/* DEBUGFS_SMC_64 0xC2000030U */
@ -32,8 +34,8 @@
*/
/* ARM SiP Service Calls version numbers */
#define ARM_SIP_SVC_VERSION_MAJOR U(0x0)
#define ARM_SIP_SVC_VERSION_MINOR U(0x2)
#define ARM_SIP_SVC_VERSION_MAJOR U(0x1)
#define ARM_SIP_SVC_VERSION_MINOR U(0x0)
/*
* Arm SiP SMC calls that are primarily used for testing purposes.

View file

@ -0,0 +1,32 @@
/*
* 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
/* 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 */

View file

@ -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.
@ -48,8 +49,13 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
SMC_RET3(handle, rc, (uint32_t)ts_value,
(uint32_t)(ts_value >> 32));
}
if (smc_fid == PMF_SMC_GET_VERSION_32) {
SMC_RET2(handle, SMC_OK, PMF_SMC_VERSION);
}
} 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.
@ -60,6 +66,10 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
(unsigned int)x3, &ts_value);
SMC_RET2(handle, rc, ts_value);
}
if (smc_fid == PMF_SMC_GET_VERSION_64) {
SMC_RET2(handle, SMC_OK, PMF_SMC_VERSION);
}
}
WARN("Unimplemented PMF Call: 0x%x \n", smc_fid);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -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);
}
@ -73,8 +76,9 @@ static uintptr_t arm_sip_handler(unsigned int smc_fid,
#endif /* ENABLE_PMF */
#if USE_DEBUGFS
if (is_debugfs_fid(smc_fid)) {
if (is_debugfs_fid_deprecated(smc_fid)) {
NOTICE("Debugfs Interface usage from arm-sip range is deprecated. \
Please migrate smc call to vendor-specific el3 range.\n");
return debugfs_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
handle, flags);
}

View file

@ -0,0 +1,97 @@
/*
* 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 <lib/debugfs.h>
#include <lib/pmf/pmf.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)
{
#if USE_DEBUGFS
if (debugfs_smc_setup() != 0) {
return 1;
}
#endif /* USE_DEBUGFS */
#if ENABLE_PMF
if (pmf_setup() != 0) {
return 1;
}
#endif /* ENABLE_PMF */
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)
{
#if USE_DEBUGFS
/*
* Dispatch debugfs calls to debugfs SMC handler and return its
* return value.
*/
if (is_debugfs_fid(smc_fid)) {
return debugfs_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
handle, flags);
}
#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 */
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
);