From patchwork Fri Nov 8 01:32:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 3155021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C86719F407 for ; Fri, 8 Nov 2013 01:32:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0AC3B204A0 for ; Fri, 8 Nov 2013 01:32:10 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 078182041A for ; Fri, 8 Nov 2013 01:32:09 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VeavH-0006qY-3E; Fri, 08 Nov 2013 01:31:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VeavB-00081K-Ik; Fri, 08 Nov 2013 01:31:37 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Veav2-0007z6-5a for linux-arm-kernel@lists.infradead.org; Fri, 08 Nov 2013 01:31:29 +0000 Received: by mail-pa0-f52.google.com with SMTP id bj1so1458061pad.25 for ; Thu, 07 Nov 2013 17:31:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EOcqTRg7AXrkX9svo1kIyxix0QqLelGUcmzGfH7erTo=; b=RkSeEj95NDAwOUFJ8f65UujhG0kjdXtXfiHk/kFcRXSqqBcco8MsuGhnum5jWfCP63 xf8L/FR470oQ55JrWWWlgNry2nSOOIqr7x+nUf5zgkoYppUOjsgF4UX4N9eoi6WvPzzC DRAavGTmoNxPXC3GNC403JrGtn0lH75+AV2Rt/2TrABIpQbyU6OuuDmr8+bqvWd3cEYe 2sIymveMExRz8YRj8VeWik8I+zJtTdaJ0mSd7M8D2fV0mz0S4dA0YGqwnNH1NnJdx9Dk 5jsj9QfRb7KoIufqJfR6+Nwrfi01im+DF0Tdo9ZIyJkOEkPcyVqUSkva9g+dpfgtHJAf blyw== X-Gm-Message-State: ALoCoQmLdroRueLv703gPCtEtUDa375gv3PLJkI84Whx8Pq5UhKJo0XSk9+KUNbqsIsh1eyrurmB X-Received: by 10.67.22.38 with SMTP id hp6mr12889137pad.53.1383874266820; Thu, 07 Nov 2013 17:31:06 -0800 (PST) Received: from localhost.localdomain (c-67-169-181-221.hsd1.ca.comcast.net. [67.169.181.221]) by mx.google.com with ESMTPSA id i6sm8072833pbc.1.2013.11.07.17.31.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 17:31:06 -0800 (PST) From: Christoffer Dall To: Gleb Natapov , Paolo Bonzini Subject: [PATCH 2/4] ARM: KVM: fix L2CTLR to be per-cluster Date: Thu, 7 Nov 2013 17:32:00 -0800 Message-Id: <1383874322-12328-3-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1383874322-12328-1-git-send-email-christoffer.dall@linaro.org> References: <1383874322-12328-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131107_203128_349062_662D7B83 X-CRM114-Status: GOOD ( 10.60 ) X-Spam-Score: -2.6 (--) Cc: kvm@vger.kernel.org, patches@linaro.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier 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 Signed-off-by: Christoffer Dall --- arch/arm/kvm/coproc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index 631e6bd..78c0885 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -124,6 +124,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;