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