From: Oliver Upton 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 Signed-off-by: Suzuki K Poulose --- arm64/include/kvm/kvm-arch.h | 2 ++ arm64/kvm.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arm64/include/kvm/kvm-arch.h b/arm64/include/kvm/kvm-arch.h index 8f508ef8..a50e6a4f 100644 --- a/arm64/include/kvm/kvm-arch.h +++ b/arm64/include/kvm/kvm-arch.h @@ -114,4 +114,6 @@ struct kvm_arch { cpu_set_t *vcpu_affinity_cpuset; }; +struct kvm_cpu *kvm__arch_mpidr_to_vcpu(struct kvm *kvm, u64 target_mpidr); + #endif /* ARM_COMMON__KVM_ARCH_H */ diff --git a/arm64/kvm.c b/arm64/kvm.c index 23b4dab1..41c47b13 100644 --- a/arm64/kvm.c +++ b/arm64/kvm.c @@ -5,6 +5,7 @@ #include "kvm/virtio-console.h" #include "kvm/fdt.h" #include "kvm/gic.h" +#include "kvm/kvm-cpu.h" #include #include @@ -128,6 +129,22 @@ void kvm__arch_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; +} + static u64 kvm__arch_get_payload_region_size(struct kvm *kvm) { if (kvm->cfg.arch.aarch32_guest) -- 2.43.0