From patchwork Fri Apr 12 13:04:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 2435591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 9677FDF2A1 for ; Fri, 12 Apr 2013 13:05:14 +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 1UQdfE-0001Qd-Lx; Fri, 12 Apr 2013 13:05:12 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQdfB-0003Pk-65; Fri, 12 Apr 2013 13:05:09 +0000 Received: from mail-qe0-f43.google.com ([209.85.128.43]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQdf7-0003PQ-OF for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2013 13:05:07 +0000 Received: by mail-qe0-f43.google.com with SMTP id f6so1500646qej.16 for ; Fri, 12 Apr 2013 06:05:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=sIaLPpcXnrCRC0W11/IkEoVQt0KlGKfKUEAT7hhwYmU=; b=Dc3eHujyjszhUIkTI8+bwu7exa4iLI9/47oIO6hzbFfTxah90U7rvBvdOjxh+dk+AE bEbPjBNKVl3XKve89z3qOP15SqBGHwVfbTkXJhJLijcz68zVzqKdhQqYdYo5jD5XPQnv 9nRQYLT2y9Kf+dfAa3riq3aOF540cayZuNyPZKT/SmP4e+shcXebYYfM7u2SkBpkZwvI BHCRgOh853vDoEouyZIQbY11TWCfaxv/1u62Iu/hh7q9+o+E3Eot5OL8I8748NJ2uuQ5 FJGVXzyJuqg/2Hzws02RC6vrhJNhBIo23eqSBLZJ6Gesy72jszdyntg5A806fQbcumjM Bevw== X-Received: by 10.229.140.96 with SMTP id h32mr4301746qcu.89.1365771901476; Fri, 12 Apr 2013 06:05:01 -0700 (PDT) Received: from slackpad.drs.calxeda.com (f053086029.adsl.alicedsl.de. [78.53.86.29]) by mx.google.com with ESMTPS id ku2sm13072905qeb.4.2013.04.12.06.04.58 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Apr 2013 06:05:00 -0700 (PDT) From: Andre Przywara To: cdall@cs.columbia.edu Subject: [PATCH] ARM: KVM: iterate over all CPUs for CPU compatibility check Date: Fri, 12 Apr 2013 15:04:35 +0200 Message-Id: <1365771875-5788-1-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 X-Gm-Message-State: ALoCoQk+isj3b2t1BXsjOBuS14pUlp2ZGv7iBI/iVin43ctjK+vDvBhYYWctlscPeWStNHiOfk9g X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130412_090505_850512_D68312C8 X-CRM114-Status: GOOD ( 16.00 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.128.43 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: marc.zyngier@arm.com, peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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 kvm_target_cpus() checks the compatibility of the used CPU with KVM, which is currently limited to ARM Cortex-A15 cores. However by calling it only once on any random CPU it assumes that all cores are the same, which is not true for big.LITTLE parts. After doing about 40 boots on a TC-2 core tile, I found it running in all but one case on one of the A7 cores (which correctly denied KVM initialization). On the 39th boot however the code ran on an A15, leading to a hang after returning success: ... TCP: reno registered UDP hash table entries: 512 (order: 2, 16384 bytes) UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) NET: Registered protocol family 1 kvm_target_cpu() on CPU #1, part is c0f0 ... (pause for a while) ... INFO: rcu_sched self-detected stall on CPUINFO: rcu_sched detected stalls on CPU s/tasks: { 1} (detected by 0, t=6002 jiffies, g=4294966999, c=4294966998, q=15) Task dump for CPU 1: swapper/0 R running 0 1 0 0x00000002 So iterate over every CPU to correctly determine the capability of the system to run the current KVM implementation. In case a big.LITTLE configuration is the reason for denial, give the user a hint how to get it running anyway (maxcpus= on the kernel command line). Please push this still into 3.9. Signed-off-by: Andre Przywara --- arch/arm/kvm/arm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 5a93698..9b53cdd 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -1128,20 +1128,35 @@ out_err: return err; } +static void check_kvm_target_cpu(void *ret) +{ + *(int*)ret = kvm_target_cpu(); +} + /** * Initialize Hyp-mode and memory mappings on all CPUs. */ int kvm_arch_init(void *opaque) { int err; + int count = 0, ret, cpu; if (!is_hyp_mode_available()) { kvm_err("HYP mode not available\n"); return -ENODEV; } - if (kvm_target_cpu() < 0) { - kvm_err("Target CPU not supported!\n"); + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1); + if (ret >= 0) { + count++; + continue; + } + if (count) + kvm_err("big.LITTLE not supported, limit to A15 CPUs with maxcpus= to use KVM\n"); + else + kvm_err("Target CPU not supported!\n"); + return -ENODEV; }