Skip to content

Commit f7a7119

Browse files
committed
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 <[email protected]> Signed-off-by: Avi Kivity <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
1 parent e46479f commit f7a7119

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4171,9 +4171,13 @@ int cpuid_maxphyaddr(struct kvm_vcpu *vcpu)
41714171
{
41724172
struct kvm_cpuid_entry2 *best;
41734173

4174+
best = kvm_find_cpuid_entry(vcpu, 0x80000000, 0);
4175+
if (!best || best->eax < 0x80000008)
4176+
goto not_found;
41744177
best = kvm_find_cpuid_entry(vcpu, 0x80000008, 0);
41754178
if (best)
41764179
return best->eax & 0xff;
4180+
not_found:
41774181
return 36;
41784182
}
41794183

0 commit comments

Comments
 (0)