aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Spyridakis <a.spyridakis@virtualopensystems.com>2015-09-04 11:06:24 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2015-09-04 12:02:48 -0400
commit0c0672922dcc70ffba11d96385e98e42fb3ae08d (patch)
treed9eaca6ea9b7eccc926a21117e3df8f2072b2d1b
parent857d1a973077245f03b351e2539529c86267bfe4 (diff)
arm/arm64: KVM: Fix PSCI affinity info return value for non valid cores
If a guest requests the affinity info for a non-existing vCPU we need to properly return an error, instead of erroneously reporting an off state. Signed-off-by: Alexander Spyridakis <a.spyridakis@virtualopensystems.com> Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--arch/arm/kvm/psci.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c
index 4b94b513168d..ad6f6424f1d1 100644
--- a/arch/arm/kvm/psci.c
+++ b/arch/arm/kvm/psci.c
@@ -126,7 +126,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
126 126
127static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) 127static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
128{ 128{
129 int i; 129 int i, matching_cpus = 0;
130 unsigned long mpidr; 130 unsigned long mpidr;
131 unsigned long target_affinity; 131 unsigned long target_affinity;
132 unsigned long target_affinity_mask; 132 unsigned long target_affinity_mask;
@@ -151,12 +151,16 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
151 */ 151 */
152 kvm_for_each_vcpu(i, tmp, kvm) { 152 kvm_for_each_vcpu(i, tmp, kvm) {
153 mpidr = kvm_vcpu_get_mpidr_aff(tmp); 153 mpidr = kvm_vcpu_get_mpidr_aff(tmp);
154 if (((mpidr & target_affinity_mask) == target_affinity) && 154 if ((mpidr & target_affinity_mask) == target_affinity) {
155 !tmp->arch.pause) { 155 matching_cpus++;
156 return PSCI_0_2_AFFINITY_LEVEL_ON; 156 if (!tmp->arch.pause)
157 return PSCI_0_2_AFFINITY_LEVEL_ON;
157 } 158 }
158 } 159 }
159 160
161 if (!matching_cpus)
162 return PSCI_RET_INVALID_PARAMS;
163
160 return PSCI_0_2_AFFINITY_LEVEL_OFF; 164 return PSCI_0_2_AFFINITY_LEVEL_OFF;
161} 165}
162 166