mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-24 13:55:56 +00:00
feat(drtm): add standard DRTM service
Added a dummy DRTM setup function and also, introduced DRTM SMCs handling as per DRTM spec [1]. Few basic SMCs are handled in this change such as ARM_DRTM_SVC_VERSION and ARM_DRTM_SVC_FEATURES that returns DRTM version and functions ids supported respectively, and others are dummy for now. [1]: https://developer.arm.com/documentation/den0113/latest Signed-off-by: Manish V Badarkhe <manish.badarkhe@arm.com> Signed-off-by: Lucian Paul-Trifu <lucian.paultrifu@gmail.com> Change-Id: I8c7afe920c78e064cbab2298f59e6837c70ba8ff
This commit is contained in:
parent
7b224f19f4
commit
e62748e3f1
6 changed files with 275 additions and 1 deletions
bl31
include
services/std_svc
|
@ -147,6 +147,10 @@ ifeq ($(FEATURE_DETECTION),1)
|
|||
BL31_SOURCES += common/feat_detect.c
|
||||
endif
|
||||
|
||||
ifeq (${DRTM_SUPPORT},1)
|
||||
BL31_SOURCES += services/std_svc/drtm/drtm_main.c
|
||||
endif
|
||||
|
||||
BL31_LINKERFILE := bl31/bl31.ld.S
|
||||
|
||||
# Flag used to indicate if Crash reporting via console should be included
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
@ -41,6 +41,8 @@
|
|||
#define FUNCID_NUM_MASK U(0xffff)
|
||||
#define FUNCID_NUM_WIDTH U(16)
|
||||
|
||||
#define FUNCID_MASK U(0xffffffff)
|
||||
|
||||
#define GET_SMC_NUM(id) (((id) >> FUNCID_NUM_SHIFT) & \
|
||||
FUNCID_NUM_MASK)
|
||||
#define GET_SMC_TYPE(id) (((id) >> FUNCID_TYPE_SHIFT) & \
|
||||
|
|
82
include/services/drtm_svc.h
Normal file
82
include/services/drtm_svc.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* DRTM service
|
||||
*
|
||||
* Authors:
|
||||
* Lucian Paul-Trifu <lucian.paultrifu@gmail.com>
|
||||
* Brian Nezvadovitz <brinez@microsoft.com> 2021-02-01
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ARM_DRTM_SVC_H
|
||||
#define ARM_DRTM_SVC_H
|
||||
|
||||
/*
|
||||
* SMC function IDs for DRTM Service
|
||||
* Upper word bits set: Fast call, SMC64, Standard Secure Svc. Call (OEN = 4)
|
||||
*/
|
||||
#define DRTM_FID(func_num) \
|
||||
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
|
||||
(SMC_64 << FUNCID_CC_SHIFT) | \
|
||||
(OEN_STD_START << FUNCID_OEN_SHIFT) | \
|
||||
((func_num) << FUNCID_NUM_SHIFT))
|
||||
|
||||
#define DRTM_FNUM_SVC_VERSION U(0x110)
|
||||
#define DRTM_FNUM_SVC_FEATURES U(0x111)
|
||||
#define DRTM_FNUM_SVC_UNPROTECT_MEM U(0x113)
|
||||
#define DRTM_FNUM_SVC_DYNAMIC_LAUNCH U(0x114)
|
||||
#define DRTM_FNUM_SVC_CLOSE_LOCALITY U(0x115)
|
||||
#define DRTM_FNUM_SVC_GET_ERROR U(0x116)
|
||||
#define DRTM_FNUM_SVC_SET_ERROR U(0x117)
|
||||
#define DRTM_FNUM_SVC_SET_TCB_HASH U(0x118)
|
||||
#define DRTM_FNUM_SVC_LOCK_TCB_HASH U(0x119)
|
||||
|
||||
#define ARM_DRTM_SVC_VERSION DRTM_FID(DRTM_FNUM_SVC_VERSION)
|
||||
#define ARM_DRTM_SVC_FEATURES DRTM_FID(DRTM_FNUM_SVC_FEATURES)
|
||||
#define ARM_DRTM_SVC_UNPROTECT_MEM DRTM_FID(DRTM_FNUM_SVC_UNPROTECT_MEM)
|
||||
#define ARM_DRTM_SVC_DYNAMIC_LAUNCH DRTM_FID(DRTM_FNUM_SVC_DYNAMIC_LAUNCH)
|
||||
#define ARM_DRTM_SVC_CLOSE_LOCALITY DRTM_FID(DRTM_FNUM_SVC_CLOSE_LOCALITY)
|
||||
#define ARM_DRTM_SVC_GET_ERROR DRTM_FID(DRTM_FNUM_SVC_GET_ERROR)
|
||||
#define ARM_DRTM_SVC_SET_ERROR DRTM_FID(DRTM_FNUM_SVC_SET_ERROR)
|
||||
#define ARM_DRTM_SVC_SET_TCB_HASH DRTM_FID(DRTM_FNUM_SVC_SET_TCB_HASH)
|
||||
#define ARM_DRTM_SVC_LOCK_TCB_HASH DRTM_FID(DRTM_FNUM_SVC_LOCK_TCB_HASH)
|
||||
|
||||
#define is_drtm_fid(_fid) \
|
||||
(((_fid) >= ARM_DRTM_SVC_VERSION) && ((_fid) <= ARM_DRTM_SVC_LOCK_TCB_HASH))
|
||||
|
||||
/* ARM DRTM Service Calls version numbers */
|
||||
#define ARM_DRTM_VERSION_MAJOR U(0)
|
||||
#define ARM_DRTM_VERSION_MAJOR_SHIFT 16
|
||||
#define ARM_DRTM_VERSION_MAJOR_MASK U(0x7FFF)
|
||||
#define ARM_DRTM_VERSION_MINOR U(1)
|
||||
#define ARM_DRTM_VERSION_MINOR_SHIFT 0
|
||||
#define ARM_DRTM_VERSION_MINOR_MASK U(0xFFFF)
|
||||
|
||||
#define ARM_DRTM_VERSION \
|
||||
((((ARM_DRTM_VERSION_MAJOR) & ARM_DRTM_VERSION_MAJOR_MASK) << \
|
||||
ARM_DRTM_VERSION_MAJOR_SHIFT) \
|
||||
| (((ARM_DRTM_VERSION_MINOR) & ARM_DRTM_VERSION_MINOR_MASK) << \
|
||||
ARM_DRTM_VERSION_MINOR_SHIFT))
|
||||
|
||||
#define ARM_DRTM_FUNC_SHIFT U(63)
|
||||
#define ARM_DRTM_FUNC_MASK U(0x1)
|
||||
#define ARM_DRTM_FUNC_ID U(0x0)
|
||||
#define ARM_DRTM_FEAT_ID U(0x1)
|
||||
|
||||
/* Initialization routine for the DRTM service */
|
||||
int drtm_setup(void);
|
||||
|
||||
/* Handler to be called to handle DRTM SMC calls */
|
||||
uint64_t drtm_smc_handler(uint32_t smc_fid,
|
||||
uint64_t x1,
|
||||
uint64_t x2,
|
||||
uint64_t x3,
|
||||
uint64_t x4,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
#endif /* ARM_DRTM_SVC_H */
|
148
services/std_svc/drtm/drtm_main.c
Normal file
148
services/std_svc/drtm/drtm_main.c
Normal file
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* DRTM service
|
||||
*
|
||||
* Authors:
|
||||
* Lucian Paul-Trifu <lucian.paultrifu@gmail.com>
|
||||
* Brian Nezvadovitz <brinez@microsoft.com> 2021-02-01
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <common/runtime_svc.h>
|
||||
#include "drtm_main.h"
|
||||
#include <services/drtm_svc.h>
|
||||
|
||||
int drtm_setup(void)
|
||||
{
|
||||
INFO("DRTM service setup\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t drtm_smc_handler(uint32_t smc_fid,
|
||||
uint64_t x1,
|
||||
uint64_t x2,
|
||||
uint64_t x3,
|
||||
uint64_t x4,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags)
|
||||
{
|
||||
/* Check that the SMC call is from the Normal World. */
|
||||
if (!is_caller_non_secure(flags)) {
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
switch (smc_fid) {
|
||||
case ARM_DRTM_SVC_VERSION:
|
||||
INFO("DRTM service handler: version\n");
|
||||
/* Return the version of current implementation */
|
||||
SMC_RET1(handle, ARM_DRTM_VERSION);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_FEATURES:
|
||||
if (((x1 >> ARM_DRTM_FUNC_SHIFT) & ARM_DRTM_FUNC_MASK) ==
|
||||
ARM_DRTM_FUNC_ID) {
|
||||
/* Dispatch function-based queries. */
|
||||
switch (x1 & FUNCID_MASK) {
|
||||
case ARM_DRTM_SVC_VERSION:
|
||||
SMC_RET1(handle, SUCCESS);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_FEATURES:
|
||||
SMC_RET1(handle, SUCCESS);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_UNPROTECT_MEM:
|
||||
SMC_RET1(handle, SUCCESS);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_DYNAMIC_LAUNCH:
|
||||
SMC_RET1(handle, SUCCESS);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_CLOSE_LOCALITY:
|
||||
WARN("ARM_DRTM_SVC_CLOSE_LOCALITY feature %s",
|
||||
"is not supported\n");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_GET_ERROR:
|
||||
SMC_RET1(handle, SUCCESS);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_SET_ERROR:
|
||||
SMC_RET1(handle, SUCCESS);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_SET_TCB_HASH:
|
||||
WARN("ARM_DRTM_SVC_TCB_HASH feature %s",
|
||||
"is not supported\n");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_LOCK_TCB_HASH:
|
||||
WARN("ARM_DRTM_SVC_LOCK_TCB_HASH feature %s",
|
||||
"is not supported\n");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
|
||||
default:
|
||||
ERROR("Unknown DRTM service function\n");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
}
|
||||
}
|
||||
|
||||
case ARM_DRTM_SVC_UNPROTECT_MEM:
|
||||
INFO("DRTM service handler: unprotect mem\n");
|
||||
SMC_RET1(handle, SMC_OK);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_DYNAMIC_LAUNCH:
|
||||
INFO("DRTM service handler: dynamic launch\n");
|
||||
SMC_RET1(handle, SMC_OK);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_CLOSE_LOCALITY:
|
||||
WARN("DRTM service handler: close locality %s\n",
|
||||
"is not supported");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_GET_ERROR:
|
||||
INFO("DRTM service handler: get error\n");
|
||||
SMC_RET2(handle, SMC_OK, 0);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_SET_ERROR:
|
||||
INFO("DRTM service handler: set error\n");
|
||||
SMC_RET1(handle, SMC_OK);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_SET_TCB_HASH:
|
||||
WARN("DRTM service handler: set TCB hash %s\n",
|
||||
"is not supported");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
|
||||
case ARM_DRTM_SVC_LOCK_TCB_HASH:
|
||||
WARN("DRTM service handler: lock TCB hash %s\n",
|
||||
"is not supported");
|
||||
SMC_RET1(handle, NOT_SUPPORTED);
|
||||
break; /* not reached */
|
||||
|
||||
default:
|
||||
ERROR("Unknown DRTM service function: 0x%x\n", smc_fid);
|
||||
SMC_RET1(handle, SMC_UNK);
|
||||
break; /* not reached */
|
||||
}
|
||||
|
||||
/* not reached */
|
||||
SMC_RET1(handle, SMC_UNK);
|
||||
}
|
24
services/std_svc/drtm/drtm_main.h
Normal file
24
services/std_svc/drtm/drtm_main.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
#ifndef DRTM_MAIN_H
|
||||
#define DRTM_MAIN_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <lib/smccc.h>
|
||||
|
||||
enum drtm_retc {
|
||||
SUCCESS = SMC_OK,
|
||||
NOT_SUPPORTED = SMC_UNK,
|
||||
INVALID_PARAMETERS = -2,
|
||||
DENIED = -3,
|
||||
NOT_FOUND = -4,
|
||||
INTERNAL_ERROR = -5,
|
||||
MEM_PROTECT_INVALID = -6,
|
||||
};
|
||||
|
||||
#endif /* DRTM_MAIN_H */
|
|
@ -13,6 +13,7 @@
|
|||
#include <lib/pmf/pmf.h>
|
||||
#include <lib/psci/psci.h>
|
||||
#include <lib/runtime_instr.h>
|
||||
#include <services/drtm_svc.h>
|
||||
#include <services/pci_svc.h>
|
||||
#include <services/rmmd_svc.h>
|
||||
#include <services/sdei.h>
|
||||
|
@ -75,6 +76,12 @@ static int32_t std_svc_setup(void)
|
|||
|
||||
trng_setup();
|
||||
|
||||
#if DRTM_SUPPORT
|
||||
if (drtm_setup() != 0) {
|
||||
ret = 1;
|
||||
}
|
||||
#endif /* DRTM_SUPPORT */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -186,6 +193,13 @@ static uintptr_t std_svc_smc_handler(uint32_t smc_fid,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if DRTM_SUPPORT
|
||||
if (is_drtm_fid(smc_fid)) {
|
||||
return drtm_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle,
|
||||
flags);
|
||||
}
|
||||
#endif /* DRTM_SUPPORT */
|
||||
|
||||
switch (smc_fid) {
|
||||
case ARM_STD_SVC_CALL_COUNT:
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue