diff options
author | Andre Przywara <andre.przywara@arm.com> | 2014-06-02 09:37:13 -0400 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2015-01-20 12:25:17 -0500 |
commit | 4429fc64b90368e9bc93f933ea8b011d8db3a2f2 (patch) | |
tree | a7cb2e3dbebe4c2d6dc7a17e648a04b1c82090b9 /arch/arm/kvm/arm.c | |
parent | 7276030a082c9c33150e5900a80e26c6e3189b16 (diff) |
arm/arm64: KVM: rework MPIDR assignment and add accessors
The virtual MPIDR registers (containing topology information) for the
guest are currently mapped linearily to the vcpu_id. Improve this
mapping for arm64 by using three levels to not artificially limit the
number of vCPUs.
To help this, change and rename the kvm_vcpu_get_mpidr() function to
mask off the non-affinity bits in the MPIDR register.
Also add an accessor to later allow easier access to a vCPU with a
given MPIDR. Use this new accessor in the PSCI emulation.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'arch/arm/kvm/arm.c')
-rw-r--r-- | arch/arm/kvm/arm.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 74603a09ee76..a7b94ecba0d8 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -1075,6 +1075,19 @@ static void check_kvm_target_cpu(void *ret) | |||
1075 | *(int *)ret = kvm_target_cpu(); | 1075 | *(int *)ret = kvm_target_cpu(); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr) | ||
1079 | { | ||
1080 | struct kvm_vcpu *vcpu; | ||
1081 | int i; | ||
1082 | |||
1083 | mpidr &= MPIDR_HWID_BITMASK; | ||
1084 | kvm_for_each_vcpu(i, vcpu, kvm) { | ||
1085 | if (mpidr == kvm_vcpu_get_mpidr_aff(vcpu)) | ||
1086 | return vcpu; | ||
1087 | } | ||
1088 | return NULL; | ||
1089 | } | ||
1090 | |||
1078 | /** | 1091 | /** |
1079 | * Initialize Hyp-mode and memory mappings on all CPUs. | 1092 | * Initialize Hyp-mode and memory mappings on all CPUs. |
1080 | */ | 1093 | */ |