2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
7 #include <arm_arch_svc.h>
9 #include <errata_report.h>
10 #include <runtime_svc.h>
12 #include <smccc_helpers.h>
13 #include <wa_cve_2017_5715.h>
14 #include <wa_cve_2018_3639.h>
16 static int32_t smccc_version(void)
18 return MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION
, SMCCC_MINOR_VERSION
);
21 static int32_t smccc_arch_features(u_register_t arg
)
25 case SMCCC_ARCH_FEATURES
:
27 #if WORKAROUND_CVE_2017_5715
28 case SMCCC_ARCH_WORKAROUND_1
:
29 if (check_wa_cve_2017_5715() == ERRATA_NOT_APPLIES
)
31 return 0; /* ERRATA_APPLIES || ERRATA_MISSING */
34 #if WORKAROUND_CVE_2018_3639
35 case SMCCC_ARCH_WORKAROUND_2
: {
36 #if DYNAMIC_WORKAROUND_CVE_2018_3639
37 unsigned long long ssbs
;
40 * Firmware doesn't have to carry out dynamic workaround if the
41 * PE implements architectural Speculation Store Bypass Safe
44 ssbs
= (read_id_aa64pfr0_el1() >> ID_AA64PFR1_EL1_SSBS_SHIFT
) &
45 ID_AA64PFR1_EL1_SSBS_MASK
;
48 * If architectural SSBS is available on this PE, no firmware
49 * mitigation via SMCCC_ARCH_WORKAROUND_2 is required.
51 if (ssbs
!= SSBS_UNAVAILABLE
)
55 * On a platform where at least one CPU requires
56 * dynamic mitigation but others are either unaffected
57 * or permanently mitigated, report the latter as not
58 * needing dynamic mitigation.
60 if (wa_cve_2018_3639_get_disable_ptr() == NULL
)
63 * If we get here, this CPU requires dynamic mitigation
64 * so report it as such.
68 /* Either the CPUs are unaffected or permanently mitigated */
69 return SMCCC_ARCH_NOT_REQUIRED
;
82 * Top-level Arm Architectural Service SMC handler.
84 static uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid
,
95 SMC_RET1(handle
, smccc_version());
96 case SMCCC_ARCH_FEATURES
:
97 SMC_RET1(handle
, smccc_arch_features(x1
));
98 #if WORKAROUND_CVE_2017_5715
99 case SMCCC_ARCH_WORKAROUND_1
:
101 * The workaround has already been applied on affected PEs
102 * during entry to EL3. On unaffected PEs, this function
107 #if WORKAROUND_CVE_2018_3639
108 case SMCCC_ARCH_WORKAROUND_2
:
110 * The workaround has already been applied on affected PEs
111 * requiring dynamic mitigation during entry to EL3.
112 * On unaffected or statically mitigated PEs, this function
118 WARN("Unimplemented Arm Architecture Service Call: 0x%x \n",
120 SMC_RET1(handle
, SMC_UNK
);
124 /* Register Standard Service Calls as runtime service */
131 arm_arch_svc_smc_handler