]> git.hungrycats.org Git - linux/commitdiff
ARM: KVM: fix L2CTLR to be per-cluster
authorMarc Zyngier <marc.zyngier@arm.com>
Mon, 23 Mar 2015 07:07:23 +0000 (15:07 +0800)
committerJiri Slaby <jslaby@suse.cz>
Thu, 30 Apr 2015 09:14:58 +0000 (11:14 +0200)
commit 9cbb6d969cb6561de45d917b8bb9281cb374bb35 upstream.

The L2CTLR register contains the number of CPUs in this cluster.

Make sure the register content is actually relevant to the vcpu
that is being configured by computing the number of cores that are
part of its cluster.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
arch/arm/kvm/coproc_a15.c

index 8611c5c45d93830f0fa1c3f230613688c02050b0..935fa0fddb29db727ea91afe8f580e34d5631ac1 100644 (file)
@@ -79,6 +79,10 @@ static void reset_l2ctlr(struct kvm_vcpu *vcpu, const struct coproc_reg *r)
        asm volatile("mrc p15, 1, %0, c9, c0, 2\n" : "=r" (l2ctlr));
        l2ctlr &= ~(3 << 24);
        ncores = atomic_read(&vcpu->kvm->online_vcpus) - 1;
+       /* How many cores in the current cluster and the next ones */
+       ncores -= (vcpu->vcpu_id & ~3);
+       /* Cap it to the maximum number of cores in a single cluster */
+       ncores = min(ncores, 3U);
        l2ctlr |= (ncores & 3) << 24;
 
        vcpu->arch.cp15[c9_L2CTLR] = l2ctlr;