]> git.hungrycats.org Git - linux/commitdiff
ARM: kvm: psci: fix handling of unimplemented functions
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Wed, 10 Jun 2015 14:19:24 +0000 (15:19 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Sat, 4 Jul 2015 03:02:32 +0000 (23:02 -0400)
[ Upstream commit e2d997366dc5b6c9d14035867f73957f93e7578c ]

According to the PSCI specification and the SMC/HVC calling
convention, PSCI function_ids that are not implemented must
return NOT_SUPPORTED as return value.

Current KVM implementation takes an unhandled PSCI function_id
as an error and injects an undefined instruction into the guest
if PSCI implementation is called with a function_id that is not
handled by the resident PSCI version (ie it is not implemented),
which is not the behaviour expected by a guest when calling a
PSCI function_id that is not implemented.

This patch fixes this issue by returning NOT_SUPPORTED whenever
the kvm PSCI call is executed for a function_id that is not
implemented by the PSCI kvm layer.

Cc: <stable@vger.kernel.org> # 3.18+
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/arm/kvm/psci.c

index 58cb3248d277bc03a6b38850a558186a34606205..4d0d89e342f990b6157812fcebb834038e9482f4 100644 (file)
@@ -237,10 +237,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
        case PSCI_0_2_FN64_AFFINITY_INFO:
                val = kvm_psci_vcpu_affinity_info(vcpu);
                break;
-       case PSCI_0_2_FN_MIGRATE:
-       case PSCI_0_2_FN64_MIGRATE:
-               val = PSCI_RET_NOT_SUPPORTED;
-               break;
        case PSCI_0_2_FN_MIGRATE_INFO_TYPE:
                /*
                 * Trusted OS is MP hence does not require migration
@@ -249,10 +245,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
                 */
                val = PSCI_0_2_TOS_MP;
                break;
-       case PSCI_0_2_FN_MIGRATE_INFO_UP_CPU:
-       case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU:
-               val = PSCI_RET_NOT_SUPPORTED;
-               break;
        case PSCI_0_2_FN_SYSTEM_OFF:
                kvm_psci_system_off(vcpu);
                /*
@@ -278,7 +270,8 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
                ret = 0;
                break;
        default:
-               return -EINVAL;
+               val = PSCI_RET_NOT_SUPPORTED;
+               break;
        }
 
        *vcpu_reg(vcpu, 0) = val;
@@ -298,12 +291,9 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu)
        case KVM_PSCI_FN_CPU_ON:
                val = kvm_psci_vcpu_on(vcpu);
                break;
-       case KVM_PSCI_FN_CPU_SUSPEND:
-       case KVM_PSCI_FN_MIGRATE:
+       default:
                val = PSCI_RET_NOT_SUPPORTED;
                break;
-       default:
-               return -EINVAL;
        }
 
        *vcpu_reg(vcpu, 0) = val;