提交 e00b6f80 编写于 作者: A aliguori

KVM: CPUID takes ecx as input value for some functions (Amit Shah)

The CPUID instruction takes the value of ECX as an input parameter
in addition to the value of EAX as the count for functions 4, 0xb
and 0xd. Make sure we pass the value to the instruction.

Also convert to the qemu-style whitespace for the surrounding code.
Signed-off-by: NAmit Shah <amit.shah@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6565 c046a42c-6fe2-441c-8c8c-71466251a162
上级 4f396364
...@@ -772,7 +772,7 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo, ...@@ -772,7 +772,7 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo,
int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
int is_write, int mmu_idx, int is_softmmu); int is_write, int mmu_idx, int is_softmmu);
void cpu_x86_set_a20(CPUX86State *env, int a20_state); void cpu_x86_set_a20(CPUX86State *env, int a20_state);
void cpu_x86_cpuid(CPUX86State *env, uint32_t index, void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
uint32_t *eax, uint32_t *ebx, uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx); uint32_t *ecx, uint32_t *edx);
......
...@@ -1403,7 +1403,8 @@ static void breakpoint_handler(CPUState *env) ...@@ -1403,7 +1403,8 @@ static void breakpoint_handler(CPUState *env)
} }
#endif /* !CONFIG_USER_ONLY */ #endif /* !CONFIG_USER_ONLY */
static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx, static void host_cpuid(uint32_t function, uint32_t count,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx) uint32_t *ecx, uint32_t *edx)
{ {
#if defined(CONFIG_KVM) #if defined(CONFIG_KVM)
...@@ -1411,19 +1412,19 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx, ...@@ -1411,19 +1412,19 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
#ifdef __x86_64__ #ifdef __x86_64__
asm volatile("cpuid" asm volatile("cpuid"
: "=a"(vec[0]), "=b"(vec[1]), : "=a"(vec[0]), "=b"(vec[1]),
"=c"(vec[2]), "=d"(vec[3]) "=c"(vec[2]), "=d"(vec[3])
: "0"(function) : "cc"); : "0"(function), "c"(count) : "cc");
#else #else
asm volatile("pusha \n\t" asm volatile("pusha \n\t"
"cpuid \n\t" "cpuid \n\t"
"mov %%eax, 0(%1) \n\t" "mov %%eax, 0(%1) \n\t"
"mov %%ebx, 4(%1) \n\t" "mov %%ebx, 4(%1) \n\t"
"mov %%ecx, 8(%1) \n\t" "mov %%ecx, 8(%1) \n\t"
"mov %%edx, 12(%1) \n\t" "mov %%edx, 12(%1) \n\t"
"popa" "popa"
: : "a"(function), "S"(vec) : : "a"(function), "c"(count), "S"(vec)
: "memory", "cc"); : "memory", "cc");
#endif #endif
if (eax) if (eax)
...@@ -1437,7 +1438,7 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx, ...@@ -1437,7 +1438,7 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
#endif #endif
} }
void cpu_x86_cpuid(CPUX86State *env, uint32_t index, void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
uint32_t *eax, uint32_t *ebx, uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx) uint32_t *ecx, uint32_t *edx)
{ {
...@@ -1462,7 +1463,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, ...@@ -1462,7 +1463,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
* actuall cpu, and say goodbye to migration between different vendors * actuall cpu, and say goodbye to migration between different vendors
* is you use compatibility mode. */ * is you use compatibility mode. */
if (kvm_enabled()) if (kvm_enabled())
host_cpuid(0, NULL, ebx, ecx, edx); host_cpuid(0, 0, NULL, ebx, ecx, edx);
break; break;
case 1: case 1:
*eax = env->cpuid_version; *eax = env->cpuid_version;
...@@ -1483,7 +1484,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, ...@@ -1483,7 +1484,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
break; break;
case 4: case 4:
/* cache info: needed for Core compatibility */ /* cache info: needed for Core compatibility */
switch (*ecx) { switch (count) {
case 0: /* L1 dcache info */ case 0: /* L1 dcache info */
*eax = 0x0000121; *eax = 0x0000121;
*ebx = 0x1c0003f; *ebx = 0x1c0003f;
...@@ -1509,7 +1510,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, ...@@ -1509,7 +1510,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
*edx = 0; *edx = 0;
break; break;
} }
break; break;
case 5: case 5:
/* mwait info: needed for Core compatibility */ /* mwait info: needed for Core compatibility */
...@@ -1554,7 +1554,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, ...@@ -1554,7 +1554,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
if (kvm_enabled()) { if (kvm_enabled()) {
uint32_t h_eax, h_edx; uint32_t h_eax, h_edx;
host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx); host_cpuid(index, 0, &h_eax, NULL, NULL, &h_edx);
/* disable CPU features that the host does not support */ /* disable CPU features that the host does not support */
......
...@@ -44,13 +44,13 @@ int kvm_arch_init_vcpu(CPUState *env) ...@@ -44,13 +44,13 @@ int kvm_arch_init_vcpu(CPUState *env)
cpuid_i = 0; cpuid_i = 0;
cpu_x86_cpuid(env, 0, &eax, &ebx, &ecx, &edx); cpu_x86_cpuid(env, 0, 0, &eax, &ebx, &ecx, &edx);
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_entry *c = &cpuid_data.entries[cpuid_i++];
cpu_x86_cpuid(env, i, &eax, &ebx, &ecx, &edx); cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
c->function = i; c->function = i;
c->eax = eax; c->eax = eax;
c->ebx = ebx; c->ebx = ebx;
...@@ -58,13 +58,13 @@ int kvm_arch_init_vcpu(CPUState *env) ...@@ -58,13 +58,13 @@ int kvm_arch_init_vcpu(CPUState *env)
c->edx = edx; c->edx = edx;
} }
cpu_x86_cpuid(env, 0x80000000, &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_entry *c = &cpuid_data.entries[cpuid_i++];
cpu_x86_cpuid(env, i, &eax, &ebx, &ecx, &edx); cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
c->function = i; c->function = i;
c->eax = eax; c->eax = eax;
c->ebx = ebx; c->ebx = ebx;
......
...@@ -1913,7 +1913,7 @@ void helper_cpuid(void) ...@@ -1913,7 +1913,7 @@ void helper_cpuid(void)
helper_svm_check_intercept_param(SVM_EXIT_CPUID, 0); helper_svm_check_intercept_param(SVM_EXIT_CPUID, 0);
cpu_x86_cpuid(env, (uint32_t)EAX, &eax, &ebx, &ecx, &edx); cpu_x86_cpuid(env, (uint32_t)EAX, (uint32_t)ECX, &eax, &ebx, &ecx, &edx);
EAX = eax; EAX = eax;
EBX = ebx; EBX = ebx;
ECX = ecx; ECX = ecx;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册