Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: KVM: Fix MPIDR computing to support virtual clusters

In order to be able to support more than 4 A7 or A15 CPUs,
we need to fix the MPIDR computing to reflect the fact that
both A15 and A7 can only exist in clusters of at most 4 CPUs.

Fix the MPIDR computing to allow virtual clusters to be exposed
to the guest.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

authored by

Marc Zyngier and committed by
Christoffer Dall
2d1d841b e4b3c9c2

+6 -4
+6 -4
arch/arm/kvm/coproc.c
··· 74 74 static void reset_mpidr(struct kvm_vcpu *vcpu, const struct coproc_reg *r) 75 75 { 76 76 /* 77 - * Compute guest MPIDR. No need to mess around with different clusters 78 - * but we read the 'U' bit from the underlying hardware directly. 77 + * Compute guest MPIDR. We build a virtual cluster out of the 78 + * vcpu_id, but we read the 'U' bit from the underlying 79 + * hardware directly. 79 80 */ 80 - vcpu->arch.cp15[c0_MPIDR] = (read_cpuid_mpidr() & MPIDR_SMP_BITMASK) 81 - | vcpu->vcpu_id; 81 + vcpu->arch.cp15[c0_MPIDR] = ((read_cpuid_mpidr() & MPIDR_SMP_BITMASK) | 82 + ((vcpu->vcpu_id >> 2) << MPIDR_LEVEL_BITS) | 83 + (vcpu->vcpu_id & 3)); 82 84 } 83 85 84 86 /* TRM entries A7:4.3.31 A15:4.3.28 - RO WI */