2018-01-19 16:58:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <arm_arch_svc.h>
|
|
|
|
#include <debug.h>
|
2018-03-12 14:47:09 +00:00
|
|
|
#include <errata_report.h>
|
2018-01-19 16:58:29 +00:00
|
|
|
#include <runtime_svc.h>
|
2018-03-21 10:49:27 +00:00
|
|
|
#include <smccc.h>
|
|
|
|
#include <smccc_helpers.h>
|
2018-03-12 14:47:09 +00:00
|
|
|
#include <workaround_cve_2017_5715.h>
|
2018-01-19 16:58:29 +00:00
|
|
|
|
|
|
|
static int32_t smccc_version(void)
|
|
|
|
{
|
|
|
|
return MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION, SMCCC_MINOR_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t smccc_arch_features(u_register_t arg)
|
|
|
|
{
|
|
|
|
switch (arg) {
|
|
|
|
case SMCCC_VERSION:
|
|
|
|
case SMCCC_ARCH_FEATURES:
|
|
|
|
return SMC_OK;
|
2018-03-28 12:06:40 +01:00
|
|
|
#if WORKAROUND_CVE_2017_5715
|
2018-01-19 16:58:29 +00:00
|
|
|
case SMCCC_ARCH_WORKAROUND_1:
|
2018-03-28 12:06:40 +01:00
|
|
|
if (check_workaround_cve_2017_5715() == ERRATA_NOT_APPLIES)
|
2018-03-12 14:47:09 +00:00
|
|
|
return 1;
|
2018-03-28 12:06:40 +01:00
|
|
|
return 0; /* ERRATA_APPLIES || ERRATA_MISSING */
|
|
|
|
#endif
|
2018-01-19 16:58:29 +00:00
|
|
|
default:
|
|
|
|
return SMC_UNK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Top-level Arm Architectural Service SMC handler.
|
|
|
|
*/
|
2018-02-12 12:36:17 +00:00
|
|
|
static uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid,
|
2018-01-19 16:58:29 +00:00
|
|
|
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 SMCCC_VERSION:
|
|
|
|
SMC_RET1(handle, smccc_version());
|
|
|
|
case SMCCC_ARCH_FEATURES:
|
|
|
|
SMC_RET1(handle, smccc_arch_features(x1));
|
|
|
|
#if WORKAROUND_CVE_2017_5715
|
|
|
|
case SMCCC_ARCH_WORKAROUND_1:
|
|
|
|
/*
|
|
|
|
* The workaround has already been applied on affected PEs
|
|
|
|
* during entry to EL3. On unaffected PEs, this function
|
|
|
|
* has no effect.
|
|
|
|
*/
|
|
|
|
SMC_RET0(handle);
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
WARN("Unimplemented Arm Architecture Service Call: 0x%x \n",
|
|
|
|
smc_fid);
|
|
|
|
SMC_RET1(handle, SMC_UNK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register Standard Service Calls as runtime service */
|
|
|
|
DECLARE_RT_SVC(
|
|
|
|
arm_arch_svc,
|
|
|
|
OEN_ARM_START,
|
|
|
|
OEN_ARM_END,
|
|
|
|
SMC_TYPE_FAST,
|
|
|
|
NULL,
|
|
|
|
arm_arch_svc_smc_handler
|
|
|
|
);
|