mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
KVM: Fetch sub-leaf cpuid values for functions 4, 0xb, 0xd. (Amit Shah)
CPUID functions 4, 0xb and 0xd have sub-leaf values which depend on the input value of ECX. Store these values as well. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6566 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
e00b6f8099
commit
486bd5a2f2
1 changed files with 38 additions and 13 deletions
|
@ -36,10 +36,10 @@
|
||||||
int kvm_arch_init_vcpu(CPUState *env)
|
int kvm_arch_init_vcpu(CPUState *env)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
struct kvm_cpuid cpuid;
|
struct kvm_cpuid2 cpuid;
|
||||||
struct kvm_cpuid_entry entries[100];
|
struct kvm_cpuid_entry2 entries[100];
|
||||||
} __attribute__((packed)) cpuid_data;
|
} __attribute__((packed)) cpuid_data;
|
||||||
uint32_t limit, i, cpuid_i;
|
uint32_t limit, i, j, cpuid_i;
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
|
||||||
cpuid_i = 0;
|
cpuid_i = 0;
|
||||||
|
@ -48,21 +48,46 @@ int kvm_arch_init_vcpu(CPUState *env)
|
||||||
limit = eax;
|
limit = eax;
|
||||||
|
|
||||||
for (i = 0; i <= limit; i++) {
|
for (i = 0; i <= limit; i++) {
|
||||||
struct kvm_cpuid_entry *c = &cpuid_data.entries[cpuid_i++];
|
struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++];
|
||||||
|
|
||||||
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
|
switch (i) {
|
||||||
c->function = i;
|
case 4:
|
||||||
c->eax = eax;
|
case 0xb:
|
||||||
c->ebx = ebx;
|
case 0xd:
|
||||||
c->ecx = ecx;
|
for (j = 0; ; j++) {
|
||||||
c->edx = edx;
|
cpu_x86_cpuid(env, i, j, &eax, &ebx, &ecx, &edx);
|
||||||
|
c->function = i;
|
||||||
|
c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
|
||||||
|
c->index = j;
|
||||||
|
c->eax = eax;
|
||||||
|
c->ebx = ebx;
|
||||||
|
c->ecx = ecx;
|
||||||
|
c->edx = edx;
|
||||||
|
c = &cpuid_data.entries[++cpuid_i];
|
||||||
|
|
||||||
|
if (i == 4 && eax == 0)
|
||||||
|
break;
|
||||||
|
if (i == 0xb && !(ecx & 0xff00))
|
||||||
|
break;
|
||||||
|
if (i == 0xd && eax == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
|
||||||
|
c->function = i;
|
||||||
|
c->eax = eax;
|
||||||
|
c->ebx = ebx;
|
||||||
|
c->ecx = ecx;
|
||||||
|
c->edx = edx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_x86_cpuid(env, 0x80000000, 0, &eax, &ebx, &ecx, &edx);
|
cpu_x86_cpuid(env, 0x80000000, 0, &eax, &ebx, &ecx, &edx);
|
||||||
limit = eax;
|
limit = eax;
|
||||||
|
|
||||||
for (i = 0x80000000; i <= limit; i++) {
|
for (i = 0x80000000; i <= limit; i++) {
|
||||||
struct kvm_cpuid_entry *c = &cpuid_data.entries[cpuid_i++];
|
struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++];
|
||||||
|
|
||||||
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
|
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
|
||||||
c->function = i;
|
c->function = i;
|
||||||
|
@ -74,7 +99,7 @@ int kvm_arch_init_vcpu(CPUState *env)
|
||||||
|
|
||||||
cpuid_data.cpuid.nent = cpuid_i;
|
cpuid_data.cpuid.nent = cpuid_i;
|
||||||
|
|
||||||
return kvm_vcpu_ioctl(env, KVM_SET_CPUID, &cpuid_data);
|
return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kvm_has_msr_star(CPUState *env)
|
static int kvm_has_msr_star(CPUState *env)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue