]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
KVM: Fix MAXPHYADDR calculation when cpuid does not support it
authorAvi Kivity <avi@redhat.com>
Sun, 11 Apr 2010 12:33:32 +0000 (15:33 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 17 May 2010 09:17:36 +0000 (12:17 +0300)
MAXPHYADDR is derived from cpuid 0x80000008, but when that isn't present, we
get some random value.

Fix by checking first that cpuid 0x80000008 is supported.

Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/x86.c

index 33a40c544c7ab020701f97584fb3a2c0d8406e58..d65e481c5fa447d7ab66299fbac52188dfd8e121 100644 (file)
@@ -4171,9 +4171,13 @@ int cpuid_maxphyaddr(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpuid_entry2 *best;
 
+       best = kvm_find_cpuid_entry(vcpu, 0x80000000, 0);
+       if (!best || best->eax < 0x80000008)
+               goto not_found;
        best = kvm_find_cpuid_entry(vcpu, 0x80000008, 0);
        if (best)
                return best->eax & 0xff;
+not_found:
        return 36;
 }