From patchwork Tue Apr 30 14:49:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 2505131 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9AD083FD85 for ; Tue, 30 Apr 2013 14:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932384Ab3D3OuV (ORCPT ); Tue, 30 Apr 2013 10:50:21 -0400 Received: from mail-pb0-f49.google.com ([209.85.160.49]:63126 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932354Ab3D3OuN (ORCPT ); Tue, 30 Apr 2013 10:50:13 -0400 Received: by mail-pb0-f49.google.com with SMTP id rp8so295372pbb.22 for ; Tue, 30 Apr 2013 07:50:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=1IVwEQXymaSNirr3mJ6AihKL6oEuyxRsyzqwhIb/DEs=; b=Fatqpwvc35ZxS1fvS2j6Ltfml2XOD3/qEYCQut1cdsG5DgRhp4Fq1YADsb7cmzC60Z FfzrMHub/mDf9aDYQ6OCcwY1ovYd7/v5sQ2DWaBZKBmhIg5KDjxVUwrON2zGRIF0wq0i ejUG/UW/9gQhTQ3uHTm3Rfojhru2I5A77xkfDjBS8INaeVev8UVL2porgVOV+aq4VcnN u6A5LiGfdQaL9wc2DQdQm9Auz/8Oia+LheRRRZKkLCfSsqU2sxCZm5R1ZdGRD+NAltvE scshiptti6AT7Id7YieMvUnrPhAvlzuTYZaD4scFgP1Rj5ykqc2o2K5ic445mBJ2Szc4 cUTw== X-Received: by 10.66.254.162 with SMTP id aj2mr24774173pad.85.1367333412954; Tue, 30 Apr 2013 07:50:12 -0700 (PDT) Received: from localhost.localdomain (c-67-169-183-77.hsd1.ca.comcast.net. [67.169.183.77]) by mx.google.com with ESMTPSA id cq1sm28799244pbc.13.2013.04.30.07.50.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:50:12 -0700 (PDT) From: Christoffer Dall To: kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Andre Przywara , Christoffer Dall Subject: [PATCH 15/15] ARM: KVM: iterate over all CPUs for CPU compatibility check Date: Tue, 30 Apr 2013 07:49:36 -0700 Message-Id: <1367333376-30983-16-git-send-email-cdall@cs.columbia.edu> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1367333376-30983-1-git-send-email-cdall@cs.columbia.edu> References: <1367333376-30983-1-git-send-email-cdall@cs.columbia.edu> X-Gm-Message-State: ALoCoQnA2O4R0i2weYsTl1bFS6UeX+HNLNpK7GYvbv239k6dly5dXeCpeSz71SnSSP7AvBfZ7CHc Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Andre Przywara 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 necessarily the case (for example in Big.Little). [ I cut some of the commit message and changed the formatting of the code slightly to pass checkpatch and look more like the rest of the kvm/arm init code - Christoffer ] Signed-off-by: Andre Przywara Signed-off-by: Christoffer Dall --- arch/arm/kvm/arm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 089c0a4..5bc99b4 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -947,21 +947,30 @@ 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) { - kvm_err("Target CPU not supported!\n"); - return -ENODEV; + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1); + if (ret < 0) { + kvm_err("Error, CPU %d not supported!\n", cpu); + return -ENODEV; + } } err = init_hyp_mode();