linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: KVM: iterate over all CPUs for CPU compatibility check
@ 2013-04-12 13:04 Andre Przywara
  2013-04-12 13:24 ` Marc Zyngier
  0 siblings, 1 reply; 53+ messages in thread
From: Andre Przywara @ 2013-04-12 13:04 UTC (permalink / raw)
  To: linux-arm-kernel

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 <andre.przywara@linaro.org>
---
 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;
 	}
 
-- 
1.7.12.1

^ permalink raw reply related	[flat|nested] 53+ messages in thread
* [PATCH] ARM: KVM: iterate over all CPUs for CPU compatibility check
@ 2013-04-17 10:52 Andre Przywara
  0 siblings, 0 replies; 53+ messages in thread
From: Andre Przywara @ 2013-04-17 10:52 UTC (permalink / raw)
  To: linux-arm-kernel

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 <andre.przywara@linaro.org>
---
 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;
 	}
-- 
1.7.12.1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2013-04-22 14:35 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-12 13:04 [PATCH] ARM: KVM: iterate over all CPUs for CPU compatibility check Andre Przywara
2013-04-12 13:24 ` Marc Zyngier
2013-04-12 13:40   ` Peter Maydell
2013-04-12 13:49     ` Marc Zyngier
2013-04-17 10:19       ` Russell King - ARM Linux
2013-04-17 10:35         ` Marc Zyngier
2013-04-17 11:07           ` Christoffer Dall
2013-04-17 11:30             ` Marc Zyngier
2013-04-17 11:38               ` Peter Maydell
2013-04-17 11:42                 ` Alexander Graf
2013-04-17 11:45                   ` Christoffer Dall
2013-04-17 12:24                 ` Marc Zyngier
2013-04-17 12:25                   ` Peter Maydell
2013-04-17 12:28                     ` Marc Zyngier
2013-04-17 12:38                       ` Peter Maydell
2013-04-17 13:00                         ` Marc Zyngier
2013-04-17 19:28                           ` Christoffer Dall
2013-04-17 11:38               ` Christoffer Dall
2013-04-12 13:58   ` Andre Przywara
2013-04-12 14:14     ` Marc Zyngier
2013-04-15  4:57   ` Christoffer Dall
2013-04-15  7:50     ` Marc Zyngier
2013-04-15  8:28       ` Christoffer Dall
2013-04-15  8:43         ` Marc Zyngier
2013-04-15  8:54           ` Christoffer Dall
2013-04-15  9:14             ` Peter Maydell
2013-04-15  9:39               ` Andre Przywara
2013-04-15  9:45                 ` Peter Maydell
     [not found]                 ` <CAJRNFKJoBzgt4UhxsH65_LyhcGXPnzB_pg3q-zeYT2OVv59q4A@mail.gmail.com>
2013-04-15 13:13                   ` Andre Przywara
2013-04-15 13:48                     ` Will Deacon
2013-04-15 14:26                       ` Andre Przywara
2013-04-15 14:39                         ` Peter Maydell
2013-04-15 14:53                         ` Alexander Spyridakis
2013-04-16 16:26                       ` Christoffer Dall
2013-04-16 16:33                         ` Marc Zyngier
2013-04-17  8:08                           ` Andre Przywara
2013-04-17  8:16                             ` Marc Zyngier
     [not found]                               ` <CAEDV+g+3nkdvbLdj0m-ZdDKt0JY2vgzhP2AQA2nf=R3h4yTQmQ@mail.gmail.com>
2013-04-19 12:58                                 ` Andre Przywara
2013-04-19 16:13                                   ` Christoffer Dall
2013-04-22 10:36                                     ` Andre Przywara
2013-04-22 11:02                                       ` Marc Zyngier
2013-04-22 11:14                                         ` Marc Zyngier
2013-04-22 14:35                                           ` Andre Przywara
2013-04-16 15:59                   ` Christoffer Dall
2013-04-16 16:03                     ` Christoffer Dall
2013-04-16 18:37                     ` Alexander Spyridakis
2013-04-16 18:43                       ` Alexander Spyridakis
2013-04-16 23:13                       ` Christoffer Dall
2013-04-16  0:26     ` Geoff Levand
2013-04-16 16:24       ` Christoffer Dall
2013-04-16 16:40         ` Marc Zyngier
2013-04-17  8:01         ` Andre Przywara
  -- strict thread matches above, loose matches on Subject: below --
2013-04-17 10:52 Andre Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).