Some PSCI calls take an MPIDR affinity as an argument. Add a helper to get the vCPU that matches an MPIDR so we can find the intended recipient. Signed-off-by: Oliver Upton <oliver.upton@xxxxxxxxx> --- arm/aarch64/include/kvm/kvm-arch.h | 1 + arm/aarch64/kvm.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h index 0d3b169b3c93..dacbc9286f50 100644 --- a/arm/aarch64/include/kvm/kvm-arch.h +++ b/arm/aarch64/include/kvm/kvm-arch.h @@ -6,6 +6,7 @@ struct kvm; unsigned long long kvm__arch_get_kern_offset(struct kvm *kvm, int fd); int kvm__arch_get_ipa_limit(struct kvm *kvm); +struct kvm_cpu *kvm__arch_mpidr_to_vcpu(struct kvm *kvm, u64 target_mpidr); #define MAX_PAGE_SIZE SZ_64K diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 848e6909994a..4929ce48843b 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -1,4 +1,5 @@ #include "kvm/kvm.h" +#include "kvm/kvm-cpu.h" #include <asm/image.h> @@ -165,3 +166,18 @@ void __kvm__arm_init(struct kvm *kvm) { kvm__arch_enable_mte(kvm); } + +struct kvm_cpu *kvm__arch_mpidr_to_vcpu(struct kvm *kvm, u64 target_mpidr) +{ + int i; + + for (i = 0; i < kvm->nrcpus; i++) { + struct kvm_cpu *tmp = kvm->cpus[i]; + u64 mpidr = kvm_cpu__get_vcpu_mpidr(tmp) & ARM_MPIDR_HWID_BITMASK; + + if (mpidr == target_mpidr) + return tmp; + } + + return NULL; +} -- 2.41.0.rc0.172.g3f132b7071-goog