1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun========================================= 4*4882a593SmuzhiyunPower State Coordination Interface (PSCI) 5*4882a593Smuzhiyun========================================= 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunKVM implements the PSCI (Power State Coordination Interface) 8*4882a593Smuzhiyunspecification in order to provide services such as CPU on/off, reset 9*4882a593Smuzhiyunand power-off to the guest. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunThe PSCI specification is regularly updated to provide new features, 12*4882a593Smuzhiyunand KVM implements these updates if they make sense from a virtualization 13*4882a593Smuzhiyunpoint of view. 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunThis means that a guest booted on two different versions of KVM can 16*4882a593Smuzhiyunobserve two different "firmware" revisions. This could cause issues if 17*4882a593Smuzhiyuna given guest is tied to a particular PSCI revision (unlikely), or if 18*4882a593Smuzhiyuna migration causes a different PSCI version to be exposed out of the 19*4882a593Smuzhiyunblue to an unsuspecting guest. 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunIn order to remedy this situation, KVM exposes a set of "firmware 22*4882a593Smuzhiyunpseudo-registers" that can be manipulated using the GET/SET_ONE_REG 23*4882a593Smuzhiyuninterface. These registers can be saved/restored by userspace, and set 24*4882a593Smuzhiyunto a convenient value if required. 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunThe following register is defined: 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun* KVM_REG_ARM_PSCI_VERSION: 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set 31*4882a593Smuzhiyun (and thus has already been initialized) 32*4882a593Smuzhiyun - Returns the current PSCI version on GET_ONE_REG (defaulting to the 33*4882a593Smuzhiyun highest PSCI version implemented by KVM and compatible with v0.2) 34*4882a593Smuzhiyun - Allows any PSCI version implemented by KVM and compatible with 35*4882a593Smuzhiyun v0.2 to be set with SET_ONE_REG 36*4882a593Smuzhiyun - Affects the whole VM (even if the register view is per-vcpu) 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun* KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1: 39*4882a593Smuzhiyun Holds the state of the firmware support to mitigate CVE-2017-5715, as 40*4882a593Smuzhiyun offered by KVM to the guest via a HVC call. The workaround is described 41*4882a593Smuzhiyun under SMCCC_ARCH_WORKAROUND_1 in [1]. 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun Accepted values are: 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL: 46*4882a593Smuzhiyun KVM does not offer 47*4882a593Smuzhiyun firmware support for the workaround. The mitigation status for the 48*4882a593Smuzhiyun guest is unknown. 49*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL: 50*4882a593Smuzhiyun The workaround HVC call is 51*4882a593Smuzhiyun available to the guest and required for the mitigation. 52*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED: 53*4882a593Smuzhiyun The workaround HVC call 54*4882a593Smuzhiyun is available to the guest, but it is not needed on this VCPU. 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun* KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2: 57*4882a593Smuzhiyun Holds the state of the firmware support to mitigate CVE-2018-3639, as 58*4882a593Smuzhiyun offered by KVM to the guest via a HVC call. The workaround is described 59*4882a593Smuzhiyun under SMCCC_ARCH_WORKAROUND_2 in [1]_. 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun Accepted values are: 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL: 64*4882a593Smuzhiyun A workaround is not 65*4882a593Smuzhiyun available. KVM does not offer firmware support for the workaround. 66*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN: 67*4882a593Smuzhiyun The workaround state is 68*4882a593Smuzhiyun unknown. KVM does not offer firmware support for the workaround. 69*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL: 70*4882a593Smuzhiyun The workaround is available, 71*4882a593Smuzhiyun and can be disabled by a vCPU. If 72*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED is set, it is active for 73*4882a593Smuzhiyun this vCPU. 74*4882a593Smuzhiyun KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED: 75*4882a593Smuzhiyun The workaround is always active on this vCPU or it is not needed. 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun.. [1] https://developer.arm.com/-/media/developer/pdf/ARM_DEN_0070A_Firmware_interfaces_for_mitigating_CVE-2017-5715.pdf 78