Skip to content

Commit 7e484d2

Browse files
ouptonMarc Zyngier
authored andcommitted
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
1 parent 821d935 commit 7e484d2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

arch/arm64/kvm/psci.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu)
435435
int kvm_psci_call(struct kvm_vcpu *vcpu)
436436
{
437437
u32 psci_fn = smccc_get_function(vcpu);
438+
int version = kvm_psci_version(vcpu);
438439
unsigned long val;
439440

440441
val = kvm_psci_check_allowed_function(vcpu, psci_fn);
@@ -443,7 +444,7 @@ int kvm_psci_call(struct kvm_vcpu *vcpu)
443444
return 1;
444445
}
445446

446-
switch (kvm_psci_version(vcpu)) {
447+
switch (version) {
447448
case KVM_ARM_PSCI_1_1:
448449
return kvm_psci_1_x_call(vcpu, 1);
449450
case KVM_ARM_PSCI_1_0:
@@ -453,6 +454,8 @@ int kvm_psci_call(struct kvm_vcpu *vcpu)
453454
case KVM_ARM_PSCI_0_1:
454455
return kvm_psci_0_1_call(vcpu);
455456
default:
456-
return -EINVAL;
457+
WARN_ONCE(1, "Unknown PSCI version %d", version);
458+
smccc_set_retval(vcpu, SMCCC_RET_NOT_SUPPORTED, 0, 0, 0);
459+
return 1;
457460
}
458461
}

0 commit comments

Comments
 (0)