diff options
author | Oliver Upton <oliver.upton@linux.dev> | 2023-04-04 18:40:47 +0300 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-04-05 14:07:41 +0300 |
commit | 7e484d2785e2a2e526a6b2679d3e4c1402ffe0ec (patch) | |
tree | 01a86b0b716e2427a09d8f23f21c8ad9b76bceaf | |
parent | 821d935c87bc95253f82deec3cbb457ccf3de003 (diff) | |
download | linux-7e484d2785e2a2e526a6b2679d3e4c1402ffe0ec.tar.xz |
KVM: arm64: Return NOT_SUPPORTED to guest for unknown PSCI version
A subsequent change to KVM will allow negative returns from SMCCC
handlers to exit to userspace. Make way for this change by explicitly
returning SMCCC_RET_NOT_SUPPORTED to the guest if the VM is configured
to use an unknown PSCI version. Add a WARN since this is undoubtedly a
KVM bug.
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230404154050.2270077-11-oliver.upton@linux.dev
-rw-r--r-- | arch/arm64/kvm/psci.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index 7fbc4c1b9df0..aff54b106c30 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -435,6 +435,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) int kvm_psci_call(struct kvm_vcpu *vcpu) { u32 psci_fn = smccc_get_function(vcpu); + int version = kvm_psci_version(vcpu); unsigned long val; val = kvm_psci_check_allowed_function(vcpu, psci_fn); @@ -443,7 +444,7 @@ int kvm_psci_call(struct kvm_vcpu *vcpu) return 1; } - switch (kvm_psci_version(vcpu)) { + switch (version) { case KVM_ARM_PSCI_1_1: return kvm_psci_1_x_call(vcpu, 1); case KVM_ARM_PSCI_1_0: @@ -453,6 +454,8 @@ int kvm_psci_call(struct kvm_vcpu *vcpu) case KVM_ARM_PSCI_0_1: return kvm_psci_0_1_call(vcpu); default: - return -EINVAL; + WARN_ONCE(1, "Unknown PSCI version %d", version); + smccc_set_retval(vcpu, SMCCC_RET_NOT_SUPPORTED, 0, 0, 0); + return 1; } } |