Browse Source
SMCCC v1.1 comes with a relaxed calling convention for AArch64 callers. The caller only needs to save x0-x3 before doing an SMC call. This patch adds support for SMCCC_VERSION and SMCCC_ARCH_FEATURES. Refer to "Firmware Interfaces for mitigating CVE_2017_5715 System Software on Arm Systems"[0] for more information. [0] https://developer.arm.com/-/media/developer/pdf/ARM%20DEN%200070A%20Firmware%20interfaces%20for%20mitigating%20CVE-2017-5715_V1.0.pdf Change-Id: If5b1c55c17d6c5c7cb9c2c3ed355d3a91cdad0a9 Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>pull/1240/head
Dimitris Papastamos
7 years ago
4 changed files with 100 additions and 2 deletions
@ -0,0 +1,14 @@ |
|||
/*
|
|||
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
#ifndef __ARM_ARCH_SVC_H__ |
|||
#define __ARM_ARCH_SVC_H__ |
|||
|
|||
#define SMCCC_VERSION U(0x80000000) |
|||
#define SMCCC_ARCH_FEATURES U(0x80000001) |
|||
#define SMCCC_ARCH_WORKAROUND_1 U(0x80008000) |
|||
|
|||
#endif /* __ARM_ARCH_SVC_H__ */ |
@ -0,0 +1,74 @@ |
|||
/*
|
|||
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
#include <arm_arch_svc.h> |
|||
#include <debug.h> |
|||
#include <runtime_svc.h> |
|||
#include <smcc.h> |
|||
#include <smcc_helpers.h> |
|||
|
|||
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; |
|||
#if WORKAROUND_CVE_2017_5715 |
|||
case SMCCC_ARCH_WORKAROUND_1: |
|||
return SMC_OK; |
|||
#endif |
|||
default: |
|||
return SMC_UNK; |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* Top-level Arm Architectural Service SMC handler. |
|||
*/ |
|||
uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid, |
|||
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 |
|||
); |
Loading…
Reference in new issue