Skip to content

Commit

Permalink
arm/arm64: KVM: Fix PSCI affinity info return value for non valid cores
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexander Spyridakis authored and Marc Zyngier committed Sep 4, 2015
1 parent 857d1a9 commit 0c06729
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions arch/arm/kvm/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)

static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
{
int i;
int i, matching_cpus = 0;
unsigned long mpidr;
unsigned long target_affinity;
unsigned long target_affinity_mask;
Expand All @@ -151,12 +151,16 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
*/
kvm_for_each_vcpu(i, tmp, kvm) {
mpidr = kvm_vcpu_get_mpidr_aff(tmp);
if (((mpidr & target_affinity_mask) == target_affinity) &&
!tmp->arch.pause) {
return PSCI_0_2_AFFINITY_LEVEL_ON;
if ((mpidr & target_affinity_mask) == target_affinity) {
matching_cpus++;
if (!tmp->arch.pause)
return PSCI_0_2_AFFINITY_LEVEL_ON;
}
}

if (!matching_cpus)
return PSCI_RET_INVALID_PARAMS;

return PSCI_0_2_AFFINITY_LEVEL_OFF;
}

Expand Down

0 comments on commit 0c06729

Please sign in to comment.