Commit 0c067292 authored by Alexander Spyridakis's avatar Alexander Spyridakis Committed by Marc Zyngier

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: default avatarAlexander Spyridakis <a.spyridakis@virtualopensystems.com>
Signed-off-by: default avatarAlvise Rigo <a.rigo@virtualopensystems.com>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent 857d1a97
...@@ -126,7 +126,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) ...@@ -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) static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
{ {
int i; int i, matching_cpus = 0;
unsigned long mpidr; unsigned long mpidr;
unsigned long target_affinity; unsigned long target_affinity;
unsigned long target_affinity_mask; unsigned long target_affinity_mask;
...@@ -151,12 +151,16 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) ...@@ -151,12 +151,16 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
*/ */
kvm_for_each_vcpu(i, tmp, kvm) { kvm_for_each_vcpu(i, tmp, kvm) {
mpidr = kvm_vcpu_get_mpidr_aff(tmp); mpidr = kvm_vcpu_get_mpidr_aff(tmp);
if (((mpidr & target_affinity_mask) == target_affinity) && if ((mpidr & target_affinity_mask) == target_affinity) {
!tmp->arch.pause) { matching_cpus++;
return PSCI_0_2_AFFINITY_LEVEL_ON; 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; return PSCI_0_2_AFFINITY_LEVEL_OFF;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment