Message ID | 20230907100931.1186690-4-maz@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/5] KVM: arm64: Simplify kvm_vcpu_get_mpidr_aff() | expand |
On Thu, Sep 07, 2023 at 11:09:29AM +0100, Marc Zyngier wrote: > If our fancy little table is present when calling kvm_mpidr_to_vcpu(), > use it to recover the corresponding vcpu. > > Signed-off-by: Marc Zyngier <maz@kernel.org> > --- > arch/arm64/kvm/arm.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 30ce394c09d4..5b75b2db12be 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -2395,6 +2395,18 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr) > unsigned long i; > > mpidr &= MPIDR_HWID_BITMASK; > + > + if (kvm->arch.mpidr_data) { > + u16 idx = kvm_mpidr_index(kvm->arch.mpidr_data, mpidr); > + > + vcpu = kvm_get_vcpu(kvm, > + kvm->arch.mpidr_data->cmpidr_to_idx[idx]); > + if (mpidr != kvm_vcpu_get_mpidr_aff(vcpu)) > + vcpu = NULL; > + > + return vcpu; > + } > + > kvm_for_each_vcpu(i, vcpu, kvm) { > if (mpidr == kvm_vcpu_get_mpidr_aff(vcpu)) > return vcpu; Reviewed-by: Joey Gouly <joey.gouly@arm.com>
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 30ce394c09d4..5b75b2db12be 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2395,6 +2395,18 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr) unsigned long i; mpidr &= MPIDR_HWID_BITMASK; + + if (kvm->arch.mpidr_data) { + u16 idx = kvm_mpidr_index(kvm->arch.mpidr_data, mpidr); + + vcpu = kvm_get_vcpu(kvm, + kvm->arch.mpidr_data->cmpidr_to_idx[idx]); + if (mpidr != kvm_vcpu_get_mpidr_aff(vcpu)) + vcpu = NULL; + + return vcpu; + } + kvm_for_each_vcpu(i, vcpu, kvm) { if (mpidr == kvm_vcpu_get_mpidr_aff(vcpu)) return vcpu;
If our fancy little table is present when calling kvm_mpidr_to_vcpu(), use it to recover the corresponding vcpu. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/kvm/arm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)