From patchwork Wed Apr 17 10:52:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 2452971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id AFCC23FC64 for ; Wed, 17 Apr 2013 10:53:05 +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 1USPyx-0003J6-4m; Wed, 17 Apr 2013 10:52:55 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1USPyu-0001eF-N1; Wed, 17 Apr 2013 10:52:52 +0000 Received: from mail-gg0-x22d.google.com ([2607:f8b0:4002:c02::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1USPyr-0001dv-3c for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2013 10:52:50 +0000 Received: by mail-gg0-f173.google.com with SMTP id 21so212757ggh.32 for ; Wed, 17 Apr 2013 03:52:44 -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=BW9hihtwEr117RRauQ9mRe0Y6kLcDmrn8YpKq8MjYLg=; b=orNZCyxAQf60Yf7tv0/EhY1tpmrLqEsHedZ6R7sfFvddjiH1uzAeQ3et2Ng6CudEHn tUgBjd65Cn9rzGhgRdtXk4Fszck3H6XFYp9GD4acuCGxiVP/oqBqJ1ffnJJWZWdtnuB4 Yy4nFnN/szkw5OnJ01mP+h01EOhZbPJaWGcpLyDJIjSlbrqN7QfTgCBOaAQP7XSjWyOW jsB2cOn9ucQysUxxvfDvMAexJBlunVCKZwYC4QJ4Tj4dk2rhfI/GK3KWTs9qQGdldbXC VVFkp7OmyxMxQ6RUlZJqnQzBywA0G9Cegm8cyPL8Nite3tlhsqAsPGavgLLsM7xItkRq QSzg== X-Received: by 10.236.37.40 with SMTP id x28mr3491865yha.127.1366195963919; Wed, 17 Apr 2013 03:52:43 -0700 (PDT) Received: from localhost.localdomain (f055066148.adsl.alicedsl.de. [78.55.66.148]) by mx.google.com with ESMTPS id c67sm8592931yhh.16.2013.04.17.03.52.41 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Apr 2013 03:52:43 -0700 (PDT) From: Andre Przywara To: cdall@cs.columbia.edu Subject: [PATCH] ARM: KVM: iterate over all CPUs for CPU compatibility check Date: Wed, 17 Apr 2013 12:52:01 +0200 Message-Id: <1366195921-28053-1-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 X-Gm-Message-State: ALoCoQkmhQeCA62pOC7cj5zVYzm6RvqWrmx/lBrjdJAC3vjiHSWRjWi9gipYUpCi8AFyS/C/9hmS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130417_065249_218212_7475F15E X-CRM114-Status: GOOD ( 15.31 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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 It turned out that this core is waiting for the first A7 to complete initialization, but this one hangs in HYP for a yet unknown reason. To avoid this, iterate over every CPU to correctly determine the capability of the system to run the current KVM implementation. If users want to use KVM anyway, it will probably help to restrict Linux to the A15 CPUs by giving an appropriate maxcpus= on the kernel command line. v2 change: remove potentially misleading hint message Please push this still into 3.9. Signed-off-by: Andre Przywara --- arch/arm/kvm/arm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index c1fe498..74513e8 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -1129,19 +1129,29 @@ 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 ret, cpu; if (!is_hyp_mode_available()) { kvm_err("HYP mode not available\n"); return -ENODEV; } - if (kvm_target_cpu() < 0) { + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1); + if (ret >= 0) + continue; + kvm_err("Target CPU not supported!\n"); return -ENODEV; }