18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci=========================================
48c2ecf20Sopenharmony_ciPower State Coordination Interface (PSCI)
58c2ecf20Sopenharmony_ci=========================================
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciKVM implements the PSCI (Power State Coordination Interface)
88c2ecf20Sopenharmony_cispecification in order to provide services such as CPU on/off, reset
98c2ecf20Sopenharmony_ciand power-off to the guest.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciThe PSCI specification is regularly updated to provide new features,
128c2ecf20Sopenharmony_ciand KVM implements these updates if they make sense from a virtualization
138c2ecf20Sopenharmony_cipoint of view.
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciThis means that a guest booted on two different versions of KVM can
168c2ecf20Sopenharmony_ciobserve two different "firmware" revisions. This could cause issues if
178c2ecf20Sopenharmony_cia given guest is tied to a particular PSCI revision (unlikely), or if
188c2ecf20Sopenharmony_cia migration causes a different PSCI version to be exposed out of the
198c2ecf20Sopenharmony_ciblue to an unsuspecting guest.
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciIn order to remedy this situation, KVM exposes a set of "firmware
228c2ecf20Sopenharmony_cipseudo-registers" that can be manipulated using the GET/SET_ONE_REG
238c2ecf20Sopenharmony_ciinterface. These registers can be saved/restored by userspace, and set
248c2ecf20Sopenharmony_cito a convenient value if required.
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciThe following register is defined:
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci* KVM_REG_ARM_PSCI_VERSION:
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci  - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set
318c2ecf20Sopenharmony_ci    (and thus has already been initialized)
328c2ecf20Sopenharmony_ci  - Returns the current PSCI version on GET_ONE_REG (defaulting to the
338c2ecf20Sopenharmony_ci    highest PSCI version implemented by KVM and compatible with v0.2)
348c2ecf20Sopenharmony_ci  - Allows any PSCI version implemented by KVM and compatible with
358c2ecf20Sopenharmony_ci    v0.2 to be set with SET_ONE_REG
368c2ecf20Sopenharmony_ci  - Affects the whole VM (even if the register view is per-vcpu)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci* KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1:
398c2ecf20Sopenharmony_ci    Holds the state of the firmware support to mitigate CVE-2017-5715, as
408c2ecf20Sopenharmony_ci    offered by KVM to the guest via a HVC call. The workaround is described
418c2ecf20Sopenharmony_ci    under SMCCC_ARCH_WORKAROUND_1 in [1].
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci  Accepted values are:
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL:
468c2ecf20Sopenharmony_ci      KVM does not offer
478c2ecf20Sopenharmony_ci      firmware support for the workaround. The mitigation status for the
488c2ecf20Sopenharmony_ci      guest is unknown.
498c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL:
508c2ecf20Sopenharmony_ci      The workaround HVC call is
518c2ecf20Sopenharmony_ci      available to the guest and required for the mitigation.
528c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED:
538c2ecf20Sopenharmony_ci      The workaround HVC call
548c2ecf20Sopenharmony_ci      is available to the guest, but it is not needed on this VCPU.
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci* KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2:
578c2ecf20Sopenharmony_ci    Holds the state of the firmware support to mitigate CVE-2018-3639, as
588c2ecf20Sopenharmony_ci    offered by KVM to the guest via a HVC call. The workaround is described
598c2ecf20Sopenharmony_ci    under SMCCC_ARCH_WORKAROUND_2 in [1]_.
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci  Accepted values are:
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL:
648c2ecf20Sopenharmony_ci      A workaround is not
658c2ecf20Sopenharmony_ci      available. KVM does not offer firmware support for the workaround.
668c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN:
678c2ecf20Sopenharmony_ci      The workaround state is
688c2ecf20Sopenharmony_ci      unknown. KVM does not offer firmware support for the workaround.
698c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL:
708c2ecf20Sopenharmony_ci      The workaround is available,
718c2ecf20Sopenharmony_ci      and can be disabled by a vCPU. If
728c2ecf20Sopenharmony_ci      KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED is set, it is active for
738c2ecf20Sopenharmony_ci      this vCPU.
748c2ecf20Sopenharmony_ci    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED:
758c2ecf20Sopenharmony_ci      The workaround is always active on this vCPU or it is not needed.
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci.. [1] https://developer.arm.com/-/media/developer/pdf/ARM_DEN_0070A_Firmware_interfaces_for_mitigating_CVE-2017-5715.pdf
78