[patch 42/87] KVM: Explicity initialize cpus_hardware_enabled

Greg KH
2009-06-09T10:26:56Z

[-- Attachment #1: kvm-explicity-initialize-cpus_hardware_enabled.patch --]
[-- Type: text/plain, Size: 930 bytes --]

2.6.29-stable review patch. If anyone has any objections, please let us know.

------------------

From: Avi Kivity <avi@redhat.com>

commit a4c0364be3f43d3e17fe19270f8b3d64881606e6 upstream.

Under CONFIG_MAXSMP, cpus_hardware_enabled is allocated from the heap and
not statically initialized. This causes a crash on reboot when kvm thinks
vmx is enabled on random nonexistent cpus and accesses nonexistent percpu
lists.

Fix by explicitly clearing the variable.

Reported-and-tested-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
virt/kvm/kvm_main.c | 1 +
1 file changed, 1 insertion(+)

--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2315,6 +2315,7 @@ int kvm_init(void *opaque, unsigned int
r = -ENOMEM;
goto out_free_0;
}
+ cpumask_clear(cpus_hardware_enabled);

r = kvm_arch_hardware_setup();
if (r < 0)