fix cpuid function 4
PATCH 1/1 fix cpuid function 4
Hi,
Currently CPUID function 4 is broken. This function's values rely on the value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.
This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather core duo target) compatibility.
Regards,
Alex
kernel/x86.c +12 -3
@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG ;
@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) { +case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ; +default : + vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + } vcpu->arch.cpuid_entries[i].padding[0 ] =0 ; vcpu->arch.cpuid_entries[i].padding[1 ] =0 ; vcpu->arch.cpuid_entries[i].padding[2 ] =0 ;
qemu/qemu-kvm-x86.c +17 -5
@@ -461,10 +461,11 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx, } -static void do_cpuid_ent (struct kvm_cpuid_entry *e,uint32_t function, +static void do_cpuid_ent (struct kvm_cpuid_entry *e,uint32_t function,uint32_t index,CPUState *env) { env->regs[R_EAX ] = function; + env->regs[R_ECX ] = index;qemu_kvm_cpuid_on_env (env); e->function = function; e->eax = env->regs[R_EAX ];
@@ -515,7 +516,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)#endif int cpuid_nent =0 ;CPUState copy; -uint32_t i, limit; +uint32_t i, j, limit; copy = *cenv;
@@ -540,16 +541,27 @@ int kvm_arch_qemu_init_env(CPUState *cenv)qemu_kvm_cpuid_on_env (©); limit = copy.regs[R_EAX ]; -for (i =0 ; i <= limit; ++i) -do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©); +for (i =0 ; i <= limit; ++i) { +switch (i) { +case 4 : +for (j =0 ; ; j++) { +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, j, ©); +if (!copy.regs[R_EAX ])break ; + } +break ; +default : +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i,0 , ©); +break ; + } + } copy.regs[R_EAX ] =0x80000000 ;qemu_kvm_cpuid_on_env (©); limit = copy.regs[R_EAX ];for (i =0x80000000 ; i <= limit; ++i) -do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©); +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i,0 , ©);kvm_setup_cpuid (kvm_context, cenv->cpu_index, cpuid_nent, cpuid_ent);return 0 ; }
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 38 lines · Alexander Graf
Hi,
Currently CPUID function 4 is broken. This function's values rely on the value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather core duo target) compatibility.
Regards,
Alex
kernel/x86.c +2
-3@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG ;@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) {
kernel/x86.c static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, · line 816
Quoted 10 lines
kernel/x86.c +10
-0+case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ; +default : + vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + }
I will not mention the whitespace damage here :-). Instead, I'd ask you to review, comment, and even try, the patch that I posted here not long ago, exposing all safe host cpuid functions to guests.
Thanks,
Dan.
libkvm/libkvm-x86.c +93 -4
@@ -485,20 +485,109 @@ __u64 kvm_get_cr8(kvm_context_t kvm, int vcpu) }int kvm_setup_cpuid (kvm_context_t kvm,int vcpu,int nent, -struct kvm_cpuid_entry *entries) +struct kvm_cpuid_entry2 *entries) { -struct kvm_cpuid *cpuid; -int r; +int r = -ENOSYS ; +#ifdef KVM_CAP_EXT_CPUID + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_EXT_CPUID ); +if (r <=0 ) +#endif + {/* kernel has no KVM_SET_CPUID2 */ +int i; +struct kvm_cpuid *cpuid; + + cpuid =malloc (sizeof (*cpuid) + + nent *sizeof (struct kvm_cpuid_entry )); +if (!cpuid) +return -ENOMEM ; + + cpuid->nent = nent; +for (i =0 ; i < nent; ++i) { + cpuid->entries[i].function = entries[i].function; + cpuid->entries[i].eax = entries[i].eax; + cpuid->entries[i].ebx = entries[i].ebx; + cpuid->entries[i].ecx = entries[i].ecx; + cpuid->entries[i].edx = entries[i].edx; + } + r =ioctl (kvm->vcpu_fd[vcpu],KVM_SET_CPUID , cpuid); +if (r) + r = -errno; + +free (cpuid); + } +#ifdef KVM_CAP_EXT_CPUID + else { +struct kvm_cpuid2 *cpuid; cpuid =malloc (sizeof (*cpuid) + nent *sizeof (*entries));if (!cpuid)return -ENOMEM ; cpuid->nent = nent;memcpy (cpuid->entries, entries, nent *sizeof (*entries)); - r =ioctl (kvm->vcpu_fd[vcpu],KVM_SET_CPUID , cpuid); + r =ioctl (kvm->vcpu_fd[vcpu],KVM_SET_CPUID2 , cpuid); +if (r) + r = -errno; + +free (cpuid); + } +#endif +return r; +} + +int kvm_get_supported_cpuid (kvm_context_t kvm,int *nent, +struct kvm_cpuid_entry2 *entries) +{ +struct kvm_cpuid2 *cpuid; +int r = -ENOSYS ; + +#ifdef KVM_CAP_EXT_CPUID + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_EXT_CPUID ); +if (r <=0 ) +return -ENOSYS ; + + cpuid =malloc (sizeof (*cpuid) + *nent *sizeof (*entries)); +if (!cpuid) +return -ENOMEM ; + cpuid->nent = *nent; + r =ioctl (kvm->vm_fd,KVM_GET_SUPPORTED_CPUID , cpuid); +if (r) + r = -errno; +else { +memcpy (entries, cpuid->entries, *nent *sizeof (*entries)); + *nent = cpuid->nent; + }free (cpuid); +#endif +return r; +} + +int kvm_get_cpuid (kvm_context_t kvm,int vcpu,int *nent, +struct kvm_cpuid_entry2 *entries) +{ +struct kvm_cpuid2 *cpuid; +int r = -ENOSYS ; + +#ifdef KVM_CAP_EXT_CPUID + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_EXT_CPUID ); +if (r <=0 ) +return -ENOSYS ; + + cpuid =malloc (sizeof (*cpuid) + *nent *sizeof (*entries)); +if (!cpuid) +return -ENOMEM ; + cpuid->nent = *nent; + + r =ioctl (kvm->vcpu_fd[vcpu],KVM_GET_CPUID2 , cpuid); +if (r) + r = -errno; +else { +memcpy (entries, cpuid->entries, *nent *sizeof (*entries)); + *nent = cpuid->nent; + } +free (cpuid); +#endif return r; }
libkvm/libkvm.h +43 -1
56 lines not on this page · raw message
qemu/hw/pc.c +4 -0
@@ -783,6 +783,10 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,#else cpu_model ="qemu32" ;#endif +#ifdef USE_KVM +if (kvm_allowed) + cpu_model ="host" ; +#endif }for (i =0 ; i < smp_cpus; i++) {
qemu/qemu-kvm-x86.c +89 -18
140 lines not on this page · raw message
qemu/target-i386/cpu.h +3 -0
@@ -588,6 +588,9 @@ typedef struct CPUX86State {uint32_t cpuid_ext2_features;uint32_t cpuid_ext3_features;uint32_t cpuid_apic_id; +#ifdef USE_KVM +int cpuid_hostlike; +#endif #ifdef USE_KQEMU int kqemu_enabled;
qemu/target-i386/helper2.c +35 -0
@@ -123,6 +123,15 @@ CPUX86State *cpu_x86_init(const char *cpu_model)return env; } +#ifdef USE_KVM +struct hostlike_user_disable { +uint32_t features; +uint32_t ext_features; +uint32_t ext2_features; +uint32_t ext3_features; +} hostlike_user_disable; +#endif + typedef struct x86_def_t { const char *name; uint32_t level;
@@ -131,6 +140,9 @@ typedef struct x86_def_t {int model;int stepping;uint32_t features, ext_features, ext2_features, ext3_features; +#ifdef USE_KVM +int hostlike; +#endif uint32_t xlevel; } x86_def_t;
@@ -207,6 +219,12 @@ static x86_def_t x86_defs[] = { .features = 0x0383F9FF, .xlevel = 0, }, +#ifdef USE_KVM + { + .name = "host", + .hostlike = 1, + }, +#endif };static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model)
@@ -229,6 +247,12 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) }if (!def) goto error; +#ifdef USE_KVM +if (!kvm_allowed && def->hostlike) { +fprintf (stderr,"hostlike cpu requires KVM.\n" ); + goto error; + } +#endif memcpy (x86_cpu_def, def,sizeof (*def)); featurestr =strtok (NULL ,"," );
@@ -288,6 +312,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) x86_cpu_def->ext_features &= ~minus_ext_features; x86_cpu_def->ext2_features &= ~minus_ext2_features; x86_cpu_def->ext3_features &= ~minus_ext3_features; +#ifdef USE_KVM +if (kvm_allowed) { + hostlike_user_disable.features = minus_features; + hostlike_user_disable.ext_features = minus_ext_features; + hostlike_user_disable.ext2_features = minus_ext2_features; + hostlike_user_disable.ext3_features = minus_ext3_features; + } +#endif free (s);return 0 ;
@@ -341,6 +373,9 @@ static int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_model[i >>2 ] |= c << (8 * (i &3 )); } } +#ifdef USE_KVM + env->cpuid_hostlike = def->hostlike; +#endif return 0 ; }
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
A message that is not in the archive (sent off-list or not yet received): 20080114161844.GA7648-iWbx9bcAnq+Hk9JtIoIkgNBPR1lH4CV8@public.gmane.org
Quoted 47 lines · Dan Kenigsberg
Quoted 45 lines · Alexander Graf
Hi,
Currently CPUID function 4 is broken. This function's values rely on the value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather core duo target) compatibility.
Regards,
Alex
kernel/x86.c +7
-3@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG ;@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) { +case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ;
Quoted 9 lines
kernel/x86.c static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, · line 817
Quoted 6 lines
kernel/x86.c +5
-0+default : + vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + }I will not mention the whitespace damage here :-). Instead, I'd ask you
Oh well, after having been into qemu source, I just got used to use spaces instead of tabs ;-).
Quoted 3 lines
to review, comment, and even try, the patch that I posted here not long ago, exposing all safe host cpuid functions to guests.
Sure.
Basically your patch targets at a completely different use case than mine though. You want to expose the host features on the virtual CPU, whereas my goal is to have a virtual Core Duo/Solo CPU, even if your host CPU is actually an SVM capable one.
So my CoreDuo CPU definition still fails to populate a proper CPUID function 4. With the -cpu host option, Linux works (as it's bright enough to know that some values are just plain wrong), but Darwin crashes. I am not exactly sure why it is, but I guess it's due to the function 4 values exposing a 2-core CPU, which kvm simply doesn't emulate.
So far I still like the approach of the cpuid2 API, so it would be great if you could take the patch one step further and have qemu defined CPUs work properly as well.
I do not know too much about the kvm code style, so I can't really say anything regarding that.
Regards,
Alex
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 69 lines · Alexander Graf
Quoted 47 lines · Dan Kenigsberg
Quoted 45 lines · Alexander Graf
Hi,
Currently CPUID function 4 is broken. This function's values rely on the value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather core duo target) compatibility.
Regards,
Alex
kernel/x86.c +7
-3@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG ;@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) { +case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ;Quoted 9 lines
kernel/x86.c static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, · line 817
Quoted 6 lines
kernel/x86.c +5
-0+default : + vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + }I will not mention the whitespace damage here :-). Instead, I'd ask you
Oh well, after having been into qemu source, I just got used to use spaces instead of tabs ;-).
Quoted 3 lines
to review, comment, and even try, the patch that I posted here not long ago, exposing all safe host cpuid functions to guests.
Sure.
Basically your patch targets at a completely different use case than mine though. You want to expose the host features on the virtual CPU, whereas my goal is to have a virtual Core Duo/Solo CPU, even if your host CPU is actually an SVM capable one.
Quoted 5 lines
So my CoreDuo CPU definition still fails to populate a proper CPUID function 4. With the -cpu host option, Linux works (as it's bright enough to know that some values are just plain wrong), but Darwin crashes. I am not exactly sure why it is, but I guess it's due to the function 4 values exposing a 2-core CPU, which kvm simply doesn't emulate.
What I wanted to say is that the fact that the usermode support is not used, is not IMHO a good-enough reason to change the kernel:kvm_vcpu_ioctl_set_cpuid() was ment to be a stupid function, to be used only with old usermode. I hate to teach it the true complex logic of Intel's CPUID.
What I would like to see is something that uses the cpuid2 API, and not circumvene it... For this to happen, I need a deep review of my code.
How about the (untested) attched kvm-cpuid.patch, on top of the attached cpuid-user patch?
Regards,
Dan.
Quoted 1 line
From
a8b795151e225452745dcd9831b828c06dff438cMon Sep 17 00:00:00 2001
From: Dan Kenigsberg <danken-atKUWr5tajBWk0Htik3J/[email protected]>
Date: Tue, 15 Jan 2008 15:31:19 +0200
Subject: [PATCH] Add -cpu host option. Expose to guest the CPUID that is supported by the
host (or specifically requested in the command line).
Note that the default cpu is now host' instead of qemu64'
--- libkvm/libkvm-x86.c | 97 +++++++++++++++++++++++++++++++++++++++-- libkvm/libkvm.h | 44 ++++++++++++++++++- qemu/hw/pc.c | 4 ++ qemu/qemu-kvm-x86.c | 103 ++++++++++++++++++++++++++++++++++++------- qemu/target-i386/cpu.h | 3 + qemu/target-i386/helper2.c | 35 +++++++++++++++ 6 files changed, 264 insertions(+), 22 deletions(-)
libkvm/libkvm-x86.c +93 -4
@@ -485,20 +485,109 @@ __u64 kvm_get_cr8(kvm_context_t kvm, int vcpu) }int kvm_setup_cpuid (kvm_context_t kvm,int vcpu,int nent, -struct kvm_cpuid_entry *entries) +struct kvm_cpuid_entry2 *entries) { -struct kvm_cpuid *cpuid; -int r; +int r = -ENOSYS ; +#ifdef KVM_CAP_EXT_CPUID + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_EXT_CPUID ); +if (r <=0 ) +#endif + {/* kernel has no KVM_SET_CPUID2 */ +int i; +struct kvm_cpuid *cpuid; + + cpuid =malloc (sizeof (*cpuid) + + nent *sizeof (struct kvm_cpuid_entry )); +if (!cpuid) +return -ENOMEM ; + + cpuid->nent = nent; +for (i =0 ; i < nent; ++i) { + cpuid->entries[i].function = entries[i].function; + cpuid->entries[i].eax = entries[i].eax; + cpuid->entries[i].ebx = entries[i].ebx; + cpuid->entries[i].ecx = entries[i].ecx; + cpuid->entries[i].edx = entries[i].edx; + } + r =ioctl (kvm->vcpu_fd[vcpu],KVM_SET_CPUID , cpuid); +if (r) + r = -errno; + +free (cpuid); + } +#ifdef KVM_CAP_EXT_CPUID + else { +struct kvm_cpuid2 *cpuid; cpuid =malloc (sizeof (*cpuid) + nent *sizeof (*entries));if (!cpuid)return -ENOMEM ; cpuid->nent = nent;memcpy (cpuid->entries, entries, nent *sizeof (*entries)); - r =ioctl (kvm->vcpu_fd[vcpu],KVM_SET_CPUID , cpuid); + r =ioctl (kvm->vcpu_fd[vcpu],KVM_SET_CPUID2 , cpuid); +if (r) + r = -errno; + +free (cpuid); + } +#endif +return r; +} + +int kvm_get_supported_cpuid (kvm_context_t kvm,int *nent, +struct kvm_cpuid_entry2 *entries) +{ +struct kvm_cpuid2 *cpuid; +int r = -ENOSYS ; + +#ifdef KVM_CAP_EXT_CPUID + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_EXT_CPUID ); +if (r <=0 ) +return -ENOSYS ; + + cpuid =malloc (sizeof (*cpuid) + *nent *sizeof (*entries)); +if (!cpuid) +return -ENOMEM ; + cpuid->nent = *nent; + r =ioctl (kvm->vm_fd,KVM_GET_SUPPORTED_CPUID , cpuid); +if (r) + r = -errno; +else { +memcpy (entries, cpuid->entries, *nent *sizeof (*entries)); + *nent = cpuid->nent; + }free (cpuid); +#endif +return r; +} + +int kvm_get_cpuid (kvm_context_t kvm,int vcpu,int *nent, +struct kvm_cpuid_entry2 *entries) +{ +struct kvm_cpuid2 *cpuid; +int r = -ENOSYS ; + +#ifdef KVM_CAP_EXT_CPUID + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_EXT_CPUID ); +if (r <=0 ) +return -ENOSYS ; + + cpuid =malloc (sizeof (*cpuid) + *nent *sizeof (*entries)); +if (!cpuid) +return -ENOMEM ; + cpuid->nent = *nent; + + r =ioctl (kvm->vcpu_fd[vcpu],KVM_GET_CPUID2 , cpuid); +if (r) + r = -errno; +else { +memcpy (entries, cpuid->entries, *nent *sizeof (*entries)); + *nent = cpuid->nent; + } +free (cpuid); +#endif return r; }
libkvm/libkvm.h +43 -1
56 lines not on this page · raw message
qemu/hw/pc.c +4 -0
@@ -783,6 +783,10 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,#else cpu_model ="qemu32" ;#endif +#ifdef USE_KVM +if (kvm_allowed) + cpu_model ="host" ; +#endif }for (i =0 ; i < smp_cpus; i++) {
qemu/qemu-kvm-x86.c +86 -17
130 lines not on this page · raw message
qemu/target-i386/cpu.h +3 -0
@@ -588,6 +588,9 @@ typedef struct CPUX86State {uint32_t cpuid_ext2_features;uint32_t cpuid_ext3_features;uint32_t cpuid_apic_id; +#ifdef USE_KVM +int cpuid_hostlike; +#endif #ifdef USE_KQEMU int kqemu_enabled;
qemu/target-i386/helper2.c +35 -0
@@ -123,6 +123,15 @@ CPUX86State *cpu_x86_init(const char *cpu_model)return env; } +#ifdef USE_KVM +struct hostlike_user_disable { +uint32_t features; +uint32_t ext_features; +uint32_t ext2_features; +uint32_t ext3_features; +} hostlike_user_disable; +#endif + typedef struct x86_def_t { const char *name; uint32_t level;
@@ -131,6 +140,9 @@ typedef struct x86_def_t {int model;int stepping;uint32_t features, ext_features, ext2_features, ext3_features; +#ifdef USE_KVM +int hostlike; +#endif uint32_t xlevel; } x86_def_t;
@@ -207,6 +219,12 @@ static x86_def_t x86_defs[] = { .features = 0x0383F9FF, .xlevel = 0, }, +#ifdef USE_KVM + { + .name = "host", + .hostlike = 1, + }, +#endif };static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model)
@@ -229,6 +247,12 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) }if (!def) goto error; +#ifdef USE_KVM +if (!kvm_allowed && def->hostlike) { +fprintf (stderr,"hostlike cpu requires KVM.\n" ); + goto error; + } +#endif memcpy (x86_cpu_def, def,sizeof (*def)); featurestr =strtok (NULL ,"," );
@@ -288,6 +312,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) x86_cpu_def->ext_features &= ~minus_ext_features; x86_cpu_def->ext2_features &= ~minus_ext2_features; x86_cpu_def->ext3_features &= ~minus_ext3_features; +#ifdef USE_KVM +if (kvm_allowed) { + hostlike_user_disable.features = minus_features; + hostlike_user_disable.ext_features = minus_ext_features; + hostlike_user_disable.ext2_features = minus_ext2_features; + hostlike_user_disable.ext3_features = minus_ext3_features; + } +#endif free (s);return 0 ;
@@ -341,6 +373,9 @@ static int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_model[i >>2 ] |= c << (8 * (i &3 )); } } +#ifdef USE_KVM + env->cpuid_hostlike = def->hostlike; +#endif return 0 ; }
Signature · 1 line
1.5.3.7
qemu/qemu-kvm-x86.c +23 -5
@@ -462,9 +462,10 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,static void do_cpuid_ent (struct kvm_cpuid_entry2 *e,uint32_t function, -CPUState *env) +uint32_t index,CPUState *env) { env->regs[R_EAX ] = function; + env->regs[R_ECX ] = index;qemu_kvm_cpuid_on_env (env); e->function = function; e->eax = env->regs[R_EAX ];
@@ -532,7 +533,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)#endif int cpuid_nent =0 ;CPUState copy; -uint32_t i, limit; +uint32_t i, j, limit; copy = *cenv;
@@ -583,7 +584,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)if (cpu_vendor_string)for (i =0x80000002 ; i <=0x80000004 ; ++i) { e =cpuid_entry_lookup (cpuid_ent, cpuid_nent, i,0 ); -do_cpuid_ent (e, i, ©); +do_cpuid_ent (e, i,0 , ©); } } }else {
@@ -591,15 +592,32 @@ int kvm_arch_qemu_init_env(CPUState *cenv)qemu_kvm_cpuid_on_env (©); limit = copy.regs[R_EAX ]; +for (i =0 ; i <= limit; ++i) { +switch (i) { +case 4 : +for (j =0 ; ; j++) { +struct kvm_cpuid_entry2 *e = &cpuid_ent[cpuid_nent++]; + +do_cpuid_ent (e, i, j, ©); + e->flags |=KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; +if (!copy.regs[R_EAX ]) +break ; + } +break ; +default : +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i,0 , ©); +break ; + } + }for (i =0 ; i <= limit; ++i) -do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©); +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i,0 , ©); copy.regs[R_EAX ] =0x80000000 ;qemu_kvm_cpuid_on_env (©); limit = copy.regs[R_EAX ];for (i =0x80000000 ; i <= limit; ++i) -do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©); +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i,0 , ©); }#ifdef KVM_CPUID_SIGNATURE
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 20080115141705.GA18060-iWbx9bcAnq+Hk9JtIoIkgNBPR1lH4CV8@public.gmane.org
Quoted 84 lines · Dan Kenigsberg
Quoted 75 lines · Alexander Graf
Quoted 49 lines · Dan Kenigsberg
Quoted 46 lines · Alexander Graf
Hi,
Currently CPUID function 4 is broken. This function's values rely on the value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather core duo target) compatibility.
Regards,
Alex
kernel/x86.c +7
-3@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG ;@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) { +case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ;Quoted 10 lines
kernel/x86.c static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, · line 818
Quoted 7 lines
kernel/x86.c +5
-0+default : + vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + }I will not mention the whitespace damage here :-). Instead, I'd ask you
Oh well, after having been into qemu source, I just got used to use spaces instead of tabs ;-).
Quoted 4 lines
to review, comment, and even try, the patch that I posted here not long ago, exposing all safe host cpuid functions to guests.
Sure.
Basically your patch targets at a completely different use case than mine though. You want to expose the host features on the virtual CPU, whereas my goal is to have a virtual Core Duo/Solo CPU, even if your host CPU is actually an SVM capable one.Quoted 6 lines
So my CoreDuo CPU definition still fails to populate a proper CPUID function 4. With the -cpu host option, Linux works (as it's bright enough to know that some values are just plain wrong), but Darwin crashes. I am not exactly sure why it is, but I guess it's due to the function 4 values exposing a 2-core CPU, which kvm simply doesn't emulate.
Quoted 7 lines
What I wanted to say is that the fact that the usermode support is not used, is not IMHO a good-enough reason to change the kernel:
kvm_vcpu_ioctl_set_cpuid()was ment to be a stupid function, to be used only with old usermode. I hate to teach it the true complex logic of Intel's CPUID.
The funny part is, you don't have to. Every complex I know of so far is simply repetitive. If the userspace just sends x cpuid values and the kernel takes x, where's the problem?
Of course having a full descriptionary approach is way better, but I see no real need to not use a stupid interface.
Quoted 3 lines
What I would like to see is something that uses the cpuid2 API, and not circumvene it... For this to happen, I need a deep review of my code.
I have to admin that I am really bad at reviewing, so don't expect anything glorious from me.
Quoted 3 lines
How about the (untested) attched kvm-cpuid.patch, on top of the attached cpuid-user patch?
Is there any real difference between this kvm-cpuid.patch and the one I sent?
What I was really wondering about is, why do you fetch the cpuid information about the host from the kernel module? CPUID does not get intercepted and can be easily triggered from userspace.
All the fancy processing of capabilities could be done in userspace as well (except for features that'd need to be implemented in the kernel, like MTRR) and this might even reduce the code, and in any case the amount of code changes in the kernel.
Furthermore most people probably don't even want their host cpu to be the default one. It renders migration near impossible.
Quoted 4 lines
#else cpu_model = "qemu32";#endif
+#ifdefUSE_KVM
Why is every other ifdef set on KVM_CAP_EXT_CPUID? Couldn't this be used here as well?
Quoted 3 lines
qemu/hw/pc.c +3
-0+if (kvm_allowed) + cpu_model ="host" ; +#endif
[...]
qemu/qemu-kvm-x86.c int kvm_arch_qemu_init_env(CPUState *cenv) · line 595
Quoted 7 lines
qemu/qemu-kvm-x86.c +7
-0+ }else { + copy.regs[R_EAX ] =0 ; +qemu_kvm_cpuid_on_env (©); + limit = copy.regs[R_EAX ]; + +for (i =0 ; i <= limit; ++i) +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©);
I don't see any index here?
qemu/qemu-kvm-x86.c int kvm_arch_qemu_init_env(CPUState *cenv) · line 602
Quoted 7 lines
qemu/qemu-kvm-x86.c +7
-0+ + copy.regs[R_EAX ] =0x80000000 ; +qemu_kvm_cpuid_on_env (©); + limit = copy.regs[R_EAX ]; + +for (i =0x80000000 ; i <= limit; ++i) +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©);
Same here.
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 93 lines · Alexander Graf
Quoted 84 lines · Dan Kenigsberg
Quoted 75 lines · Alexander Graf
Quoted 49 lines · Dan Kenigsberg
Quoted 46 lines · Alexander Graf
Hi,
Currently CPUID function 4 is broken. This function's values rely on the value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather core duo target) compatibility.
Regards,
Alex
kernel/x86.c +7
-3@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG ;@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) { +case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ;Quoted 10 lines
kernel/x86.c static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, · line 818
Quoted 7 lines
kernel/x86.c +5
-0+default : + vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + }I will not mention the whitespace damage here :-). Instead, I'd ask you
Oh well, after having been into qemu source, I just got used to use spaces instead of tabs ;-).
Quoted 4 lines
to review, comment, and even try, the patch that I posted here not long ago, exposing all safe host cpuid functions to guests.
Sure.
Basically your patch targets at a completely different use case than mine though. You want to expose the host features on the virtual CPU, whereas my goal is to have a virtual Core Duo/Solo CPU, even if your host CPU is actually an SVM capable one.Quoted 6 lines
So my CoreDuo CPU definition still fails to populate a proper CPUID function 4. With the -cpu host option, Linux works (as it's bright enough to know that some values are just plain wrong), but Darwin crashes. I am not exactly sure why it is, but I guess it's due to the function 4 values exposing a 2-core CPU, which kvm simply doesn't emulate.
Quoted 7 lines
What I wanted to say is that the fact that the usermode support is not used, is not IMHO a good-enough reason to change the kernel:
kvm_vcpu_ioctl_set_cpuid()was ment to be a stupid function, to be used only with old usermode. I hate to teach it the true complex logic of Intel's CPUID.
Quoted 6 lines
The funny part is, you don't have to. Every complex I know of so far is simply repetitive. If the userspace just sends x cpuid values and the kernel takes x, where's the problem?
Of course having a full descriptionary approach is way better, but I see no real need to not use a stupid interface.
The only reason is that a smarter interface exists, and I want it to be used, not hacked arround.
Quoted 6 lines
Quoted 3 lines
What I would like to see is something that uses the cpuid2 API, and not circumvene it... For this to happen, I need a deep review of my code.
I have to admin that I am really bad at reviewing, so don't expect anything glorious from me.
Anything beyond silence would be glorious.
Quoted 6 lines
Quoted 3 lines
How about the (untested) attched kvm-cpuid.patch, on top of the attached cpuid-user patch?
Is there any real difference between this kvm-cpuid.patch and the one I sent?
There is none. I just wanted to recruit you to test my own patch.
Quoted 2 lines
What I was really wondering about is, why do you fetch the cpuid information about the host from the kernel module?
Because only the kernel knows which cpu features are safe to be exposed. You've added the SSSSSSSSE3 bit there, haven't you?
Quoted 6 lines
CPUID does not get
intercepted and can be easily triggered from userspace.
All the fancy processing of capabilities could be done in userspace as well (except for features that'd need to be implemented in the kernel, like MTRR) and this might even reduce the code, and in any case the amount of code changes in the kernel.
I don't understand. Are you speaking about the cpuid2 api already committed into kvm.git? Guest cpuid operations are intercepted and handled by the kernel, don't they?
Quoted 2 lines
Furthermore most people probably don't even want their host cpu to be the default one. It renders migration near impossible.
I think "most people" are end users who want to run kvm as fast as they can on their PC, and care less about migration between different hosts. People who run kvm in large farms would probably use their own least-common-denominator and not any default I choose.
Quoted 8 lines
Quoted 5 lines
#else cpu_model = "qemu32";#endif
+#ifdefUSE_KVMWhy is every other ifdef set on
KVM_CAP_EXT_CPUID? Couldn't this be used here as well?
Right. Thanks.
Quoted 14 lines
Quoted 3 lines
qemu/hw/pc.c +3
-0+if (kvm_allowed) + cpu_model ="host" ; +#endif [...]
qemu/qemu-kvm-x86.c int kvm_arch_qemu_init_env(CPUState *cenv) · line 595
Quoted 7 lines
qemu/qemu-kvm-x86.c +7
-0+ }else { + copy.regs[R_EAX ] =0 ; +qemu_kvm_cpuid_on_env (©); + limit = copy.regs[R_EAX ]; + +for (i =0 ; i <= limit; ++i) +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©);
Quoted 2 lines
I don't see any index here?
That's the job of your kvm-cpuid.patch...
Regards,
Dan.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): 20080116201248.GC4880-dWpoJoFu5G6Ak5MFH8DghG3U47Q5hpJU@public.gmane.org
Quoted 114 lines · Dan Kenigsberg
Quoted 113 lines · Alexander Graf
Quoted 96 lines · Dan Kenigsberg
Quoted 85 lines · Alexander Graf
Quoted 55 lines · Dan Kenigsberg
Quoted 52 lines · Alexander Graf
Hi,
Currently CPUID function 4 is broken. This function's values rely on the
value of ECX.
To solve the issue cleanly, there is already a new API for cpuid settings, which is not used yet.
Using the current interface, the function 4 can be easily passed through, by giving multiple function 4 outputs and increasing the index-identifier on the fly. This does not break compatibility.This fix is really important for Mac OS X, as it requires cache information. Please also see my previous patches for Mac OS X (or rather
core duo target) compatibility.Regards,
Alex
kernel/x86.c +1
-1@@ -783,7 +783,7 @@ static int kvm_vcpu_ioctl_set_cpuid(structkvm_vcpu *vcpu, struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, n = 0;struct kvm_cpuid_entry *cpuid_entries;r = -E2BIG;kernel/x86.c +7
-2@@ -803,8 +803,17 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index =0 ; - vcpu->arch.cpuid_entries[i].flags =0 ; +switch (vcpu->arch.cpuid_entries[i].function) { +case 4 : + vcpu->arch.cpuid_entries[i].index = n; + vcpu->arch.cpuid_entries[i].flags =KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; + n++; +break ; +default :Quoted 10 lines
kernel/x86.c static int kvm_vcpu_ioctl_set_cpuid(struct · line 819
Quoted 6 lines
kernel/x86.c +4
-0+ vcpu->arch.cpuid_entries[i].index =0 ; + vcpu->arch.cpuid_entries[i].flags =0 ; +break ; + }I will not mention the whitespace damage here :-). Instead, I'd ask you
Oh well, after having been into qemu source, I just got used to use spaces instead of tabs ;-).
Quoted 5 lines
to review, comment, and even try, the patch that I posted here not long
ago, exposing all safe host cpuid functions to guests.Sure.
Basically your patch targets at a completely different use case than
mine though. You want to expose the host features on the virtual CPU,
whereas my goal is to have a virtual Core Duo/Solo CPU, even if your
host CPU is actually an SVM capable one.Quoted 8 lines
So my CoreDuo CPU definition still fails to populate a proper CPUID function 4. With the -cpu host option, Linux works (as it's bright enough to know that some values are just plain wrong), but Darwin crashes. I am not exactly sure why it is, but I guess it's due to the
function 4 values exposing a 2-core CPU, which kvm simply doesn't emulate.Quoted 10 lines
What I wanted to say is that the fact that the usermode support is not
used, is not IMHO a good-enough reason to change the kernel:kvm_vcpu_ioctl_set_cpuid()was ment to be a stupid function, to be used
only with old usermode. I hate to teach it the true complex logic of Intel's
CPUID.The funny part is, you don't have to. Every complex I know of so far is
simply repetitive. If the userspace just sends x cpuid values and the kernel takes x, where's the problem?
Quoted 8 lines
Quoted 3 lines
Of course having a full descriptionary approach is way better, but I see
no real need to not use a stupid interface.The only reason is that a smarter interface exists, and I want it to be used,
not hacked arround.
This is a valid complaint. Still, one wouldn't have needed the smart interface in the first place. Now that it is in, one should of course use it.
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
What I would like to see is something that uses the cpuid2 API, and not
circumvene it... For this to happen, I need a deep review of my code.I have to admin that I am really bad at reviewing, so don't expect anything glorious from me.
Anything beyond silence would be glorious.
Let's break it and get cpuid2 support in libkvm upstream, then! I believe having the host CPU's features exposed is a really beneficial feature here. I do believe this might be useful in kqemu as well though, so you might want to keep it as independent from kvm as possible.
Any complaints about these patches from anyone?
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
How about the (untested) attched kvm-cpuid.patch, on top of the attached
cpuid-user patch?Is there any real difference between this kvm-cpuid.patch and the one I
sent?There is none. I just wanted to recruit you to test my own patch.
Ok, I will.
Quoted 7 lines
Quoted 2 lines
What I was really wondering about is, why do you fetch the cpuid information about the host from the kernel module?
Because only the kernel knows which cpu features are safe to be exposed. You've
added the SSSSSSSSE3 bit there, haven't you?
Right. Maybe I did get something wrong, but where are the host cpuid flags received from?
Quoted 9 lines
Quoted 8 lines
CPUID does not get
intercepted and can be easily triggered from userspace. All the fancy processing of capabilities could be done in userspace as
well (except for features that'd need to be implemented in the kernel,
like MTRR) and this might even reduce the code, and in any case the amount of code changes in the kernel.
Quoted 6 lines
I don't understand. Are you speaking about the cpuid2 api already committed
into kvm.git? Guest cpuid operations are intercepted and handled by the kernel,
don't they?
I'm talking about normal userspace code running on the host OS. Guest CPUIDs of course get intercepted and handled by kvm.
Quoted 11 lines
Quoted 2 lines
Furthermore most people probably don't even want their host cpu to be the default one. It renders migration near impossible.
I think "most people" are end users who want to run kvm as fast as they can on
their PC, and care less about migration between different hosts. People who run
kvm in large farms would probably use their own least-common- denominator and
not any default I choose.
I wouldn't bet on this, but it's a valid thought. I don't know which direction kvm is going to develop to. S390 support definitely is nothing for "end users on their PCs".
Quoted 26 lines
Quoted 9 lines
Quoted 5 lines
#else cpu_model = "qemu32";#endif
+#ifdefUSE_KVMWhy is every other ifdef set on
KVM_CAP_EXT_CPUID? Couldn't this be used
here as well?Right. Thanks.
Quoted 14 lines
Quoted 3 lines
qemu/hw/pc.c +3
-0+if (kvm_allowed) + cpu_model ="host" ; +#endif [...]
Quoted 7 lines
qemu/qemu-kvm-x86.c +7
-0+ }else { + copy.regs[R_EAX ] =0 ; +qemu_kvm_cpuid_on_env (©); + limit = copy.regs[R_EAX ]; + +for (i =0 ; i <= limit; ++i) +do_cpuid_ent (&cpuid_ent[cpuid_nent++], i, ©);
Quoted 4 lines
Quoted 2 lines
I don't see any index here?
That's the job of your kvm-cpuid.patch...
I assumed you touched it, sorry ;-).
Regards,
Alex
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/