Ver código fonte

KVM: Fix MAXPHYADDR calculation when cpuid does not support it

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>
Avi Kivity 15 anos atrás
pai
commit
f7a711971e
1 arquivos alterados com 4 adições e 0 exclusões
  1. 4 0
      arch/x86/kvm/x86.c

+ 4 - 0
arch/x86/kvm/x86.c

@@ -4171,9 +4171,13 @@ int cpuid_maxphyaddr(struct kvm_vcpu *vcpu)
 {
 {
 	struct kvm_cpuid_entry2 *best;
 	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);
 	best = kvm_find_cpuid_entry(vcpu, 0x80000008, 0);
 	if (best)
 	if (best)
 		return best->eax & 0xff;
 		return best->eax & 0xff;
+not_found:
 	return 36;
 	return 36;
 }
 }