From 282c6d6ce8da4c0502385779ab92abe8312778f5 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 11 Apr 2010 16:35:35 +0300 Subject: [PATCH] kvm: Fix off-by-one bugs in kvm__setup_cpuid() The cpuid_highest_func() and cpuid_highest_ext_func() return the highest possible function number, not the first non-existing function. Signed-off-by: Pekka Enberg --- tools/kvm/cpuid.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/tools/kvm/cpuid.c b/tools/kvm/cpuid.c index 92bac1d9d61a..e8c9549e7724 100644 --- a/tools/kvm/cpuid.c +++ b/tools/kvm/cpuid.c @@ -84,7 +84,7 @@ void kvm__setup_cpuid(struct kvm *self) highest = cpuid_highest_func(); - for (function = 0; function < highest; function++) { + for (function = 0; function <= highest; function++) { /* * NOTE NOTE NOTE! Functions 0x0b and 0x0d seem to need special * treatment as per qemu sources but we treat them as regular @@ -176,7 +176,7 @@ void kvm__setup_cpuid(struct kvm *self) highest_ext = cpuid_highest_ext_func(); - for (function = CPUID_GET_HIGHEST_EXT_FUNCTION; function < highest_ext; function++) { + for (function = CPUID_GET_HIGHEST_EXT_FUNCTION; function <= highest_ext; function++) { struct cpuid_regs regs; regs = (struct cpuid_regs) { @@ -195,17 +195,6 @@ void kvm__setup_cpuid(struct kvm *self) }; } - /* - * We need to set up MAXPHYADDR; otherwise switching to long mode in the - * guest will triple fault. - */ - if (highest_ext <= 0x80000008) { - kvm_cpuid->entries[ndx++] = (struct kvm_cpuid_entry2) { - .function = 0x80000008, - .eax = 0x00003028, /* 64-bit CPU */ - }; - } - assert(ndx < MAX_KVM_CPUID_ENTRIES); kvm_cpuid->nent = ndx; -- 2.39.5