diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-18 03:47:17 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-18 03:47:17 +0000 |
commit | e8197aa9e81cfeefec5249a9e5fd350fb6830204 (patch) | |
tree | 1bc2c7528414de3900e3b868e851c80723feb7cb /src/smccc/arch/calls.rs | |
parent | 17527effd9ef92ce76d8cb68735446ca0a08459b (diff) | |
parent | 627742b5f75b5c2fe5665799fd4da8dcbcc40f26 (diff) | |
download | psci-e8197aa9e81cfeefec5249a9e5fd350fb6830204.tar.gz |
Snap for 9959853 from 627742b5f75b5c2fe5665799fd4da8dcbcc40f26 to udc-d1-releaseandroid-14.0.0_r9android-14.0.0_r8android-14.0.0_r7android-14.0.0_r6android-14.0.0_r5android-14.0.0_r4android-14.0.0_r3android-14.0.0_r12android-14.0.0_r11android-14.0.0_r10android14-d1-s7-releaseandroid14-d1-s6-releaseandroid14-d1-s5-releaseandroid14-d1-s4-releaseandroid14-d1-s3-releaseandroid14-d1-s2-releaseandroid14-d1-s1-releaseandroid14-d1-release
Change-Id: Ib1f266ecee44cfe7b77d38a7fb2dd55b861a6048
Diffstat (limited to 'src/smccc/arch/calls.rs')
-rw-r--r-- | src/smccc/arch/calls.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/smccc/arch/calls.rs b/src/smccc/arch/calls.rs new file mode 100644 index 0000000..0164616 --- /dev/null +++ b/src/smccc/arch/calls.rs @@ -0,0 +1,43 @@ +// Copyright 2023 the authors. +// This project is dual-licensed under Apache 2.0 and MIT terms. +// See LICENSE-APACHE and LICENSE-MIT for details. + +use super::{ + error::Error, SocIdType, Version, SMCCC_ARCH_FEATURES, SMCCC_ARCH_SOC_ID, + SMCCC_ARCH_WORKAROUND_1, SMCCC_ARCH_WORKAROUND_2, SMCCC_ARCH_WORKAROUND_3, SMCCC_VERSION, +}; +use crate::smccc::{ + call32, + error::{positive_or_error_32, success_or_error_32}, +}; + +/// Returns the implemented version of the SMC Calling Convention. +pub fn version() -> Result<Version, Error> { + (call32(SMCCC_VERSION, [0; 7])[0] as i32).try_into() +} + +/// Returns whether the given Arm Architecture Service function is implemented, and any feature +/// flags specific to the function. +pub fn features(arch_func_id: u32) -> Result<u32, Error> { + positive_or_error_32(call32(SMCCC_ARCH_FEATURES, [arch_func_id, 0, 0, 0, 0, 0, 0])[0]) +} + +/// Returns the SiP defined SoC identification details. +pub fn soc_id(soc_id_type: SocIdType) -> Result<u32, Error> { + positive_or_error_32(call32(SMCCC_ARCH_SOC_ID, [soc_id_type.into(), 0, 0, 0, 0, 0, 0])[0]) +} + +/// Executes a firmware workaround to mitigate CVE-2017-5715. +pub fn arch_workaround_1() -> Result<(), Error> { + success_or_error_32(call32(SMCCC_ARCH_WORKAROUND_1, [0; 7])[0]) +} + +/// Enables or disables the mitigation for CVE-2018-3639. +pub fn arch_workaround_2(enable: bool) -> Result<(), Error> { + success_or_error_32(call32(SMCCC_ARCH_WORKAROUND_2, [enable.into(), 0, 0, 0, 0, 0, 0])[0]) +} + +/// Executes a firmware workaround to mitigate CVE-2017-5715 and CVE-2022-23960. +pub fn arch_workaround_3() -> Result<(), Error> { + success_or_error_32(call32(SMCCC_ARCH_WORKAROUND_3, [0; 7])[0]) +} |