KVM: arm64: Add big.LITTLE architecture support for vcpu
PATCH 1/1 KVM: arm64: Add big.LITTLE architecture support for vcpu
In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT several times.Sometimes the thread will run on the big core, sometimes will run on the little core.The big core and the little core has always different cpuid, but the init target is fixed. and that leads to init->target != phys_target. So modify phys target from the current core to all cpu online.
--- arch/arm64/kvm/arm.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
arch/arm64/kvm/arm.c +21 -9
@@ -983,20 +983,37 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,return -EINVAL ; } +static void check_kvm_target_cpu (void *ret) +{ + *(int *)ret =kvm_target_cpu (); +} + +static int kvm_cpu_online_target (int init_target) +{ +int cpu, ret =-1 ; + +for_each_online_cpu (cpu) { +smp_call_function_single (cpu, check_kvm_target_cpu, &ret,1 ); +if (ret == init_target) +return 0 ; + } + +return -EINVAL ; +} +static int kvm_vcpu_set_target (struct kvm_vcpu *vcpu,const struct kvm_vcpu_init *init) {unsigned int i, ret; -int phys_target =kvm_target_cpu (); -if (init->target != phys_target) +if (kvm_cpu_online_target (init->target))return -EINVAL ;/* * Secondary and subsequent calls to KVM_ARM_VCPU_INIT must * use the same target. */ -if (vcpu->arch.target !=-1 && vcpu->arch.target != init->target) +if (vcpu->arch.target !=-1 &&kvm_cpu_online_target (init->target))return -EINVAL ;/* -ENOENT for unknown features, -EINVAL for invalid combinations. */
@@ -1018,7 +1035,7 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,set_bit (i, vcpu->arch.features); } - vcpu->arch.target = phys_target; + vcpu->arch.target = init->target;/* Now we know what it is, we can reset it. */ ret =kvm_reset_vcpu (vcpu);
@@ -1815,11 +1832,6 @@ static int init_hyp_mode(void)return err; } -static void check_kvm_target_cpu (void *ret) -{ - *(int *)ret =kvm_target_cpu (); -} -struct kvm_vcpu *kvm_mpidr_to_vcpu (struct kvm *kvm,unsigned long mpidr) {struct kvm_vcpu *vcpu;
Signature · 1 line
2.29.0
Marc Zyngier
maintainerQuoted 7 lines · Yejune Deng
In big.LITTLE architecture,the application layer calls
KVM_ARM_VCPU_INITseveral times.Sometimes the thread will run on the big core, sometimes will run on the little core.The big core and the little core has always different cpuid, but the init target is fixed. and that leads toinit->target!=phys_target. So modify phys target from the current core to all cpu online.
This is done on purpose, and it is userspace's responsibility to pin its vcpu threads to a certain type of CPUs if it cares at all.
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm