fix(rme/fid): refactor RME fid macros

Refactored RME FID macros to simplify usage.

Signed-off-by: Subhasish Ghosh <subhasish.ghosh@arm.com>
Change-Id: I68f51f43d6c100d90069577412c2e495fe7b7e40
This commit is contained in:
Subhasish Ghosh 2022-05-12 12:22:17 +01:00 committed by Soby Mathew
parent 5e529e32ee
commit fb00dc4a7b
2 changed files with 47 additions and 50 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -10,17 +10,18 @@
#include <lib/smccc.h>
#include <lib/utils_def.h>
/* Construct RMM fastcall std FID from function number */
#define RMM_FID(smc_cc, func_num) \
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
((smc_cc) << FUNCID_CC_SHIFT) | \
(OEN_STD_START << FUNCID_OEN_SHIFT) | \
((func_num) << FUNCID_NUM_SHIFT))
/* The macros below are used to identify RMI calls from the SMC function ID */
/* STD calls FNUM Min/Max ranges */
#define RMI_FNUM_MIN_VALUE U(0x150)
#define RMI_FNUM_MAX_VALUE U(0x18F)
/* Construct RMI fastcall std FID from offset */
#define SMC64_RMI_FID(_offset) \
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
(SMC_64 << FUNCID_CC_SHIFT) | \
(OEN_STD_START << FUNCID_OEN_SHIFT) | \
(((RMI_FNUM_MIN_VALUE + (_offset)) & FUNCID_NUM_MASK) \
<< FUNCID_NUM_SHIFT))
#define is_rmi_fid(fid) __extension__ ({ \
__typeof__(fid) _fid = (fid); \
((GET_SMC_NUM(_fid) >= RMI_FNUM_MIN_VALUE) && \
@ -31,13 +32,13 @@
((_fid & 0x00FE0000) == 0U)); })
/*
* RMI_FNUM_REQ_COMPLETE is the only function in the RMI rnage that originates
* RMI_FNUM_REQ_COMPLETE is the only function in the RMI range that originates
* from the Realm world and is handled by the RMMD. The RMI functions are
* always invoked by the Normal world, forwarded by RMMD and handled by the
* RMM
* RMM.
*/
#define RMI_FNUM_REQ_COMPLETE U(0x18F)
#define RMMD_RMI_REQ_COMPLETE RMM_FID(SMC_64, RMI_FNUM_REQ_COMPLETE)
/* 0x18F */
#define RMMD_RMI_REQ_COMPLETE SMC64_RMI_FID(U(0x3F))
/* The SMC in the range 0x8400 0190 - 0x8400 01AF are reserved for RSIs.*/
@ -50,6 +51,14 @@
#define RMMD_EL3_FNUM_MIN_VALUE U(0x1B0)
#define RMMD_EL3_FNUM_MAX_VALUE U(0x1CF)
/* Construct RMM_EL3 fastcall std FID from offset */
#define SMC64_RMMD_EL3_FID(_offset) \
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
(SMC_64 << FUNCID_CC_SHIFT) | \
(OEN_STD_START << FUNCID_OEN_SHIFT) | \
(((RMMD_EL3_FNUM_MIN_VALUE + (_offset)) & FUNCID_NUM_MASK) \
<< FUNCID_NUM_SHIFT))
/* The macros below are used to identify GTSI calls from the SMC function ID */
#define is_rmmd_el3_fid(fid) __extension__ ({ \
__typeof__(fid) _fid = (fid); \
@ -60,14 +69,9 @@
(GET_SMC_OEN(_fid) == OEN_STD_START) && \
((_fid & 0x00FE0000) == 0U)); })
/* RMMD Service Function NUmbers */
#define GTSI_DELEGATE U(0x1B0)
#define GTSI_UNDELEGATE U(0x1B1)
#define ATTEST_GET_REALM_KEY U(0x1B2)
#define ATTEST_GET_PLAT_TOKEN U(0x1B3)
#define RMMD_GTSI_DELEGATE RMM_FID(SMC_64, GTSI_DELEGATE)
#define RMMD_GTSI_UNDELEGATE RMM_FID(SMC_64, GTSI_UNDELEGATE)
/* 0x1B0 - 0x1B1 */
#define RMMD_GTSI_DELEGATE SMC64_RMMD_EL3_FID(U(0))
#define RMMD_GTSI_UNDELEGATE SMC64_RMMD_EL3_FID(U(1))
/* Return error codes from RMM-EL3 SMCs */
#define RMMD_OK 0
@ -77,21 +81,6 @@
#define RMMD_ERR_INVAL -5
#define RMMD_ERR_UNK -6
/*
* Retrieve Platform token from EL3.
* The arguments to this SMC are :
* arg0 - Function ID.
* arg1 - Platform attestation token buffer Physical address. (The challenge
* object is passed in this buffer.)
* arg2 - Platform attestation token buffer size (in bytes).
* arg3 - Challenge object size (in bytes). It has be one of the defined SHA hash
* sizes.
* The return arguments are :
* ret0 - Status / error.
* ret1 - Size of the platform token if successful.
*/
#define RMMD_ATTEST_GET_PLAT_TOKEN RMM_FID(SMC_64, ATTEST_GET_PLAT_TOKEN)
/* Acceptable SHA sizes for Challenge object */
#define SHA256_DIGEST_SIZE 32U
#define SHA384_DIGEST_SIZE 48U
@ -110,7 +99,24 @@
* ret0 - Status / error.
* ret1 - Size of the realm attestation key if successful.
*/
#define RMMD_ATTEST_GET_REALM_KEY RMM_FID(SMC_64, ATTEST_GET_REALM_KEY)
/* 0x1B2 */
#define RMMD_ATTEST_GET_REALM_KEY SMC64_RMMD_EL3_FID(U(2))
/*
* Retrieve Platform token from EL3.
* The arguments to this SMC are :
* arg0 - Function ID.
* arg1 - Platform attestation token buffer Physical address. (The challenge
* object is passed in this buffer.)
* arg2 - Platform attestation token buffer size (in bytes).
* arg3 - Challenge object size (in bytes). It has to be one of the defined
* SHA hash sizes.
* The return arguments are :
* ret0 - Status / error.
* ret1 - Size of the platform token if successful.
*/
/* 0x1B3 */
#define RMMD_ATTEST_GET_PLAT_TOKEN SMC64_RMMD_EL3_FID(U(3))
/* ECC Curve types for attest key generation */
#define ATTEST_KEY_CURVE_ECC_SECP384R1 0

View file

@ -30,19 +30,10 @@ typedef struct trp_args {
#define write_trp_arg(args, offset, val) (((args)->regs[offset >> 3]) \
= val)
/* RMI handled by TRP */
#define RMI_FNUM_VERSION_REQ U(0x150)
#define RMI_FNUM_GRANULE_DELEGATE U(0x151)
#define RMI_FNUM_GRANULE_UNDELEGATE U(0x152)
#define RMI_RMM_REQ_VERSION RMM_FID(SMC_64, RMI_FNUM_VERSION_REQ)
#define RMI_RMM_GRANULE_DELEGATE RMM_FID(SMC_64, \
RMI_FNUM_GRANULE_DELEGATE)
#define RMI_RMM_GRANULE_UNDELEGATE RMM_FID(SMC_64, \
RMI_FNUM_GRANULE_UNDELEGATE)
/* RMI SMC64 FIDs handled by the TRP */
#define RMI_RMM_REQ_VERSION SMC64_RMI_FID(U(0))
#define RMI_RMM_GRANULE_DELEGATE SMC64_RMI_FID(U(1))
#define RMI_RMM_GRANULE_UNDELEGATE SMC64_RMI_FID(U(2))
/* Definitions for RMI VERSION */
#define RMI_ABI_VERSION_MAJOR U(0x0)