Skip to content

Commit 1158fca

Browse files
jaustinchazy
authored andcommitted
KVM: ARM: Fix calculation of virtual CPU ID
KVM does not have a notion of multiple clusters for CPUs, just a linear array of CPUs. When using a system with cores in more than one cluster, the current method for calculating the virtual MPIDR will leak the (physical) cluster information into the virtual MPIDR. One effect of this is that Linux under KVM fails to boot multiple CPUs that aren't in the 0th cluster. This patch does away with exposing the real MPIDR fields in favour of simply using the virtual CPU number (but preserving the U bit, as before). Signed-off-by: Jonathan Austin <jonathan.austin@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
1 parent 740edfc commit 1158fca

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

arch/arm/kvm/coproc_a15.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@
2727
static void reset_mpidr(struct kvm_vcpu *vcpu, const struct coproc_reg *r)
2828
{
2929
/*
30-
* Compute guest MPIDR:
31-
* (Even if we present only one VCPU to the guest on an SMP
32-
* host we don't set the U bit in the MPIDR, or vice versa, as
33-
* revealing the underlying hardware properties is likely to
34-
* be the best choice).
30+
* Compute guest MPIDR. No need to mess around with different clusters
31+
* but we read the 'U' bit from the underlying hardware directly.
3532
*/
36-
vcpu->arch.cp15[c0_MPIDR] = (read_cpuid_mpidr() & ~MPIDR_LEVEL_MASK)
37-
| (vcpu->vcpu_id & MPIDR_LEVEL_MASK);
33+
vcpu->arch.cp15[c0_MPIDR] = (read_cpuid_mpidr() & MPIDR_SMP_BITMASK)
34+
| vcpu->vcpu_id;
3835
}
3936

4037
#include "coproc.h"

0 commit comments

Comments
 (0)