blob: a809c429a047851211ecfde8f6e1201b20bc512a [file] [log] [blame]
Dimitris Papastamos0dcdb1a2018-01-19 16:58:29 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arm_arch_svc.h>
8#include <debug.h>
9#include <runtime_svc.h>
10#include <smcc.h>
11#include <smcc_helpers.h>
12
13static int32_t smccc_version(void)
14{
15 return MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION, SMCCC_MINOR_VERSION);
16}
17
18static int32_t smccc_arch_features(u_register_t arg)
19{
20 switch (arg) {
21 case SMCCC_VERSION:
22 case SMCCC_ARCH_FEATURES:
23 return SMC_OK;
24#if WORKAROUND_CVE_2017_5715
25 case SMCCC_ARCH_WORKAROUND_1:
26 return SMC_OK;
27#endif
28 default:
29 return SMC_UNK;
30 }
31}
32
33/*
34 * Top-level Arm Architectural Service SMC handler.
35 */
Roberto Vargas05712702018-02-12 12:36:17 +000036static uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid,
Dimitris Papastamos0dcdb1a2018-01-19 16:58:29 +000037 u_register_t x1,
38 u_register_t x2,
39 u_register_t x3,
40 u_register_t x4,
41 void *cookie,
42 void *handle,
43 u_register_t flags)
44{
45 switch (smc_fid) {
46 case SMCCC_VERSION:
47 SMC_RET1(handle, smccc_version());
48 case SMCCC_ARCH_FEATURES:
49 SMC_RET1(handle, smccc_arch_features(x1));
50#if WORKAROUND_CVE_2017_5715
51 case SMCCC_ARCH_WORKAROUND_1:
52 /*
53 * The workaround has already been applied on affected PEs
54 * during entry to EL3. On unaffected PEs, this function
55 * has no effect.
56 */
57 SMC_RET0(handle);
58#endif
59 default:
60 WARN("Unimplemented Arm Architecture Service Call: 0x%x \n",
61 smc_fid);
62 SMC_RET1(handle, SMC_UNK);
63 }
64}
65
66/* Register Standard Service Calls as runtime service */
67DECLARE_RT_SVC(
68 arm_arch_svc,
69 OEN_ARM_START,
70 OEN_ARM_END,
71 SMC_TYPE_FAST,
72 NULL,
73 arm_arch_svc_smc_handler
74);