Skip to content

Commit 827c2ab

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Actually prevent SMC64 SYSTEM_RESET2 from AArch32
The SMCCC does not allow the SMC64 calling convention to be used from AArch32. While KVM checks to see if the calling convention is allowed in PSCI_1_0_FN_PSCI_FEATURES, it does not actually prevent calls to unadvertised PSCI v1.0+ functions. Hoist the check to see if the requested function is allowed into kvm_psci_call(), thereby preventing SMC64 calls from AArch32 for all PSCI versions. Fixes: d43583b ("KVM: arm64: Expose PSCI SYSTEM_RESET2 call to the guest") Acked-by: Will Deacon <will@kernel.org> Reviewed-by: Reiji Watanabe <reijiw@google.com> Signed-off-by: Oliver Upton <oupton@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220322183538.2757758-3-oupton@google.com
1 parent 2da0aeb commit 827c2ab

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

arch/arm64/kvm/psci.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
231231
unsigned long val;
232232
int ret = 1;
233233

234-
val = kvm_psci_check_allowed_function(vcpu, psci_fn);
235-
if (val)
236-
goto out;
237-
238234
switch (psci_fn) {
239235
case PSCI_0_2_FN_PSCI_VERSION:
240236
/*
@@ -302,7 +298,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
302298
break;
303299
}
304300

305-
out:
306301
smccc_set_retval(vcpu, val, 0, 0, 0);
307302
return ret;
308303
}
@@ -422,6 +417,15 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu)
422417
*/
423418
int kvm_psci_call(struct kvm_vcpu *vcpu)
424419
{
420+
u32 psci_fn = smccc_get_function(vcpu);
421+
unsigned long val;
422+
423+
val = kvm_psci_check_allowed_function(vcpu, psci_fn);
424+
if (val) {
425+
smccc_set_retval(vcpu, val, 0, 0, 0);
426+
return 1;
427+
}
428+
425429
switch (kvm_psci_version(vcpu)) {
426430
case KVM_ARM_PSCI_1_1:
427431
return kvm_psci_1_x_call(vcpu, 1);

0 commit comments

Comments
 (0)